Package org.hawaiiframework.async
Class DelegatingExecutor
java.lang.Object
org.hawaiiframework.async.DelegatingExecutor
- All Implemented Interfaces:
Executor,org.springframework.core.task.AsyncTaskExecutor,org.springframework.core.task.TaskExecutor,org.springframework.scheduling.SchedulingTaskExecutor
public class DelegatingExecutor
extends Object
implements org.springframework.core.task.AsyncTaskExecutor, org.springframework.scheduling.SchedulingTaskExecutor
Task executor that delegates to the task executor configured for a task.
In addition to the delegate, the async configuration properties and the task name is stored, so we know which task this executor is for and we are able to determine the timeout.
- Since:
- 2.0.0
-
Field Summary
Fields inherited from interface org.springframework.core.task.AsyncTaskExecutor
TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor delegate, ExecutorConfigurationProperties executorConfigurationProperties, Collection<TaskListenerFactory> taskListenerFactories, String taskName) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidDeprecated.see super class for explanation.intFor testing purposes.Return the view on the statistics.booleanhasDelegate(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor executor) For testing purposes.booleanFuture<?><T> Future<T>Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.task.AsyncTaskExecutor
submitCompletable, submitCompletable
-
Constructor Details
-
DelegatingExecutor
public DelegatingExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor delegate, ExecutorConfigurationProperties executorConfigurationProperties, Collection<TaskListenerFactory> taskListenerFactories, String taskName) Constructor.- Parameters:
delegate- the delegateexecutorConfigurationProperties- the configuration propertiestaskListenerFactories- The task context providers.taskName- the task name
-
-
Method Details
-
execute
Configures a
SharedTaskContextHolderbefore delegating execution. -
execute
Deprecated.see super class for explanation. Configures aSharedTaskContextHolderbefore delegating execution.- Specified by:
executein interfaceorg.springframework.core.task.AsyncTaskExecutor
-
submit
Configures a
SharedTaskContextHolderbefore delegating execution.- Specified by:
submitin interfaceorg.springframework.core.task.AsyncTaskExecutor
-
submit
Configures a
SharedTaskContextHolderbefore delegating execution.- Specified by:
submitin interfaceorg.springframework.core.task.AsyncTaskExecutor- Type Parameters:
T- The return type of the task.- Parameters:
task- The task to submit to be executed.- Returns:
- A future for the task.
-
getExecutorStatistics
Return the view on the statistics.- Returns:
- A view on the executor's statistics.
-
hasDelegate
public boolean hasDelegate(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor executor) For testing purposes.- Parameters:
executor- The executor to check this delegate against.- Returns:
trueif this delegating executor has the givenexecutor.
-
getActiveCount
public int getActiveCount()For testing purposes. Return the number of currently active threads.- Returns:
- the number of threads
- See Also:
-
prefersShortLivedTasks
public boolean prefersShortLivedTasks()- Specified by:
prefersShortLivedTasksin interfaceorg.springframework.scheduling.SchedulingTaskExecutor
-