Class LoggingSmartLifecycle

java.lang.Object
io.microsphere.spring.context.lifecycle.AbstractSmartLifecycle
io.microsphere.spring.context.lifecycle.LoggingSmartLifecycle
All Implemented Interfaces:
org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class LoggingSmartLifecycle extends AbstractSmartLifecycle
A SmartLifecycle implementation that logs lifecycle events for debugging and monitoring purposes.

This class extends AbstractSmartLifecycle and provides logging capabilities for lifecycle methods such as doStart() and doStop(). The logging is performed using the Logger interface provided by the MicroSphere logging framework.

Example Usage

To use this class in a Spring application context, simply define it as a bean:


 @Bean
 public LoggingSmartLifecycle loggingSmartLifecycle() {
     return new LoggingSmartLifecycle();
 }
 

Example Output

When the Spring context starts or stops, the following messages will be logged:

 doStart()...
 doStop()...
 

Customization

Subclasses can override the lifecycle methods to add custom behavior while retaining the logging functionality. For example:


 @Override
 protected void doStart() {
     logger.info("Performing custom startup logic...");
     // custom startup logic
     super.doStart(); // optional
 }
 
Since:
1.0.0
Author:
Mercy
See Also: