Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

events in non-GUI environment

 
Maalti Iyer
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!