List of usage examples for org.apache.commons.configuration HierarchicalConfiguration addConfigurationListener
public void addConfigurationListener(ConfigurationListener l)
From source file:com.netflix.config.ConcurrentMapConfigurationTest.java
@Test public void testPerformance() { MyListener listener = new MyListener(); BaseConfiguration baseConfig = new BaseConfiguration(); baseConfig.addConfigurationListener(listener); HierarchicalConfiguration hConfig = new HierarchicalConfiguration(); hConfig.addConfigurationListener(listener); ConcurrentMapConfiguration conf = new ConcurrentMapConfiguration(); conf.addConfigurationListener(listener); testConfigurationSet(baseConfig);//ww w. ja va 2s. c o m testConfigurationSet(hConfig); testConfigurationSet(conf); testConfigurationAdd(baseConfig); testConfigurationAdd(hConfig); testConfigurationAdd(conf); testConfigurationGet(baseConfig); testConfigurationGet(hConfig); testConfigurationGet(conf); }
From source file:com.github.steveash.typedconfig.ConfigProxyFactory.java
/** * Simple convenience method that creates a proxy, implementing the given interface class, that retrieves values from the given {@link HierarchicalConfiguration}. * <p/>/*from w w w. ja va2 s .co m*/ * <tt>interfaze</tt> must represent a class that will be used as a "strongly-typed" configuration proxy whcih may * be optionally annotated with {@link com.github.steveash.typedconfig.annotation.ConfigProxy} containing methods optionally annotated with {@link com.github.steveash.typedconfig.annotation.Config} * * @param interfaze * @param configuration * @return */ @SuppressWarnings("unchecked") public <T> T make(Class<T> interfaze, HierarchicalConfiguration configuration) { Preconditions.checkNotNull(interfaze); Preconditions.checkArgument(interfaze.isInterface(), "You can only build proxies for interfaces"); // the context listens to the root configuration because the subnode configs dont seem to propagate events configuration.addConfigurationListener(context); ConfigBinding binding = ConfigBinding.makeRootBinding(TypeToken.of(interfaze)); ValueResolverFactory factory = context.getRegistry().lookup(binding); return (T) factory.makeForThis(binding, configuration, context).resolve(); }