I am designing a webservice which requires a single instance of an object to be created, and then run continously while other webservices access it. I only have experience with simple webservices at the moment, passing text around etc., and so any help would be appreciated.
I have no knowledge of EJB, but would a solution here be to utilise EJB, and pass the bean to each webservice that needs it, (it needs to be synchronized obviously). The problem with my current approaches is the persistence of the object, I want each webservice to be accessing the same object.
Many thanks in advance,
If all the webservices are deployed under the same application context, you can:
- Create the bean in a Filter
- Add the instance of the bean to the web application context
- Use the the bean from the app context when the servlet (I am assuming Axis or some other Servlet based implementation)
I maybe VERY wrong here but certainly a start to what could be an interesting discussion.
Sorry, what do you mean by application context? :-)
And yes, I am using Axis on Tomcat.
I'll elaborate slightly to help in my view of what I would like to happen (all this happens within a controlled workflow);
1. Initially an object (TaskBagManager) will be created, and within this, a Hashtable or something similar initialised.
2. A reference to this will be returned.
3. When certain constraints have been met, a task will fire off, which will add detail to the Hashtable created in (1), by calling some exposed method of the object.
4. Repeat 3 for multiple tasks.
All the while, the object (TaskBagManager) created in (1) is running away, and every n seconds performs some analysis on the Hashtable (which should be being updated every so often) and performs some task based on the analysis.
The reason to expose this as a webservice is partly proof of concept, but when released in the wild it will be needed for interoperability over many worldwide sites.
Any help would be appreciated! Thanks :-)
1. Why are you using web services at all?
2. What does your singleton do?