Web services are implemented in one of two ways: either as a servlet, or as a session bean.
Both of these are managed by the container, and both have appropriate lifecycle callbacks that you can use to populate member variables.
Typically, these tend to be reasonably long lived objects, but they have different behaviors.
For example, a Servlet is created just once by the container, and then reused by all of the requests, which means you need to be careful about dealing multiple threads accessing the same member variables.
Whereas Session Beans tend to be pooled up to a configurable amount, and reused for requests. These don't have any multi threading issues.
But, minimally, they both have lifecycle callbacks that are used during the creation and destruction of the instance by the container. You'll need to look up the details.
[Message sent by forum member 'whartung' (whartung)]
http://forums.java.net/jive/thread.jspa?messageID=252140