Skip to content

io microsphere spring context event EventPublishingBeanInitializer

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

EventPublishingBeanInitializer

Type: Class | 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/EventPublishingBeanInitializer.java

Overview

An ApplicationContextInitializer that registers processors to publish Spring bean lifecycle events during context initialization.

This initializer executes with the highest priority to guarantee that bean event publishing capabilities are established before other components are processed. It automatically registers an EventPublishingBeanBeforeProcessor as a org.springframework.beans.factory.config.BeanFactoryPostProcessor.

Configuration

The initializer is disabled by default. Enable it via the application configuration:

# application.properties
microsphere.spring.event-publishing-bean.enabled=true

Example

After enabling, you can listen to bean events by implementing a BeanListener:

@Component
public class MyBeanListener implements BeanListener {
    @Override
    public void onBeanBeforeInitialization(String beanName, Class<?> beanType) {
        // Custom logic before bean initialization
    }
}

Declaration

public class EventPublishingBeanInitializer extends ConfigurableApplicationContextInitializer implements PriorityOrdered

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.30-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

Example 1

# application.properties
microsphere.spring.event-publishing-bean.enabled=true

Example 2

&#64;Component
public class MyBeanListener implements BeanListener {
    &#64;Override
    public void onBeanBeforeInitialization(String beanName, Class&lt;?&gt; beanType) {
        // Custom logic before bean initialization
    }
}

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

API Reference

Public Methods

Method Description
getOrder

See Also

  • EventPublishingBeanBeforeProcessor
  • EventPublishingBeanAfterProcessor
  • BeanListeners
  • BeanListener
  • BeanListenerAdapter
  • BeanFactoryListeners
  • BeanFactoryListener
  • BeanFactoryListenerAdapter
  • ApplicationContextInitializer
  • PriorityOrdered

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