This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide and have Khalid Mughal and Vasily Strelnikov on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Change the value at runtime

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To put the things in a simple way. I think Rajasekar is advising you to create a singleton class.
 
reply
    Bookmark Topic Watch Topic
  • New Topic