Package io.micronaut.aop.chain
Class InterceptorChain<B,R>
java.lang.Object
io.micronaut.aop.chain.InterceptorChain<B,R>
- Type Parameters:
B- The declaring typeR- The result of the method call
- All Implemented Interfaces:
InvocationContext<B,,R> AnnotationMetadata,AnnotationMetadataDelegate,AnnotationMetadataProvider,AnnotationSource,AttributeHolder,MutableAttributeHolder,Executable<B,R>
- Direct Known Subclasses:
MethodInterceptorChain
An internal representation of the
Interceptor chain. This class implements InvocationContext and is
consumed by the framework itself and should not be used directly in application code.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MutableConvertibleValues<Object>protected final ExecutableMethod<B,R> protected intprotected final intprotected final Interceptor<B,R>[] protected static final org.slf4j.LoggerUsed by subclasses!protected final Object[]protected Map<String,MutableArgumentValue<?>> protected final BFields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBERFields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionInterceptorChain(Interceptor<B, R>[] interceptors, B target, ExecutableMethod<B, R> method, Object... originalParameters) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionSupplies the metadata.Argument[]The required argument types.Overrides the defaultAttributeHolder.getAttributes()method to return a mutable object.Returns the current parameters as a map of mutable argument values.Returns the current state of the parameters as an array by parameter index.Invokes the method.proceed()Proceeds with the invocation.proceed(@NonNull Interceptor from) Proceeds with the invocation using the given interceptor as a position to start from.static Interceptor[]resolveAroundInterceptors(@Nullable BeanContext beanContext, ExecutableMethod<?, ?> method, Interceptor... interceptors) Deprecated.static <T> Interceptor<T,?>[] resolveAroundInterceptors(InterceptorRegistry interceptorRegistry, ExecutableMethod<T, ?> method, List<BeanRegistration<Interceptor<T, ?>>> interceptors) Resolves theAroundinterceptors for a method.static <T> Interceptor<T,?>[] resolveAroundInterceptors(BeanContext beanContext, ExecutableMethod<T, ?> method, List<BeanRegistration<Interceptor<T, ?>>> interceptors) Resolves theAroundinterceptors for a method.protected static @NonNull Collection<AnnotationValue<?>>resolveInterceptorValues(@NonNull AnnotationMetadata annotationMetadata, @NonNull InterceptorKind kind) Resolve interceptor binding for the given annotation metadata and kind.static Interceptor[]resolveIntroductionInterceptors(@Nullable BeanContext beanContext, ExecutableMethod<?, ?> method, Interceptor... interceptors) Deprecated.static <T> Interceptor<T,?>[] resolveIntroductionInterceptors(InterceptorRegistry interceptorRegistry, ExecutableMethod<T, ?> method, List<BeanRegistration<Interceptor<T, ?>>> interceptors) Resolves theIntroductioninterceptors for a method.static <T> Interceptor<T,?>[] resolveIntroductionInterceptors(BeanContext beanContext, ExecutableMethod<T, ?> method, List<BeanRegistration<Interceptor<T, ?>>> interceptors) Resolves theIntroductioninterceptors for a method.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresentMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, copyAnnotationMetadata, 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, getAnnotationValuesByName, getAnnotationValuesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByName, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getTargetAnnotationMetadata, 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, synthesizeDeclaredAnnotationsByTypeMethods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttributeMethods inherited from interface io.micronaut.aop.InvocationContext
getDeclaringType, getKind, getParameters, getParameterValueMap, getParameterValues, proceed, setAttributeMethods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
getAttributes, removeAttribute
-
Field Details
-
target
-
executionHandle
-
LOG
protected static final org.slf4j.Logger LOGUsed by subclasses! -
interceptors
-
originalParameters
-
interceptorCount
protected final int interceptorCount -
attributes
-
index
protected int index -
parameters
-
-
Constructor Details
-
InterceptorChain
public InterceptorChain(Interceptor<B, R>[] interceptors, B target, ExecutableMethod<B, R> method, Object... originalParameters) Constructor.- Parameters:
interceptors- array of interceptorstarget- target typemethod- result methodoriginalParameters- parameters
-
-
Method Details
-
getAnnotationMetadata
Description copied from interface:AnnotationMetadataProviderSupplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA.- Specified by:
getAnnotationMetadatain interfaceAnnotationMetadataProvider- Returns:
- The
AnnotationMetadata
-
getArguments
Description copied from interface:ExecutableThe required argument types.- Specified by:
getArgumentsin interfaceExecutable<B,R> - Returns:
- The arguments
-
invoke
Description copied from interface:ExecutableInvokes the method.- Specified by:
invokein interfaceExecutable<B,R> - Parameters:
instance- The instance. Nullable only if it's a static method call.arguments- The arguments- Returns:
- The result
-
getTarget
- Specified by:
getTargetin interfaceInvocationContext<B,R> - Returns:
- The target object
-
proceed
Description copied from interface:InvocationContextProceeds with the invocation. If this is the last interceptor in the chain then the final implementation method is invoked- Specified by:
proceedin interfaceInvocationContext<B,R> - Returns:
- The return value of the method
- Throws:
RuntimeException- chain may throw RTE
-
resolveAroundInterceptors
@Internal public static <T> Interceptor<T,?>[] resolveAroundInterceptors(BeanContext beanContext, ExecutableMethod<T, ?> method, List<BeanRegistration<Interceptor<T, ?>>> interceptors) Resolves theAroundinterceptors for a method.- Type Parameters:
T- The intercepted type- Parameters:
beanContext- bean context passed inmethod- The methodinterceptors- The array of interceptors- Returns:
- The filtered array of interceptors
-
resolveAroundInterceptors
@Internal public static <T> Interceptor<T,?>[] resolveAroundInterceptors(InterceptorRegistry interceptorRegistry, ExecutableMethod<T, ?> method, List<BeanRegistration<Interceptor<T, ?>>> interceptors) Resolves theAroundinterceptors for a method.- Type Parameters:
T- The intercepted type- Parameters:
interceptorRegistry- the interceptor registrymethod- The methodinterceptors- The array of interceptors- Returns:
- The filtered array of interceptors
- Since:
- 4.3.0
-
resolveIntroductionInterceptors
@Internal public static <T> Interceptor<T,?>[] resolveIntroductionInterceptors(BeanContext beanContext, ExecutableMethod<T, ?> method, List<BeanRegistration<Interceptor<T, ?>>> interceptors) Resolves theIntroductioninterceptors for a method.- Type Parameters:
T- The intercepted type- Parameters:
beanContext- bean context passed inmethod- The methodinterceptors- The array of interceptors- Returns:
- The filtered array of interceptors
- Since:
- 4.3.0
-
resolveIntroductionInterceptors
@Internal public static <T> Interceptor<T,?>[] resolveIntroductionInterceptors(InterceptorRegistry interceptorRegistry, ExecutableMethod<T, ?> method, List<BeanRegistration<Interceptor<T, ?>>> interceptors) Resolves theIntroductioninterceptors for a method.- Type Parameters:
T- The intercepted type- Parameters:
interceptorRegistry- the interceptor registrymethod- The methodinterceptors- The array of interceptors- Returns:
- The filtered array of interceptors
- Since:
- 4.3.0
-
resolveAroundInterceptors
@Internal @Deprecated public static Interceptor[] resolveAroundInterceptors(@Nullable @Nullable BeanContext beanContext, ExecutableMethod<?, ?> method, Interceptor... interceptors) Deprecated.Resolves theAroundinterceptors for a method.- Parameters:
beanContext- bean context passed inmethod- The methodinterceptors- The array of interceptors- Returns:
- The filtered array of interceptors
-
resolveIntroductionInterceptors
@Internal @Deprecated public static Interceptor[] resolveIntroductionInterceptors(@Nullable @Nullable BeanContext beanContext, ExecutableMethod<?, ?> method, Interceptor... interceptors) Deprecated.Resolves the interceptors for a method forIntroductionadvise. ForIntroductionadvise anyAroundadvise interceptors are applied first- Parameters:
beanContext- Bean Contextmethod- The methodinterceptors- The array of interceptors- Returns:
- The filtered array of interceptors
-
getParameterValues
Description copied from interface:InvocationContextReturns the current state of the parameters as an array by parameter index. Note that mutations to the array have no effect. If you wish to mutate the parameters useInvocationContext.getParameters()and theMutableArgumentValueinterface instead- Specified by:
getParameterValuesin interfaceInvocationContext<B,R> - Returns:
- The bound
ArgumentValueinstances
-
getAttributes
Description copied from interface:MutableAttributeHolderOverrides the defaultAttributeHolder.getAttributes()method to return a mutable object.- Specified by:
getAttributesin interfaceAttributeHolder- Specified by:
getAttributesin interfaceMutableAttributeHolder- Returns:
- The mutable attributes
-
getParameters
Description copied from interface:InvocationContextReturns the current parameters as a map of mutable argument values. This method allows mutation of the argument values and is generally more expensive than usingInvocationContext.getParameterValues()andExecutable.getArguments()directly, hence should be used with care.- Specified by:
getParametersin interfaceInvocationContext<B,R> - Returns:
- The bound
ArgumentValueinstances
-
proceed
Description copied from interface:InvocationContextProceeds with the invocation using the given interceptor as a position to start from. Mainly useful forIntroductionadvise where you want to invoke the target multiple times or where you want to repeat the entire chain.- Specified by:
proceedin interfaceInvocationContext<B,R> - Parameters:
from- The interceptor to start from (note: will not be included in the execution)- Returns:
- The return value of the method
- Throws:
RuntimeException- chain may throw RTE
-
resolveInterceptorValues
@NonNull protected static @NonNull Collection<AnnotationValue<?>> resolveInterceptorValues(@NonNull @NonNull AnnotationMetadata annotationMetadata, @NonNull @NonNull InterceptorKind kind) Resolve interceptor binding for the given annotation metadata and kind.- Parameters:
annotationMetadata- The annotation metadatakind- The kind- Returns:
- The binding
- Since:
- 3.3.0
-
resolveAroundInterceptors(BeanContext, ExecutableMethod, List)