Thursday, July 31, 2008

Updating the state of a Singleton Object after specific interval of time

I've created a Singleton Object which holds some values which are fetched from the database table. Following are the class specs:

1) All setter methods are private
2) All getter methods are public
3) One configuration method that sets all the values in the related attributes of class using their private setters

The need was to update the state of this singleton object when there are any changes made in the configuration table in the database. But to achieve this, I need to restart the server each time when any changes has been made in the configuration table.

So I created one WatchDog class in a thread that continuously changes the state of a singleton configuration object after a specific interval of time, & this time interval in-turn is fetched dynamically from the same configuration table from the database :)

2 comments:

Anonymous said...

i agree your idea ! very nice blog

Anonymous said...

Although from different places, but this perception is consistent, which is relatively rare point!


_________________________________________________________________________________________________________________

"Look at the sky. We are not alone. The whole Universe is friendly to us and conspires only to give the best to those who dream and work."

- Dr. A P J Abdul Kalam
_________________________________________________________________________________________________________________