One intercepted call as a MethodInterceptor sees it: the call's details plus a way to continue it.
Every advised call passes through a chain of interceptors, outermost
first, and each one receives a MethodInvocation. An interceptor
written by hand (for a PointcutAdvisor bean) gets it in
MethodInterceptor.invoke; aspect advice sees a JoinPoint instead.
Unlike a join point, its args are the live arguments: an interceptor
may change them in place before calling proceed. For a member
returning a Future, it is also an AsyncMethodInvocation.
// Logs each call on the way in.
class LoggingInterceptor implements MethodInterceptor {
@override
Object? invoke(MethodInvocation invocation) {
log.info('-> ${invocation.signature.name}${invocation.args}');
return invocation.proceed();
}
}
Spring (Java):
class LoggingInterceptor implements MethodInterceptor {
public Object invoke(MethodInvocation invocation) throws Throwable {
log.info("-> " + invocation.getMethod().getName());
return invocation.proceed();
}
}
- Implemented types
Properties
-
args
→ List<
Object?> -
The arguments the next step receives; an interceptor may change
them in place before calling proceed.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- proxy → Object
-
The proxy the caller called, the object other beans hold. For a
generated subclass proxy it is the bean itself, like target.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- signature → MethodSignature
-
The called member: its name, types and annotations.
no setterinherited
- target → Object
-
The bean whose member runs: the object behind the proxy.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
proceed(
[List< Object?> ? args]) → Object? -
Runs the next advice, or the member itself after the last one, and
returns its result.
inherited
-
toShortString(
) → String -
A short description for logs, such as
execution(Greeter.greet(..)).inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited