当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationListener类代码示例

本文整理汇总了Java中org.apache.commons.configuration.event.ConfigurationListener的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationListener类的具体用法?Java ConfigurationListener怎么用?Java ConfigurationListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConfigurationListener类属于org.apache.commons.configuration.event包,在下文中一共展示了ConfigurationListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialValue

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
@Override
protected PropertyUtil initialValue() {
	PropertyUtil p = new PropertyUtil(
			System.getProperty("application.properties.file",
					"resources/application.properties"));
	p.setProperty("isfw.build.info", getBuildInfo());
	p.setEncoding(p.getString(ApplicationProperties.LOCALE_CHAR_ENCODING.key, "UTF-8"));

	File prjDir = new File(".").getAbsoluteFile().getParentFile();
	p.setProperty("project.path", prjDir.getAbsolutePath());
	if(!p.containsKey("project.name"))
	p.setProperty("project.name", prjDir.getName());

	log.info("ISFW build info: " + p.getProperty("isfw.build.info"));
	String[] resources = p.getStringArray("env.resources", "resources");
	for (String resource : resources) {
		addBundle(p, resource);
	}
	ConfigurationListener cl = new PropertyConfigurationListener();
	p.addConfigurationListener(cl);
	return p;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:23,代码来源:ConfigurationManager.java

示例2: DynamicRequestLimiter

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
public DynamicRequestLimiter(DynamicDistributedLogConfiguration dynConf,
                             StatsLogger statsLogger, Feature rateLimitDisabledFeature) {
    final StatsLogger limiterStatsLogger = statsLogger.scope("dynamic");
    this.dynConf = dynConf;
    this.rateLimitDisabledFeature = rateLimitDisabledFeature;
    this.listener = new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent event) {
            // Note that this method may be called several times if several config options
            // are changed. The effect is harmless except that we create and discard more
            // objects than we need to.
            LOG.debug("Config changed callback invoked with event {} {} {} {}", new Object[] {
                    event.getPropertyName(), event.getPropertyValue(), event.getType(),
                    event.isBeforeUpdate()});
            if (!event.isBeforeUpdate()) {
                limiterStatsLogger.getCounter("config_changed").inc();
                LOG.debug("Rebuilding limiter");
                limiter = build();
            }
        }
    };
    LOG.debug("Registering config changed callback");
    dynConf.addConfigurationListener(listener);
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:25,代码来源:DynamicRequestLimiter.java

