Hi,
Let me explain why I thought of using singleton. This is a simple example of dynamic statistics monitoring in the management interface. This is for monitoring total requests for an engine.
- A handler of a globally engaged module increments a count at each invocation.
- Webservice deployed in the same Axis2 engine provides a getTotalRequests() method to check the current value of the count.
- Same count variable should be accessible from a MBean, which exposes it as an attribute.
- Both Webservice and MBean should be able to set the count to zero.
In this scenario same count variable has to be accessed by three objects: handler, webservice and MBean. So I thought of using a singleton object which stores this variable. Therefore all other objects can get a reference to it.
If we can store this information in the configeration context and access it form any object, we can use context instead of sigleton.
How can I access the configuration context within a web service? And where in the configuration context should I store information? I think we have to store an object which contains all the information.
Another approach I thought of is to store the information in an object and register it in the MBeanServer. So that all other objects can access it from the MBeanServer by providing its name. This approach would give us all feathers of using the singleton method, but without having to make our objects singleton.
Any suggestions....
Thanks,
Chathura.
