Package io.micronaut.aop
Interface InvocationContext<T,R>
- Type Parameters:
T
- The declaring typeR
- The result of the method call
- All Superinterfaces:
AnnotationMetadata
,AnnotationMetadataDelegate
,AnnotationMetadataProvider
,AnnotationSource
,AttributeHolder
,Executable<T,
,R> MutableAttributeHolder
- All Known Subinterfaces:
ConstructorInvocationContext<T>
,MethodInvocationContext<T,
R>
- All Known Implementing Classes:
ConstructorInterceptorChain
,InterceptorChain
,MethodInterceptorChain
public interface InvocationContext<T,R>
extends Executable<T,R>, AnnotationMetadataDelegate, MutableAttributeHolder
An InvocationContext passed to one or many Interceptor
instances. Attributes can be stored within the
context and shared between multiple Interceptor
implementations. The proceed()
method should be
called to proceed to the next Interceptor
with the last interceptor in the chain being the original
decorated method implementation.
The parameters to pass to the next Interceptor
can be mutated using MutableArgumentValue
interface returned by the getParameters()
method
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull InterceptorKind
getKind()
Returns the current parameters as a map of mutable argument values.Returns the current state of the parameters as a map keyed by parameter name.Returns the current state of the parameters as an array by parameter index.proceed()
Proceeds with the invocation.proceed
(Interceptor from) Proceeds with the invocation using the given interceptor as a position to start from.default @NonNull InvocationContext<T,
R> setAttribute
(@NonNull CharSequence name, Object value) Sets an attribute on the message.Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresent
Methods 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, synthesizeDeclaredAnnotationsByType
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
getAnnotationMetadata
Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.core.type.Executable
getArguments, invoke
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
getAttributes, removeAttribute
-
Method Details
-
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
- Returns:
- The target object
-
proceed
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:
RuntimeException
- chain may throw RTE
-
proceed
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:
RuntimeException
- chain may throw RTE
-
getKind
- Returns:
- An enum representing the kind of interception that is occurring.
- Since:
- 3.0.0
-
getDeclaringType
- Specified by:
getDeclaringType
in interfaceExecutable<T,
R> - Returns:
- The declaring type
-
setAttribute
@NonNull default @NonNull InvocationContext<T,R> setAttribute(@NonNull @NonNull CharSequence name, Object value) Description copied from interface:MutableAttributeHolder
Sets an attribute on the message.- Specified by:
setAttribute
in interfaceMutableAttributeHolder
- Parameters:
name
- The name of the attributevalue
- The value of the attribute- Returns:
- This message
-
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
Returns the current state of the parameters as a map keyed by parameter name.- Returns:
- A map of parameter names to values
-