Class SpringLifecycleRegistry
- All Implemented Interfaces:
LifecycleRegistry,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware
LifecycleRegistry implementation that registers all lifecycle handlers as Spring
SmartLifecycle beans to ensure Spring weaves these lifecycles into the other
Spring bean lifecycles.
By being a BeanFactory implementation, this LifecycleRegistry is capable of registering the
aforementioned SmartLifecycle beans based on the LifecycleHandlers provided through
onStart(int, LifecycleHandler) and onShutdown(int, LifecycleHandler).
- Since:
- 5.0.0
- Author:
- Allard Buijze
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiononShutdown(int phase, LifecycleHandler shutdownHandler) Registers an asynchronousshutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.onStart(int phase, LifecycleHandler startHandler) Registers an asynchronousstartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.registerLifecyclePhaseTimeout(long timeout, TimeUnit timeUnit) Configures the timeout of each lifecycle phase.voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.common.configuration.LifecycleRegistry
onShutdown, onShutdown, onShutdown, onShutdown, onStart, onStart, onStart, onStart
-
Constructor Details
-
SpringLifecycleRegistry
public SpringLifecycleRegistry()
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(@Nonnull org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
registerLifecyclePhaseTimeout
Description copied from interface:LifecycleRegistryConfigures the timeout of each lifecycle phase. TheLifecycleRegistryinvokes lifecycle phases during start-up and shutdown of an application.Note that if a lifecycle phase exceeds the configured
timeoutandtimeUnitcombination, theLifecycleRegistrywill proceed with the following phase. A phase-skip is marked with a warn logging message, as the chances are high this causes undesired side effects.The default lifecycle phase timeout is five seconds.
- Specified by:
registerLifecyclePhaseTimeoutin interfaceLifecycleRegistry- Parameters:
timeout- The amount of time to wait for lifecycle phase completion.timeUnit- The unit in which thetimeoutis expressed.- Returns:
- The current instance of the
LifecycleRegistry, for chaining purposes. - See Also:
-
onStart
Description copied from interface:LifecycleRegistryRegisters an asynchronousstartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.Handlers cannot be registered when the configuration has already been created from this registry.
- Specified by:
onStartin interfaceLifecycleRegistry- Parameters:
phase- Defines aphasein which the start handler will be invoked duringAxonConfiguration.start(). When starting the configuration the given handlers are started in ascending order based on theirphase.startHandler- The handler to be executed asynchronously when theAxonConfigurationis started.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onShutdown
Description copied from interface:LifecycleRegistryRegisters an asynchronousshutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.The behavior for handlers that are registered when the configuration is already shut down is undefined.
- Specified by:
onShutdownin interfaceLifecycleRegistry- Parameters:
phase- Defines a phase in which the shutdown handler will be invoked duringAxonConfiguration.shutdown(). When shutting down the configuration the given handlers are executing in descending order based on theirphase.shutdownHandler- The handler to be executed asynchronously when theAxonConfigurationis shut down.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-