• Post Reply Bookmark Topic Watch Topic
  • New Topic

Change the value at runtime  RSS feed

 
Jyoti Aggarwal
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have created a caching system. It is currently reading the thread pool size from the properties file. It need to be changed in such a way so the value can be chnaged at runtime without re-starting the server. Please throw some ideas how it can be done?
 
Rajasekhar Devi Reddy
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about maintaining an application configuration? If that is so, I would do it this way..

Have a class that provides methods to read application configuration properties, like config.getproperty(propertyName). All the classes that need to read some property will call this method.

The class constructor is private and read the properties file here. Class will have a private variable that holds its own instance.

Other objects of the application obtain an instance of this class by calling a static method Configuration.getInstance(). This method returns the local variable that we talked about above.

write a method to reload configuration that makes the local instance variable null and re creates it . Call this method when ever a change is made to your properties file.

Hope it helps.

 
Ragav Baskaran
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To put the things in a simple way. I think Rajasekar is advising you to create a singleton class.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!