Class EJBClientInvocationContext


  • public final class EJBClientInvocationContext
    extends AbstractInvocationContext
    An invocation context for Enterprise Beans invocations from an Enterprise Bean client
    Author:
    David M. Lloyd, Jaikiran Pai
    • Field Detail

      • RETURNED_CONTEXT_DATA_KEY

        public static final String RETURNED_CONTEXT_DATA_KEY
        A context data key that may contain a Set of Strings. Any context data on the server side invocation context stored under these keys will be returned to the client.
        See Also:
        Constant Field Values
    • Method Detail

      • addReturnedContextDataKey

        public void addReturnedContextDataKey​(String key)
        Indicates to the server that a client side interceptor is interested in the context data that is stored under the given key. Any object on the context data map (i.e. InvocationContext.getContextData() that is present at the end of the server invocation will be serialised and returned to the client. If an object is present under this key and is not serializable then the request will fail.
        Parameters:
        key - The context data key the client interceptor is interested in
      • getProxyAttachment

        public <T> T getProxyAttachment​(AttachmentKey<T> key)
        Get a value attached to the proxy.
        Type Parameters:
        T - the value type
        Parameters:
        key - the attachment key
        Returns:
        the value, or null if there is none
      • removeProxyAttachment

        public <T> T removeProxyAttachment​(AttachmentKey<T> key)
        Remove a value attached to the proxy.
        Type Parameters:
        T - the value type
        Parameters:
        key - the attachment key
        Returns:
        the value, or null if there is none
      • isClientAsync

        public boolean isClientAsync()
        Determine whether the method is marked client-asynchronous, meaning that invocation should be asynchronous regardless of whether the server-side method is asynchronous.
        Returns:
        true if the method is marked client-asynchronous, false otherwise
      • isSynchronous

        public boolean isSynchronous()
        Determine whether the method is definitely synchronous, that is, it is not marked client-async, and the return value of the method is not void or Future<?>.
        Returns:
        true if the method is definitely synchronous, false if the method may be asynchronous
      • isIdempotent

        public boolean isIdempotent()
        Determine whether the method is marked idempotent, meaning that the method may be invoked more than one time with no additional effect.
        Returns:
        true if the method is marked idempotent, false otherwise
      • getTransactionPolicy

        public ClientTransactionPolicy getTransactionPolicy()
        Determine whether the method has an explicit transaction policy set.
        Returns:
        the transaction policy, if any, or null if none was explicitly set
      • isCompressRequest

        public boolean isCompressRequest()
        Determine whether the request is expected to be compressed.
        Returns:
        true if the request is expected to be compressed, false otherwise
      • isCompressResponse

        public boolean isCompressResponse()
        Determine whether the response is expected to be compressed.
        Returns:
        true if the response is expected to be compressed, false otherwise
      • getCompressionLevel

        public int getCompressionLevel()
        Get the compression hint level. If no compression hint is given, -1 is returned.
        Returns:
        the compression hint level, or -1 for no compression hint
      • getMethodSignatureString

        public String getMethodSignatureString()
        Get the method type signature string, used to identify the method.
        Returns:
        the method signature string
      • getMethodLocator

        public EJBMethodLocator getMethodLocator()
        Get the Enterprise Beans method locator.
        Returns:
        the Enterprise Beans method locator
      • isBlockingCaller

        public boolean isBlockingCaller()
        Determine whether this invocation is currently blocking the calling thread.
        Returns:
        true if the calling thread is being blocked; false otherwise
      • setBlockingCaller

        public void setBlockingCaller​(boolean blockingCaller)
        Establish whether this invocation is currently blocking the calling thread.
        Parameters:
        blockingCaller - true if the calling thread is being blocked; false otherwise
      • addSuppressed

        public void addSuppressed​(Throwable cause)
        Add a suppressed exception to the request.
        Parameters:
        cause - the suppressed exception (must not be null)
      • addSuppressed

        public void addSuppressed​(Supplier<? extends Throwable> cause)
        Add a suppressed exception to the request.
        Parameters:
        cause - the suppressed exception (must not be null)
      • sendRequest

        public void sendRequest()
                         throws Exception
        Proceed with sending the request normally.
        Throws:
        Exception - if the request was not successfully sent
      • getInvokedProxy

        public Object getInvokedProxy()
        Get the invoked proxy object.
        Returns:
        the invoked proxy
      • getInvokedMethod

        public Method getInvokedMethod()
        Get the invoked proxy method.
        Returns:
        the invoked method
      • getParameters

        public Object[] getParameters()
        Get the invocation method parameters.
        Returns:
        the invocation method parameters
      • getRemainingInvocationTime

        public long getRemainingInvocationTime​(TimeUnit timeUnit)
        Get the remaining invocation time in the given unit. If there is no invocation timeout, Long.MAX_VALUE is always returned. If the invocation time has elapsed, 0 is returned.
        Parameters:
        timeUnit - the time unit (must not be null)
        Returns:
        the invocation's remaining time in the provided unit
      • awaitCancellationResult

        public boolean awaitCancellationResult()
        Wait to determine whether this invocation was cancelled.
        Returns:
        true if the invocation was cancelled; false if it completed or failed or the thread was interrupted