/** * Creates an event and calls {@link ConfigurationListener#configurationChanged(ConfigurationEvent)} * for all listeners while catching Throwable. */ @Override protected void fireEvent(int type, String propName, Object propValue, boolean beforeUpdate) { if (listeners == null || listeners.size() == 0) { return; } ConfigurationEvent event = createEvent(type, propName, propValue, beforeUpdate); for (ConfigurationListener l: listeners) { try { l.configurationChanged(event); } catch (ValidationException e) { if (beforeUpdate) { throw e; } else { logger.error("Unexpected exception", e); } } catch (Throwable e) { logger.error("Error firing configuration event", e); } } }
/** * Creates an event and calls {@link ConfigurationListener#configurationChanged(ConfigurationEvent)} * for all listeners while catching Throwable. */ @Override protected void fireEvent(int type, String propName, Object propValue, boolean beforeUpdate) { if (listeners == null || listeners.size() == 0) { return; } ConfigurationEvent event = createEvent(type, propName, propValue, beforeUpdate); for (ConfigurationListener l: listeners) { try { l.configurationChanged(event); } catch (ValidationException e) { if (beforeUpdate) { throw e; } else { logger.error("Unexpected exception", e); } } catch (Throwable e) { logger.error("Error firing configuration event", e); } } }
@Override public void configurationChanged(ConfigurationEvent event) { if (event.getSource() instanceof XMLConfiguration) { for (ConfigurationListener listener : getConfigurationListeners()) { listener.configurationChanged(event); } } }
@Override public void configurationChanged(ConfigurationEvent event) { if (event.getSource() instanceof XMLConfiguration) { for (ConfigurationListener listener : getConfigurationListeners()) { listener.configurationChanged(event); } } }
/** * Creates an event object and delivers it to all registered event * listeners. The method will check first if sending an event is allowed * (making use of the {@code detailEvents} property), and if * listeners are registered. * * @param type the event's type * @param propName the name of the affected property (can be <b>null</b>) * @param propValue the value of the affected property (can be <b>null</b>) * @param before the before update flag */ protected void fireEvent(int type, String propName, Object propValue, boolean before) { if (checkDetailEvents(-1)) { Iterator<ConfigurationListener> it = listeners.iterator(); if (it.hasNext()) { ConfigurationEvent event = createEvent(type, propName, propValue, before); while (it.hasNext()) { it.next().configurationChanged(event); } } } }
/** * Creates an event object and delivers it to all registered event * listeners. The method will check first if sending an event is allowed * (making use of the {@code detailEvents} property), and if * listeners are registered. * * @param type the event's type * @param propName the name of the affected property (can be <b>null</b>) * @param propValue the value of the affected property (can be <b>null</b>) * @param before the before update flag */ protected void fireEvent(int type, String propName, Object propValue, boolean before) { if (checkDetailEvents(-1)) { Iterator<ConfigurationListener> it = listeners.iterator(); if (it.hasNext()) { ConfigurationEvent event = createEvent(type, propName, propValue, before); while (it.hasNext()) { it.next().configurationChanged(event); } } } }
@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)); } } } }
@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)); } } } }
flumeConfigListener.configurationChanged(new ConfigurationEvent(this, AbstractConfiguration.EVENT_SET_PROPERTY, FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY, config.getProperty(FlumeLoggerLoader.FLUME_LOGGER_ENABLED_PROPERTY), false));