Class AbstractSmartLifecycle
- java.lang.Object
-
- io.microsphere.spring.context.lifecycle.AbstractSmartLifecycle
-
- All Implemented Interfaces:
org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
- Direct Known Subclasses:
LoggingSmartLifecycle
public abstract class AbstractSmartLifecycle extends java.lang.Object implements org.springframework.context.SmartLifecycleAbstract base class for implementingSmartLifecyclestrategies.This class provides a skeletal implementation of the
SmartLifecycleinterface, making it easier to create custom lifecycle beans with specific startup and shutdown logic.Key Features
- Centralizes common lifecycle state management.
- Offers phase-based control for startup and shutdown order.
- Ensures consistent lifecycle behavior across implementations.
Example Usage
{@code public class MyCustomLifecycle extends AbstractSmartLifecycle { private boolean running = false;- Since:
- 1.0.0
- Author:
- Mercy
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PHASECompatible withSmartLifecycle.DEFAULT_PHASEbefore Spring Framework 5.1static intEARLIEST_PHASEThe earliest phasestatic intLATEST_PHASEThe latest phase
-
Constructor Summary
Constructors Constructor Description AbstractSmartLifecycle()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voiddoStart()protected abstract voiddoStop()intgetPhase()booleanisAutoStartup()booleanisRunning()booleanisStarted()voidsetPhase(int phase)protected voidsetStarted(boolean started)voidstart()voidstop()voidstop(java.lang.Runnable callback)
-
-
-
Field Detail
-
EARLIEST_PHASE
public static final int EARLIEST_PHASE
The earliest phase- See Also:
- Constant Field Values
-
LATEST_PHASE
public static final int LATEST_PHASE
The latest phase- See Also:
- Constant Field Values
-
DEFAULT_PHASE
public static final int DEFAULT_PHASE
Compatible withSmartLifecycle.DEFAULT_PHASEbefore Spring Framework 5.1- See Also:
SmartLifecycle.DEFAULT_PHASE, Constant Field Values
-
-
Method Detail
-
start
public final void start()
- Specified by:
startin interfaceorg.springframework.context.Lifecycle
-
doStart
protected abstract void doStart()
-
stop
public final void stop()
- Specified by:
stopin interfaceorg.springframework.context.Lifecycle
-
doStop
protected abstract void doStop()
-
isRunning
public final boolean isRunning()
- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle
-
isAutoStartup
public boolean isAutoStartup()
- Specified by:
isAutoStartupin interfaceorg.springframework.context.SmartLifecycle
-
stop
public void stop(java.lang.Runnable callback)
- Specified by:
stopin interfaceorg.springframework.context.SmartLifecycle
-
getPhase
public final int getPhase()
- Specified by:
getPhasein interfaceorg.springframework.context.Phased- Specified by:
getPhasein interfaceorg.springframework.context.SmartLifecycle
-
isStarted
public boolean isStarted()
-
setPhase
public final void setPhase(int phase)
-
setStarted
protected void setStarted(boolean started)
-
-