Skip to content

io microsphere spring context event ApplicationListenerInterceptorChain

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

ApplicationListenerInterceptorChain

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/ApplicationListenerInterceptorChain.java

Overview

A contract for an interceptor chain that allows the execution flow to be intercepted and processed by a series of ApplicationListenerInterceptor instances. This chain enables pre-processing, post-processing, and around-processing of events before and after they are handled by the actual ApplicationListener.

Implementations of this interface are responsible for managing the order and execution of interceptors. Each interceptor in the chain has the ability to decide whether to pass the invocation to the next interceptor or to short-circuit the chain.

Example Usage

`public class CustomInterceptor implements ApplicationListenerInterceptor {
    public void intercept(ApplicationListenerInterceptorChain chain, ApplicationListener listener, ApplicationEvent event) {
        // Pre-processing logic
        System.out.println("Before event handling");

        // Proceed to the next interceptor or the target listener
        chain.intercept(listener, event);

        // Post-processing logic
        System.out.println("After event handling");
    `
}
}

In the example above, the custom interceptor adds behavior before and after the event is processed by the target application listener. The call to #intercept(ApplicationListener, ApplicationEvent) ensures the chain continues execution.

Declaration

public interface ApplicationListenerInterceptorChain

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 CustomInterceptor implements ApplicationListenerInterceptor {
    public void intercept(ApplicationListenerInterceptorChain chain, ApplicationListener<?> listener, ApplicationEvent event) {
        // Pre-processing logic
        System.out.println("Before event handling");

        // Proceed to the next interceptor or the target listener
        chain.intercept(listener, event);

        // Post-processing logic
        System.out.println("After event handling");
    }
}

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.ApplicationListenerInterceptorChain;

API Reference

Public Methods

Method Description
intercept

See Also

  • ApplicationListenerInterceptor
  • ApplicationListener
  • ApplicationEvent

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