LifecycleProcessor strategy.
Provides interaction with Lifecycle and SmartLifecycle beans in
groups for specific phases, on startup/shutdown as well as for explicit start/stop
interactions on a org..
Provides interaction with Lifecycle and SmartLifecycle beans in
groups for specific phases, on startup/shutdown as well as for explicit start/stop
interactions on a org..
As of 6.1, this also includes support for JVM checkpoint/restore (Project CRaC)
when the org.crac:crac dependency on the classpath.
| Modifier and Type | Class and Description |
|---|---|
| private class | DefaultLifecycleProcessor.CracDelegate
Inner class to avoid a hard dependency on Project CRaC at runtime. |
| private class | DefaultLifecycleProcessor.CracResourceAdapter
Resource adapter for Project CRaC, triggering a stop-and-restart cycle for Spring-managed lifecycle beans around a JVM checkpoint/restore. |
| private class | DefaultLifecycleProcessor.LifecycleGroup
Helper class for maintaining a group of Lifecycle beans that should be started and stopped together based on their 'phase' value (or the default value of 0). |
| private static record | DefaultLifecycleProcessor.LifecycleGroupMember
A simple record of a LifecycleGroup member. |
| Modifier and Type | Field and Description |
|---|---|
| private volatile ConfigurableListableBeanFactory | |
| public static final String | CHECKPOINT_PROPERTY_NAME
Property name for a common context checkpoint: spring.context.checkpoint. |
| private static final boolean | |
| private Object | |
| public static final String | EXIT_PROPERTY_NAME
Property name for terminating the JVM when the context reaches a specific phase: spring.context.exit. |
| private static final boolean | |
| private final Log | |
| public static final String | ON_REFRESH_VALUE
Recognized value for the context checkpoint and exit properties: onRefresh. |
| private volatile boolean | |
| private volatile Set | |
| private volatile long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | doStart(Map<String, ? extends Lifecycle>
a Map with bean name as key and Lifecycle instance as value lifecycleBeans, String the name of the bean to start beanName, boolean autoStartupOnly)Start the specified bean as part of the given set of Lifecycle beans, making sure that any beans that it depends on are started first. |
| private void | doStop(Map<String, ? extends Lifecycle>
a Map with bean name as key and Lifecycle instance as value lifecycleBeans, final String the name of the bean to stop beanName, final CountDownLatch latch, final Set<String> countDownBeanNames)Stop the specified bean as part of the given set of Lifecycle beans, making sure that any beans that depends on it are stopped first. |
| private ConfigurableListableBeanFactory | |
| protected Map | Returns: the Map of applicable beans, with bean names as keys and bean instances as valuesRetrieve all applicable Lifecycle beans: all singletons that have already been created, as well as all SmartLifecycle beans (even if they are marked as lazy-init). |
| protected int | |
| private boolean | |
| public boolean | isRunning()
Implements org. |
| private boolean | |
| public void | onClose()
Implements org. |
| public void | onRefresh()
Implements org. |
| pack-priv void | |
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. |
| public void | setTimeoutPerShutdownPhase(long timeoutPerShutdownPhase)
Specify the maximum time allotted in milliseconds for the shutdown of any
phase (group of |
| public void | start()
Implements org. Lifecycle and are not
already running.
|
| private void | |
| public void | stop()
Implements org. Lifecycle and are
currently running.
|
| private void | |
| pack-priv void | |
| private boolean |
| beanFactory | back to summary |
|---|---|
| private volatile ConfigurableListableBeanFactory beanFactory
| |
| CHECKPOINT_PROPERTY_NAME | back to summary |
|---|---|
| public static final String CHECKPOINT_PROPERTY_NAME Property name for a common context checkpoint: spring.context.checkpoint.
| |
| checkpointOnRefresh | back to summary |
|---|---|
| private static final boolean checkpointOnRefresh | |
| cracResource | back to summary |
|---|---|
| private Object cracResource
| |
| EXIT_PROPERTY_NAME | back to summary |
|---|---|
| public static final String EXIT_PROPERTY_NAME Property name for terminating the JVM when the context reaches a specific phase: spring.context.exit.
| |
| exitOnRefresh | back to summary |
|---|---|
| private static final boolean exitOnRefresh | |
| logger | back to summary |
|---|---|
| private final Log logger | |
| ON_REFRESH_VALUE | back to summary |
|---|---|
| public static final String ON_REFRESH_VALUE Recognized value for the context checkpoint and exit properties: onRefresh.
| |
| running | back to summary |
|---|---|
| private volatile boolean running | |
| stoppedBeans | back to summary |
|---|---|
| private volatile Set<String> stoppedBeans
| |
| timeoutPerShutdownPhase | back to summary |
|---|---|
| private volatile long timeoutPerShutdownPhase | |
| DefaultLifecycleProcessor | back to summary |
|---|---|
| public DefaultLifecycleProcessor() | |
| doStart | back to summary |
|---|---|
| private void doStart(Map<String, ? extends Lifecycle> lifecycleBeans, String beanName, boolean autoStartupOnly) Start the specified bean as part of the given set of Lifecycle beans, making sure that any beans that it depends on are started first. | |
| doStop | back to summary |
|---|---|
| private void doStop(Map<String, ? extends Lifecycle> lifecycleBeans, final String beanName, final CountDownLatch latch, final Set<String> countDownBeanNames) Stop the specified bean as part of the given set of Lifecycle beans, making sure that any beans that depends on it are stopped first. | |
| getBeanFactory | back to summary |
|---|---|
| private ConfigurableListableBeanFactory getBeanFactory() | |
| getLifecycleBeans | back to summary |
|---|---|
| protected Map Retrieve all applicable Lifecycle beans: all singletons that have already been created, as well as all SmartLifecycle beans (even if they are marked as lazy-init). | |
| getPhase | back to summary |
|---|---|
| protected int getPhase(Lifecycle bean) Determine the lifecycle phase of the given bean. The default implementation checks for the
| |
| isAutoStartupCandidate | back to summary |
|---|---|
| private boolean isAutoStartupCandidate(String beanName, Lifecycle bean) | |
| isRunning | back to summary |
|---|---|
| public boolean isRunning() Implements org. Doc from org. Check whether this component is currently running. In the case of a container, this will return
| |
| matchesBeanType | back to summary |
|---|---|
| private boolean matchesBeanType(Class<?> targetType, String beanName, BeanFactory beanFactory) | |
| onClose | back to summary |
|---|---|
| public void onClose() Implements org. Doc from org. Notification of context close phase, e.g. for auto-stopping components.
| |
| onRefresh | back to summary |
|---|---|
| public void onRefresh() Implements org. Doc from org. Notification of context refresh, e.g. for auto-starting components.
| |
| restartAfterStop | back to summary |
|---|---|
| pack-priv void restartAfterStop() | |
| setBeanFactory | back to summary |
|---|---|
| public void setBeanFactory(BeanFactory beanFactory) Implements org. Doc from org. Callback that supplies the owning factory to a bean instance. Invoked after the population of normal bean properties
but before an initialization callback such as
| |
| setTimeoutPerShutdownPhase | back to summary |
|---|---|
| public void setTimeoutPerShutdownPhase(long timeoutPerShutdownPhase) Specify the maximum time allotted in milliseconds for the shutdown of any
phase (group of The default value is 30000 milliseconds (30 seconds).
| |
| start | back to summary |
|---|---|
| public void start() Implements org. Start all registered beans that implement
| |
| startBeans | back to summary |
|---|---|
| private void startBeans(boolean autoStartupOnly) | |
| stop | back to summary |
|---|---|
| public void stop() Implements org. Stop all registered beans that implement
| |
| stopBeans | back to summary |
|---|---|
| private void stopBeans() | |
| stopForRestart | back to summary |
|---|---|
| pack-priv void stopForRestart() | |
| toBeStarted | back to summary |
|---|---|
| private boolean toBeStarted(String beanName, Lifecycle bean) | |
org.crac.Core
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public Object |
| CracDelegate | back to summary |
|---|---|
| private CracDelegate() | |
| checkpointRestore | back to summary |
|---|---|
| public void checkpointRestore() | |
| registerResource | back to summary |
|---|---|
| public Object registerResource() | |
stopForRestart(), restartAfterStop()
| Modifier and Type | Field and Description |
|---|---|
| private CyclicBarrier |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterRestore(Context<? extends Resource>
Context providing notificationImplements org. Context as a notification about restore.
|
| private void | |
| public void | beforeCheckpoint(Context<? extends Resource>
Context providing notificationImplements org. Context as a notification about checkpoint.
|
| barrier | back to summary |
|---|---|
| private CyclicBarrier barrier
| |
| CracResourceAdapter | back to summary |
|---|---|
| private CracResourceAdapter() | |
| afterRestore | back to summary |
|---|---|
| public void afterRestore(Context<? extends Resource> context) Implements org. Doc from org. Invoked by a | |
| awaitPreventShutdownBarrier | back to summary |
|---|---|
| private void awaitPreventShutdownBarrier() | |
| beforeCheckpoint | back to summary |
|---|---|
| public void beforeCheckpoint(Context<? extends Resource> context) Implements org. Doc from org. Invoked by a | |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final Map | |
| private final List | |
| private final int | |
| private int | |
| private final long |
| Access | Constructor and Description |
|---|---|
| public | LifecycleGroup(int phase, long timeout, Map<String, ? extends Lifecycle> lifecycleBeans, boolean autoStartupOnly)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void |
| autoStartupOnly | back to summary |
|---|---|
| private final boolean autoStartupOnly | |
| lifecycleBeans | back to summary |
|---|---|
| private final Map<String, ? extends Lifecycle> lifecycleBeans | |
| members | back to summary |
|---|---|
| private final List<DefaultLifecycleProcessor. | |
| phase | back to summary |
|---|---|
| private final int phase | |
| smartMemberCount | back to summary |
|---|---|
| private int smartMemberCount | |
| timeout | back to summary |
|---|---|
| private final long timeout | |
| LifecycleGroup | back to summary |
|---|---|
| public LifecycleGroup(int phase, long timeout, Map<String, ? extends Lifecycle> lifecycleBeans, boolean autoStartupOnly) | |
| add | back to summary |
|---|---|
| public void add(String name, Lifecycle bean) | |
| start | back to summary |
|---|---|
| public void start() | |
| stop | back to summary |
|---|---|
| public void stop() | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Lifecycle | |
| public final boolean | equals(Object
the reference object with which to compare. o)Implements abstract java. |
| public final int | |
| public String | |
| public final String | toString()
Implements abstract java. |
| bean | back to summary |
|---|---|
| private final Lifecycle bean Record Component accessed by bean(). | |
| name | back to summary |
|---|---|
| private final String name Record Component accessed by name(). | |
| LifecycleGroupMember | back to summary |
|---|---|
| private LifecycleGroupMember(String name, Lifecycle bean) | |
| bean | back to summary |
|---|---|
| public Lifecycle bean() Record Component getter of bean. | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of
| |
| name | back to summary |
|---|---|
| public String name() Record Component getter of name. | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.
| |