Class DefaultLifecycleProcessor

    • Method Detail

      • setTimeoutPerShutdownPhase

        public void setTimeoutPerShutdownPhase​(long timeoutPerShutdownPhase)
        Specify the maximum time allotted in milliseconds for the shutdown of any phase (group of SmartLifecycle beans with the same 'phase' value).

        The default value is 30 seconds.

      • start

        public void start()
        Start all registered beans that implement Lifecycle and are not already running. Any bean that implements SmartLifecycle will be started within its 'phase', and all phases will be ordered from lowest to highest value. All beans that do not implement SmartLifecycle will be started in the default phase 0. A bean declared as a dependency of another bean will be started before the dependent bean regardless of the declared phase.
        Specified by:
        start in interface Lifecycle
        See Also:
        SmartLifecycle.isAutoStartup()
      • stop

        public void stop()
        Stop all registered beans that implement Lifecycle and are currently running. Any bean that implements SmartLifecycle will be stopped within its 'phase', and all phases will be ordered from highest to lowest value. All beans that do not implement SmartLifecycle will be stopped in the default phase 0. A bean declared as dependent on another bean will be stopped before the dependency bean regardless of the declared phase.
        Specified by:
        stop in interface Lifecycle
        See Also:
        SmartLifecycle.stop(Runnable), DisposableBean.destroy()
      • isRunning

        public boolean isRunning()
        Description copied from interface: Lifecycle
        Check whether this component is currently running.

        In the case of a container, this will return true only if all components that apply are currently running.

        Specified by:
        isRunning in interface Lifecycle
        Returns:
        whether the component is currently running
      • getLifecycleBeans

        protected Map<String,​LifecyclegetLifecycleBeans()
        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).
        Returns:
        the Map of applicable beans, with bean names as keys and bean instances as values
      • getPhase

        protected int getPhase​(Lifecycle bean)
        Determine the lifecycle phase of the given bean.

        The default implementation checks for the Phased interface, using a default of 0 otherwise. Can be overridden to apply other/further policies.

        Parameters:
        bean - the bean to introspect
        Returns:
        the phase (an integer value)
        See Also:
        Phased.getPhase(), SmartLifecycle