DefaultMethodInterceptor class final
Default implementation of MethodInterceptorRegistry and related intercept processing.
This class serves as the central registry and dispatcher for method-level interceptors in a JetLeaf application. It is responsible for:
- Collecting all MethodInterceptor implementations from the PodFactory.
- Applying ordering rules based on
PriorityOrderedandOrderedannotations. - Managing a custom MethodInterceptorDispatcher if provided.
- Injecting itself into any Interceptable pods so they can delegate method calls for interception.
Responsibilities
- Interceptor Management: Add, remove, and maintain ordered sets of interceptors.
- Dispatcher Configuration: Support custom dispatcher injection and fallback to default dispatching logic.
- Pod Lifecycle Integration: Implements
PodInstantiationProcessorandSmartInitializingSingletonto hook into pod creation and initialization events for automatic registration of interceptors. - Logging: Uses JetLeaf logging for info/debug during interceptor collection and registration.
Lifecycle
- During pod instantiation, this registry can attach itself to Interceptable pods.
- After singleton initialization (onSingletonReady), it:
- Collects all MethodInterceptor pods from the
PodFactory. - Collects all MethodInterceptorConfigurer pods and invokes
their
configuremethod to register additional interceptors.
- Collects all MethodInterceptor pods from the
- Interceptors are sorted by priority and order annotations using AnnotationAwareOrderComparator.
- Once initialized, the registry can be used to intercept method calls transparently via AbstractMethodDispatcher.
Example Usage
final registry = DefaultMethodInterceptor();
registry.setPodFactory(podFactory);
await registry.onSingletonReady(); // Collect interceptors
// Adding a custom interceptor manually
registry.addMethodInterceptor(CustomLoggingInterceptor());
// Setting a custom dispatcher if needed
registry.setMethodInterceptorDispatcher(MyCustomDispatcher());
- Inheritance
-
- Object
- AbstractMethodDispatcher
- DefaultMethodInterceptor
- Implemented types
Constructors
- DefaultMethodInterceptor()
- Default implementation of MethodInterceptorRegistry and related intercept processing.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- podFactory ↔ ConfigurableListablePodFactory
-
The pod factory used to discover and instantiate interceptors and configurers.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addMethodInterceptor(
MethodInterceptor interceptor, [String? podName]) → void -
Registers a MethodInterceptor with this registry.
override
-
getMethodInterceptorDispatcher(
) → MethodInterceptorDispatcher? -
Retrieves the active MethodInterceptorDispatcher responsible for
managing method-level interception logic.
override
-
getMethodInterceptors(
) → List< MethodInterceptor> -
Retrieves the list of method interceptors to be applied by this dispatcher.
override
-
getPackageName(
) → String - Represents an abstraction for identifying the package that an object, resource, or service belongs to.
-
intercept<
T> (MethodInvocation< T> invocation) → Future<T> -
Executes a method invocation through the configured interceptor chain.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onSingletonReady(
) → Future< void> - Callback interface triggered at the end of the singleton pre-instantiation phase.
-
processAfterInitialization(
Object pod, Class podClass, String name) → Future< Object?> - Processes the pod after all initialization callbacks have completed.
-
processBeforeInitialization(
Object pod, Class podClass, String name) → Future< Object?> - Processes the pod before any initialization callbacks are invoked.
-
setMethodInterceptorDispatcher(
MethodInterceptorDispatcher dispatcher) → void -
Sets the MethodInterceptorDispatcher that executes the registered interceptors.
override
-
setPodFactory(
PodFactory podFactory) → void -
Sets the
PodFactorythat created and manages this component.override -
shouldProcessBeforeInitialization(
Object pod, Class podClass, String name) → Future< bool> - Determines whether this processor should be applied to the given pod.
-
toString(
) → String -
A string representation of this object.
inherited
-
when<
T> (AsyncMethodInvocator< T> function, Object target, String methodName, [ExecutableArgument? arguments, Class? targetClass]) → Future<T> -
Executes a function with interception support and conditional routing.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited