This content has been marked as final.
Show 1 reply
-
1. Re: Forcing singleton reload
jomu78 May 31, 2012 4:39 AM (in response to jomu78)Hi,
I found a solution using CDI (JSR 299 / 330). Instead of using the listeners I now inject an javax.enterprise.event.Event instead.
@Inject Event<ConfigurationReloadEvent> event;
ConfigReloadEvent is an empty class as I do not need any payload at the moment. When the configurtion is reloaded, I simply need to "fire" this event.
event.fire(new ConfigurationReloadEvent());
The listeners are also configured using annotations
public void reloadConfiguraiton(@Observes ConfigurationReloadEvent event) { // do what ever needs to be done when notfied about config reload }
So no need to destroy and re-create the singletons, they just listen on the event and do whats needed. You only have to take care about the synchronisation - you never know when the event is fired and in which status your application currently is.