Class AbstractMultiCommandExecutor<CONTEXT,RESULT>

java.lang.Object
org.fuin.cqrs4j.AbstractMultiCommandExecutor<CONTEXT,RESULT>
Type Parameters:
CONTEXT - Type of context for the command execution.
RESULT - Result of the command execution.
All Implemented Interfaces:
CommandExecutor<CONTEXT,RESULT,Command>
Direct Known Subclasses:
MultiCommandExecutor

public abstract class AbstractMultiCommandExecutor<CONTEXT,RESULT> extends Object implements CommandExecutor<CONTEXT,RESULT,Command>
Handles multiple commands by delegating the call to other executors.
  • Constructor Details

    • AbstractMultiCommandExecutor

      public AbstractMultiCommandExecutor(@NotEmpty @NotEmpty CommandExecutor... cmdExecutors)
      Constructor with command handler array.
      Parameters:
      cmdExecutors - Array of command executors.
    • AbstractMultiCommandExecutor

      public AbstractMultiCommandExecutor(@NotEmpty @NotEmpty List<CommandExecutor> cmdExecutors)
      Constructor with mandatory data.
      Parameters:
      cmdExecutors - List of command executors.
  • Method Details

    • getCommandTypes

      public final Set<org.fuin.ddd4j.ddd.EventType> getCommandTypes()
      Description copied from interface: CommandExecutor
      Returns a list of commands this executor can handle.
      Specified by:
      getCommandTypes in interface CommandExecutor<CONTEXT,RESULT,Command>
      Returns:
      List of unique command types.
    • execute

      public final RESULT execute(CONTEXT ctx, Command cmd) throws org.fuin.ddd4j.ddd.AggregateVersionConflictException, org.fuin.ddd4j.ddd.AggregateNotFoundException, org.fuin.ddd4j.ddd.AggregateVersionNotFoundException, org.fuin.ddd4j.ddd.AggregateDeletedException, org.fuin.ddd4j.ddd.AggregateAlreadyExistsException, CommandExecutionFailedException
      Description copied from interface: CommandExecutor
      Executes the given command. Only the main aggregate related exceptions are modeled via throws. All other checked exceptions must be wrapped into a CommandExecutionFailedException.
      Specified by:
      execute in interface CommandExecutor<CONTEXT,RESULT,Command>
      Parameters:
      ctx - Context of the execute.
      cmd - Command to execute.
      Returns:
      Result.
      Throws:
      org.fuin.ddd4j.ddd.AggregateVersionConflictException - There is a conflict between an expected and an actual version for the aggregate targeted by the command.
      org.fuin.ddd4j.ddd.AggregateNotFoundException - The aggregate targeted by the command with a given type and identifier was not found in the repository.
      org.fuin.ddd4j.ddd.AggregateVersionNotFoundException - The requested version for the aggregate targeted by the command does not exist.
      org.fuin.ddd4j.ddd.AggregateDeletedException - The aggregate targeted by the command was deleted from the repository.
      org.fuin.ddd4j.ddd.AggregateAlreadyExistsException - The aggregate targeted by the command already exists when trying to create it.
      CommandExecutionFailedException - Other checked exceptions are wrapped into this one.