Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.BaseConfiguration


        ConfigurationFactory configurationFactory = new ConfigurationFactory();
        configurationFactory.setConfigurationFileName(compositeConfigurationFile);
        Configuration compositeConfiguration = configurationFactory.getConfiguration();

        Configuration mapping = new BaseConfiguration();
        Configuration mapping2 = new BaseConfiguration();

        for (Iterator keys = simpleConfiguration.getKeys(); keys.hasNext();)
        {
            String key = (String) keys.next();
            String[] keyParts = StringUtils.split(key, ".");

            if ((keyParts.length == 3) && keyParts[0].equals("prefix") && keyParts[2].equals("postfix"))
            {
                String serviceKey = keyParts[1];

                if (!mapping.containsKey(serviceKey))
                {
                    mapping.setProperty(serviceKey, simpleConfiguration.getString(key));
                }
            }
        }

        for (Iterator keys = compositeConfiguration.getKeys(); keys.hasNext();)
        {
            String key = (String) keys.next();
            String[] keyParts = StringUtils.split(key, ".");

            if ((keyParts.length == 3) && keyParts[0].equals("prefix") && keyParts[2].equals("postfix"))
            {
                String serviceKey = keyParts[1];

                if (!mapping2.containsKey(serviceKey))
                {
                    mapping2.setProperty(serviceKey, compositeConfiguration.getString(key));
                }
            }
        }
    }
View Full Code Here


     */
    public void init()
            throws InitializationException
    {
        ServletConfig config = Turbine.getTurbineServletConfig();
        Configuration loaderConf = new BaseConfiguration();

        String[] names = getConfiguration().getStringArray(NAME);
       
        log.warn("The ComponentService is deprecated!");

        for (int i = 0; i < names.length; i++)
        {
            String key = names[i];

            loaderConf.addProperty(COMPONENT + "." + NAME, key);

            String subProperty = COMPONENT + "." + key;
            Configuration subConf = getConfiguration().subset(key);

            for (Iterator it = subConf.getKeys(); it.hasNext();)
            {
                String subKey = (String) it.next();
                Object subVal = subConf.getProperty(subKey);

                if (subKey.equals(CONFIG))
                {
                    log.debug("Fixing up " + subVal);
                    String newPath =
                            config.getServletContext().getRealPath((String) subVal);

                    if (newPath == null)
                    {
                      throw new InitializationException("Could not translate path " + subVal);
                    }

                    subVal = newPath;
                    log.debug("Now: " + subVal);
                }

                loaderConf.addProperty(subProperty + "." + subKey,
                        subVal);
            }

            log.info("Added " + key + " as a component");
        }
View Full Code Here

   * Create a TitanGraph from the configuration
   *
   * @return TitanGraph
   */
  public TitanGraph createTitanGraph() {
    Configuration conf = new BaseConfiguration();
    List<String> titanConf = configurationService.listConfigurationKeys("titan");
    for (String key : titanConf) {
      String titanKey = key.replaceFirst("^titan\\.", "");
      conf.setProperty(titanKey, configurationService.getStringConfiguration(key));
    }

    return TitanFactory.open(conf);
  }
View Full Code Here

    server = new Server(this, 9000);
   
    //
    // Create  configuration properties for the broadcaster
    //
    Configuration properties = new BaseConfiguration();
    properties.addProperty("widget.import.broadcast", true);
    properties.addProperty("widget.import.broadcast.url", broadcastUrl);
   
    //
    // Create a new broadcast, and check the server received it
    //
    NewWidgetBroadcaster.broadcast(properties, "TEST_BROADCAST");
View Full Code Here

        ConfigurationFactory configurationFactory = new ConfigurationFactory();
        configurationFactory.setConfigurationFileName(compositeConfigurationFile);
        Configuration compositeConfiguration = configurationFactory.getConfiguration();

        Configuration mapping = new BaseConfiguration();
        Configuration mapping2 = new BaseConfiguration();

        for (Iterator keys = simpleConfiguration.getKeys(); keys.hasNext();)
        {
            String key = (String) keys.next();
            String[] keyParts = StringUtils.split(key, ".");

            if ((keyParts.length == 3) && keyParts[0].equals("prefix") && keyParts[2].equals("postfix"))
            {
                String serviceKey = keyParts[1];

                if (!mapping.containsKey(serviceKey))
                {
                    mapping.setProperty(serviceKey, simpleConfiguration.getString(key));
                }
            }
        }

        for (Iterator keys = compositeConfiguration.getKeys(); keys.hasNext();)
        {
            String key = (String) keys.next();
            String[] keyParts = StringUtils.split(key, ".");

            if ((keyParts.length == 3) && keyParts[0].equals("prefix") && keyParts[2].equals("postfix"))
            {
                String serviceKey = keyParts[1];

                if (!mapping2.containsKey(serviceKey))
                {
                    mapping2.setProperty(serviceKey, compositeConfiguration.getString(key));
                }
            }
        }
    }
View Full Code Here

*/
public class TestServletRequestConfiguration extends TestAbstractConfiguration
{
    protected AbstractConfiguration getConfiguration()
    {
        final Configuration configuration = new BaseConfiguration();
        ((BaseConfiguration) configuration).setListDelimiter('\0');
        configuration.setProperty("key1", "value1");
        configuration.setProperty("key2", "value2");
        configuration.addProperty("list", "value1");
        configuration.addProperty("list", "value2");
        configuration.addProperty("listesc", "value1\\,value2");

        return createConfiguration(configuration);
    }
View Full Code Here

     * Creates the underlying configuration object for the dyna bean.
     * @return the underlying configuration object
     */
    protected Configuration createConfiguration()
    {
        return new BaseConfiguration();
    }
View Full Code Here

        return createConfiguration(configuration);
    }

    protected AbstractConfiguration getEmptyConfiguration()
    {
        final Configuration configuration = new BaseConfiguration();

        ServletRequest request = new MockHttpServletRequest()
        {
            public String getParameter(String key)
            {
                return null;
            }

            public Enumeration getParameterNames()
            {
                return new IteratorEnumeration(configuration.getKeys());
            }
        };

        return new ServletRequestConfiguration(request);
    }
View Full Code Here

    public void testListWithEscapedElements()
    {
        String[] values =
        { "test1", "test2\\,test3", "test4\\,test5" };
        final String listKey = "test.list";
        BaseConfiguration config = new BaseConfiguration();
        config.setListDelimiter('\0');
        config.addProperty(listKey, values);
        assertEquals("Wrong number of list elements", values.length, config
                .getList(listKey).size());
        Configuration c = createConfiguration(config);
        List v = c.getList(listKey);
        assertEquals("Wrong number of elements in list", values.length, v
                .size());
View Full Code Here

        {
            return new AppletConfiguration(new Applet());
        }
        else
        {
            return new BaseConfiguration();
        }
    }
View Full Code Here

TOP

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

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.