示例3: onApplicationEvent

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
@Override
public void onApplicationEvent(EnvironmentChangeEvent event) {
	AbstractConfiguration manager = ConfigurationManager.getConfigInstance();
	for (String key : event.getKeys()) {
		for (ConfigurationListener listener : manager
				.getConfigurationListeners()) {
			Object source = event.getSource();
			// TODO: Handle add vs set vs delete?
			int type = AbstractConfiguration.EVENT_SET_PROPERTY;
			String value = this.env.getProperty(key);
			boolean beforeUpdate = false;
			listener.configurationChanged(new ConfigurationEvent(source, type,
					key, value, beforeUpdate));
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:17,代码来源:ArchaiusAutoConfiguration.java

示例4: environmentChangeEventPropagated

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
@Test
public void environmentChangeEventPropagated() {
	this.context = new AnnotationConfigApplicationContext(
			ArchaiusAutoConfiguration.class);
	ConfigurationManager.getConfigInstance().addConfigurationListener(
			new ConfigurationListener() {
				@Override
				public void configurationChanged(ConfigurationEvent event) {
					if (event.getPropertyName().equals("my.prop")) {
						ArchaiusAutoConfigurationTests.this.propertyValue = event
								.getPropertyValue();
					}
				}
			});
	EnvironmentTestUtils.addEnvironment(this.context, "my.prop=my.newval");
	this.context.publishEvent(new EnvironmentChangeEvent(Collections
			.singleton("my.prop")));
	assertEquals("my.newval", this.propertyValue);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:20,代码来源:ArchaiusAutoConfigurationTests.java

示例5: invokeListeners

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
private void invokeListeners()
{
    if (m_configurationListeners != null)
    {
        try
        {
            ConfigurationEvent event = new ConfigurationEvent(this,AbstractConfiguration.EVENT_SET_PROPERTY,null,this, false);
            for (ConfigurationListener listener:m_configurationListeners)
            {
                listener.configurationChanged(event);
            }
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:RogerParkinson,项目名称:MaduraConfiguration,代码行数:19,代码来源:MaduraConfiguration.java

示例6: childValue

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
@Override
protected PropertyUtil childValue(PropertyUtil parentValue) {
	PropertyUtil cp = new PropertyUtil(parentValue);
	ConfigurationListener cl = new PropertyConfigurationListener();
	cp.addConfigurationListener(cl);
	return cp;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:8,代码来源:ConfigurationManager.java

示例7: addConfigurationListener

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
private void addConfigurationListener() {
    final MetricsCloudWatchConfiguration springConfig = this;
    ConfigurationManager.getConfigInstance().addConfigurationListener(new ConfigurationListener() {

        @Override
        public synchronized void configurationChanged(ConfigurationEvent event) {
            if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY ||
                    event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY)) {
                return;
            }
            if (event.isBeforeUpdate()) {
                return;
            }
            String name = event.getPropertyName();

            if (!(name.equals(METRICS_AWS_ENABLED) ||
                    name.equals(METRICS_AWS_FILTER) ||
                    name.equals(METRICS_AWS_PUBLISH_INTERVAL) ||
                    name.equals(METRICS_AWS_PUBLISH_INTERVAL_UNIT))) {
                return;
            }

            springConfig.enabled = name.equals(METRICS_AWS_ENABLED) ? Boolean.parseBoolean(event.getPropertyValue() + "") : springConfig.enabled;
            destroyReporter();
            if (springConfig.enabled) {
                createReporter();
            }

        }
    });
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:32,代码来源:MetricsCloudWatchConfiguration.java

示例8: addConfigurationListener

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
private void addConfigurationListener() {
    final MetricsGraphiteConfiguration springConfig = this;
    ConfigurationManager.getConfigInstance().addConfigurationListener(new ConfigurationListener() {

        @Override
        public synchronized void configurationChanged(ConfigurationEvent event) {
            if (!(event.getType() == AbstractConfiguration.EVENT_SET_PROPERTY ||
                    event.getType() == AbstractConfiguration.EVENT_ADD_PROPERTY)) {
                return;
            }
            if (event.isBeforeUpdate()) {
                return;
            }
            String name = event.getPropertyName();
            if (!(name.equals(METRICS_GRAPHITE_ENABLED) ||
                    name.equals(METRICS_GRAPHITE_SERVER) ||
                    name.equals(METRICS_GRAPHITE_PORT) ||
                    name.equals(METRICS_GRAPHITE_FILTER) ||
                    name.equals(METRICS_GRAPHITE_PUBLISH_INTERVAL) ||
                    name.equals(METRICS_GRAPHITE_PUBLISH_INTERVAL_UNIT))) {
                return;
            }

            springConfig.enabled = name.equals(METRICS_GRAPHITE_ENABLED) ? Boolean.parseBoolean(event.getPropertyValue() + "") : springConfig.enabled;

            destroyReporterLoader();
            if (springConfig.enabled) {
                createReporterLoader();
            }

        }
    });
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:34,代码来源:MetricsGraphiteConfiguration.java

示例9: ConfigurationHelper

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
private ConfigurationHelper(String applicationContextName)
{	

 DataSource ds = getDataSourceForContext(applicationContextName);         			
 DatabaseConfiguration config = new DatabaseConfiguration(ds,
                 TABLE_NAME, KEY_COLUMN, VALUE_COLUMN);
			
 ConfigurationListener listener = new LockoutConfigurationListener();
 config.addConfigurationListener(listener);
 config.addErrorListener((ConfigurationErrorListener) listener);			
 config.setDelimiterParsingDisabled(true);
 dataConfig = new DataConfiguration(config);
}
 
开发者ID:NCIP,项目名称:common-security-module,代码行数:14,代码来源:ConfigurationHelper.java

示例10: addConfigurationListener

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
public void addConfigurationListener(ConfigurationListener l) {
	((PropertiesConfiguration)configuration).addConfigurationListener(l);
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:4,代码来源:PmsConfiguration.java

示例11: removeConfigurationListener

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
public void removeConfigurationListener(ConfigurationListener l) {
	((PropertiesConfiguration)configuration).removeConfigurationListener(l);
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:4,代码来源:PmsConfiguration.java

示例12: testExceptionInConfigLoad

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
@Test(timeout = 60000)
public void testExceptionInConfigLoad() throws Exception {
    PropertiesWriter writer = new PropertiesWriter();
    writer.setProperty("prop1", "1");
    writer.save();

    DeterministicScheduler mockScheduler = new DeterministicScheduler();
    FileConfigurationBuilder builder = new PropertiesConfigurationBuilder(writer.getFile().toURI().toURL());
    ConcurrentConstConfiguration conf = new ConcurrentConstConfiguration(new DistributedLogConfiguration());
    List<FileConfigurationBuilder> fileConfigBuilders = Lists.newArrayList(builder);
    ConfigurationSubscription confSub =
            new ConfigurationSubscription(conf, fileConfigBuilders, mockScheduler, 100, TimeUnit.MILLISECONDS);

    final AtomicInteger count = new AtomicInteger(1);
    conf.addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent event) {
            LOG.info("config changed {}", event);
            // Throw after so we actually see the update anyway.
            if (!event.isBeforeUpdate()) {
                count.getAndIncrement();
                throw new RuntimeException("config listener threw and exception");
            }
        }
    });

    int i = 0;
    int initial = 0;
    while (count.get() == initial) {
        writer.setProperty("prop1", Integer.toString(i++));
        writer.save();
        mockScheduler.tick(100, TimeUnit.MILLISECONDS);
    }

    initial = count.get();
    while (count.get() == initial) {
        writer.setProperty("prop1", Integer.toString(i++));
        writer.save();
        mockScheduler.tick(100, TimeUnit.MILLISECONDS);
    }
}
 
开发者ID:twitter,项目名称:distributedlog,代码行数:42,代码来源:TestConfigurationSubscription.java

示例13: addConfigurationListener

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
@Override
public void addConfigurationListener(ConfigurationListener l) {
  eventSource.addConfigurationListener(l);
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:5,代码来源:OtrosConfiguration.java

示例14: removeConfigurationListener

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
@Override
public boolean removeConfigurationListener(ConfigurationListener l) {
  return eventSource.removeConfigurationListener(l);
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:5,代码来源:OtrosConfiguration.java

示例15: getConfigurationListeners

import org.apache.commons.configuration.event.ConfigurationListener; //导入依赖的package包/类
@Override
public Collection<ConfigurationListener> getConfigurationListeners() {
  return eventSource.getConfigurationListeners();
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:5,代码来源:OtrosConfiguration.java


注:本文中的org.apache.commons.configuration.event.ConfigurationListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。