Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.XMLConfiguration


    this.solutions = null;
  }
 
  public void read(String filename) {
    logger.info("read vrp from file " + filename);
    XMLConfiguration xmlConfig = new XMLConfiguration();
    xmlConfig.setFileName(filename);
    xmlConfig.setAttributeSplittingDisabled(true);
    xmlConfig.setDelimiterParsingDisabled(true);
   
    if(schemaValidation){
      final InputStream resource = Resource.getAsInputStream("vrp_xml_schema.xsd");
      if(resource != null) {
        EntityResolver resolver = new EntityResolver() {

          @Override
          public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            {
              InputSource is = new InputSource(resource);
              return is;
            }
          }
        };
        xmlConfig.setEntityResolver(resolver);
        xmlConfig.setSchemaValidation(true);
        logger.info("validating " + filename + " with xsd-schema");
      }
      else{
        logger.warn("cannot find schema-xsd file (vrp_xml_schema.xsd). try to read xml without xml-file-validation.");
      }   
    }
    try {
      xmlConfig.load();
    } catch (ConfigurationException e) {
      logger.error(e);
      e.printStackTrace();
      System.exit(1);
    }
View Full Code Here


    private XMLConfiguration config;

    protected void setUp() throws Exception
    {
        super.setUp();
        config = new XMLConfiguration();
        config.setExpressionEngine(new XPathExpressionEngine());
    }
View Full Code Here

     * Tests to watch a configuration file in a jar. In this case the jar file
     * itself should be monitored.
     */
    public void testFromJar() throws Exception
    {
        XMLConfiguration config = new XMLConfiguration();
        // use some jar: URL
        config.setURL(new URL("jar:" + new File("conf/resources.jar").getAbsoluteFile().toURI().toURL() + "!/test-jar.xml"));
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        config.setReloadingStrategy(strategy);
        File file = strategy.getFile();
        assertNotNull("Strategy's file is null", file);
        assertEquals("Strategy does not monitor the jar file", "resources.jar", file.getName());
    }
View Full Code Here

        logger.setAdditivity(false);
        ExprLookup.Variables vars = new ExprLookup.Variables();
        vars.add(new ExprLookup.Variable("String", org.apache.commons.lang.StringUtils.class));
        vars.add(new ExprLookup.Variable("Util", new Utility("Hello")));
        vars.add(new ExprLookup.Variable("System", "Class:java.lang.System"));
        XMLConfiguration config = new XMLConfiguration(TEST_FILE);
        config.setLogger(log);
        ExprLookup lookup = new ExprLookup(vars);
        lookup.setConfiguration(config);
        String str = lookup.lookup(PATTERN1);
        assertTrue(str.startsWith("Goodbye"));
        str = lookup.lookup(PATTERN2);
View Full Code Here

            protected String interpolate(String o)
            {
                return conf.interpolate(o);
            }
        });
        conf.addConfiguration(new XMLConfiguration(file)
        {
            protected String interpolate(String o)
            {
                return conf.interpolate(o);
            }
View Full Code Here

            {
                port = getNextAvailable(port + 1);
            }
            _brokerPorts[i] = port;

            XMLConfiguration testConfiguration = new XMLConfiguration();
            testConfiguration.addProperty("management.enabled", "false");

            XMLConfiguration testVirtualhosts = new XMLConfiguration();
            String host = null;
            if (i == 1 || i == _brokerPorts.length - 1)
            {
                host = FAILOVER_VIRTUAL_HOST;
            }
            else
            {
                host = NON_FAILOVER_VIRTUAL_HOST;
            }
            testVirtualhosts.addProperty("virtualhost.name", host);
            testVirtualhosts.addProperty("virtualhost." + host + ".store.class", getTestProfileMessageStoreClassName());
            testVirtualhosts.addProperty(
                    "virtualhost." + host + ".store." + MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY, "${QPID_WORK}/"
                            + host);

            startBroker(port, testConfiguration, testVirtualhosts);
            revertSystemProperties();
View Full Code Here

     * Tests to watch a configuration file in a jar. In this case the jar file
     * itself should be monitored.
     */
    public void testFromJar() throws Exception
    {
        XMLConfiguration config = new XMLConfiguration();
        // use some jar: URL
        config.setURL(new URL("jar:" + new File("conf/resources.jar").getAbsoluteFile().toURL() + "!/test-jar.xml"));
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        config.setReloadingStrategy(strategy);
        File file = strategy.getFile();
        assertNotNull("Strategy's file is null", file);
        assertEquals("Strategy does not monitor the jar file", "resources.jar", file.getName());
    }
View Full Code Here

   
    FITS_XML = FITS_HOME+"xml"+File.separator;
    FITS_TOOLS = FITS_HOME+"tools"+File.separator;
   
    try {
      config = new XMLConfiguration(FITS_XML+"fits.xml");
    } catch (ConfigurationException e) {
      throw new FitsConfigurationException("Error reading "+FITS_XML+"fits.xml",e);
    }
    try {
      mapper = new FitsXmlMapper();
View Full Code Here

public class ToolBelt {
 
  private List<Tool> tools;
 
  public ToolBelt(String configFile) throws FitsConfigurationException {
    XMLConfiguration config = null;
    try {
      config = new XMLConfiguration(configFile);
    } catch (ConfigurationException e) {
      throw new FitsConfigurationException("Error reading "+configFile,e);
    }
 
    tools = new ArrayList<Tool>();
   
    // get number of tools
    int size = config.getList("tools.tool[@class]").size();
    // for each tools get the class path and any excluded extensions
    for(int i=0;i<size;i++) {
      String tClass = config.getString("tools.tool("+i+")[@class]");
      @SuppressWarnings("unchecked")
      List<String> excludes = config.getList("tools.tool("+i+")[@exclude-exts]");
      @SuppressWarnings("unchecked")
      List<String> includes = config.getList("tools.tool("+i+")[@include-exts]");
      Tool t = null;
      try {
        Class c = Class.forName(tClass);
        t = (Tool)c.newInstance();
      }
View Full Code Here

public class XsltTransformMap {
 
  public static Hashtable getMap(String config) throws FitsConfigurationException {
    Hashtable mappings = new Hashtable();
    XMLConfiguration conf = null;
    try {
      conf = new XMLConfiguration(config);
    } catch (ConfigurationException e) {
      throw new FitsConfigurationException("Error reading "+config+"fits.xml",e);
    }
   
    List fields = conf.configurationsAt("map");
    for(Iterator it = fields.iterator(); it.hasNext();)  {
        HierarchicalConfiguration sub = (HierarchicalConfiguration) it.next();
        // sub contains now all data about a single field
        String format = sub.getString("[@format]");
        String transform = sub.getString("[@transform]");
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.XMLConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.