Interface CommandExecutor

All Known Implementing Classes:
CommandExecutorImpl

public interface CommandExecutor
Service for executing/submitting PersistTasks.

The Mode class provides means to control the execution. It will for example control how to handle PersistExceptions by either propagating them or wrapping them into a specified exception.

  • Method Details

    • perform

      <A, T, E extends Exception> Optional<T> perform(Mode<E> mode, PersistTask<A,T> task, @Nullable A a) throws E
      Performs the given task immediately using the thread of the caller. The supplied mode controls the execution of the task.
      Type Parameters:
      T - type of the result of the task
      E - the expected exception
      Parameters:
      mode - the mode controls the execution
      task - the task to execute
      Throws:
      E
    • getCommandService

      CommandService getCommandService()
      Returns the default CommandService for asynchronously executing persist tasks.

      Note, the configuration of the thread pool of the service is left to the implementation. It can be assumed that there are more than one thread executing the persist tasks. Thus, if ordering is important, you would need to create a single-threaded command service using createForThreadPool(ExecutorService).

    • createForThreadPool

      CommandService createForThreadPool(ExecutorService executorService)
      Creates a new CommandService using the specified thread pool. The returned service is thread safe and can be used as a singleton like any other service.