Interface CommandHandlingModule.CommandHandlerPhase

All Superinterfaces:
ModuleBuilder<CommandHandlingModule>
Enclosing interface:
CommandHandlingModule

public static interface CommandHandlingModule.CommandHandlerPhase extends ModuleBuilder<CommandHandlingModule>
The command handler configuration phase of the command handling module.

Every registered CommandHandler will be subscribed with the CommandBus of the ApplicationConfigurer this module is given to.

Provides roughly two options for configuring command handlers. Firstly, a command handler can be registered as is, through the commandHandler(QualifiedName, CommandHandler) method. Secondly, if the command handler provides components from the Configuration, a builder of the command handler can be registered through the commandHandler(QualifiedName, ComponentBuilder) method.

  • Method Details

    • commandHandler

      default CommandHandlingModule.CommandHandlerPhase commandHandler(@Nonnull QualifiedName commandName, @Nonnull CommandHandler commandHandler)
      Registers the given commandHandler for the given qualified commandName within this module.

      Use this command handler registration method when the command handler in question does not require entities or receives entities through another mechanism. Using a MessageTypeResolver to derive the commandName is beneficial to ensure consistent naming across handler subscriptions.

      Once this module is finalized, the command handler will be subscribed with the CommandBus of the ApplicationConfigurer the module is registered on.

      Parameters:
      commandName - The qualified name of the command the given commandHandler can handle.
      commandHandler - The command handler to register with this module.
      Returns:
      The command handler phase of this builder, for a fluent API.
    • commandHandler

      CommandHandlingModule.CommandHandlerPhase commandHandler(@Nonnull QualifiedName commandName, @Nonnull ComponentBuilder<CommandHandler> commandHandlerBuilder)
      Registers the given commandHandlerBuilder for the given qualified commandName within this module.

      Using a MessageTypeResolver to derive the commandName is beneficial to ensure consistent naming across handler subscriptions.

      Once this module is finalized, the command handler from the commandHandlerBuilder will be subscribed with the CommandBus of the ApplicationConfigurer the module is registered on.

      Parameters:
      commandName - The qualified name of the command the CommandHandler created by the given commandHandlerBuilder.
      commandHandlerBuilder - A builder of a CommandHandler. Provides the Configuration to retrieve components from to use during construction of the command handler.
      Returns:
      The command handler phase of this builder, for a fluent API.
    • commandHandlingComponent

      CommandHandlingModule.CommandHandlerPhase commandHandlingComponent(@Nonnull ComponentBuilder<CommandHandlingComponent> handlingComponentBuilder)
      Registers the given handlingComponentBuilder within this module.

      Use this command handler registration method when the command handling component in question does not require entities or receives entities through another mechanism.

      Once this module is finalized, the resulting CommandHandlingComponent from the handlingComponentBuilder will be subscribed with the CommandBus of the ApplicationConfigurer the module is registered on.

      Parameters:
      handlingComponentBuilder - A builder of a CommandHandlingComponent. Provides the Configuration to retrieve components from to use during construction of the command handling component.
      Returns:
      The command handler phase of this builder, for a fluent API.
    • annotatedCommandHandlingComponent

      default CommandHandlingModule.CommandHandlerPhase annotatedCommandHandlingComponent(@Nonnull ComponentBuilder<Object> handlingComponentBuilder)
      Registers the given handlingComponentBuilder as an AnnotatedCommandHandlingComponent within this module.

      This will scan the given handlingComponentBuilder for methods annotated with CommandHandler and register them as command handlers for the CommandBus of the ApplicationConfigurer.

      Parameters:
      handlingComponentBuilder - A builder of a CommandHandlingComponent. Provides the Configuration to retrieve components from to use during construction of the command handling component.
      Returns:
      The command handler phase of this builder, for a fluent API.