T
- typeR
- result@Internal public final class MethodInterceptorChain<T,R> extends InterceptorChain<T,R> implements MethodInvocationContext<T,R>
Interceptor
chain. This class implements MethodInvocationContext
and is
consumed by the framework itself and should not be used directly in application code.Modifier and Type | Field and Description |
---|---|
protected MutableConvertibleValues<Object> |
attributes |
protected int |
index |
protected int |
interceptorCount |
protected Interceptor<B,R>[] |
interceptors |
protected static org.slf4j.Logger |
LOG
Used by subclasses!
|
protected Object[] |
originalParameters |
protected Map<String,MutableArgumentValue<?>> |
parameters |
executionHandle, target
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
EMPTY
Constructor and Description |
---|
MethodInterceptorChain(Interceptor<T,R>[] interceptors,
T target,
ExecutableMethod<T,R> executionHandle)
Constructor for empty parameters.
|
MethodInterceptorChain(Interceptor<T,R>[] interceptors,
T target,
ExecutableMethod<T,R> executionHandle,
InterceptorKind kind)
Constructor for empty parameters.
|
MethodInterceptorChain(Interceptor<T,R>[] interceptors,
T target,
ExecutableMethod<T,R> executionHandle,
Object... originalParameters)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static <T1> T1 |
dispose(BeanResolutionContext resolutionContext,
BeanContext beanContext,
BeanDefinition<T1> definition,
ExecutableMethod<T1,T1> preDestroyMethod,
T1 bean)
Internal method that handles the logic for executing
InterceptorKind.PRE_DESTROY interception. |
Class[] |
getArgumentTypes() |
MutableConvertibleValues<Object> |
getAttributes()
Overrides the default
AttributeHolder.getAttributes() method to return a mutable object. |
Class<T> |
getDeclaringType() |
ExecutableMethod<T,R> |
getExecutableMethod()
The underlying
ExecutableMethod reference. |
InterceptorKind |
getKind() |
String |
getMethodName() |
Map<String,MutableArgumentValue<?>> |
getParameters()
Returns the current parameters as a map of mutable argument values.
|
Object[] |
getParameterValues()
Returns the current state of the parameters as an array by parameter index.
|
ReturnType<R> |
getReturnType() |
Method |
getTargetMethod() |
static <T1> T1 |
initialize(BeanResolutionContext resolutionContext,
BeanContext beanContext,
BeanDefinition<T1> definition,
ExecutableMethod<T1,T1> postConstructMethod,
T1 bean)
Internal method that handles the logic for executing
InterceptorKind.POST_CONSTRUCT interception. |
R |
invoke(T instance,
Object... arguments)
Invokes the method.
|
boolean |
isAbstract()
Defines whether the method is abstract.
|
boolean |
isSuspend()
Defines whether the method is Kotlin suspend function.
|
R |
proceed()
Proceeds with the invocation.
|
R |
proceed(Interceptor from)
Proceeds with the invocation using the given interceptor as a position to start from.
|
protected static Collection<AnnotationValue<?>> |
resolveInterceptorValues(AnnotationMetadata annotationMetadata,
InterceptorKind kind)
Resolve interceptor binding for the given annotation metadata and kind.
|
String |
toString() |
getAnnotationMetadata, getArguments, getTarget, resolveAroundInterceptors, resolveAroundInterceptors, resolveIntroductionInterceptors, resolveIntroductionInterceptors
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParameters, getParameterValueMap, getParameterValues, getTarget, proceed, setAttribute
getAttributes, removeAttribute
getAttribute, getAttribute
getDescription, getDescription
getArgumentNames, getArguments, getName
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasPropertyExpressions, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
getAnnotationValuesByName, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
getAnnotationMetadata
protected static final org.slf4j.Logger LOG
protected final Interceptor<B,R>[] interceptors
protected final Object[] originalParameters
protected final int interceptorCount
protected volatile MutableConvertibleValues<Object> attributes
protected int index
protected volatile Map<String,MutableArgumentValue<?>> parameters
public MethodInterceptorChain(Interceptor<T,R>[] interceptors, T target, ExecutableMethod<T,R> executionHandle)
interceptors
- array of interceptorstarget
- targetexecutionHandle
- executionHandlepublic MethodInterceptorChain(Interceptor<T,R>[] interceptors, T target, ExecutableMethod<T,R> executionHandle, @Nullable InterceptorKind kind)
interceptors
- array of interceptorstarget
- targetexecutionHandle
- executionHandlekind
- The interception kindpublic MethodInterceptorChain(Interceptor<T,R>[] interceptors, T target, ExecutableMethod<T,R> executionHandle, Object... originalParameters)
interceptors
- array of interceptorstarget
- targetexecutionHandle
- executionHandleoriginalParameters
- originalParameters@NonNull public InterceptorKind getKind()
getKind
in interface InvocationContext<T,R>
public R invoke(T instance, Object... arguments)
Executable
invoke
in interface Executable<T,R>
invoke
in class InterceptorChain<T,R>
instance
- The instancearguments
- The argumentspublic boolean isSuspend()
ExecutableMethod
isSuspend
in interface MethodInvocationContext<T,R>
isSuspend
in interface ExecutableMethod<T,R>
public boolean isAbstract()
ExecutableMethod
isAbstract
in interface MethodInvocationContext<T,R>
isAbstract
in interface ExecutableMethod<T,R>
public R proceed() throws RuntimeException
InvocationContext
proceed
in interface InvocationContext<T,R>
proceed
in class InterceptorChain<T,R>
RuntimeException
- chain may throw RTEpublic String getMethodName()
getMethodName
in interface MethodReference<T,R>
public Class[] getArgumentTypes()
getArgumentTypes
in interface MethodReference<T,R>
public Method getTargetMethod()
getTargetMethod
in interface MethodReference<T,R>
public ReturnType<R> getReturnType()
getReturnType
in interface MethodReference<T,R>
public Class<T> getDeclaringType()
getDeclaringType
in interface InvocationContext<T,R>
getDeclaringType
in interface MethodInvocationContext<T,R>
getDeclaringType
in interface Executable<T,R>
getDeclaringType
in interface MethodReference<T,R>
@NonNull public ExecutableMethod<T,R> getExecutableMethod()
MethodInvocationContext
ExecutableMethod
reference.getExecutableMethod
in interface MethodInvocationContext<T,R>
@Internal @NonNull public static <T1> T1 initialize(@NonNull BeanResolutionContext resolutionContext, @NonNull BeanContext beanContext, @NonNull BeanDefinition<T1> definition, @NonNull ExecutableMethod<T1,T1> postConstructMethod, @NonNull T1 bean)
InterceptorKind.POST_CONSTRUCT
interception.T1
- The bean typeresolutionContext
- The resolution contextbeanContext
- The bean contextdefinition
- The definitionpostConstructMethod
- The post construct methodbean
- The bean@Internal @NonNull public static <T1> T1 dispose(@NonNull BeanResolutionContext resolutionContext, @NonNull BeanContext beanContext, @NonNull BeanDefinition<T1> definition, @NonNull ExecutableMethod<T1,T1> preDestroyMethod, @NonNull T1 bean)
InterceptorKind.PRE_DESTROY
interception.T1
- The bean typeresolutionContext
- The resolution contextbeanContext
- The bean contextdefinition
- The definitionpreDestroyMethod
- The pre destroy methodbean
- The bean@NonNull public Object[] getParameterValues()
InvocationContext
InvocationContext.getParameters()
and the MutableArgumentValue
interface insteadgetParameterValues
in interface InvocationContext<B,R>
ArgumentValue
instances@NonNull public MutableConvertibleValues<Object> getAttributes()
MutableAttributeHolder
AttributeHolder.getAttributes()
method to return a mutable object.getAttributes
in interface AttributeHolder
getAttributes
in interface MutableAttributeHolder
@NonNull public Map<String,MutableArgumentValue<?>> getParameters()
InvocationContext
InvocationContext.getParameterValues()
and Executable.getArguments()
directly, hence
should be used with care.getParameters
in interface InvocationContext<B,R>
ArgumentValue
instancespublic R proceed(@NonNull Interceptor from) throws RuntimeException
InvocationContext
Introduction
advise where you want to
invoke the target multiple times or where you want to repeat the entire chain.proceed
in interface InvocationContext<B,R>
from
- The interceptor to start from (note: will not be included in the execution)RuntimeException
- chain may throw RTE@NonNull protected static Collection<AnnotationValue<?>> resolveInterceptorValues(@NonNull AnnotationMetadata annotationMetadata, @NonNull InterceptorKind kind)
annotationMetadata
- The annotation metadatakind
- The kind