Class Stub

java.lang.Object
com.sun.xml.ws.client.Stub
All Implemented Interfaces:
Component, ComponentRegistry, ResponseContextReceiver, WSBindingProvider, jakarta.xml.ws.BindingProvider, Closeable, AutoCloseable
Direct Known Subclasses:
DispatchImpl, SEIStub

public abstract class Stub extends Object implements WSBindingProvider, ResponseContextReceiver, ComponentRegistry
Base class for stubs, which accept method invocations from client applications and pass the message to a Tube for processing.

This class implements the management of pipe instances, and most of the BindingProvider methods.

Author:
Kohsuke Kawaguchi
  • Field Details

    • PREVENT_SYNC_START_FOR_ASYNC_INVOKE

      public static final String PREVENT_SYNC_START_FOR_ASYNC_INVOKE
      Internal flag indicating async dispatch should be used even when the SyncStartForAsyncInvokeFeature is present on the binding associated with a stub. There is no type associated with this property on the request context. Its presence is what triggers the 'prevent' behavior.
      See Also:
    • owner

      protected final WSServiceDelegate owner
      The WSServiceDelegate object that owns us.
    • endpointReference

      @Nullable protected WSEndpointReference endpointReference
      Non-null if this stub is configured to talk to an EPR.

      When this field is non-null, its reference parameters are sent as out-bound headers. This field can be null even when addressing is enabled, but if the addressing is not enabled, this field must be null.

      Unlike endpoint address, we are not letting users to change the EPR, as it contains references to services and so on that we don't want to change.

    • binding

      protected final BindingImpl binding
    • portInfo

      protected final WSPortInfo portInfo
    • addrVersion

      protected AddressingVersion addrVersion
      represents AddressingVersion on binding if enabled, otherwise null;
    • requestContext

      public RequestContext requestContext
    • wsdlPort

      @Nullable protected final WSDLPort wsdlPort
    • portname

      protected QName portname
    • operationDispatcher

      protected OperationDispatcher operationDispatcher
  • Constructor Details

    • Stub

      @Deprecated protected Stub(WSServiceDelegate owner, Tube master, BindingImpl binding, WSDLPort wsdlPort, EndpointAddress defaultEndPointAddress, @Nullable WSEndpointReference epr)
      Deprecated.
      Parameters:
      master - The created stub will send messages to this pipe.
      binding - As a BindingProvider, this object will return this binding from BindingProvider.getBinding().
      defaultEndPointAddress - The destination of the message. The actual destination could be overridden by RequestContext.
      epr - To create a stub that sends out reference parameters of a specific EPR, give that instance. Otherwise null. Its address field will not be used, and that should be given separately as the defaultEndPointAddress.
    • Stub

      @Deprecated protected Stub(QName portname, WSServiceDelegate owner, Tube master, BindingImpl binding, WSDLPort wsdlPort, EndpointAddress defaultEndPointAddress, @Nullable WSEndpointReference epr)
      Deprecated.
      Parameters:
      portname - The name of this port
      master - The created stub will send messages to this pipe.
      binding - As a BindingProvider, this object will return this binding from BindingProvider.getBinding().
      defaultEndPointAddress - The destination of the message. The actual destination could be overridden by RequestContext.
      epr - To create a stub that sends out reference parameters of a specific EPR, give that instance. Otherwise null. Its address field will not be used, and that should be given separately as the defaultEndPointAddress.
    • Stub

      protected Stub(WSPortInfo portInfo, BindingImpl binding, Tube master, EndpointAddress defaultEndPointAddress, @Nullable WSEndpointReference epr)
      Parameters:
      portInfo - PortInfo for this stub
      binding - As a BindingProvider, this object will return this binding from BindingProvider.getBinding().
      master - The created stub will send messages to this pipe.
      defaultEndPointAddress - The destination of the message. The actual destination could be overridden by RequestContext.
      epr - To create a stub that sends out reference parameters of a specific EPR, give that instance. Otherwise null. Its address field will not be used, and that should be given separately as the defaultEndPointAddress.
    • Stub

      protected Stub(WSPortInfo portInfo, BindingImpl binding, EndpointAddress defaultEndPointAddress, @Nullable WSEndpointReference epr)
      Parameters:
      portInfo - PortInfo for this stub
      binding - As a BindingProvider, this object will return this binding from BindingProvider.getBinding().
      defaultEndPointAddress - The destination of the message. The actual destination could be overridden by RequestContext.
      epr - To create a stub that sends out reference parameters of a specific EPR, give that instance. Otherwise null. Its address field will not be used, and that should be given separately as the defaultEndPointAddress.
  • Method Details

    • getWSDLPort

      public WSDLPort getWSDLPort()
    • getService

      public WSService getService()
    • getTubes

      public Pool<Tube> getTubes()
    • getPortInfo

      public WSPortInfo getPortInfo()
      Specified by:
      getPortInfo in interface WSBindingProvider
      Returns:
      WSPortInfo object that captures the port information for which the stub is created.
    • getOperationDispatcher

      @Nullable public OperationDispatcher getOperationDispatcher()
      Nullable when there is no associated WSDL Model
    • getPortName

      @NotNull protected abstract QName getPortName()
      Gets the port name that this stub is configured to talk to.

      When wsdlPort is non-null, the port name is always the same as WSDLPort.getName(), but this method returns a port name even if no WSDL is available for this stub.

    • getServiceName

      @NotNull protected final QName getServiceName()
      Gets the service name that this stub is configured to talk to.

      When wsdlPort is non-null, the service name is always the same as the one that's inferred from WSDLPort.getOwner(), but this method returns a port name even if no WSDL is available for this stub.

    • getExecutor

      public final Executor getExecutor()
      Gets the Executor to be used for asynchronous method invocations.

      Note that the value this method returns may different from invocations to invocations. The caller must not cache.

      Returns:
      always non-null.
    • process

      protected final Packet process(Packet packet, RequestContext requestContext, ResponseContextReceiver receiver)
      Passes a message to a pipe for processing.

      Unlike Tube instances, this method is thread-safe and can be invoked from multiple threads concurrently.

      Parameters:
      packet - The message to be sent to the server
      requestContext - The RequestContext when this invocation is originally scheduled. This must be the same object as requestContext for synchronous invocations, but for asynchronous invocations, it needs to be a snapshot captured at the point of invocation, to correctly satisfy the spec requirement.
      receiver - Receives the ResponseContext. Since the spec requires that the asynchronous invocations must not update response context, depending on the mode of invocation they have to go to different places. So we take a setter that abstracts that away.
    • processAsync

      protected final void processAsync(AsyncResponseImpl<?> receiver, Packet request, RequestContext requestContext, Fiber.CompletionCallback completionCallback)
      Passes a message through a Tubeline for processing. The processing happens asynchronously and when the response is available, Fiber.CompletionCallback is called. The processing could happen on multiple threads.

      Unlike Tube instances, this method is thread-safe and can be invoked from multiple threads concurrently.

      Parameters:
      receiver - The Response implementation
      request - The message to be sent to the server
      requestContext - The RequestContext when this invocation is originally scheduled. This must be the same object as requestContext for synchronous invocations, but for asynchronous invocations, it needs to be a snapshot captured at the point of invocation, to correctly satisfy the spec requirement.
      completionCallback - Once the processing is done, the callback is invoked.
    • configureFiber

      protected void configureFiber(Fiber fiber)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getBinding

      public final WSBinding getBinding()
      Specified by:
      getBinding in interface jakarta.xml.ws.BindingProvider
    • getRequestContext

      public final Map<String,Object> getRequestContext()
      Specified by:
      getRequestContext in interface jakarta.xml.ws.BindingProvider
    • resetRequestContext

      public void resetRequestContext()
    • getResponseContext

      public final ResponseContext getResponseContext()
      Specified by:
      getResponseContext in interface jakarta.xml.ws.BindingProvider
    • setResponseContext

      public void setResponseContext(ResponseContext rc)
      Description copied from interface: ResponseContextReceiver
      Called upon the completion of the invocation to set a ResponseContext.

      This method is invoked even when the invocation fails.

      Specified by:
      setResponseContext in interface ResponseContextReceiver
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getWSEndpointReference

      public final WSEndpointReference getWSEndpointReference()
      Description copied from interface: WSBindingProvider
      Similar to {link BindingProvider#getEndpointReference(}, but returns WSEndpointReference that has more convenience methods
      Specified by:
      getWSEndpointReference in interface WSBindingProvider
      Returns:
      WSEndpointReference of the target servcie endpoint
    • getEndpointReference

      public final jakarta.xml.ws.wsaddressing.W3CEndpointReference getEndpointReference()
      Specified by:
      getEndpointReference in interface jakarta.xml.ws.BindingProvider
    • getEndpointReference

      public final <T extends jakarta.xml.ws.EndpointReference> T getEndpointReference(Class<T> clazz)
      Specified by:
      getEndpointReference in interface jakarta.xml.ws.BindingProvider
    • getManagedObjectManager

      @NotNull public org.glassfish.gmbal.ManagedObjectManager getManagedObjectManager()
      Description copied from interface: WSBindingProvider
      Get the ManagedObjectManager for this provider.
      Specified by:
      getManagedObjectManager in interface WSBindingProvider
    • setOutboundHeaders

      public final void setOutboundHeaders(List<Header> headers)
      Description copied from interface: WSBindingProvider
      Sets the out-bound headers to be added to messages sent from this BindingProvider.

      Calling this method would discard any out-bound headers that were previously set.

      A new Header object can be created by using one of the methods on Headers.

      Specified by:
      setOutboundHeaders in interface WSBindingProvider
      Parameters:
      headers - The headers to be added to the future request messages. To clear the outbound headers, pass in either null or empty list.
    • setOutboundHeaders

      public final void setOutboundHeaders(Header... headers)
      Description copied from interface: WSBindingProvider
      Sets the out-bound headers to be added to messages sent from this BindingProvider.

      Works like WSBindingProvider.setOutboundHeaders(List) except that it accepts a var arg array.

      Specified by:
      setOutboundHeaders in interface WSBindingProvider
      Parameters:
      headers - Can be null or empty.
    • getInboundHeaders

      public final List<Header> getInboundHeaders()
      Specified by:
      getInboundHeaders in interface WSBindingProvider
    • setAddress

      public final void setAddress(String address)
      Description copied from interface: WSBindingProvider
      Sets the endpoint address for all the invocations that happen from BindingProvider. Instead of doing the following

      ((BindingProvider)proxy).getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "...")

      you could do this:

      ((WSBindingProvider)proxy).setAddress("...");

      Specified by:
      setAddress in interface WSBindingProvider
      Parameters:
      address - Address of the service
    • getSPI

      public <S> S getSPI(Class<S> spiType)
      Description copied from interface: Component
      Gets the specified SPI.

      This method works as a kind of directory service for SPIs, allowing various components to define private contract and talk to each other.

      Specified by:
      getSPI in interface Component
      Returns:
      null if such an SPI is not provided by this object.
    • getComponents

      public Set<Component> getComponents()
      Description copied from interface: ComponentRegistry
      Returns the set of Components registered with this object
      Specified by:
      getComponents in interface ComponentRegistry
      Returns:
      set of registered components