Skip to content

io microsphere spring context event ApplicationEventInterceptorChain

github-actions[bot] edited this page Jun 18, 2026 · 18 revisions

ApplicationEventInterceptorChain

Type: Interface | Module: microsphere-spring-context | Package: io.microsphere.spring.context.event | Since: 1.0.0

Source: microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/ApplicationEventInterceptorChain.java

Overview

A chain of ApplicationEventInterceptor instances that can be used to apply cross-cutting logic before and after the processing of an ApplicationEvent.

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 ApplicationEventInterceptorChain#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 ApplicationEventInterceptorChain#intercept, the event processing will be short-circuited, and subsequent interceptors (as well as the final event handler) will not be invoked.

Declaration

public interface ApplicationEventInterceptorChain

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.27-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

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());
    }
}

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-context</artifactId>
    <version>${microsphere-spring.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.context.event.ApplicationEventInterceptorChain;

See Also

  • ApplicationEventInterceptor

This documentation was auto-generated from the source code of microsphere-spring.

Home

spring-context

spring-guice

spring-jdbc

spring-test

spring-web

spring-webflux

spring-webmvc

Clone this wiki locally