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>,io.micronaut.core.annotation.AnnotationMetadata,io.micronaut.core.annotation.AnnotationMetadataDelegate,io.micronaut.core.annotation.AnnotationMetadataProvider,io.micronaut.core.annotation.AnnotationSource,io.micronaut.core.attr.AttributeHolder,io.micronaut.core.attr.MutableAttributeHolder,io.micronaut.core.type.Executable<B,R>
- Direct Known Subclasses:
MethodInterceptorChain
@Internal public class InterceptorChain<B,R> extends java.lang.Object implements InvocationContext<B,R>
An internal representation of theInterceptorchain. This class implementsInvocationContextand is consumed by the framework itself and should not be used directly in application code.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>attributesprotected io.micronaut.inject.ExecutableMethod<B,R>executionHandleprotected intindexprotected intinterceptorCountprotected Interceptor<B,R>[]interceptorsprotected static org.slf4j.LoggerLOGUsed by subclasses!protected java.lang.Object[]originalParametersprotected java.util.Map<java.lang.String,io.micronaut.core.type.MutableArgumentValue<?>>parametersprotected Btarget
-
Constructor Summary
Constructors Constructor Description InterceptorChain(Interceptor<B,R>[] interceptors, B target, io.micronaut.inject.ExecutableMethod<B,R> method, java.lang.Object... originalParameters)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description io.micronaut.core.annotation.AnnotationMetadatagetAnnotationMetadata()io.micronaut.core.type.Argument[]getArguments()io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object>getAttributes()java.util.Map<java.lang.String,io.micronaut.core.type.MutableArgumentValue<?>>getParameters()Returns the current parameters as a map of mutable argument values.java.lang.Object[]getParameterValues()Returns the current state of the parameters as an array by parameter index.BgetTarget()Rinvoke(B instance, java.lang.Object... arguments)Rproceed()Proceeds with the invocation.Rproceed(Interceptor from)Proceeds with the invocation using the given interceptor as a position to start from.static Interceptor[]resolveAroundInterceptors(io.micronaut.context.BeanContext beanContext, io.micronaut.inject.ExecutableMethod<?,?> method, Interceptor... interceptors)Deprecated.static Interceptor[]resolveAroundInterceptors(io.micronaut.context.BeanContext beanContext, io.micronaut.inject.ExecutableMethod<?,?> method, java.util.List<io.micronaut.context.BeanRegistration<Interceptor<?,?>>> interceptors)Resolves theAroundinterceptors for a method.protected static java.util.Collection<io.micronaut.core.annotation.AnnotationValue<?>>resolveInterceptorValues(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, InterceptorKind kind)Resolve interceptor binding for the given annotation metadata and kind.static Interceptor[]resolveIntroductionInterceptors(io.micronaut.context.BeanContext beanContext, io.micronaut.inject.ExecutableMethod<?,?> method, Interceptor... interceptors)Deprecated.static Interceptor[]resolveIntroductionInterceptors(io.micronaut.context.BeanContext beanContext, io.micronaut.inject.ExecutableMethod<?,?> method, java.util.List<io.micronaut.context.BeanRegistration<Interceptor<?,?>>> interceptors)Resolves theIntroductioninterceptors for a method.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
getAnnotationValuesByName, getAnnotationValuesByStereotype, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
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, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, 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
-
Methods inherited from interface io.micronaut.aop.InvocationContext
getDeclaringType, getKind, getParameters, getParameterValueMap, getParameterValues, proceed, setAttribute
-
-
-
-
Field Detail
-
target
protected final B target
-
LOG
protected static final org.slf4j.Logger LOG
Used by subclasses!
-
interceptors
protected final Interceptor<B,R>[] interceptors
-
originalParameters
protected final java.lang.Object[] originalParameters
-
interceptorCount
protected final int interceptorCount
-
attributes
protected volatile io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> attributes
-
index
protected int index
-
parameters
protected volatile java.util.Map<java.lang.String,io.micronaut.core.type.MutableArgumentValue<?>> parameters
-
-
Constructor Detail
-
InterceptorChain
public InterceptorChain(Interceptor<B,R>[] interceptors, B target, io.micronaut.inject.ExecutableMethod<B,R> method, java.lang.Object... originalParameters)
Constructor.- Parameters:
interceptors- array of interceptorstarget- target typemethod- result methodoriginalParameters- parameters
-
-
Method Detail
-
getAnnotationMetadata
public io.micronaut.core.annotation.AnnotationMetadata getAnnotationMetadata()
- Specified by:
getAnnotationMetadatain interfaceio.micronaut.core.annotation.AnnotationMetadataProvider
-
getArguments
public io.micronaut.core.type.Argument[] getArguments()
-
getTarget
public B getTarget()
- Specified by:
getTargetin interfaceInvocationContext<B,R>- Returns:
- The target object
-
proceed
public R proceed() throws java.lang.RuntimeException
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:
java.lang.RuntimeException- chain may throw RTE
-
resolveAroundInterceptors
@Internal public static Interceptor[] resolveAroundInterceptors(@Nullable io.micronaut.context.BeanContext beanContext, io.micronaut.inject.ExecutableMethod<?,?> method, java.util.List<io.micronaut.context.BeanRegistration<Interceptor<?,?>>> interceptors)
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 public static Interceptor[] resolveIntroductionInterceptors(@Nullable io.micronaut.context.BeanContext beanContext, io.micronaut.inject.ExecutableMethod<?,?> method, java.util.List<io.micronaut.context.BeanRegistration<Interceptor<?,?>>> interceptors)
Resolves theIntroductioninterceptors for a method.- Parameters:
beanContext- bean context passed inmethod- The methodinterceptors- The array of interceptors- Returns:
- The filtered array of interceptors
-
resolveAroundInterceptors
@Internal @Deprecated public static Interceptor[] resolveAroundInterceptors(@Nullable io.micronaut.context.BeanContext beanContext, io.micronaut.inject.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 io.micronaut.context.BeanContext beanContext, io.micronaut.inject.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
@NonNull public java.lang.Object[] 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
@NonNull public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> getAttributes()
- Specified by:
getAttributesin interfaceio.micronaut.core.attr.AttributeHolder- Specified by:
getAttributesin interfaceio.micronaut.core.attr.MutableAttributeHolder
-
getParameters
@NonNull public java.util.Map<java.lang.String,io.micronaut.core.type.MutableArgumentValue<?>> 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
public R proceed(@NonNull Interceptor from) throws java.lang.RuntimeExceptionDescription 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:
java.lang.RuntimeException- chain may throw RTE
-
resolveInterceptorValues
@NonNull protected static java.util.Collection<io.micronaut.core.annotation.AnnotationValue<?>> resolveInterceptorValues(@NonNull io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, @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
-
-