Class CommandExecutorImpl

java.lang.Object
ch.tocco.nice2.persist.core.impl.exec.CommandExecutorImpl
All Implemented Interfaces:
CommandExecutor

@Component public class CommandExecutorImpl extends Object implements CommandExecutor
  • Constructor Details

  • Method Details

    • registryDidShutdown

      @PreDestroy public void registryDidShutdown()
    • setListeners

      @Autowired(required=false) public void setListeners(List<CommandServiceListener> listeners)
    • setDefaultThreadCount

      @Value("${persist.tasks.commandservice.maxThreads}") public void setDefaultThreadCount(int defaultThreadCount)
    • initializeService

      @PostConstruct public void initializeService()
    • setModes

      @Autowired public void setModes(List<ModeWrapper> modes)
    • perform

      public <A, T, E extends Exception> Optional<T> perform(Mode<E> mode, PersistTask<A,T> task, @Nullable A arg) throws E
      Description copied from interface: CommandExecutor
      Performs the given task immediately using the thread of the caller. The supplied mode controls the execution of the task.
      Specified by:
      perform in interface CommandExecutor
      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
    • createForThreadPool

      public CommandService createForThreadPool(ExecutorService executorService)
      Description copied from interface: CommandExecutor
      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.
      Specified by:
      createForThreadPool in interface CommandExecutor
    • getCommandService

      public CommandService getCommandService()
      Description copied from interface: CommandExecutor
      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 CommandExecutor.createForThreadPool(ExecutorService).

      Specified by:
      getCommandService in interface CommandExecutor