List of usage examples for org.apache.commons.chain.config ConfigParser parse
public void parse(URL url) throws Exception
Parse the XML document at the specified URL using the configured RuleSet, registering catalogs with nested chains and commands as they are encountered.
From source file:com.netsteadfast.greenstep.base.chain.SimpleChain.java
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; }
From source file:org.ambiance.chain.CatalogAmbianceChain.java
public void initialize() throws InitializationException { ConfigParser parser = new ConfigParser(); try {/* w ww . j a v a2 s. c o m*/ parser.parse(this.getClass().getResource(catalogFileName)); catalog = CatalogFactoryBase.getInstance().getCatalog(); } catch (Exception e) { throw new InitializationException("Unable to load rules catalog", e); } }
From source file:org.apache.struts.action.ActionServlet.java
/** * <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. *///from w ww .jav a2s . c o m 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); } }
From source file:org.apache.struts.chain.legacy.CatalogConfiguratorPlugIn.java
/** * <p>Parse the configuration documents specified by the <code>path</code> * or <code>resource</code> property to configure the default * {@link Catalog} that is registered in the {@link CatalogFactory} * instance for this application.</p> */// ww w . ja v a 2 s . c o m public void init(ActionServlet servlet, ModuleConfig config) throws ServletException { // Parse the configuration file specified by path or resource try { ConfigParser parser = new ConfigParser(); URL configResource = null; if (path != null) { log.info("Loading context relative resources from '" + path + "'"); configResource = servlet.getServletContext().getResource(path); } else if (resource != null) { log.info("Loading classloader resources from '" + resource + "'"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { loader = this.getClass().getClassLoader(); } configResource = loader.getResource(resource); } parser.parse(configResource); } catch (Exception e) { log.error("Exception loading resources", e); throw new ServletException(e); } }
From source file:org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin.java
public CommonsXMLConfigurationPlugin(InitParams params, ConfigurationManager configurationManager) throws Exception { ValueParam confFile = params.getValueParam("config-file"); if (confFile != null) { final String path = confFile.getValue(); final ConfigParser parser = new ConfigParser(); // may work for StandaloneContainer URL res = SecurityHelper.doPrivilegedAction(new PrivilegedAction<URL>() { public URL run() { return Thread.currentThread().getContextClassLoader().getResource(path); }// ww w .j av a 2 s. c o m }); // for PortalContainer if (res == null) res = configurationManager.getResource(path); if (res == null) throw new Exception("Resource not found " + path); LOG.info("Catalog configuration found at " + res); final URL fRes = res; SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>() { public Void run() throws Exception { parser.parse(fRes); return null; } }); } }
From source file:org.seasar.struts.hotdeploy.impl.ChainConfigLoaderImpl.java
protected void initChain() throws ServletException { // Parse the configuration file specified by path or resource try {//w ww.ja v a 2 s . c o m 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); } }