Class CommandExecutorImpl
java.lang.Object
ch.tocco.nice2.persist.core.impl.exec.CommandExecutorImpl
- All Implemented Interfaces:
CommandExecutor
-
Constructor Summary
ConstructorsConstructorDescriptionCommandExecutorImpl(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 newCommandServiceusing the specified thread pool.Returns the defaultCommandServicefor asynchronously executingpersist tasks.voidperform(Mode<E> mode, PersistTask<A, T> task, A arg) Performs the given task immediately using the thread of the caller.voidvoidsetDefaultThreadCount(int defaultThreadCount) voidsetListeners(List<CommandServiceListener> listeners) voidsetModes(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:CommandExecutorPerforms the given task immediately using the thread of the caller. The supplied mode controls the execution of the task.- Specified by:
performin 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
-
createForThreadPool
Description copied from interface:CommandExecutorCreates a newCommandServiceusing the specified thread pool. The returned service is thread safe and can be used as a singleton like any other service.- Specified by:
createForThreadPoolin interfaceCommandExecutor
-
getCommandService
Description copied from interface:CommandExecutorReturns 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 usingCommandExecutor.createForThreadPool(ExecutorService).- Specified by:
getCommandServicein interfaceCommandExecutor
-