- java.lang.Object
-
- org.microbean.interceptor.Chain
-
- All Implemented Interfaces:
InvocationContext
,Callable<Object>
@Deprecated(forRemoval=true) public class Chain extends Object implements Callable<Object>, InvocationContext
Deprecated, for removal: This API element is subject to removal in a future version.SeeInterceptions
.ACallable
InvocationContext
implementation representing the interception of a constructor, method, or lifecycle event.- Author:
- Laird Nelson
- See Also:
proceed()
-
-
Constructor Summary
Constructors Constructor Description Chain()
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
primarily for testing purposes.Chain(List<? extends InterceptorMethod> interceptorMethods, Constructor<?> terminalConstructor)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-construct interceptions.Chain(List<? extends InterceptorMethod> interceptorMethods, Constructor<?> terminalConstructor, Supplier<? extends Object[]> argumentsSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-construct interceptions.Chain(List<? extends InterceptorMethod> interceptorMethods, Function<? super Object[],?> terminalFunction, Supplier<? extends Object[]> argumentsSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-construct interceptions.Chain(List<? extends InterceptorMethod> interceptorMethods, Supplier<?> targetSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for lifecycle method interceptions.Chain(List<? extends InterceptorMethod> interceptorMethods, Supplier<?> targetSupplier, Method terminalMethod)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-invoke interceptions.Chain(List<? extends InterceptorMethod> interceptorMethods, Supplier<?> targetSupplier, Method terminalMethod, Supplier<? extends Object[]> argumentsSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-invoke interceptions.Chain(List<? extends InterceptorMethod> interceptorMethods, Supplier<?> targetSupplier, Function<? super Object[],?> terminalFunction, boolean setTarget, Supplier<? extends Object[]> argumentsSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-construct or around-invoke interceptions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Object
call()
Deprecated, for removal: This API element is subject to removal in a future version.Invokes theproceed()
method and returns its result.Constructor<?>
getConstructor()
Deprecated, for removal: This API element is subject to removal in a future version.Returns theConstructor
being intercepted, if available, ornull
.Map<String,Object>
getContextData()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the context dataMap
shared by the current invocation.Method
getMethod()
Deprecated, for removal: This API element is subject to removal in a future version.Returns theMethod
being intercepted, if available, ornull
.Object[]
getParameters()
Deprecated, for removal: This API element is subject to removal in a future version.Returns any arguments in effect for the current interception.Object
getTarget()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the target instance, if available, ornull
.Object
getTimer()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the timer, if available, ornull
.Object
proceed()
Deprecated, for removal: This API element is subject to removal in a future version.Applies the next interception in thisChain
, or calls the terminal function, and returns the result of the interception, which may benull
.void
setParameters(Object[] arguments)
Deprecated, for removal: This API element is subject to removal in a future version.Sets arguments to be in effect for the current interception.void
setTarget(Object target)
Deprecated.This really shouldn't be needed as part of the public API.static Function<Object[],Object>
terminalFunctionOf(MethodHandle receiverlessMethodHandle)
Deprecated, for removal: This API element is subject to removal in a future version.Creates and returns aFunction
encapsulating the suppliedMethodHandle
.static Function<Object[],Object>
terminalFunctionOf(MethodHandle mh, Supplier<?> receiverSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates and returns aFunction
encapsulating the suppliedMethodHandle
.static Function<Object[],Object>
terminalFunctionOf(Constructor<?> c)
Deprecated, for removal: This API element is subject to removal in a future version.Creates and returns aFunction
encapsulating the suppliedConstructor
.static Function<Object[],Object>
terminalFunctionOf(Method staticMethod)
Deprecated, for removal: This API element is subject to removal in a future version.static Function<Object[],Object>
terminalFunctionOf(Method m, Supplier<?> receiverSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.static void
validate(Class<?>[] parameterTypes, Object[] arguments)
Deprecated, for removal: This API element is subject to removal in a future version.A convenience method that ensures that every element of the suppliedarguments
array can be assigned to a reference bearing the correspondingClass
drawn from the suppliedparameterTypes
array.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.interceptor.InvocationContext
getInterceptorBinding, getInterceptorBindings, getInterceptorBindings
-
-
-
-
Constructor Detail
-
Chain
public Chain()
Deprecated, for removal: This API element is subject to removal in a future version.
-
Chain
public Chain(List<? extends InterceptorMethod> interceptorMethods, Supplier<?> targetSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for lifecycle method interceptions.The resulting
Chain
will returnnull
from the following methods:- Parameters:
interceptorMethods
- aList
ofInterceptorMethod
s; may, rather uselessly, benull
targetSupplier
- aSupplier
of the target instance; may, rather uselessly, benull
-
Chain
public Chain(List<? extends InterceptorMethod> interceptorMethods, Constructor<?> terminalConstructor) throws IllegalAccessException
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-construct interceptions.The resulting
Chain
will returnnull
from the following methods:- Parameters:
interceptorMethods
- aList
ofInterceptorMethod
s; may, rather uselessly, benull
terminalConstructor
- theConstructor
being intercepted; must not benull
- Throws:
NullPointerException
- ifterminalConstructor
isnull
IllegalAccessException
- if unreflecting fails
-
Chain
public Chain(List<? extends InterceptorMethod> interceptorMethods, Constructor<?> terminalConstructor, Supplier<? extends Object[]> argumentsSupplier) throws IllegalAccessException
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-construct interceptions.The resulting
Chain
will returnnull
from the following methods:- Parameters:
interceptorMethods
- aList
ofInterceptorMethod
s; may, rather uselessly, benull
terminalConstructor
- theConstructor
being intercepted; must not benull
argumentsSupplier
- aSupplier
supplying the arguments for theConstructor
; may benull
- Throws:
NullPointerException
- ifterminalConstructor
isnull
IllegalAccessException
- if unreflecting fails
-
Chain
public Chain(List<? extends InterceptorMethod> interceptorMethods, Function<? super Object[],?> terminalFunction, Supplier<? extends Object[]> argumentsSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-construct interceptions.The resulting
Chain
will returnnull
from the following methods:- Parameters:
interceptorMethods
- aList
ofInterceptorMethod
s; may, rather uselessly, benull
terminalFunction
- the terminalFunction
to intercept; must not benull
argumentsSupplier
- aSupplier
supplying the arguments for the terminalFunction
; may benull
- Throws:
NullPointerException
- ifterminalFunction
isnull
-
Chain
public Chain(List<? extends InterceptorMethod> interceptorMethods, Supplier<?> targetSupplier, Method terminalMethod) throws IllegalAccessException
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-invoke interceptions.The resulting
Chain
will returnnull
from the following methods:- Parameters:
interceptorMethods
- aList
ofInterceptorMethod
s; may, rather uselessly, benull
targetSupplier
- aSupplier
of the target instance; may, rather uselessly, benull
terminalMethod
- theMethod
to intercept; must not benull
- Throws:
NullPointerException
- ifterminalMethod
isnull
IllegalAccessException
- if unreflecting fails
-
Chain
public Chain(List<? extends InterceptorMethod> interceptorMethods, Supplier<?> targetSupplier, Method terminalMethod, Supplier<? extends Object[]> argumentsSupplier) throws IllegalAccessException
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-invoke interceptions.The resulting
Chain
will returnnull
from the following methods:- Parameters:
interceptorMethods
- aList
ofInterceptorMethod
s; may, rather uselessly, benull
targetSupplier
- aSupplier
of the target instance; may, rather uselessly, benull
terminalMethod
- theMethod
to intercept; must not benull
argumentsSupplier
- aSupplier
supplying the arguments for theMethod
; may benull
- Throws:
NullPointerException
- ifterminalMethod
isnull
IllegalAccessException
- if unreflecting fails
-
Chain
public Chain(List<? extends InterceptorMethod> interceptorMethods, Supplier<?> targetSupplier, Function<? super Object[],?> terminalFunction, boolean setTarget, Supplier<? extends Object[]> argumentsSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a newChain
for around-construct or around-invoke interceptions.The resulting
Chain
will returnnull
from the following methods:- Parameters:
interceptorMethods
- aList
ofInterceptorMethod
s; may, rather uselessly, benull
targetSupplier
- aSupplier
of the target instance; may, rather uselessly, benull
terminalFunction
- the terminalFunction
to intercept; must not benull
setTarget
- whether the suppliedterminalFunction
is effectively a constructorargumentsSupplier
- aSupplier
supplying the arguments for the terminalFunction
; may benull
- Throws:
NullPointerException
- ifterminalFunction
isnull
-
-
Method Detail
-
getConstructor
public final Constructor<?> getConstructor()
Deprecated, for removal: This API element is subject to removal in a future version.Returns theConstructor
being intercepted, if available, ornull
.- Specified by:
getConstructor
in interfaceInvocationContext
- Returns:
- the
Constructor
being intercepted, if available, ornull
-
getContextData
public final Map<String,Object> getContextData()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the context dataMap
shared by the current invocation.- Specified by:
getContextData
in interfaceInvocationContext
- Returns:
- the context data
Map
shared by the current invocation; nevernull
- See Also:
InvocationContext.getContextData()
-
getMethod
public final Method getMethod()
Deprecated, for removal: This API element is subject to removal in a future version.Returns theMethod
being intercepted, if available, ornull
.- Specified by:
getMethod
in interfaceInvocationContext
- Returns:
- the
Method
being intercepted, if available, ornull
-
getParameters
public final Object[] getParameters()
Deprecated, for removal: This API element is subject to removal in a future version.Returns any arguments in effect for the current interception.For historical reasons, the Jakarta Interceptors specification refers, incorrectly, to arguments as "parameters".
- Specified by:
getParameters
in interfaceInvocationContext
- Returns:
- any arguments in effect for the current interception; never
null
- Throws:
IllegalStateException
- if invoked within a lifecycle callback method that is not anAroundConstruct
callback- See Also:
setParameters(Object[])
-
getTarget
public final Object getTarget()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the target instance, if available, ornull
.- Specified by:
getTarget
in interfaceInvocationContext
- Returns:
- the target instance, if available, or
null
-
setTarget
@Deprecated public final void setTarget(Object target)
Deprecated.This really shouldn't be needed as part of the public API.Sets the target instance to be the suppliedtarget
.- Parameters:
target
- the target instance; must not benull
- Throws:
NullPointerException
- iftarget
isnull
- See Also:
getTarget()
-
getTimer
public final Object getTimer()
Deprecated, for removal: This API element is subject to removal in a future version.Returns the timer, if available, ornull
.- Specified by:
getTimer
in interfaceInvocationContext
- Returns:
- the timer, if available, or
null
-
call
public final Object call() throws Exception
Deprecated, for removal: This API element is subject to removal in a future version.Invokes theproceed()
method and returns its result.
-
proceed
public Object proceed() throws Exception
Deprecated, for removal: This API element is subject to removal in a future version.Applies the next interception in thisChain
, or calls the terminal function, and returns the result of the interception, which may benull
.Overrides must not call
call()
or an infinite loop will result.- Specified by:
proceed
in interfaceInvocationContext
- Returns:
- the result of proceeding, which may be
null
- Throws:
Exception
- if an error occurs
-
setParameters
public final void setParameters(Object[] arguments)
Deprecated, for removal: This API element is subject to removal in a future version.Sets arguments to be in effect for the current interception.For historical reasons, the Jakarta Interceptors specification refers, incorrectly, to arguments as "parameters".
- Specified by:
setParameters
in interfaceInvocationContext
- Parameters:
arguments
- the arguments; may benull
- Throws:
IllegalArgumentException
- if the arguments are invalidIllegalStateException
- if invoked within a lifecycle callback method that is not anAroundConstruct
callback- See Also:
getParameters()
-
terminalFunctionOf
public static final Function<Object[],Object> terminalFunctionOf(Constructor<?> c) throws IllegalAccessException
Deprecated, for removal: This API element is subject to removal in a future version.Creates and returns aFunction
encapsulating the suppliedConstructor
.- Parameters:
c
- aConstructor
; must not benull
- Returns:
- a
Function
encapsulating the suppliedConstructor
; nevernull
- Throws:
NullPointerException
- ifc
isnull
IllegalAccessException
- if unreflecting fails
-
terminalFunctionOf
public static final Function<Object[],Object> terminalFunctionOf(Method staticMethod) throws IllegalAccessException
Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
staticMethod
- astatic
Method
; must not benull
- Returns:
- a
Function
encapsulating the suppliedstatic
Method
; nevernull
- Throws:
NullPointerException
- ifstaticMethod
isnull
IllegalAccessException
- if unreflecting fails
-
terminalFunctionOf
public static final Function<Object[],Object> terminalFunctionOf(Method m, Supplier<?> receiverSupplier) throws IllegalAccessException
Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
m
- aMethod
; must not benull
. Ifm
is a virtual method, then the suppliedreceiverSupplier
will be used to supply its receiverreceiverSupplier
- aSupplier
of the receiver for the suppliedMethod
; may benull
in which case the suppliedMethod
must bestatic
- Returns:
- a
Function
encapsulating the suppliedMethod
; nevernull
- Throws:
NullPointerException
- ifm
isnull
IllegalAccessException
- if unreflecting fails
-
terminalFunctionOf
public static final Function<Object[],Object> terminalFunctionOf(MethodHandle receiverlessMethodHandle)
Deprecated, for removal: This API element is subject to removal in a future version.Creates and returns aFunction
encapsulating the suppliedMethodHandle
.- Parameters:
receiverlessMethodHandle
- aMethodHandle
; must not benull
; must be receiverless or bound to a receiver already.- Returns:
- a
Function
encapsulating the suppliedMethodHandle
; nevernull
- Throws:
NullPointerException
- ifreceiverlessMethodHandle
isnull
-
terminalFunctionOf
public static final Function<Object[],Object> terminalFunctionOf(MethodHandle mh, Supplier<?> receiverSupplier)
Deprecated, for removal: This API element is subject to removal in a future version.Creates and returns aFunction
encapsulating the suppliedMethodHandle
.- Parameters:
mh
- aMethodHandle
; must not benull
. Ifmh
is aMethodHandle
requiring a receiver, then the suppliedreceiverSupplier
, if non-null
, will be used to supply its receiverreceiverSupplier
- aSupplier
of the receiver for the suppliedMethodHandle
; may benull
in which case the suppliedMethodHandle
must be receiverless- Returns:
- a
Function
encapsulating the suppliedMethodHandle
; nevernull
- Throws:
NullPointerException
- ifmh
isnull
-
validate
public static final void validate(Class<?>[] parameterTypes, Object[] arguments)
Deprecated, for removal: This API element is subject to removal in a future version.A convenience method that ensures that every element of the suppliedarguments
array can be assigned to a reference bearing the correspondingClass
drawn from the suppliedparameterTypes
array.Boxing, unboxing and widening conversions are taken into consideration.
This method implements the logic implied, but nowhere actually specified, by the contract of
InvocationContext.setParameters(Object[])
.- Parameters:
parameterTypes
- an array ofClass
instances; may benull
; must not containnull
elements orvoid.class
; must have a length equal to that of the suppliedarguments
arrayarguments
- an array ofObject
s; may benull
; must have a length equal to that of the suppliedparameterTypes
array- Throws:
IllegalArgumentException
- if not every element of the suppliedarguments
array can be assigned to a reference bearing the correspondingClass
drawn from the suppliedparameterTypes
array- See Also:
setParameters(Object[])
-
-