File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refresh a Singleton Object values

 
Ansa Suseelan
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I am woring on a MOM system, where we load the application specific values from an XML file thru a servlet init() method during the application start up time and put into a hashtable with key-value pair. A Singleton class is created to access these values. Now i want to change the xml file and refresh the hashtable with the new values without restarting the server. Is there any option to do it?
Thanks,
Ansa
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your singleton object's class provide a method to refresh or re-read the xml file?
 
Ansa Suseelan
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the class contains methods such as put,get,add and remove objects, which inturns calls another class which extends Hashtable. It is possible to clear all the contents and create the new instance by manually. But i want this to be done automatically whenever/immediately the file get changed.
Thanks,
Ansa
[ April 17, 2008: Message edited by: Ansa Suseelan ]
 
bala nagireddy
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a a logic in the singleton class like whenver someone tries to get the any value from hashtable you can check whether the file contents are changed before returning the value and then update the hashtable and then return the new value.
 
Ansa Suseelan
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, the logic sounds ok, but this will affect the performance !!! In this logic we will have to check the file property each time we access the hashtable. As I have mentioend earlier its a MOM system processing >1M records daily. Is there any listener available for file change or folder change?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic