Search in sources :

Example 6 with Digester

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);
}
Also used : Digester(org.apache.commons.digester.Digester)

Example 7 with Digester

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);
}
Also used : Digester(org.apache.commons.digester.Digester) ConfigRuleSet(org.apache.struts.config.ConfigRuleSet) URL(java.net.URL)

Example 8 with Digester

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());
    }
}
Also used : InputStream(java.io.InputStream) Digester(org.apache.commons.digester.Digester) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) URL(java.net.URL) SAXException(org.xml.sax.SAXException)

Aggregations

Digester (org.apache.commons.digester.Digester)8 URL (java.net.URL)4 InputStream (java.io.InputStream)3 SAXException (org.xml.sax.SAXException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 ServletException (javax.servlet.ServletException)1 ConfigRuleSet (org.apache.struts.config.ConfigRuleSet)1 ModuleConfig (org.apache.struts.config.ModuleConfig)1 ModuleConfigFactory (org.apache.struts.config.ModuleConfigFactory)1 ErrorHandler (org.xml.sax.ErrorHandler)1 SAXParseException (org.xml.sax.SAXParseException)1