Class CommandExecutorImpl
java.lang.Object
ch.tocco.nice2.persist.core.impl.exec.CommandExecutorImpl
- All Implemented Interfaces:
CommandExecutor
-
Constructor Summary
ConstructorDescriptionCommandExecutorImpl
(org.slf4j.Logger log, Context currentContext, ContextManager contextManager, PersistenceService persistenceService, QueryBuilderFactory queryBuilderFactory, ThreadHandlerManager threadHandlerManager, L10N l10N) -
Method Summary
Modifier and TypeMethodDescriptioncreateForThreadPool
(ExecutorService executorService) Creates a newCommandService
using the specified thread pool.Returns the defaultCommandService
for asynchronously executingpersist tasks
.void
perform
(Mode<E> mode, PersistTask<A, T> task, A arg) 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.void
void
setDefaultThreadCount
(int defaultThreadCount) void
setListeners
(List<CommandServiceListener> listeners) void
setModes
(List<ModeWrapper> modes)
-
Constructor Details
-
CommandExecutorImpl
public CommandExecutorImpl(org.slf4j.Logger log, Context currentContext, ContextManager contextManager, @Lazy PersistenceService persistenceService, QueryBuilderFactory queryBuilderFactory, ThreadHandlerManager threadHandlerManager, L10N l10N)
-
-
Method Details
-
registryDidShutdown
@PreDestroy public void registryDidShutdown() -
setListeners
-
setDefaultThreadCount
@Value("${persist.tasks.commandservice.maxThreads}") public void setDefaultThreadCount(int defaultThreadCount) -
initializeService
@PostConstruct public void initializeService() -
setModes
-
perform
public <A,T, Optional<T> performE extends Exception> (Mode<E> mode, PersistTask<A, T> task, @Nullable A arg) throws EDescription 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 interfaceCommandExecutor
- 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 public <A,T, Optional<T> performUninterruptlyE extends Exception> (Mode<E> mode, PersistTask<A, T> task, @Nullable A arg) throws EDeprecated.Description copied from interface:CommandExecutor
LikeCommandExecutor.perform(Mode, PersistTask, Object)
but retries on interrupt until the task is completed. It re-interrupts the thread if necessary.- Specified by:
performUninterruptly
in interfaceCommandExecutor
- Throws:
E
-
performInterruptible
@Deprecated public <A,T, Optional<T> performInterruptibleE extends Exception> (Mode<E> mode, PersistTask<A, T> task, @Nullable A arg) throws EDeprecated.Description copied from interface:CommandExecutor
LikeCommandExecutor.perform(Mode, PersistTask, Object)
but will stop on interrupt and wrap theInterruptedException
into the exception specified by the givenmode
.- Specified by:
performInterruptible
in interfaceCommandExecutor
- Throws:
E
-
createForThreadPool
Description copied from interface:CommandExecutor
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.- Specified by:
createForThreadPool
in interfaceCommandExecutor
-
getCommandService
Description copied from interface:CommandExecutor
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 usingCommandExecutor.createForThreadPool(ExecutorService)
.- Specified by:
getCommandService
in interfaceCommandExecutor
-