java.lang.Object
dk.cloudcreate.essentials.reactive.command.AbstractCommandBus
All Implemented Interfaces:
CommandBus
Direct Known Subclasses:
LocalCommandBus

public abstract class AbstractCommandBus extends Object implements CommandBus
Base implementation of the CommandBus - provides default implementation for all operations except for CommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration)
  • Field Details

  • Constructor Details

  • Method Details

    • getInterceptors

      public List<CommandBusInterceptor> getInterceptors()
      Description copied from interface: CommandBus
      Returns an immutable list of interceptors
      Specified by:
      getInterceptors in interface CommandBus
      Returns:
      Returns an immutable list of interceptors
    • addInterceptor

      public CommandBus addInterceptor(CommandBusInterceptor interceptor)
      Description copied from interface: CommandBus
      Add a new interceptor
      Specified by:
      addInterceptor in interface CommandBus
      Parameters:
      interceptor - the interceptor to add
      Returns:
      this bus instance
    • hasInterceptor

      public boolean hasInterceptor(CommandBusInterceptor interceptor)
      Description copied from interface: CommandBus
      Guard method to test if the CommandBus already contains the interceptor
      Specified by:
      hasInterceptor in interface CommandBus
      Parameters:
      interceptor - the interceptor to check
      Returns:
      true if the CommandBus already contains the interceptor, otherwise false
    • removeInterceptor

      public CommandBus removeInterceptor(CommandBusInterceptor interceptor)
      Description copied from interface: CommandBus
      Remove an interceptor
      Specified by:
      removeInterceptor in interface CommandBus
      Parameters:
      interceptor - the interceptor to remove
      Returns:
      this bus instance
    • addCommandHandler

      public CommandBus addCommandHandler(CommandHandler commandHandler)
      Description copied from interface: CommandBus
      Add a new command handler.
      Specified by:
      addCommandHandler in interface CommandBus
      Parameters:
      commandHandler - the command handler to add
      Returns:
      this bus instance
    • removeCommandHandler

      public CommandBus removeCommandHandler(CommandHandler commandHandler)
      Description copied from interface: CommandBus
      Remove a command handler.
      Specified by:
      removeCommandHandler in interface CommandBus
      Parameters:
      commandHandler - the command handler to remove
      Returns:
      this bus instance
    • send

      public <R, C> R send(C command)
      Description copied from interface: CommandBus
      The send command synchronously and process the command on the sending thread
      Specified by:
      send in interface CommandBus
      Type Parameters:
      R - the return type
      C - the command type
      Parameters:
      command - the command to send
      Returns:
      the result of the command processing (if any)
    • sendAsync

      public <R, C> reactor.core.publisher.Mono<R> sendAsync(C command)
      Description copied from interface: CommandBus
      The send command asynchronously and process the command on a Schedulers.boundedElastic() thread
      Specified by:
      sendAsync in interface CommandBus
      Type Parameters:
      R - the return type
      C - the command type
      Parameters:
      command - the command to send
      Returns:
      a Mono that will contain the result of the command processing (if any)
    • findCommandHandlerCapableOfHandling

      public CommandHandler findCommandHandlerCapableOfHandling(Object command)
      Description copied from interface: CommandBus
      Find a CommandHandler capable of handling the given command
      Specified by:
      findCommandHandlerCapableOfHandling in interface CommandBus
      Parameters:
      command - the command to handle
      Returns:
      the single CommandHandler that's capable of handling the given command
    • hasCommandHandler

      public boolean hasCommandHandler(CommandHandler commandHandler)
      Description copied from interface: CommandBus
      Guard method to test if the CommandBus already contains the commandHandler
      Specified by:
      hasCommandHandler in interface CommandBus
      Parameters:
      commandHandler - the commandHandler to check
      Returns:
      true if the CommandBus already contains the commandHandler, otherwise false
    • toString

      public String toString()
      Overrides:
      toString in class Object