Interface CommandHandlerRegistry<S extends CommandHandlerRegistry<S>>

Type Parameters:
S - The type of the registry itself, used for fluent interfacing.
All Known Subinterfaces:
CommandBus
All Known Implementing Classes:
DistributedCommandBus, InterceptingCommandBus, RecordingCommandBus, RecordingCommandBus, RetryingCommandBus, SimpleCommandBus, SimpleCommandHandlingComponent, TracingCommandBus

public interface CommandHandlerRegistry<S extends CommandHandlerRegistry<S>>
Interface describing a registry of command handlers.
Since:
5.0.0
Author:
Allard Buijze, Gerard Klijs, Milan Savic, Mitchell Herrijgers, Sara Pellegrini, Steven van Beelen
  • Method Details

    • subscribe

      S subscribe(@Nonnull QualifiedName name, @Nonnull CommandHandler commandHandler)
      Subscribe the given handler for commands of the given name.

      If a subscription already exists for the name, the behavior is undefined. Implementations may throw an exception to refuse duplicate subscription or alternatively decide whether the existing or new handler gets the subscription.

      Parameters:
      name - The name the given commandHandler can handle.
      commandHandler - The handler instance that handles commands for the given name.
      Returns:
      This registry for fluent interfacing.
    • subscribe

      default S subscribe(@Nonnull Set<QualifiedName> names, @Nonnull CommandHandler commandHandler)
      Subscribe the given handler for commands of the given names.

      If a subscription already exists for any name in the given set, the behavior is undefined. Implementations may throw an exception to refuse duplicate subscription or alternatively decide whether the existing or new handler gets the subscription.

      Parameters:
      names - The names of the given commandHandler can handle.
      commandHandler - The handler instance that handles commands for the given names.
      Returns:
      This registry for fluent interfacing.
    • subscribe

      default S subscribe(@Nonnull CommandHandlingComponent handlingComponent)
      Subscribe the given handlingComponent with this registry.

      Typically invokes subscribe(Set, CommandHandler), using the CommandHandlingComponent.supportedCommands() as the set of compatible names the component in question can deal with.

      If a subscription already exists for any name in the supported command names, the behavior is undefined. Implementations may throw an exception to refuse duplicate subscription or alternatively decide whether the existing or new handler gets the subscription.

      Parameters:
      handlingComponent - The command handling component instance to subscribe with this registry.
      Returns:
      This registry for fluent interfacing.