Defines the core interception contract for JetLeaf’s AOP (Aspect-Oriented Programming) framework, allowing runtime interception and augmentation of method invocations.
Implementations of MethodInterceptor can selectively intercept method calls based
on metadata, annotations, or execution context.
Each interceptor determines its applicability via canIntercept, enabling fine-grained
interception pipelines.
Interception Lifecycle
- JetLeaf identifies candidate interceptors for a given Method.
- Each interceptor’s canIntercept is evaluated.
- Interceptors returning
trueare added to the execution chain. - Depending on their subtype, they may act before, after, or around the method invocation.
Example
final interceptor = TransactionInterceptor();
if (interceptor.canIntercept(method)) {
await interceptor.beforeInvocation(invocation);
}
Typical Implementations
- MethodBeforeInterceptor — execute logic before invocation.
- AfterReturningInterceptor — execute logic after successful return.
- AfterThrowingInterceptor — handle exceptions.
- AfterInvocationInterceptor — always invoked at the end.
- AroundMethodInterceptor — fully wraps invocation for total control.
See Also
- MethodInvocation
- Class
- Method
InterceptorChain
- Mixed-in types
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
canIntercept(
Method method) → bool -
Determines whether this interceptor can intercept the specified
method. -
equalizedProperties(
) → List< Object?> -
Mixin-style contract for value-based equality,
hashCode, andtoString.inherited -
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