Package org.jboss.invocation
Class InterceptorContext
- java.lang.Object
-
- org.jboss.invocation.InterceptorContext
-
- All Implemented Interfaces:
Cloneable,PrivilegedExceptionAction<Object>
public final class InterceptorContext extends Object implements Cloneable, PrivilegedExceptionAction<Object>
An interceptor/invocation context object.- Author:
- David M. Lloyd
-
-
Constructor Summary
Constructors Constructor Description InterceptorContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InterceptorContextclone()Clone this interceptor context instance.Constructor<?>getConstructor()Get the intercepted constructor.Map<String,Object>getContextData()Get the context data which is reported to the interceptor invocation context.Interceptor[]getInterceptors()Get the current interceptors.List<Interceptor>getInterceptors$$bridge()Binary compatibility bridge for interceptors list.jakarta.interceptor.InvocationContextgetInvocationContext()Get the invocation context.MethodgetMethod()Get the invoked method which is reported to the interceptor invocation context.intgetNextInterceptorIndex()Returns the next interceptor index.Object[]getParameters()Get the method parameters which are reported to the interceptor invocation context.<T> TgetPrivateData(Class<T> type)Get a private data item.ObjectgetPrivateData(Object key)Get a private data item.ObjectgetTarget()Get the invocation target which is reported to the interceptor invocation context.ObjectgetTimer()Get the timer object which is reported to the interceptor invocation context.jakarta.transaction.TransactiongetTransaction()Get the transaction for this invocation, if any.booleanhasTransaction()Determine if a transaction supplier was established for this invocation.booleanisBlockingCaller()Determine whether this invocation is currently directly blocking the calling thread.Objectproceed()Pass the invocation on to the next step in the chain.<T> TputPrivateData(Class<T> type, T value)Insert a private data item.ObjectputPrivateData(Object key, Object value)Insert a private data item.Objectrun()Synonymous withproceed(); exists to implementPrivilegedExceptionAction.voidsetBlockingCaller(boolean blockingCaller)Establish whether this invocation is currently directly blocking the calling thread.voidsetConstructor(Constructor<?> constructor)Set the intercepted constructor.voidsetContextData(Map<String,Object> contextData)Set the context data which is reported to the interceptor invocation context.voidsetInterceptors(List<Interceptor> interceptorList)Set the interceptor array from a list.voidsetInterceptors(List<Interceptor> interceptorList, int nextIndex)Set the interceptors, with a starting index to proceed from.voidsetInterceptors(Interceptor[] interceptors)Set the interceptor iterator.voidsetInterceptors(Interceptor[] interceptors, int nextIndex)Set the interceptors, with a starting index to proceed from.voidsetMethod(Method method)Set the invoked method which is reported to the interceptor invocation context.voidsetParameters(Object[] parameters)Set the method parameters which are reported to the interceptor invocation context.voidsetTarget(Object target)Set the invocation target which is reported to the interceptor invocation context.voidsetTimer(Object timer)Set the timer object which is reported to the interceptor invocation context.voidsetTransaction(jakarta.transaction.Transaction transaction)Set the transaction for the invocation.voidsetTransactionSupplier(org.wildfly.common.function.ExceptionSupplier<jakarta.transaction.Transaction,jakarta.transaction.SystemException> transactionSupplier)Set the transaction supplier for the invocation.
-
-
-
Method Detail
-
getTarget
public Object getTarget()
Get the invocation target which is reported to the interceptor invocation context.- Returns:
- the invocation target
-
setTarget
public void setTarget(Object target)
Set the invocation target which is reported to the interceptor invocation context.- Parameters:
target- the invocation target
-
getMethod
public Method getMethod()
Get the invoked method which is reported to the interceptor invocation context.- Returns:
- the method
-
setMethod
public void setMethod(Method method)
Set the invoked method which is reported to the interceptor invocation context.- Parameters:
method- the method
-
getConstructor
public Constructor<?> getConstructor()
Get the intercepted constructor.- Returns:
- the constructor
-
setConstructor
public void setConstructor(Constructor<?> constructor)
Set the intercepted constructor.- Parameters:
constructor- the constructor
-
getParameters
public Object[] getParameters()
Get the method parameters which are reported to the interceptor invocation context.- Returns:
- the method parameters
-
setParameters
public void setParameters(Object[] parameters)
Set the method parameters which are reported to the interceptor invocation context.- Parameters:
parameters- the method parameters
-
getContextData
public Map<String,Object> getContextData() throws IllegalStateException
Get the context data which is reported to the interceptor invocation context.- Returns:
- the context data
- Throws:
IllegalStateException- if the context data was never initialized
-
setContextData
public void setContextData(Map<String,Object> contextData)
Set the context data which is reported to the interceptor invocation context.- Parameters:
contextData- the context data
-
getTimer
public Object getTimer()
Get the timer object which is reported to the interceptor invocation context.- Returns:
- the timer object
-
setTimer
public void setTimer(Object timer)
Set the timer object which is reported to the interceptor invocation context.- Parameters:
timer- the timer object
-
getInvocationContext
public jakarta.interceptor.InvocationContext getInvocationContext()
Get the invocation context.- Returns:
- the invocation context
-
hasTransaction
public boolean hasTransaction()
Determine if a transaction supplier was established for this invocation.- Returns:
trueif there is an enclosing transaction,falseotherwise
-
getTransaction
public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemExceptionGet the transaction for this invocation, if any.- Returns:
- the transaction for this invocation, or
nullif there is no transaction - Throws:
jakarta.transaction.SystemException- if the transaction import failed
-
setTransaction
public void setTransaction(jakarta.transaction.Transaction transaction)
Set the transaction for the invocation. Ifnull, then there is no enclosing transaction.- Parameters:
transaction- the transaction for the invocation
-
setTransactionSupplier
public void setTransactionSupplier(org.wildfly.common.function.ExceptionSupplier<jakarta.transaction.Transaction,jakarta.transaction.SystemException> transactionSupplier)
Set the transaction supplier for the invocation. Ifnull, then there is no enclosing transaction. The supplier must not returnnull.- Parameters:
transactionSupplier- the transaction supplier, ornullto clear the present transaction
-
getPrivateData
public <T> T getPrivateData(Class<T> type)
Get a private data item.- Type Parameters:
T- the data type- Parameters:
type- the data type class object- Returns:
- the data item or
nullif no such item exists
-
getPrivateData
public Object getPrivateData(Object key)
Get a private data item. The key will be looked up by object identity, not by value.- Parameters:
key- the object key- Returns:
- the private data object
-
putPrivateData
public <T> T putPrivateData(Class<T> type, T value)
Insert a private data item.- Type Parameters:
T- the data type- Parameters:
type- the data type class objectvalue- the data item value, ornullto remove the mapping- Returns:
- the data item which was previously mapped to this position, or
nullif no such item exists
-
putPrivateData
public Object putPrivateData(Object key, Object value)
Insert a private data item. The key is used by object identity, not by value; in addition, if the key is aClassthen the value given must be assignable to that class.- Parameters:
key- the data keyvalue- the data item value, ornullto remove the mapping- Returns:
- the data item which was previously mapped to this position, or
nullif no such item exists
-
isBlockingCaller
public boolean isBlockingCaller()
Determine whether this invocation is currently directly blocking the calling thread. This means that the interceptor is running in the same thread as the original caller.- Returns:
trueif the calling thread is being blocked;falseotherwise
-
setBlockingCaller
public void setBlockingCaller(boolean blockingCaller)
Establish whether this invocation is currently directly blocking the calling thread. This means that the interceptor is running in the same thread as the original caller.- Parameters:
blockingCaller-trueif the calling thread is being blocked;falseotherwise
-
getInterceptors
public Interceptor[] getInterceptors()
Get the current interceptors. The returned array should not be modified.- Returns:
- the interceptors
-
getInterceptors$$bridge
public List<Interceptor> getInterceptors$$bridge()
Binary compatibility bridge for interceptors list.- Returns:
- the interceptors array as a list
-
getNextInterceptorIndex
public int getNextInterceptorIndex()
Returns the next interceptor index.- Returns:
- the next interceptor index
-
setInterceptors
public void setInterceptors(Interceptor[] interceptors)
Set the interceptor iterator.- Parameters:
interceptors- the interceptor list
-
setInterceptors
public void setInterceptors(List<Interceptor> interceptorList)
Set the interceptor array from a list.- Parameters:
interceptorList- the interceptor list
-
setInterceptors
public void setInterceptors(Interceptor[] interceptors, int nextIndex)
Set the interceptors, with a starting index to proceed from.- Parameters:
interceptors- the interceptor arraynextIndex- the next index to proceed
-
setInterceptors
public void setInterceptors(List<Interceptor> interceptorList, int nextIndex)
Set the interceptors, with a starting index to proceed from.- Parameters:
interceptorList- the interceptor listnextIndex- the next index to proceed
-
proceed
public Object proceed() throws Exception
Pass the invocation on to the next step in the chain.- Returns:
- the result
- Throws:
Exception- if an invocation throws an exception
-
run
public Object run() throws Exception
Synonymous withproceed(); exists to implementPrivilegedExceptionAction.
-
clone
public InterceptorContext clone()
Clone this interceptor context instance. The cloned context will resume execution at the same point that this context would have at the moment it was cloned.
-
-