Search in sources :

Example 1 with ConfigParser

use of org.apache.commons.chain.config.ConfigParser in project sonar-java by SonarSource.

the class ActionServlet method initChain.

/**
 * <p>Parse the configuration documents specified by the
 * <code>chainConfig</code> init-param to configure the default {@link
 * org.apache.commons.chain.Catalog} that is registered in the {@link
 * CatalogFactory} instance for this application.</p>
 *
 * @throws ServletException if an error occurs.
 */
protected void initChain() throws ServletException {
    // Parse the configuration file specified by path or resource
    try {
        String value;
        value = getServletConfig().getInitParameter("chainConfig");
        if (value != null) {
            chainConfig = value;
        }
        ConfigParser parser = new ConfigParser();
        List urls = splitAndResolvePaths(chainConfig);
        URL resource;
        for (Iterator i = urls.iterator(); i.hasNext(); ) {
            resource = (URL) i.next();
            log.info("Loading chain catalog from " + resource);
            parser.parse(resource);
        }
    } catch (Exception e) {
        log.error("Exception loading resources", e);
        throw new ServletException(e);
    }
}
Also used : ServletException(javax.servlet.ServletException) Iterator(java.util.Iterator) ConfigParser(org.apache.commons.chain.config.ConfigParser) List(java.util.List) ArrayList(java.util.ArrayList) URL(java.net.URL) ServletException(javax.servlet.ServletException) MissingResourceException(java.util.MissingResourceException) SAXException(org.xml.sax.SAXException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException)

Example 2 with ConfigParser

use of org.apache.commons.chain.config.ConfigParser in project sonarqube by SonarSource.

the class ActionServlet method initChain.

/**
     * <p>Parse the configuration documents specified by the
     * <code>chainConfig</code> init-param to configure the default {@link
     * org.apache.commons.chain.Catalog} that is registered in the {@link
     * CatalogFactory} instance for this application.</p>
     *
     * @throws ServletException if an error occurs.
     */
protected void initChain() throws ServletException {
    // Parse the configuration file specified by path or resource
    try {
        String value;
        value = getServletConfig().getInitParameter("chainConfig");
        if (value != null) {
            chainConfig = value;
        }
        ConfigParser parser = new ConfigParser();
        List urls = splitAndResolvePaths(chainConfig);
        URL resource;
        for (Iterator i = urls.iterator(); i.hasNext(); ) {
            resource = (URL) i.next();
            log.info("Loading chain catalog from " + resource);
            parser.parse(resource);
        }
    } catch (Exception e) {
        log.error("Exception loading resources", e);
        throw new ServletException(e);
    }
}
Also used : ServletException(javax.servlet.ServletException) Iterator(java.util.Iterator) ConfigParser(org.apache.commons.chain.config.ConfigParser) List(java.util.List) ArrayList(java.util.ArrayList) URL(java.net.URL) ServletException(javax.servlet.ServletException) MissingResourceException(java.util.MissingResourceException) SAXException(org.xml.sax.SAXException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException)

Example 3 with ConfigParser

use of org.apache.commons.chain.config.ConfigParser in project bamboobsc by billchen198318.

the class SimpleChain method getCatalog.

public Catalog getCatalog(String resourceConfig, String catalogName) throws Exception {
    ConfigParser parser = new ConfigParser();
    parser.parse(this.getClass().getResource(resourceConfig));
    Catalog catalog = CatalogFactoryBase.getInstance().getCatalog(catalogName);
    return catalog;
}
Also used : ConfigParser(org.apache.commons.chain.config.ConfigParser) Catalog(org.apache.commons.chain.Catalog)

Aggregations

ConfigParser (org.apache.commons.chain.config.ConfigParser)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 MissingResourceException (java.util.MissingResourceException)2 ServletException (javax.servlet.ServletException)2 UnavailableException (javax.servlet.UnavailableException)2 SAXException (org.xml.sax.SAXException)2 Catalog (org.apache.commons.chain.Catalog)1