Java 类org.apache.commons.configuration.event.ConfigurationEvent 实例源码

项目:distributedlog    文件:DynamicRequestLimiter.java   
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);
}
项目:spring-cloud-netflix    文件:ArchaiusAutoConfiguration.java   
@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));
        }
    }
}
项目:spring-cloud-netflix    文件:ArchaiusAutoConfigurationTests.java   
@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);
}
项目:MaduraConfiguration    文件:MaduraConfiguration.java   
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);
        }
    }
}
项目:otroslogviewer    文件:MarkAllFoundAction.java   
@Override
public void configurationChanged(ConfigurationEvent e) {
  if (e.getPropertyName() != null && e.getPropertyName().equalsIgnoreCase("gui.markColor")) {
    final Object propertyValue = e.getPropertyValue();
    if (propertyValue instanceof MarkerColors) {
      markerColors = (MarkerColors) propertyValue;
    } else if (propertyValue instanceof String) {
      String value = (String) propertyValue;
      markerColors = MarkerColors.fromString(value);
    }
  }
}
项目:otroslogviewer    文件:ConfTest.java   
public void configurationChanged(ConfigurationEvent event) {
  if (!event.isBeforeUpdate()) {
    // only display events after the modification was done
    System.out.println(name + " Received event!");
    System.out.println(name + " Type = " + event.getType());
    if (event.getPropertyName() != null) {
      System.out.println(name + " Property name = " + event.getPropertyName());
    }
    if (event.getPropertyValue() != null) {
      System.out.println(name + " Property value = " + event.getPropertyValue());
    }
  }
}
项目:batmass    文件:BMProject.java   
@Override
        public void configurationChanged(ConfigurationEvent event) {
            if (!event.isBeforeUpdate()) {
                // only display events after the modification was done
                projectState.markModified();

                // get the root node from LogicalViewProvider and update the project display name
                BMProjectLogicalView lvp = BMProject.this.getLookup().lookup(BMProjectLogicalView.class);
                BMProjectLogicalView.BMProjectNode rootNode = lvp.getRootNode();
                rootNode.setDisplayName(rootNode.getDisplayName());

//                NotifyDescriptor.Message msg = new NotifyDescriptor.Message("in ConfigChangeListener.configurationChanged()");
//                DialogDisplayer.getDefault().notify(msg);
            }
        }
项目:tajo    文件:TajoSystemMetrics.java   
@Override
public synchronized void configurationChanged(ConfigurationEvent event) {
  if (!event.isBeforeUpdate()) {
    stopAndClearReporter();
    start();
  }
}
项目:incubator-tajo    文件:TajoSystemMetrics.java   
@Override
public synchronized void configurationChanged(ConfigurationEvent event) {
  if (!event.isBeforeUpdate()) {
    stopAndClearReporter();
    start();
  }
}
项目:tajo-cdh    文件:TajoSystemMetrics.java   
@Override
public synchronized void configurationChanged(ConfigurationEvent event) {
  if (!event.isBeforeUpdate()) {
    stopAndClearReporter();
    start();
  }
}
项目:chassis    文件:MetricsCloudWatchConfiguration.java   
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();
            }

        }
    });
}
项目:chassis    文件:MetricsGraphiteConfiguration.java   
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();
            }

        }
    });
}
项目:commons-configuration-zookeeper    文件:ZKPropertiesConfigurationEventTest.java   
/**
 * {@inheritDoc}
 */
@Override
public void configurationChanged(final ConfigurationEvent pEvent) {

    if (!pEvent.isBeforeUpdate()) {
        eventType = pEvent.getType();
        path = (String) pEvent.getPropertyValue();
        System.out.println(path);
    }
}
项目:TNT4J    文件:FileTokenRepository.java   
@Override
public void configurationChanged(ConfigurationEvent event) {
    if (event.isBeforeUpdate()) {
        return;
    }
    logger.log(OpLevel.DEBUG, "configurationChanged: type={0}, {1}:{2}", event.getType(), event.getPropertyName(),
            event.getPropertyValue());
    switch (event.getType()) {
    case AbstractConfiguration.EVENT_ADD_PROPERTY:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_ADD_KEY,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    case AbstractConfiguration.EVENT_SET_PROPERTY:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_SET_KEY,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    case AbstractConfiguration.EVENT_CLEAR_PROPERTY:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_CLEAR_KEY,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    case AbstractConfiguration.EVENT_CLEAR:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_CLEAR,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    case AbstractFileConfiguration.EVENT_RELOAD:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_RELOAD,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    }
}
项目:Runway-SDK    文件:CommonsConfigurationReader.java   
/**
   * @see org.apache.commons.configuration.event.ConfigurationListener#configurationChanged(org.apache.commons.configuration.event.ConfigurationEvent)
   */
  @Override
  public void configurationChanged(ConfigurationEvent event)
  {
//    if (!event.isBeforeUpdate()) {
//      this.config = ((CompositeConfiguration) this.config).interpolatedConfiguration();
//    }
  }
