Guys, I've a peculiar problem to take care. Our application has a configuration file. We need to change the configuration settings, externally (from unix shell) and application should be aware of the settings changes dynamically without bouncing the app server. Is it possible to accomplish this using events/action listeners. A piece of code snippet - greatly appreciated. Thanks, Maalti iyer.
You should be able to do that. The basic steps would be to create a subclass of EventObject to encapsulate the event maybe, call it ConfigurationEvent; create a Runnable that periodically checks for file modification, call it ConfigurarionEventDispatcher with an addConfigurationListener(ConfigurationListener l) method; and an interface for call back, call it ConfigurationListener with a method called configChanged(ConfigurationEvent e). The ConfigurarionEventDispatcher would run in a separate thread and when lastModified() on the config file changed, it would then call configChanged() on all registered ConfigurationListeners.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher