|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.xml.ws.api.server.InstanceResolver<T>
com.sun.xml.ws.api.server.AbstractInstanceResolver<T>
com.sun.xml.ws.server.AbstractMultiInstanceResolver<T>
com.sun.xml.ws.server.StatefulInstanceResolver<T>
public final class StatefulInstanceResolver<T>
InstanceResolver that looks at JAX-WS cookie header to
determine the instance to which a message will be routed.
See StatefulWebServiceManager for more about user-level semantics.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.sun.xml.ws.api.server.AbstractInstanceResolver |
|---|
AbstractInstanceResolver.FieldInjectionPlan<T,R>, AbstractInstanceResolver.InjectionPlan<T,R>, AbstractInstanceResolver.MethodInjectionPlan<T,R> |
| Nested classes/interfaces inherited from interface com.sun.xml.ws.developer.StatefulWebServiceManager |
|---|
StatefulWebServiceManager.Callback<T> |
| Field Summary |
|---|
| Fields inherited from class com.sun.xml.ws.server.AbstractMultiInstanceResolver |
|---|
clazz, owner |
| Constructor Summary | |
|---|---|
StatefulInstanceResolver(Class<T> clazz)
|
|
| Method Summary | ||
|---|---|---|
void |
dispose()
Called by WSEndpoint
when WSEndpoint.dispose() is called. |
|
|
export(Class<EPR> adrsVer,
Packet currentRequest,
T o)
Exports an object. |
|
|
export(Class<EPR> adrsVer,
Packet currentRequest,
T o,
EPRRecipe recipe)
The same as StatefulWebServiceManager.export(Class, Packet, Object) except
that it takes EPRRecipe. |
|
|
export(Class<EPR> adrsVer,
String endpointAddress,
String wsdlAddress,
T o,
EPRRecipe recipe)
|
|
|
export(Class<EPR> adrsVer,
String endpointAddress,
T o)
Exports an object. |
|
|
export(Class<EPR> epr,
T o)
Exports an object. |
|
|
export(Class<EPR> epr,
T o,
EPRRecipe recipe)
Exports an object. |
|
|
export(Class<EPR> epr,
WebServiceContext context,
T o)
Exports an object (for asynchronous web services.) |
|
W3CEndpointReference |
export(T o)
Exports an object. |
|
void |
postInvoke(Packet request,
T servant)
Called by the default Invoker after the method call is done. |
|
T |
resolve(EndpointReference epr)
Checks if the given EPR represents an object that has been exported from this manager. |
|
T |
resolve(Packet request)
Decides which instance of 'T' serves the given request message. |
|
void |
setFallbackInstance(T o)
Sets the "fallback" instance. |
|
void |
setTimeout(long milliseconds,
StatefulWebServiceManager.Callback<T> callback)
Configures timeout for exported instances. |
|
void |
start(WSWebServiceContext wsc,
WSEndpoint endpoint)
Called by WSEndpoint when it's set up. |
|
void |
touch(T o)
Resets the time out timer for the given instance. |
|
void |
unexport(T o)
Unexports the given instance. |
|
| Methods inherited from class com.sun.xml.ws.server.AbstractMultiInstanceResolver |
|---|
create, dispose, prepare |
| Methods inherited from class com.sun.xml.ws.api.server.AbstractInstanceResolver |
|---|
buildInjectionPlan, findAnnotatedMethod, getResourceInjector, invokeMethod |
| Methods inherited from class com.sun.xml.ws.api.server.InstanceResolver |
|---|
createDefault, createDefault, createFromInstanceResolverAnnotation, createInvoker, createNewInstance, createSingleton, start |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StatefulInstanceResolver(Class<T> clazz)
| Method Detail |
|---|
@NotNull public T resolve(Packet request)
InstanceResolverThis 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.
resolve in class InstanceResolver<T>request - Always non-null. Represents the request message to be served.
The caller may not consume the Message.
public void postInvoke(@NotNull
Packet request,
@NotNull
T servant)
InstanceResolverInvoker after the method call is done.
This gives InstanceResolver a chance to do clean up.
Alternatively, one could override InstanceResolver.createInvoker() to
create a custom invoker to do this in more flexible way.
The default implementation is a no-op.
postInvoke in class InstanceResolver<T>request - The same request packet given to InstanceResolver.resolve(Packet) method.servant - The object returned from the InstanceResolver.resolve(Packet) method.
public void start(WSWebServiceContext wsc,
WSEndpoint endpoint)
InstanceResolverWSEndpoint when it's set up.
This is an opportunity for InstanceResolver
to do a endpoint-specific initialization process.
start in class AbstractMultiInstanceResolver<T>wsc - The WebServiceContext instance to be injected
to the user instances (assuming InstanceResolverpublic void dispose()
InstanceResolverWSEndpoint
when WSEndpoint.dispose() is called.
This allows InstanceResolver to do final clean up.
This method is guaranteed to be only called once by WSEndpoint.
dispose in class InstanceResolver<T>@NotNull public W3CEndpointReference export(T o)
StatefulWebServiceManagerJAX-WS RI assigns an unique EPR to the exported object, and from now on, messages that are sent to this EPR will be routed to the given object.
The object will be locked in memory, so be sure to
unexport it when it's no longer needed.
Notice that the obtained EPR contains the address of the service, which depends on the currently processed request. So invoking this method multiple times with the same object may return different EPRs, if such multiple invocations are done while servicing different requests. (Of course all such EPRs point to the same object, so messages sent to those EPRs will be served by the same instance.)
export in interface StatefulWebServiceManager<T>W3CEndpointReference that identifies this exported
object. Always non-null.
@NotNull
public <EPR extends EndpointReference> EPR export(Class<EPR> epr,
T o)
StatefulWebServiceManager
This method works like StatefulWebServiceManager.export(Object) except that
you can obtain the EPR in your choice of addressing version,
by passing in the suitable epr parameter.
export in interface StatefulWebServiceManager<T>epr - Either W3CEndpointReference or MemberSubmissionEndpointReference.
If other types are specified, this method throws an WebServiceException.
EndpointReference-subclass that identifies this exported
object.
public <EPR extends EndpointReference> EPR export(Class<EPR> epr,
T o,
EPRRecipe recipe)
StatefulWebServiceManager
This method works like StatefulWebServiceManager.export(Object) except that
you can obtain the EPR in your choice of addressing version,
by passing in the suitable epr parameter.
export in interface StatefulWebServiceManager<T>epr - Either W3CEndpointReference or MemberSubmissionEndpointReference.
If other types are specified, this method throws an WebServiceException.o - The object to be exported, whose identity be referenced by the returned EPR.recipe - The additional data to be put into EPR. Can be null.
EndpointReference-subclass that identifies this exported
object.
@NotNull
public <EPR extends EndpointReference> EPR export(Class<EPR> epr,
WebServiceContext context,
T o)
StatefulWebServiceManagerasynchronous web services.)
This method works like StatefulWebServiceManager.export(Class,Object) but it
takes an extra WebServiceContext that represents the request currently
being processed by the caller (the JAX-WS RI remembers this when the service
processing is synchronous, and that's why this parameter is only needed for
asynchronous web services.)
WebServiceContext is needed?
The obtained EPR contains address, such as host name. The server does not
know what its own host name is (or there are more than one of them),
so this value is determined by what the current client thinks the server name is.
This is why we need to take WebServiceContext. Pass in the
object given to AsyncProvider.invoke(Object, AsyncProviderCallback,WebServiceContext).
export in interface StatefulWebServiceManager<T>
@NotNull
public <EPR extends EndpointReference> EPR export(Class<EPR> adrsVer,
@NotNull
Packet currentRequest,
T o)
StatefulWebServiceManager
This method is not meant for application code.
This is for Tubes that wish to use stateful web service support.
export in interface StatefulWebServiceManager<T>currentRequest - The request that we are currently processing. This is used to infer the address in EPR.StatefulWebServiceManager.export(Class, WebServiceContext, Object)
public <EPR extends EndpointReference> EPR export(Class<EPR> adrsVer,
@NotNull
Packet currentRequest,
T o,
EPRRecipe recipe)
StatefulWebServiceManagerStatefulWebServiceManager.export(Class, Packet, Object) except
that it takes EPRRecipe.
export in interface StatefulWebServiceManager<T>recipe - See StatefulWebServiceManager.export(Class, Object, EPRRecipe).
@NotNull
public <EPR extends EndpointReference> EPR export(Class<EPR> adrsVer,
String endpointAddress,
T o)
StatefulWebServiceManager
export in interface StatefulWebServiceManager<T>endpointAddress - The endpoint address URL. Normally, this information is determined by other inputs,
like Packet or WebServiceContext.
@NotNull
public <EPR extends EndpointReference> EPR export(Class<EPR> adrsVer,
String endpointAddress,
String wsdlAddress,
T o,
EPRRecipe recipe)
public void unexport(@Nullable
T o)
StatefulWebServiceManagerJAX-WS will release a strong reference to unexported objects, and they will never receive further requests (requests targeted for those unexported objects will be served by the fallback object.)
unexport in interface StatefulWebServiceManager<T>o - if null, this method will be no-op.public T resolve(EndpointReference epr)
StatefulWebServiceManagerThis method can be used to have two endpoints in the same application communicate locally.
resolve in interface StatefulWebServiceManager<T>public void setFallbackInstance(T o)
StatefulWebServiceManagerWhen the incoming request does not have the necessary header to distinguish instances of T, or when the header is present but its value does not correspond with any of the active exported instances known to the JAX-WS, then the JAX-WS RI will try to route the request to the fallback instance.
This provides the application an opportunity to perform application specific error recovery.
If no fallback instance is provided, then the JAX-WS RI will send back the fault. By default, no fallback instance is set.
This method can be invoked any time, but most often you'd like to use one instance at the get-go. The following code example illustrates how to do this:
@WebServiceclass BankAccount { ... continuting from the example in class javadoc ... @Resourcestatic void setManager(StatefulWebServiceManagermanager) { manager.setFallbackInstance(new BankAccount(0) { @Overridevoid deposit(int amount) { putToAuditRecord(id); if(thisLooksBad()) callPolice(); throw newWebServiceException("No such bank account exists"); } }); } }
setFallbackInstance in interface StatefulWebServiceManager<T>o - Can be null.
public void setTimeout(long milliseconds,
StatefulWebServiceManager.Callback<T> callback)
StatefulWebServiceManagerWhen configured, the JAX-WS RI will internally use a timer so that exported objects that have not received any request for the given amount of minutes will be automatically unexported.
At some point after the time out has occurred for an instance,
the JAX-WS RI will invoke the StatefulWebServiceManager.Callback to notify the application
that the time out has reached. Application then has a choice of
either let the object go unexported, or touch
let the object live for another round of timer interval.
If no callback is set, the expired object will automatically unexported.
When you call this method multiple times, its effect on existing instances are unspecified, although deterministic.
setTimeout in interface StatefulWebServiceManager<T>milliseconds - The time out interval. Specify 0 to cancel the timeout timer.
Note that this only guarantees that time out does not occur
at least until this amount of time has elapsed. It does not
guarantee that the time out will always happen right after
the timeout is reached.callback - application may choose to install a callback to control the
timeout behavior.public void touch(T o)
StatefulWebServiceManagerIf the object is null, not exported, or already unexported, this method will be no-op.
touch in interface StatefulWebServiceManager<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||