Package io.micronaut.aop
Interface InvocationContext<T,R>
-
- Type Parameters:
T
- The declaring typeR
- The result of the method call
- All Superinterfaces:
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.type.Executable<T,R>
,io.micronaut.core.attr.MutableAttributeHolder
- All Known Subinterfaces:
ConstructorInvocationContext<T>
,MethodInvocationContext<T,R>
- All Known Implementing Classes:
ConstructorInterceptorChain
,InterceptorChain
,MethodInterceptorChain
public interface InvocationContext<T,R> extends io.micronaut.core.type.Executable<T,R>, io.micronaut.core.annotation.AnnotationMetadataDelegate, io.micronaut.core.attr.MutableAttributeHolder
An InvocationContext passed to one or many
Interceptor
instances. Attributes can be stored within the context and shared between multipleInterceptor
implementations. Theproceed()
method should be called to proceed to the nextInterceptor
with the last interceptor in the chain being the original decorated method implementation.The parameters to pass to the next
Interceptor
can be mutated usingMutableArgumentValue
interface returned by thegetParameters()
method- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.lang.Class<T>
getDeclaringType()
default InterceptorKind
getKind()
java.util.Map<java.lang.String,io.micronaut.core.type.MutableArgumentValue<?>>
getParameters()
Returns the current parameters as a map of mutable argument values.default java.util.Map<java.lang.String,java.lang.Object>
getParameterValueMap()
Returns the current state of the parameters as a map keyed by parameter name.default java.lang.Object[]
getParameterValues()
Returns the current state of the parameters as an array by parameter index.T
getTarget()
R
proceed()
Proceeds with the invocation.R
proceed(Interceptor from)
Proceeds with the invocation using the given interceptor as a position to start from.default InvocationContext<T,R>
setAttribute(java.lang.CharSequence name, java.lang.Object value)
-
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
-
-
-
-
Method Detail
-
getParameters
@NonNull java.util.Map<java.lang.String,io.micronaut.core.type.MutableArgumentValue<?>> getParameters()
Returns the current parameters as a map of mutable argument values. This method allows mutation of the argument values and is generally more expensive than usinggetParameterValues()
andExecutable.getArguments()
directly, hence should be used with care.- Returns:
- The bound
ArgumentValue
instances
-
getTarget
@NonNull T getTarget()
- Returns:
- The target object
-
proceed
@Nullable R proceed() throws java.lang.RuntimeException
Proceeds with the invocation. If this is the last interceptor in the chain then the final implementation method is invoked- Returns:
- The return value of the method
- Throws:
java.lang.RuntimeException
- chain may throw RTE
-
proceed
@Nullable R proceed(Interceptor from) throws java.lang.RuntimeException
Proceeds with the invocation using the given interceptor as a position to start from. Mainly useful forIntroduction
advise where you want to invoke the target multiple times or where you want to repeat the entire chain.- 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
-
getKind
@NonNull default InterceptorKind getKind()
- Returns:
- An enum representing the kind of interception that is occurring.
- Since:
- 3.0.0
-
getDeclaringType
default java.lang.Class<T> getDeclaringType()
-
setAttribute
default InvocationContext<T,R> setAttribute(@NonNull java.lang.CharSequence name, java.lang.Object value)
- Specified by:
setAttribute
in interfaceio.micronaut.core.attr.MutableAttributeHolder
-
getParameterValues
@NonNull default java.lang.Object[] getParameterValues()
Returns 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 usegetParameters()
and theMutableArgumentValue
interface instead- Returns:
- The bound
ArgumentValue
instances
-
getParameterValueMap
@NonNull default java.util.Map<java.lang.String,java.lang.Object> getParameterValueMap()
Returns the current state of the parameters as a map keyed by parameter name.- Returns:
- A map of parameter names to values
-
-