Package org.jboss.ejb.client
Class EJBClientInvocationContext
- java.lang.Object
-
- org.jboss.ejb.client.Attachable
-
- org.jboss.ejb.client.AbstractInvocationContext
-
- org.jboss.ejb.client.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 Summary
Fields Modifier and Type Field Description static String
PRIVATE_ATTACHMENTS_KEY
static String
RETURNED_CONTEXT_DATA_KEY
A context data key that may contain a Set of Strings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.void
addSuppressed(Throwable cause)
Add a suppressed exception to the request.void
addSuppressed(Supplier<? extends Throwable> cause)
Add a suppressed exception to the request.boolean
awaitCancellationResult()
Wait to determine whether this invocation was cancelled.void
discardResult()
Discard the result from this request.int
getCompressionLevel()
Get the compression hint level.Method
getInvokedMethod()
Get the invoked proxy method.Object
getInvokedProxy()
Get the invoked proxy object.EJBMethodLocator
getMethodLocator()
Get the Enterprise Beans method locator.String
getMethodSignatureString()
Get the method type signature string, used to identify the method.Object[]
getParameters()
Get the invocation method parameters.<T> T
getProxyAttachment(AttachmentKey<T> key)
Get a value attached to the proxy.long
getRemainingInvocationTime(TimeUnit timeUnit)
Get the remaining invocation time in the given unit.Object
getResult()
Get the invocation result from this request.ClientTransactionPolicy
getTransactionPolicy()
Determine whether the method has an explicit transaction policy set.boolean
isBlockingCaller()
Determine whether this invocation is currently blocking the calling thread.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.boolean
isCompressRequest()
Determine whether the request is expected to be compressed.boolean
isCompressResponse()
Determine whether the response is expected to be compressed.boolean
isIdempotent()
Determine whether the method is marked idempotent, meaning that the method may be invoked more than one time with no additional effect.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 notvoid
orFuture<?>
.<T> T
removeProxyAttachment(AttachmentKey<T> key)
Remove a value attached to the proxy.void
requestRetry()
Request that the current operation be retried if possible.void
sendRequest()
Proceed with sending the request normally.void
setBlockingCaller(boolean blockingCaller)
Establish whether this invocation is currently blocking the calling thread.<T> void
setLocator(EJBLocator<T> locator)
Set the locator for the invocation target.-
Methods inherited from class org.jboss.ejb.client.AbstractInvocationContext
getAuthenticationContext, getClientContext, getContextData, getDestination, getInitialCluster, getLocator, getTargetAffinity, getTransaction, getViewClass, getWeakAffinity, setDestination, setTargetAffinity, setTransaction, setWeakAffinity
-
Methods inherited from class org.jboss.ejb.client.Attachable
getAttachment, getAttachments, putAttachment, putAttachmentIfAbsent, removeAttachment, removeAttachment, replaceAttachment, replaceAttachment
-
-
-
-
Field Detail
-
PRIVATE_ATTACHMENTS_KEY
public static final String PRIVATE_ATTACHMENTS_KEY
- See Also:
- Constant Field Values
-
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 notvoid
orFuture<?>
.- 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 benull
)
-
addSuppressed
public void addSuppressed(Supplier<? extends Throwable> cause)
Add a suppressed exception to the request.- Parameters:
cause
- the suppressed exception (must not benull
)
-
requestRetry
public void requestRetry()
Description copied from class:AbstractInvocationContext
Request that the current operation be retried if possible.- Specified by:
requestRetry
in classAbstractInvocationContext
-
sendRequest
public void sendRequest() throws Exception
Proceed with sending the request normally.- Throws:
Exception
- if the request was not successfully sent
-
getResult
public Object getResult() throws Exception
Get the invocation result from this request. The result is not actually acquired unless all interceptors call this method. Should only be called fromEJBClientInterceptor.handleInvocationResult(EJBClientInvocationContext)
.- Returns:
- the invocation result
- Throws:
Exception
- if the invocation did not succeed
-
discardResult
public void discardResult() throws IllegalStateException
Discard the result from this request. Should only be called fromEJBClientInterceptor.handleInvocationResult(EJBClientInvocationContext)
.- Throws:
IllegalStateException
- if there is no result to discard
-
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 benull
)- Returns:
- the invocation's remaining time in the provided unit
-
setLocator
public <T> void setLocator(EJBLocator<T> locator)
Description copied from class:AbstractInvocationContext
Set the locator for the invocation target.- Overrides:
setLocator
in classAbstractInvocationContext
- Parameters:
locator
- the locator for the invocation target
-
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
-
-