@Retention(value=RUNTIME) @Target(value=TYPE) @Documented @WebServiceFeatureAnnotation(id="http://jax-ws.dev.java.net/features/servlet/httpSessionScope", bean=HttpSessionScopeFeature.class) @InstanceResolverAnnotation(value=HttpSessionInstanceResolver.class) public @interface HttpSessionScope
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.
Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.