Class HierarchicalConfiguration
java.lang.Object
org.axonframework.common.configuration.HierarchicalConfiguration
- All Implemented Interfaces:
LifecycleRegistry
The HierarchicalConfiguration is a configuration that will ensure the to-be-built child configuration will be passed
a
LifecycleRegistry that is a child of the parent configuration's LifecycleRegistry. This will ensure
that the child configuration's start- and shutdown handlers receive the child configuration, so they can retrieve
their own components.- Since:
- 5.0.0
- Author:
- Mitchell Herrijgers
-
Method Summary
Modifier and TypeMethodDescriptionstatic Configurationbuild(LifecycleRegistry parentLifecycleRegistry, Function<LifecycleRegistry, Configuration> childConfigurationBuilder) Builds aConfigurationbased on the passedchildConfigurationBuilder.onShutdown(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.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
-
Method Details
-
build
public static Configuration build(LifecycleRegistry parentLifecycleRegistry, Function<LifecycleRegistry, Configuration> childConfigurationBuilder) Builds aConfigurationbased on the passedchildConfigurationBuilder. This builder will receive aLifecycleRegistrythat is a child of the passedparentLifecycleRegistry. The builder is created with a newLifecycleRegistrythat is scoped to the child configuration. This will ensure child configuration lifecycle handlers are called with the child configuration, not with the parent, which would leave them unable to find their own components due to the encapsulation.- Parameters:
parentLifecycleRegistry- The parentLifecycleRegistryto build the child configuration from.childConfigurationBuilder- The builder that will be used to create the child configuration. It will receive aLifecycleRegistrythat is a child of theparentLifecycleRegistry.- Returns:
- The child configuration that was built using the passed
childConfigurationBuilder.
-
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:
-