-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface InterceptorMethod
A representation of a Jakarta Interceptors interceptor method.- Author:
- Laird Nelson
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
intercept(InvocationContext ic)
Performs interception and returns any result.static InterceptorMethod
of(MethodHandle receiverlessOrBoundMethodHandle)
static InterceptorMethod
of(MethodHandle mh, Supplier<?> receiverSupplier)
Returns a newInterceptorMethod
that adapts the suppliedMethodHandle
and the suppliedSupplier
of its receiver.static InterceptorMethod
of(Method staticMethod)
static InterceptorMethod
of(Method m, Supplier<?> targetSupplier)
Returns a newInterceptorMethod
that adapts the suppliedMethod
and the suppliedSupplier
of its receiver.
-
-
-
Method Detail
-
intercept
Object intercept(InvocationContext ic) throws Exception
Performs interception and returns any result.- Parameters:
ic
- anInvocationContext
; must not benull
- Returns:
- the result of interception, often computed by invoking the
InvocationContext.proceed()
method; the return value may benull
- Throws:
Exception
- if any error occurs
-
of
static InterceptorMethod of(Method staticMethod)
- Parameters:
staticMethod
- astatic
Method
; must not benull
; must accept exactly oneInvocationContext
-typed argument- Returns:
- a new
InterceptorMethod
; nevernull
- Throws:
NullPointerException
- ifstaticMethod
isnull
-
of
static InterceptorMethod of(Method m, Supplier<?> targetSupplier)
Returns a newInterceptorMethod
that adapts the suppliedMethod
and the suppliedSupplier
of its receiver.- Parameters:
m
- aMethod
; must not benull
; must accept exactly oneInvocationContext
-typed argumenttargetSupplier
- aSupplier
of the suppliedMethod
's receiver; often memoized; may benull
in which case the suppliedMethod
must bestatic
- Returns:
- a new
InterceptorMethod
; nevernull
- Throws:
NullPointerException
- ifm
isnull
InterceptorException
- if unreflecting fails
-
of
static InterceptorMethod of(MethodHandle receiverlessOrBoundMethodHandle)
- Parameters:
receiverlessOrBoundMethodHandle
- aMethodHandle
; must not benull
; must either not require a receiver or must be already bound to one; must accept exactly oneInvocationContext
-typed argument- Returns:
- a new
InterceptorMethod
; nevernull
- Throws:
NullPointerException
- ifreceiverlessOrBoundMethodHandle
isnull
-
of
static InterceptorMethod of(MethodHandle mh, Supplier<?> receiverSupplier)
Returns a newInterceptorMethod
that adapts the suppliedMethodHandle
and the suppliedSupplier
of its receiver.- Parameters:
mh
- aMethodHandle
; must not benull
; must either accept two arguments where the first argument's type is a valid receiver type and the second argument's type isInvocationContext
, or one argument whose type isInvocationContext
receiverSupplier
- aSupplier
of the suppliedMethodHandle
's receiver; often memoized; may benull
in which case the suppliedMethodHandle
must either not require a receiver or must be already bound to one- Returns:
- a new
InterceptorMethod
; nevernull
- Throws:
NullPointerException
- ifm
isnull
-
-