Package io.micronaut.aop.chain
Class ConstructorInterceptorChain<T>
java.lang.Object
io.micronaut.aop.chain.ConstructorInterceptorChain<T>
- Type Parameters:
T- The bean type
- All Implemented Interfaces:
ConstructorInvocationContext<T>,InvocationContext<T,,T> 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<T,T>
@Internal
public final class ConstructorInterceptorChain<T>
extends Object
implements ConstructorInvocationContext<T>
Implementation of
InvocationContext for constructor interception.- Since:
- 3.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected io.micronaut.core.convert.value.MutableConvertibleValues<Object>protected intprotected final intprotected final Interceptor<T,T>[] protected static final org.slf4j.LoggerUsed by subclasses!protected final Object[]Fields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBERFields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY -
Method Summary
Modifier and TypeMethodDescription@NonNull io.micronaut.core.type.Argument<?>[]@NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object>@NonNull io.micronaut.core.beans.BeanConstructor<T>@NonNull InterceptorKindgetKind()Returns the current parameters as a map of mutable argument values.@NonNull Object[]Returns the current state of the parameters as an array by parameter index.static <T1> T1instantiate(@NonNull io.micronaut.context.BeanResolutionContext resolutionContext, @NonNull io.micronaut.context.BeanContext beanContext, @Nullable List<io.micronaut.context.BeanRegistration<Interceptor<T1, T1>>> interceptors, @NonNull io.micronaut.inject.BeanDefinition<T1> definition, @NonNull io.micronaut.core.beans.BeanConstructor<T1> constructor, int additionalProxyConstructorParametersCount, @NonNull Object... parameters) Internal methods that handles the logic of instantiating a bean that has constructor interception applied.static <T1> T1instantiate(@NonNull io.micronaut.context.BeanResolutionContext resolutionContext, @NonNull io.micronaut.context.BeanContext beanContext, @Nullable List<io.micronaut.context.BeanRegistration<Interceptor<T1, T1>>> interceptors, @NonNull io.micronaut.inject.BeanDefinition<T1> definition, @NonNull io.micronaut.core.beans.BeanConstructor<T1> constructor, @NonNull Object... parameters) Deprecated.proceed()Proceeds with the invocation.proceed(@NonNull Interceptor from) Proceeds with the invocation using the given interceptor as a position to start from.protected static @NonNull 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.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.annotation.AnnotationMetadataProvider
getAnnotationMetadataMethods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttributeMethods inherited from interface io.micronaut.aop.ConstructorInvocationContext
getDeclaringType, proceedMethods inherited from interface io.micronaut.aop.InvocationContext
getParameters, getParameterValueMap, getParameterValues, setAttributeMethods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
getAttributes, removeAttribute
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOGUsed by subclasses! -
interceptors
-
originalParameters
-
interceptorCount
protected final int interceptorCount -
attributes
-
index
protected int index -
parameters
-
-
Method Details
-
getKind
- Specified by:
getKindin interfaceInvocationContext<T,T> - Returns:
- An enum representing the kind of interception that is occurring.
-
getTarget
- Specified by:
getTargetin interfaceInvocationContext<T,T> - 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 interfaceConstructorInvocationContext<T>- Specified by:
proceedin interfaceInvocationContext<T,T> - Returns:
- The return value of the method
- Throws:
RuntimeException- chain may throw RTE
-
getArguments
@NonNull public @NonNull io.micronaut.core.type.Argument<?>[] getArguments() -
invoke
-
getConstructor
- Specified by:
getConstructorin interfaceConstructorInvocationContext<T>- Returns:
- The bean type.
-
instantiate
@Internal @NonNull @Deprecated public static <T1> T1 instantiate(@NonNull @NonNull io.micronaut.context.BeanResolutionContext resolutionContext, @NonNull @NonNull io.micronaut.context.BeanContext beanContext, @Nullable @Nullable List<io.micronaut.context.BeanRegistration<Interceptor<T1, T1>>> interceptors, @NonNull @NonNull io.micronaut.inject.BeanDefinition<T1> definition, @NonNull @NonNull io.micronaut.core.beans.BeanConstructor<T1> constructor, @NonNull @NonNull Object... parameters) Deprecated.Internal methods that handles the logic of instantiating a bean that has constructor interception applied.- Type Parameters:
T1- The bean type- Parameters:
resolutionContext- The resolution contextbeanContext- The bean contextinterceptors- The interceptors. Can be null and if so should be resolved from the context.definition- The definitionconstructor- The bean constructorparameters- The resolved parameters- Returns:
- The instantiated bean
- Since:
- 3.0.0
-
instantiate
@Internal @NonNull public static <T1> T1 instantiate(@NonNull @NonNull io.micronaut.context.BeanResolutionContext resolutionContext, @NonNull @NonNull io.micronaut.context.BeanContext beanContext, @Nullable @Nullable List<io.micronaut.context.BeanRegistration<Interceptor<T1, T1>>> interceptors, @NonNull @NonNull io.micronaut.inject.BeanDefinition<T1> definition, @NonNull @NonNull io.micronaut.core.beans.BeanConstructor<T1> constructor, int additionalProxyConstructorParametersCount, @NonNull @NonNull Object... parameters) Internal methods that handles the logic of instantiating a bean that has constructor interception applied.- Type Parameters:
T1- The bean type- Parameters:
resolutionContext- The resolution contextbeanContext- The bean contextinterceptors- The interceptors. Can be null and if so should be resolved from the context.definition- The definitionconstructor- The bean constructoradditionalProxyConstructorParametersCount- The additional proxy constructor parameters countparameters- The resolved parameters- Returns:
- The instantiated bean
- Since:
- 3.0.0
-
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 @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()- Specified by:
getAttributesin interfaceio.micronaut.core.attr.AttributeHolder- Specified by:
getAttributesin interfaceio.micronaut.core.attr.MutableAttributeHolder
-
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<io.micronaut.core.annotation.AnnotationValue<?>> resolveInterceptorValues(@NonNull @NonNull io.micronaut.core.annotation.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
-