Class DefaultAxonApplication

java.lang.Object
org.axonframework.common.configuration.DefaultAxonApplication
All Implemented Interfaces:
ApplicationConfigurer, LifecycleRegistry

public class DefaultAxonApplication extends Object implements ApplicationConfigurer, LifecycleRegistry
Default implementation of the AxonApplication.
Since:
5.0.0
Author:
Allard Buijze, Steven van Beelen
  • Constructor Details

    • DefaultAxonApplication

      public DefaultAxonApplication()
      Creates a default axon application.
  • Method Details

    • onStart

      public DefaultAxonApplication 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 DefaultAxonApplication 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:
    • registerLifecyclePhaseTimeout

      public DefaultAxonApplication 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:
    • build

      public AxonConfiguration build()
      Description copied from interface: ApplicationConfigurer
      Returns the completely initialized Configuration instance of type C built using this Configurer implementation.

      It is not recommended to change any configuration on this ApplicationConfigurer once this method is called.

      Specified by:
      build in interface ApplicationConfigurer
      Returns:
      The fully initialized Configuration instance of type C.
    • componentRegistry

      public ApplicationConfigurer componentRegistry(@Nonnull Consumer<ComponentRegistry> componentRegistrar)
      Description copied from interface: ApplicationConfigurer
      Executes the given componentRegistrar on the component registry associated with this ApplicationConfigurer.
      Specified by:
      componentRegistry in interface ApplicationConfigurer
      Parameters:
      componentRegistrar - The actions to take on the component registry.
      Returns:
      This ApplicationConfigurer for a fluent API.
    • lifecycleRegistry

      public ApplicationConfigurer lifecycleRegistry(@Nonnull Consumer<LifecycleRegistry> lifecycleRegistrar)
      Description copied from interface: ApplicationConfigurer
      Executes the given lifecycleRegistrar on the lifecycle registry associated with this ApplicationConfigurer.
      Specified by:
      lifecycleRegistry in interface ApplicationConfigurer
      Parameters:
      lifecycleRegistrar - The actions to take on the lifecycle registry.
      Returns:
      This ApplicationConfigurer for a fluent API.