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
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:
-
AbstractSmartLifecycleSmartLifecycleLogger
-
Field Summary
Fields inherited from class io.microsphere.spring.context.lifecycle.AbstractSmartLifecycle
DEFAULT_PHASE, EARLIEST_PHASE, LATEST_PHASE -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class io.microsphere.spring.context.lifecycle.AbstractSmartLifecycle
getPhase, isAutoStartup, isRunning, isStarted, setPhase, setStarted, start, stop, stop
-
Constructor Details
-
LoggingSmartLifecycle
public LoggingSmartLifecycle()
-
-
Method Details
-
doStart
protected void doStart()- Specified by:
doStartin classAbstractSmartLifecycle
-
doStop
protected void doStop()- Specified by:
doStopin classAbstractSmartLifecycle
-