File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes events in  non-GUI environment Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "events in  non-GUI environment" Watch "events in  non-GUI environment" New topic
Author

events in non-GUI environment

Maalti Iyer
Ranch Hand

Joined: Jul 11, 2001
Posts: 52
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

Joined: Jan 30, 2002
Posts: 3451
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: events in non-GUI environment
 
Similar Threads
Am I being silly by taking the must too far? Andrews book confuses me.
Design Patterns in my design after refactoring the server side classes, advice needed.
Scheduled Startup Servlet and clustered environment
How to migrate from Glassfish to JBoss?
STRUTS 2 : How to explicitly specify struts.xml in web.xml ?