Class InstanceResolver<T>
- java.lang.Object
-
- com.sun.xml.ws.api.server.InstanceResolver<T>
-
- Direct Known Subclasses:
AbstractInstanceResolver
public abstract class InstanceResolver<T> extends Object
Determines the instance that serves the given request packet.The JAX-WS spec always use a singleton instance to serve all the requests, but this hook provides a convenient way to route messages to a proper receiver.
Externally, an instance of
InstanceResolver
is associated withWSEndpoint
.Possible Uses
One can use WS-Addressing message properties to decide which instance to deliver a message. This would be an important building block for a stateful web services.
One can associate an instance of a service with a specific WS-RM session.
- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description InstanceResolver()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> InstanceResolver<T>
createDefault(Class<T> clazz)
Creates a defaultInstanceResolver
that serves the given class.static <T> InstanceResolver<T>
createDefault(Class<T> clazz, boolean bool)
Deprecated.This is added here because a Glassfish integration happened with this signature.static <T> InstanceResolver<T>
createFromInstanceResolverAnnotation(Class<T> clazz)
Checks forInstanceResolverAnnotation
and creates an instance resolver from it if any.Invoker
createInvoker()
Wraps thisInstanceResolver
into anInvoker
.protected static <T> T
createNewInstance(Class<T> cl)
static <T> InstanceResolver<T>
createSingleton(T singleton)
Creates aInstanceResolver
implementation that always returns the specified singleton instance.void
dispose()
Called byWSEndpoint
whenWSEndpoint.dispose()
is called.void
postInvoke(Packet request, T servant)
Called by the defaultInvoker
after the method call is done.abstract T
resolve(Packet request)
Decides which instance of 'T' serves the given request message.void
start(WSWebServiceContext wsc, WSEndpoint endpoint)
Called byWSEndpoint
when it's set up.void
start(jakarta.xml.ws.WebServiceContext wsc)
Deprecated.
-
-
-
Method Detail
-
resolve
@NotNull public abstract T resolve(@NotNull Packet request)
Decides which instance of 'T' serves the given request message.This method is called concurrently by multiple threads. It is also on a criticail path that affects the performance. A good implementation should try to avoid any synchronization, and should minimize the amount of work as much as possible.
- Parameters:
request
- Always non-null. Represents the request message to be served. The caller may not consume theMessage
.
-
postInvoke
public void postInvoke(@NotNull Packet request, @NotNull T servant)
Called by the defaultInvoker
after the method call is done. This givesInstanceResolver
a chance to do clean up.Alternatively, one could override
createInvoker()
to create a custom invoker to do this in more flexible way.The default implementation is a no-op.
- Parameters:
request
- The same request packet given toresolve(Packet)
method.servant
- The object returned from theresolve(Packet)
method.- Since:
- 2.1.2
-
start
public void start(@NotNull WSWebServiceContext wsc, @NotNull WSEndpoint endpoint)
Called byWSEndpoint
when it's set up.This is an opportunity for
InstanceResolver
to do a endpoint-specific initialization process.- Parameters:
wsc
- TheWebServiceContext
instance to be injected to the user instances (assumingInstanceResolver
-
start
public void start(@NotNull jakarta.xml.ws.WebServiceContext wsc)
Deprecated.
-
dispose
public void dispose()
Called byWSEndpoint
whenWSEndpoint.dispose()
is called. This allowsInstanceResolver
to do final clean up.This method is guaranteed to be only called once by
WSEndpoint
.
-
createSingleton
public static <T> InstanceResolver<T> createSingleton(T singleton)
Creates aInstanceResolver
implementation that always returns the specified singleton instance.
-
createDefault
public static <T> InstanceResolver<T> createDefault(@NotNull Class<T> clazz, boolean bool)
Deprecated.This is added here because a Glassfish integration happened with this signature. Please do not use this. Will be removed after the next GF integration.
-
createDefault
public static <T> InstanceResolver<T> createDefault(@NotNull Class<T> clazz)
Creates a defaultInstanceResolver
that serves the given class.
-
createFromInstanceResolverAnnotation
public static <T> InstanceResolver<T> createFromInstanceResolverAnnotation(@NotNull Class<T> clazz)
Checks forInstanceResolverAnnotation
and creates an instance resolver from it if any. Otherwise null.
-
createNewInstance
protected static <T> T createNewInstance(Class<T> cl)
-
createInvoker
@NotNull public Invoker createInvoker()
Wraps thisInstanceResolver
into anInvoker
.
-
-