Class HierarchicalConfiguration

java.lang.Object
org.axonframework.common.configuration.HierarchicalConfiguration
All Implemented Interfaces:
LifecycleRegistry

public class HierarchicalConfiguration extends Object implements 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 Details

    • build

      public static Configuration build(LifecycleRegistry parentLifecycleRegistry, Function<LifecycleRegistry,Configuration> childConfigurationBuilder)
      Builds a Configuration based on the passed childConfigurationBuilder. This builder will receive a LifecycleRegistry that is a child of the passed parentLifecycleRegistry. The builder is created with a new LifecycleRegistry that 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 parent LifecycleRegistry to build the child configuration from.
      childConfigurationBuilder - The builder that will be used to create the child configuration. It will receive a LifecycleRegistry that is a child of the parentLifecycleRegistry.
      Returns:
      The child configuration that was built using the passed childConfigurationBuilder.
    • registerLifecyclePhaseTimeout

      public LifecycleRegistry registerLifecyclePhaseTimeout(long timeout, @Nonnull TimeUnit timeUnit)
      Description copied from interface: LifecycleRegistry
      Configures the timeout of each lifecycle phase. The LifecycleRegistry invokes lifecycle phases during start-up and shutdown of an application.

      Note that if a lifecycle phase exceeds the configured timeout and timeUnit combination, the LifecycleRegistry will 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:
      registerLifecyclePhaseTimeout in interface LifecycleRegistry
      Parameters:
      timeout - The amount of time to wait for lifecycle phase completion.
      timeUnit - The unit in which the timeout is expressed.
      Returns:
      The current instance of the LifecycleRegistry, for chaining purposes.
      See Also:
    • onStart

      public LifecycleRegistry onStart(int phase, @Nonnull LifecycleHandler startHandler)
      Description copied from interface: LifecycleRegistry
      Registers an asynchronous startHandler to be executed in the given phase when the configuration this registry belongs to is started.

      Handlers cannot be registered when the configuration has already been created from this registry.

      Specified by:
      onStart in interface LifecycleRegistry
      Parameters:
      phase - Defines a phase in which the start handler will be invoked during AxonConfiguration.start(). When starting the configuration the given handlers are started in ascending order based on their phase.
      startHandler - The handler to be executed asynchronously when the AxonConfiguration is started.
      Returns:
      The current instance of the LifecycleRegistry for a fluent API.
      See Also:
    • onShutdown

      public LifecycleRegistry onShutdown(int phase, @Nonnull LifecycleHandler shutdownHandler)
      Description copied from interface: LifecycleRegistry
      Registers an asynchronous shutdownHandler to be executed in the given phase when 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:
      onShutdown in interface LifecycleRegistry
      Parameters:
      phase - Defines a phase in which the shutdown handler will be invoked during AxonConfiguration.shutdown(). When shutting down the configuration the given handlers are executing in descending order based on their phase.
      shutdownHandler - The handler to be executed asynchronously when the AxonConfiguration is shut down.
      Returns:
      The current instance of the LifecycleRegistry for a fluent API.
      See Also: