use of org.apache.commons.digester.Digester in project OpenClinica by OpenClinica.
the class DAODigester method run.
public void run() throws IOException, SAXException {
Digester digester = new Digester();
digester.push(this);
// set up a simple format for grabbing queries through XML
/*
* <queries> <query> <name>userDaoInsert</name> <sql>INSERT INTO USER
* (USER_ID, USER_NAME, USER_PASS) VALUES (USER_ID_SEQ.NEXTVAL,?,?);</sql>
* </query> </queries>
*
*/
digester.addCallMethod("queries/query", "setQuery", 2);
digester.addCallParam("queries/query/name", 0);
digester.addCallParam("queries/query/sql", 1);
digester.parse(fis);
}
use of org.apache.commons.digester.Digester in project sonarqube by SonarSource.
the class ActionServlet method initConfigDigester.
/**
* <p>Create (if needed) and return a new <code>Digester</code> instance
* that has been initialized to process Struts module configuration files
* and configure a corresponding <code>ModuleConfig</code> object (which
* must be pushed on to the evaluation stack before parsing begins).</p>
*
* @return A new configured <code>Digester</code> instance.
* @throws ServletException if a Digester cannot be configured
* @since Struts 1.1
*/
protected Digester initConfigDigester() throws ServletException {
// Do we have an existing instance?
if (configDigester != null) {
return (configDigester);
}
// Create a new Digester instance with standard capabilities
configDigester = new Digester();
configDigester.setNamespaceAware(true);
configDigester.setValidating(this.isValidating());
configDigester.setUseContextClassLoader(true);
configDigester.addRuleSet(new ConfigRuleSet());
for (int i = 0; i < registrations.length; i += 2) {
URL url = this.getClass().getResource(registrations[i + 1]);
if (url != null) {
configDigester.register(registrations[i], url.toString());
}
}
this.addRuleSets();
// Return the completely configured Digester instance
return (configDigester);
}
use of org.apache.commons.digester.Digester in project jackrabbit by apache.
the class CommandLineFactory method init.
/**
* parses the configuration file
* @throws ConfigurationException
* an <code>Exception</code> occurs while parsing
*/
private void init() throws ConfigurationException {
try {
// Configure Digester from XML ruleset
URL rulesFile = getClass().getResource(COMMAND_LINE_RULES_FILE);
URL clFile = getClass().getResource(COMMAND_LINE_FILE);
// init digester
Digester digester = DigesterLoader.createDigester(rulesFile);
// Push empty List onto Digester's Stack
List cls = new ArrayList();
digester.push(cls);
// Parse the XML document
InputStream input = clFile.openStream();
digester.parse(input);
input.close();
// Add to cache
Iterator iter = cls.iterator();
while (iter.hasNext()) {
CommandLine cl = (CommandLine) iter.next();
cache.put(cl.getName(), cl);
// Add to alias cache
Iterator aliasIt = cl.getAlias().iterator();
while (aliasIt.hasNext()) {
String aliasName = (String) aliasIt.next();
if (alias.containsKey(aliasName)) {
throw new ConfigurationException("exception.alias.already.in.use", new String[] { aliasName, cl.getName() });
}
alias.put(aliasName, cl);
}
}
} catch (IOException e) {
throw new ConfigurationException(e.getLocalizedMessage());
} catch (SAXException e) {
throw new ConfigurationException(e.getLocalizedMessage());
}
}
Aggregations