Interface CommandHandlingModule

All Superinterfaces:
Module, ModuleBuilder<CommandHandlingModule>

public interface CommandHandlingModule extends Module, ModuleBuilder<CommandHandlingModule>
A Module and ModuleBuilder implementation providing operation to construct a command handling application module.

The CommandHandlingModule follows a builder paradigm, wherein several CommmandHandlers can be registered in any order.

To register command handlers, a similar registration phase switch should be made, by invoking CommandHandlingModule.SetupPhase.commandHandlers().

Here's an example of how to register two command handler lambdas:

 CommandHandlingModule.named("my-module")
                              .commandHandlers()
                              .commandHandler(new QualifiedName(RenameCourseCommand.class),
                                              (cmd, context) -> { ...command handling logic... })
                              .commandHandler(new QualifiedName(ChangeCourseClassRoomCommand.class),
                                              (cmd, context) -> { ...command handling logic... });
 

Note that users do not have to invoke ModuleBuilder.build() themselves when using this interface, as the ApplicationConfigurer takes care of that.

Since:
5.0.0
Author:
Allard Buijze, Mateusz Nowak, Mitchell Herrijgers, Steven van Beelen
  • Method Details

    • named

      static CommandHandlingModule.SetupPhase named(@Nonnull String moduleName)
      Starts a CommandHandlingModule module with the given moduleName.
      Parameters:
      moduleName - The name of the CommandHandlingModule under construction.
      Returns:
      The setup phase of this module, for a fluent API.