AspectAdviceInterceptor class final
The MethodInterceptor that runs one aspect advice method: it turns the advice kind (before, after, around, ...) into the right place in the call.
The AspectAutoProxyCreator and AspectJProxyFactory create one for
every AspectAdvice; applications do not. It looks the aspect up for
every call, so lazy and prototype aspects work, and per-instance
aspects (perthis / pertarget) get the instance of the proxy or
target. The advice method gets its own join point whose args are a
copy (like Spring's JoinPoint.getArgs()): changing that list does
nothing, only proceed(args) changes the arguments.
For a method returning a Future (or a FutureOr that is one),
@After, @AfterReturning and @AfterThrowing run when the future
completes. An advice method other than @Around may be async: on such
a method the call waits for it; on a synchronous method the call fails
with an AopInvocationException, since nothing could wait.
// Runs `advice` on the auditAspect bean, looked up for every call.
final interceptor = AspectAdviceInterceptor(
advice,
() => beanFactory.getBeanByName('auditAspect'),
);
Spring (Java):
// One advice class per kind, e.g. AspectJMethodBeforeAdvice, with the
// aspect obtained from a BeanFactoryAspectInstanceFactory.
new AspectJMethodBeforeAdvice(method, pointcut, aspectInstanceFactory);
- Implemented types
Constructors
-
AspectAdviceInterceptor(AspectAdvice<
Object> advice, Object aspect()) -
Runs
adviceon the aspect thataspectreturns, called for every advised call. -
AspectAdviceInterceptor.forInvocation(AspectAdvice<
Object> advice, Object aspectFor(MethodInvocation invocation)) -
Runs
adviceon the aspectaspectForreturns for the call, so the instance can depend on the proxy or target (perthis/pertargetaspects).
Properties
-
advice
→ AspectAdvice<
Object> -
The advice method to run.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
aspectFor(
MethodInvocation invocation) → Object -
The aspect instance the advice runs on for
invocation. -
invoke(
MethodInvocation invocation, [Map< String, Object?> bindings = const {}]) → Object? -
Runs the advice around
invocationand returns the call's result.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited