/** * 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); }
@Override public void configurationError(ConfigurationErrorEvent event) { logger.log(OpLevel.ERROR, "Configuration error detected, event={0}", event, event.getCause()); repListener.repositoryError(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_EXCEPTION, event.getPropertyName(), event.getPropertyValue(), event.getCause())); }
public void configurationError(ConfigurationErrorEvent event) { System.out.println("An internal error occurred!"); configurationChanged(event); event.getCause().printStackTrace(); }