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

项目:herd    文件:ReloadablePropertySource.java   
/**
 * Constructs the object with all parameters specified.
 *
 * @param name the name of the property source.
 * @param source the properties.
 * @param configuration the configuration that knows how to read properties.
 * @param refreshIntervalSecs the refresh interval in seconds to wait before refreshing the properties when a property is requested.
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public ReloadablePropertySource(String name, Properties source, Configuration configuration, long refreshIntervalSecs)
{
    super(name, (Map) source);
    this.configuration = configuration;

    /*
     * Catches any errors and records it in the lastConfigurationErrorEvent variable.
     * It is safe to assume that all configurations are an instance of EventSource.
     * All concrete implementations of Configuration are an extension of AbstractConfiguration, which is an extension of EventSource.
     */
    ((EventSource) configuration).addErrorListener(new ConfigurationErrorListener()
    {
        @Override
        public void configurationError(ConfigurationErrorEvent event)
        {
            lastConfigurationErrorEvent = event;
        }
    });

    this.refreshIntervalMillis = refreshIntervalSecs * MILLISECONDS_IN_A_SECOND;
    updateLastRefreshTime();
    updateRefreshInterval();
    LOGGER.info("A refresh interval has been configured. propertiesRefreshIntervalInSeconds={}", refreshIntervalSecs);
}
项目:otroslogviewer    文件:OtrosConfiguration.java   
/**
 * Creates a new instance of {@code DataConfiguration} and sets the
 * wrapped configuration.
 *
 * @param configuration the wrapped configuration
 */
public OtrosConfiguration(Configuration configuration) {
  super(configuration);
  if (configuration instanceof EventSource) {
    eventSource = (EventSource) configuration;
  } else {
    eventSource = this;
  }

}