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 EJB invocations from an EJB client- Author:
- David M. Lloyd, Jaikiran Pai
-
-
Field Summary
Fields Modifier and Type Field Description static StringPRIVATE_ATTACHMENTS_KEYstatic StringRETURNED_CONTEXT_DATA_KEYA context data key that may contain a Set of Strings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReturnedContextDataKey(String key)Indicates to the server that a client side interceptor is interested in the context data that is stored under the given key.voidaddSuppressed(Throwable cause)Add a suppressed exception to the request.voidaddSuppressed(Supplier<? extends Throwable> cause)Add a suppressed exception to the request.booleanawaitCancellationResult()Wait to determine whether this invocation was cancelled.voiddiscardResult()Discard the result from this request.org.wildfly.security.auth.client.AuthenticationContextgetAuthenticationContext()intgetCompressionLevel()Get the compression hint level.MethodgetInvokedMethod()Get the invoked proxy method.ObjectgetInvokedProxy()Get the invoked proxy object.EJBMethodLocatorgetMethodLocator()Get the EJB method locator.StringgetMethodSignatureString()Get the method type signature string, used to identify the method.Object[]getParameters()Get the invocation method parameters.<T> TgetProxyAttachment(AttachmentKey<T> key)Get a value attached to the proxy.longgetRemainingInvocationTime(TimeUnit timeUnit)Get the remaining invocation time in the given unit.ObjectgetResult()Get the invocation result from this request.ClientTransactionPolicygetTransactionPolicy()Determine whether the method has an explicit transaction policy set.booleanisBlockingCaller()Determine whether this invocation is currently blocking the calling thread.booleanisClientAsync()Determine whether the method is marked client-asynchronous, meaning that invocation should be asynchronous regardless of whether the server-side method is asynchronous.booleanisCompressRequest()Determine whether the request is expected to be compressed.booleanisCompressResponse()Determine whether the response is expected to be compressed.booleanisIdempotent()Determine whether the method is marked idempotent, meaning that the method may be invoked more than one time with no additional effect.booleanisSynchronous()Determine whether the method is definitely synchronous, that is, it is not marked client-async, and the return value of the method is notvoidorFuture<?>.<T> TremoveProxyAttachment(AttachmentKey<T> key)Remove a value attached to the proxy.voidrequestRetry()Request that the current operation be retried if possible.voidsendRequest()Proceed with sending the request normally.voidsetBlockingCaller(boolean blockingCaller)Establish whether this invocation is currently blocking the calling thread.<T> voidsetLocator(EJBLocator<T> locator)Set the locator for the invocation target.-
Methods inherited from class org.jboss.ejb.client.AbstractInvocationContext
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
nullif 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
nullif 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:
trueif the method is marked client-asynchronous,falseotherwise
-
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 notvoidorFuture<?>.- Returns:
trueif the method is definitely synchronous,falseif 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:
trueif the method is marked idempotent,falseotherwise
-
getTransactionPolicy
public ClientTransactionPolicy getTransactionPolicy()
Determine whether the method has an explicit transaction policy set.- Returns:
- the transaction policy, if any, or
nullif none was explicitly set
-
isCompressRequest
public boolean isCompressRequest()
Determine whether the request is expected to be compressed.- Returns:
trueif the request is expected to be compressed,falseotherwise
-
isCompressResponse
public boolean isCompressResponse()
Determine whether the response is expected to be compressed.- Returns:
trueif the response is expected to be compressed,falseotherwise
-
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 EJB method locator.- Returns:
- the EJB method locator
-
isBlockingCaller
public boolean isBlockingCaller()
Determine whether this invocation is currently blocking the calling thread.- Returns:
trueif the calling thread is being blocked;falseotherwise
-
setBlockingCaller
public void setBlockingCaller(boolean blockingCaller)
Establish whether this invocation is currently blocking the calling thread.- Parameters:
blockingCaller-trueif the calling thread is being blocked;falseotherwise
-
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:AbstractInvocationContextRequest that the current operation be retried if possible.- Specified by:
requestRetryin classAbstractInvocationContext
-
sendRequest
public void sendRequest() throws ExceptionProceed 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 IllegalStateExceptionDiscard 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_VALUEis 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:AbstractInvocationContextSet the locator for the invocation target.- Overrides:
setLocatorin classAbstractInvocationContext- Parameters:
locator- the locator for the invocation target
-
getAuthenticationContext
@NotNull public org.wildfly.security.auth.client.AuthenticationContext getAuthenticationContext()
-
awaitCancellationResult
public boolean awaitCancellationResult()
Wait to determine whether this invocation was cancelled.- Returns:
trueif the invocation was cancelled;falseif it completed or failed or the thread was interrupted
-
-