Examples of AbstractConfiguration


Examples of org.apache.commons.configuration.AbstractConfiguration

     * @throws InterruptedException
     */
    @Test
    public void testUpdateProperties() throws InterruptedException {
        AbstractConfiguration.setDefaultListDelimiter(',');
        AbstractConfiguration config  = new ConcurrentCompositeConfiguration();
        config.addConfigurationListener(new ExpandedConfigurationListenerAdapter(new MyListener()));
        MyListener.resetCount();
        config.setProperty("test", "host,host1,host2");
        config.setProperty("test12", "host12");
        Map<String,Object> added = Maps.newHashMap();
        added.put("test.host","test,test1");
        Map<String,Object> changed = Maps.newHashMap();
        changed.put("test","host,host1");
        changed.put("test.host","");
        dynamicPropertyUpdater.updateProperties(WatchedUpdateResult.createIncremental(added, changed, null), config, false);
        assertEquals("",config.getProperty("test.host"));
        assertEquals(2,((CopyOnWriteArrayList)(config.getProperty("test"))).size());
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test"))).contains("host"));
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test"))).contains("host1"));
        assertEquals(5, MyListener.count);
    }
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

 
    @Test
    public void testAddorChangeProperty(){
        AbstractConfiguration.setDefaultListDelimiter(',');
        AbstractConfiguration config  = new ConcurrentCompositeConfiguration();
        config.addConfigurationListener(new ExpandedConfigurationListenerAdapter(new MyListener()));
        MyListener.resetCount();
        config.setProperty("test.host", "test,test1,test2");
        assertEquals(1, MyListener.count);
        dynamicPropertyUpdater.addOrChangeProperty("test.host", "test,test1,test2", config);
        assertEquals(3,((CopyOnWriteArrayList)(config.getProperty("test.host"))).size());
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host"))).contains("test"));
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host"))).contains("test1"));
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host"))).contains("test2"));
        assertEquals(1, MyListener.count);
        dynamicPropertyUpdater.addOrChangeProperty("test.host", "test,test1,test2", config);
        assertEquals(3,((CopyOnWriteArrayList)(config.getProperty("test.host"))).size());
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host"))).contains("test"));
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host"))).contains("test1"));
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host"))).contains("test2"));
        assertEquals(1, MyListener.count);
        dynamicPropertyUpdater.addOrChangeProperty("test.host", "test,test1", config);
        assertEquals(2,((CopyOnWriteArrayList)(config.getProperty("test.host"))).size());
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host"))).contains("test"));
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host"))).contains("test1"));
        assertEquals(2, MyListener.count);
       
        dynamicPropertyUpdater.addOrChangeProperty("test.host1", "test1,test12", config);
        assertEquals(2,((CopyOnWriteArrayList)(config.getProperty("test.host1"))).size());
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host1"))).contains("test1"));
        assertTrue(((CopyOnWriteArrayList)(config.getProperty("test.host1"))).contains("test12"));
        assertEquals(3, MyListener.count);
       
        config.setProperty("test.host1", "test1.test12");
        dynamicPropertyUpdater.addOrChangeProperty("test.host1", "test1.test12", config);
        assertEquals("test1.test12",config.getProperty("test.host1"));
        assertEquals(4, MyListener.count);
    }
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

        } catch (IOException e) {
            LOG.error(String.format("Exception loading properties file - %s, Explorers application may not work correctly ",
                     propertiesFileName));
        }

        AbstractConfiguration configuration = ConfigurationManager.getConfigInstance();

        environmentName     = configuration.getString(PROPERTY_ENVIRONMENT_NAME);
        currentRegion       = configuration.getString(PROPERTY_CURRENT_REGION);
        applicationVersion  = (String) configuration.getProperty(PROPERTY_APPLICATION_VERSION);
        applicationName     = (String) configuration.getProperty(PROPERTY_APPLICATION_NAME);
        isLocal             = configuration.getBoolean(PROPERTY_IS_LOCAL, false);
        homePageUrl         = configuration.getString(PROPERTY_HOME_PAGE);
        defaultPort         = configuration.getShort(PROPERTY_DEFAULT_PORT, (short) 8080);
        dataCenter          = configuration.getString(PROPERTY_DATA_CENTER);
        defaultExplorerName = configuration.getString(PROPERTY_DEFAULT_EXPLORER);

        try {
            Iterator<String> dcKeySet = configuration.getKeys(PROPERTIES_PREFIX + ".dc");
            while (dcKeySet.hasNext()) {
                String dcKey = dcKeySet.next();
                String key  = StringUtils.substringBefore(dcKey, ".");
                String attr = StringUtils.substringAfter (dcKey,  ".");

                CrossLink link = links.get(key);
                if (link == null) {
                    link = new CrossLink();
                    links.put(key,  link);
                }

                BeanUtils.setProperty(link, attr, configuration.getProperty(dcKey));
            }
        } catch (Exception e) {
            LOG.error("Exception in constructing links map ", e);
            throw new RuntimeException(e);
        }
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

    public static DynamicPropertyFactory initWithConfigurationSource(DynamicPropertySupport dynamicPropertySupport) {
        synchronized (ConfigurationManager.class) {
            if (dynamicPropertySupport == null) {
                throw new IllegalArgumentException("dynamicPropertySupport is null");
            }
            AbstractConfiguration configuration = null;
            if (dynamicPropertySupport instanceof AbstractConfiguration) {
                configuration = (AbstractConfiguration) dynamicPropertySupport;
            } else if (dynamicPropertySupport instanceof ConfigurationBackedDynamicPropertySupportImpl) {
                configuration = ((ConfigurationBackedDynamicPropertySupportImpl) dynamicPropertySupport).getConfiguration();
            }
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

     */
    public static DynamicPropertyFactory getInstance() {
        if (config == null) {
            synchronized (ConfigurationManager.class) {
                if (config == null) {
                    AbstractConfiguration configFromManager = ConfigurationManager.getConfigInstance();
                    if (configFromManager != null) {
                        initWithConfigurationSource(configFromManager);
                        initializedWithDefaultConfig = !ConfigurationManager.isConfigurationInstalled();
                        logger.info("DynamicPropertyFactory is initialized with configuration sources: " + configFromManager);
                    }
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

        }
        return props;
    }
   
    public static void loadAppOverrideProperties(String appConfigName) throws IOException {
        AbstractConfiguration config = getConfigInstance();
        Properties props = loadCascadedProperties(appConfigName);
        if (config instanceof AggregatedConfiguration) {
            AggregatedConfiguration aggregated = (AggregatedConfiguration) config;
            Configuration appConfig = aggregated.getConfiguration(APPLICATION_PROPERTIES);
            if (appConfig != null) {
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

        }
    };
   
    public ConfigurationBasedDeploymentContext() {
        super();
        AbstractConfiguration config = ConfigurationManager.getConfigInstance();
        if (config != null) {
            String contextValue = getValueFromConfig(DEPLOYMENT_APPLICATION_ID_PROPERTY);
            if (contextValue != null) {
                setApplicationId(contextValue);
            }
            contextValue = getValueFromConfig(DEPLOYMENT_DATACENTER_PROPERTY);
            if (contextValue != null) {
                setDeploymentDatacenter(contextValue);
            }
            contextValue = getValueFromConfig(DEPLOYMENT_ENVIRONMENT_PROPERTY);
            if (contextValue != null) {
                setDeploymentEnvironment(contextValue);
            }
            contextValue = getValueFromConfig(DEPLOYMENT_REGION_PROPERTY);
            if (contextValue != null) {
                setDeploymentRegion(contextValue);
            }
            contextValue = getValueFromConfig(DEPLOYMENT_STACK_PROPERTY);
            if (contextValue != null) {
                setDeploymentStack(contextValue);
            }   
            contextValue = getValueFromConfig(DEPLOYMENT_SERVER_ID_PROPERTY);
            if (contextValue != null) {
                setDeploymentStack(contextValue);
            }   
            config.addConfigurationListener(configListener);
        }
    }
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

            throw new IllegalArgumentException("Can't remove container configuration");
        }
    }
   
    public AbstractConfiguration removeConfigurationAt(int index) {
        AbstractConfiguration config = configList.remove(index);
        String nameFound = getNameForConfiguration(config);
        if (nameFound != null) {
            namedConfigurations.remove(nameFound);
        }
        return config;
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

    // Step 1.
    // Create a Source of Configuration
    // Here we use a simple ConcurrentMapConfiguration
    // You can use your own, or use of the pre built ones including JDBCConfigurationSource
    // which lets you load properties from any RDBMS
    AbstractConfiguration myConfiguration = new ConcurrentMapConfiguration();
    myConfiguration.setProperty("com.netflix.config.samples.sampleapp.prop1", "value1");
    myConfiguration.setProperty(
        "com.netflix.config.samples.SampleApp.SampleBean.name",
        "A Coffee Bean from Gautemala");

    // STEP 2: Optional. Dynamic Runtime property change option
    // We would like to utilize the benefits of obtaining dynamic property
View Full Code Here

Examples of org.apache.commons.configuration.AbstractConfiguration

        this.archaiusPropertyRegister = archaiusPropertyRegister;
    }

    public void register() {
        archaiusPropertyRegister.register(breakerboxConfiguration);
        final AbstractConfiguration configInstance = ConfigurationManager.getConfigInstance();
        for (Map.Entry<TenacityPropertyKey, TenacityConfiguration> entry : configurations.entrySet()) {
            registerConfiguration(entry.getKey(), entry.getValue(), configInstance);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.