This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I work on JEE project that communicates to multiple external systems. I have to implement connection log, i.e. up/down for each external subsystem. If outgoing request is successful then connection state is switched to UP, if not then it is DOWN. The log should not contain same repeating entries for the connection. That is only when state is switched, entry has to be written to log file. This is why we have to store current connection state somewhere. We update connection state in Hashtable everytime request goes out. What is the best place to put this hashtable. Initially I made singleton. But now we are thinking to move it to stateless session bean and save this data in context.
It depends on how many read/ write operations you want to perform, if you are going to have many read/ write operations on that state values then a cache system like EhCache would be very suitable for a single instance or a clustered environment. You can use ehCache event handlers to store the changes in a database system or a log file when an state value changes. By using event system you will not involve your system with database for many read/ write operations. On the other hand If you have a few read and write operations then Database would do the trick.