项目:project-bacon    文件:Preferences.java   
@Override
public void configurationChanged(ConfigurationEvent event) {

    Object prop = conf.getProperty(event.getPropertyName());

    //Add to the list of changed settings.
    if (event.isBeforeUpdate() && conf.containsKey(event.getPropertyName())) {

        if (event.getPropertyValue() instanceof Integer) {
            if (prop instanceof String) {
                if (!(((String) prop).equals(((Integer) event.getPropertyValue()) + ""))) {
                    changedSettings.add(event.getPropertyName());
                }
            } else {
                if (!(((Integer) prop).equals(((Integer) event.getPropertyValue())))) {
                    changedSettings.add(event.getPropertyName());
                }
            }
        } else if (event.getPropertyValue() instanceof Double) {
            if (prop instanceof String) {
                if (!(((String) prop).equals(((Double) event.getPropertyValue()) + ""))) {
                    changedSettings.add(event.getPropertyName());
                }
            } else {
                if (!(((Double) prop).equals(((Double) event.getPropertyValue())))) {
                    changedSettings.add(event.getPropertyName());
                }
            }
        } else if (event.getPropertyValue() instanceof String) {
            if (!(((String) prop).equals(((String) event.getPropertyValue())))) {
                changedSettings.add(event.getPropertyName());
            }
        }
    }
}
项目:beankeeper    文件:NodeManagerImpl.java   
/**
 * If anything changed, reload the configuration values.
 */
public void configurationChanged(ConfigurationEvent event)
{
   if ( (event.getPropertyName()!=null) && 
         (event.getPropertyName().startsWith("beankeeper.n")) )
      configurationReload();
}
项目:MaduraConfiguration    文件:SampleListener.java   
public void configurationChanged(ConfigurationEvent arg0)
{
    System.out.println("identifier: "+m_identifier);
    Configuration configuration = (Configuration)arg0.getPropertyValue();
    String s = configuration.getString(m_identifier);
    s.toString();
}
项目:MaduraConfiguration    文件:ReloadListener.java   
public void configurationChanged(ConfigurationEvent event)
{
    if (!event.isBeforeUpdate() && event.getType() == AbstractFileConfiguration.EVENT_RELOAD)
    {
        if (m_applicationContext instanceof AbstractRefreshableApplicationContext)
        {
            ((AbstractRefreshableApplicationContext)m_applicationContext).refresh();
        }
    }
}
项目:unitimes    文件:MessageResources.java   
public void configurationChanged(ConfigurationEvent arg0) {
    SessionListener.reloadMessageResources(basePath);
}
项目:distributedlog    文件:TestConfigurationSubscription.java   
@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);
    }
}
项目:av-sched    文件:ConfigurationManager.java   
@Override
public void configurationChanged(ConfigurationEvent event) {
    needsReload = true;
    LOG.debug("Configuration reloaded, notification should happen soon.");
}
项目:unitime    文件:MessageResources.java   
public void configurationChanged(ConfigurationEvent arg0) {
    SessionListener.reloadMessageResources(basePath);
}
项目:pi    文件:PropertyParseBase.java   
@Override
public void configurationChanged(ConfigurationEvent event) {
    LOG.debug(String.format("configurationChanged(%s)", event.getPropertyValue()));
    processProperties(ConfigurationConverter.getProperties((Configuration) event.getSource()));
}
项目:activecheck    文件:ActivecheckPlugin.java   
@Override
public final void configurationChanged(ConfigurationEvent arg0) {
    logger.debug("Received configuration change '{}' for plugin '{}' attribute '{}' => '{}'",
            arg0.getType(), getPluginName(), arg0.getPropertyName(), arg0.getPropertyValue());
    reloadConfiguration();
}
项目:beankeeper    文件:ModificationTrackerImpl.java   
public void configurationChanged(ConfigurationEvent event)
{
   if ( (event.getPropertyName()!=null) && 
         (event.getPropertyName().startsWith("beankeeper.cache.modification_")) )
      configurationReload();
}
项目:beankeeper    文件:ConnectionSourceImpl.java   
public void configurationChanged(ConfigurationEvent event)
{
   if ( "beankeeper.pool.connection_timeout".equals(event.getPropertyName()) )
      configurationReload();
}
项目:beankeeper    文件:MinimalResultsCache.java   
public void configurationChanged(ConfigurationEvent event)
{
   if ( (event.getPropertyName()!=null) && 
         (event.getPropertyName().startsWith("beankeeper.cache")) )
      configurationReload();
}
项目:p2p-core    文件:PropertyParseBase.java   
@Override
public void configurationChanged(ConfigurationEvent event) {
    LOG.debug(String.format("configurationChanged(%s)", event.getPropertyValue()));
    processProperties(ConfigurationConverter.getProperties((Configuration) event.getSource()));
}