/** * 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); }
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); }
@Override public void addErrorListener(ConfigurationErrorListener l) { eventSource.addErrorListener(l); }
@Override public boolean removeErrorListener(ConfigurationErrorListener l) { return eventSource.removeErrorListener(l); }
@Override public Collection<ConfigurationErrorListener> getErrorListeners() { return eventSource.getErrorListeners(); }