Interface CommandExecutor
- All Known Implementing Classes:
CommandExecutorImpl
public interface CommandExecutor
Service for executing/submitting
PersistTask
s.
The Mode
class provides means to control the execution. It will for example control how
to handle PersistException
s by either propagating them or wrapping
them into a specified exception.
-
Method Summary
Modifier and TypeMethodDescriptioncreateForThreadPool
(ExecutorService executorService) Creates a newCommandService
using the specified thread pool.Returns the defaultCommandService
for asynchronously executingpersist tasks
.perform
(Mode<E> mode, PersistTask<A, T> task, A a) Performs the given task immediately using the thread of the caller.performInterruptible
(Mode<E> mode, PersistTask<A, T> task, A arg) Deprecated.performUninterruptly
(Mode<E> mode, PersistTask<A, T> task, A arg) Deprecated.useperform(Mode, PersistTask, Object)
instead
-
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
-
performUninterruptly
@Deprecated <A,T, Optional<T> performUninterruptlyE extends Exception> (Mode<E> mode, PersistTask<A, T> task, @Nullable A arg) throws EDeprecated.useperform(Mode, PersistTask, Object)
insteadLikeperform(Mode, PersistTask, Object)
but retries on interrupt until the task is completed. It re-interrupts the thread if necessary.- Throws:
E
-
performInterruptible
@Deprecated <A,T, Optional<T> performInterruptibleE extends Exception> (Mode<E> mode, PersistTask<A, T> task, @Nullable A arg) throws EDeprecated.useperform(Mode, PersistTask, Object)
insteadLikeperform(Mode, PersistTask, Object)
but will stop on interrupt and wrap theInterruptedException
into the exception specified by the givenmode
.- Throws:
E
-
getCommandService
CommandService getCommandService()Returns the defaultCommandService
for 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 newCommandService
using the specified thread pool. The returned service is thread safe and can be used as a singleton like any other service.
-
perform(Mode, PersistTask, Object)
instead