Interface ApplicationEventInterceptorChain
-
public interface ApplicationEventInterceptorChain
A chain ofApplicationEventInterceptor
instances that can be used to apply cross-cutting logic before and after the processing of anApplicationEvent
.ApplicationEventInterceptor
implementations can perform actions such as:- Measuring the time taken to process an event
- Adding contextual information before event processing
- Performing cleanup or post-processing after event handling
Interceptors in the chain are typically ordered, and each interceptor decides whether to pass the event along to the next interceptor in the chain by calling
intercept(ApplicationEvent, ResolvableType)
.Example Usage
public class LoggingInterceptor implements ApplicationEventInterceptor { public void intercept(ApplicationEvent event, ResolvableType eventType, ApplicationEventInterceptorChain chain) { System.out.println("Before processing event: " + event.getClass().getSimpleName()); chain.intercept(event, eventType); // continue the chain System.out.println("After processing event: " + event.getClass().getSimpleName()); } }
When building an interceptor, it's important to decide whether to proceed with the chain. If an interceptor chooses not to call
intercept(org.springframework.context.ApplicationEvent, org.springframework.core.ResolvableType)
, the event processing will be short-circuited, and subsequent interceptors (as well as the final event handler) will not be invoked.- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ApplicationEventInterceptor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
intercept(org.springframework.context.ApplicationEvent event, org.springframework.core.ResolvableType eventType)
Causes the next interceptor in the chain to be invoked, or if the calling interceptor is the last interceptor in the chain, causes the resource at the end of the chain to be invoked.
-
-
-
Method Detail
-
intercept
void intercept(org.springframework.context.ApplicationEvent event, org.springframework.core.ResolvableType eventType)
Causes the next interceptor in the chain to be invoked, or if the calling interceptor is the last interceptor in the chain, causes the resource at the end of the chain to be invoked.- Parameters:
event
-ApplicationEvent
eventType
-ResolvableType
to present the type ofApplicationEvent
-
-