Package com.sun.xml.ws.developer.servlet
Annotation Type HttpSessionScope
@Retention(RUNTIME)
@Target(TYPE)
@Documented
@WebServiceFeatureAnnotation(id="http://jax-ws.dev.java.net/features/servlet/httpSessionScope",
bean=HttpSessionScopeFeature.class)
@InstanceResolverAnnotation(HttpSessionInstanceResolver.class)
public @interface HttpSessionScope
Designates a service class that should be tied to
HttpSession
scope.
When a service class is annotated with this annotation like the following,
the JAX-WS RI runtime will instanciate a new instance of the service class for
each HttpSession
.
@WebService
@HttpSessionScope
class CounterService { protected int count = 0; public CounterService() {} public int inc() { return count++; } }
This allows you to use instance fields for storing per-session state (in the above example, it will create a separate counter for each client.)
The service instance will be GCed when the corresponding HttpSession
is GCed. Refer to servlet documentation for how to configure the timeout behavior.
- Since:
- JAX-WS 2.1
- Author:
- Kohsuke Kawaguchi