Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.Configuration


    @Override
    public Map<String, Object> convertStoreConfiguration(Configuration storeConfiguration)
    {
        Map<String, Object> convertedMap = new HashMap<String, Object>();
        Configuration delaysConfig = storeConfiguration.subset("delays");

        @SuppressWarnings("unchecked")
        Iterator<String> delays = delaysConfig.getKeys();

        Map<String,Long> delaysMap = new HashMap<String, Long>();

        while (delays.hasNext())
        {
            String key = delays.next();

            if (key.endsWith("pre"))
            {
                delaysMap.put("pre"+key.substring(0, key.length() - 4), delaysConfig.getLong(key));
            }
            else if (key.endsWith("post"))
            {
                delaysMap.put("post"+key.substring(0, key.length() - 5), delaysConfig.getLong(key));
            }
        }

        if(!delaysMap.isEmpty())
        {
View Full Code Here


    public Map<String, Object> convertVirtualHostConfiguration(Configuration configuration)
    {

        LinkedHashMap<String,Object> convertedMap = new LinkedHashMap<String, Object>();

        Configuration storeConfiguration = configuration.subset("store");

        convertedMap.put(org.apache.qpid.server.model.VirtualHost.STORE_PATH, storeConfiguration.getString(MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY));
        convertedMap.put(MessageStoreConstants.OVERFULL_SIZE_ATTRIBUTE, storeConfiguration.getString(MessageStoreConstants.OVERFULL_SIZE_PROPERTY));
        convertedMap.put(MessageStoreConstants.UNDERFULL_SIZE_ATTRIBUTE, storeConfiguration.getString(MessageStoreConstants.UNDERFULL_SIZE_PROPERTY));
        convertedMap.put("haGroupName", configuration.getString("store.highAvailability.groupName"));
        convertedMap.put("haNodeName", configuration.getString("store.highAvailability.nodeName"));
        convertedMap.put("haNodeAddress", configuration.getString("store.highAvailability.nodeHostPort"));
        convertedMap.put("haHelperAddress", configuration.getString("store.highAvailability.helperHostPort"));
View Full Code Here

    private ClusterSpec whirrConfigurationToClusterSpec(HostDescription hostDescription,
                                                        File workingDirectory) throws IOException, GFacHandlerException, ConfigurationException {
        File whirrConfig = getWhirrConfigurationFile(hostDescription, workingDirectory);
        CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
        Configuration configuration = new PropertiesConfiguration(whirrConfig);
        compositeConfiguration.addConfiguration(configuration);

        ClusterSpec hadoopClusterSpec = new ClusterSpec(compositeConfiguration);

        for (ClusterSpec.Property required : EnumSet.of(CLUSTER_NAME, PROVIDER, IDENTITY, CREDENTIAL,
View Full Code Here

        this(name, loadConfiguration(name, configurationFile), broker);
    }

    private static Configuration loadConfiguration(String name, File configurationFile) throws ConfigurationException
    {
        Configuration configuration = null;
        if (configurationFile == null)
        {
            throw new IllegalConfigurationException("Virtualhost configuration file must be supplied!");
        }
        else
        {
            Configuration virtualHostConfig = XmlConfigurationUtilities.parseConfig(configurationFile);

            // check for the element with the same name as virtual host
            Configuration config = virtualHostConfig.subset("virtualhost." + XmlConfigurationUtilities.escapeTagName(name));
            if (config.isEmpty())
            {
                throw new IllegalConfigurationException("No configuration found for virtual host '" + name + "' in " + configurationFile.getAbsolutePath());
            }
            else
            {
View Full Code Here

        return _configXml;
    }

    private VirtualHost createVirtualHost(String hostName) throws Exception
    {
        Configuration config = getConfigXml().subset("virtualhosts.virtualhost." + XmlConfigurationUtilities.escapeTagName(hostName));
        VirtualHostConfiguration virtualHostConfiguration = new VirtualHostConfiguration(hostName, config, _broker);
        return BrokerTestHelper.createVirtualHost(virtualHostConfiguration, _virtualHostRegistry);
    }
View Full Code Here

    private VirtualHost createVirtualHostUsingStoreType(String virtualHostName) throws ConfigurationException, Exception
    {
        Broker broker = BrokerTestHelper.createBrokerMock();
        _virtualHostRegistry = broker.getVirtualHostRegistry();

        Configuration config = new PropertiesConfiguration();
        VirtualHostConfiguration configuration = new  VirtualHostConfiguration(virtualHostName, config, broker);
        final org.apache.qpid.server.model.VirtualHost virtualHost = mock(org.apache.qpid.server.model.VirtualHost.class);
        when(virtualHost.getAttribute(eq(org.apache.qpid.server.model.VirtualHost.STORE_TYPE))).thenReturn(TestMemoryMessageStore.TYPE);
        VirtualHost host = new StandardVirtualHostFactory().createVirtualHost(_virtualHostRegistry, mock(StatisticsGatherer.class), new SecurityManager(mock(Broker.class), false), configuration,
                virtualHost);
View Full Code Here

    @Override
    public Map<String, Object> convertVirtualHostConfiguration(Configuration configuration)
    {
        Map<String,Object> convertedMap = new LinkedHashMap<String, Object>();
        Configuration storeConfiguration = configuration.subset("store");
        convertedMap.put(org.apache.qpid.server.model.VirtualHost.STORE_TYPE, storeConfiguration.getString("type"));
        convertedMap.put(org.apache.qpid.server.model.VirtualHost.STORE_PATH, storeConfiguration.getString(MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY));

        convertedMap.put(MessageStoreConstants.OVERFULL_SIZE_ATTRIBUTE, storeConfiguration.getString(MessageStoreConstants.OVERFULL_SIZE_PROPERTY));
        convertedMap.put(MessageStoreConstants.UNDERFULL_SIZE_ATTRIBUTE, storeConfiguration.getString(MessageStoreConstants.UNDERFULL_SIZE_PROPERTY));

        for(MessageStoreFactory mf : new MessageStoreCreator().getFactories())
        {
            convertedMap.putAll(mf.convertStoreConfiguration(storeConfiguration));
        }
View Full Code Here

  private static void executeArgumentsGroup(CLIArgumentsGroup argumentsGroup) {
   
    /* load configuration file */
   
    Configuration config = new BaseConfiguration();
    File configFile = null;
   
    CLIArguments representativeArgs = argumentsGroup.getRepresentative();
   
    if (representativeArgs.isConfig()) {
View Full Code Here

    }
   
    if (locations != null) {
      for (int i = 0; i < locations.length; i++) {
        URL url = locations[i].getURL();
        Configuration props = new PropertiesConfiguration(url);
        configuration.addConfiguration(props);
      }
    }
  }
View Full Code Here

    configurationFactory.afterPropertiesSet();
    assertNotNull(configurationFactory.getObject());
  }

  public void testMergeConfigurations() throws Exception {
    Configuration one = new BaseConfiguration();
    one.setProperty("foo", "bar");
    PropertiesConfiguration two = new PropertiesConfiguration();
    String properties = "## some header \n" + "foo = bar1\n" + "bar = foo\n";
    two.load(new StringReader(properties));

    configurationFactory.setConfigurations(new Configuration[] { one, two });
View Full Code Here

TOP

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

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.