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 Summary
Modifier and TypeMethodDescriptioncreateForThreadPool(ExecutorService executorService) Creates a newCommandServiceusing the specified thread pool.Returns the defaultCommandServicefor asynchronously executingpersist tasks.perform(Mode<E> mode, PersistTask<A, T> task, A a) Performs the given task immediately using the thread of the caller.
-
Method Details
-
perform
<A,T, Optional<T> performE extends Exception> (Mode<E> mode, PersistTask<A, T> task, @Nullable A a) throws EPerforms 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 taskE- the expected exception- Parameters:
mode- the mode controls the executiontask- the task to execute- Throws:
E
-
getCommandService
CommandService getCommandService()Returns the defaultCommandServicefor asynchronously executingpersist 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 usingcreateForThreadPool(ExecutorService). -
createForThreadPool
Creates a newCommandServiceusing the specified thread pool. The returned service is thread safe and can be used as a singleton like any other service.
-