Package org.hawaiiframework.async
Class DelegatingExecutor
- java.lang.Object
-
- org.hawaiiframework.async.DelegatingExecutor
-
- All Implemented Interfaces:
Executor,org.springframework.core.task.AsyncListenableTaskExecutor,org.springframework.core.task.AsyncTaskExecutor,org.springframework.core.task.TaskExecutor,org.springframework.scheduling.SchedulingTaskExecutor
public class DelegatingExecutor extends Object implements org.springframework.core.task.AsyncListenableTaskExecutor, 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
- Author:
- Rutger Lubbers, Paul Klos
-
-
Constructor Summary
Constructors Constructor Description DelegatingExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor delegate, ExecutorConfigurationProperties executorConfigurationProperties, String taskName)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute(Runnable task)voidexecute(Runnable task, long startTimeout)intgetActiveCount()For testing purposes.ExecutorStatisticsViewgetExecutorStatistics()Return the view on the statistics.booleanhasDelegate(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor executor)For testing purposes.booleanprefersShortLivedTasks()Future<?>submit(Runnable task)<T> Future<T>submit(Callable<T> task)org.springframework.util.concurrent.ListenableFuture<?>submitListenable(Runnable task)<T> org.springframework.util.concurrent.ListenableFuture<T>submitListenable(Callable<T> task)
-
-
-
Constructor Detail
-
DelegatingExecutor
public DelegatingExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor delegate, ExecutorConfigurationProperties executorConfigurationProperties, String taskName)Constructor.- Parameters:
delegate- the delegateexecutorConfigurationProperties- the configuration propertiestaskName- the task name
-
-
Method Detail
-
execute
public void execute(@NonNull Runnable task)Configures a
SharedTaskContextHolderbefore delegating execution.
-
execute
public void execute(@NonNull Runnable task, long startTimeout)Configures a
SharedTaskContextHolderbefore delegating execution.- Specified by:
executein interfaceorg.springframework.core.task.AsyncTaskExecutor
-
submit
public Future<?> submit(@NonNull Runnable task)
Configures a
SharedTaskContextHolderbefore delegating execution.- Specified by:
submitin interfaceorg.springframework.core.task.AsyncTaskExecutor
-
submit
public <T> Future<T> submit(@NonNull Callable<T> task)
Configures a
SharedTaskContextHolderbefore delegating execution.- Specified by:
submitin interfaceorg.springframework.core.task.AsyncTaskExecutor
-
submitListenable
public org.springframework.util.concurrent.ListenableFuture<?> submitListenable(Runnable task)
Configures a
SharedTaskContextHolderbefore delegating execution.- Specified by:
submitListenablein interfaceorg.springframework.core.task.AsyncListenableTaskExecutor
-
submitListenable
public <T> org.springframework.util.concurrent.ListenableFuture<T> submitListenable(Callable<T> task)
Configures a
SharedTaskContextHolderbefore delegating execution.- Specified by:
submitListenablein interfaceorg.springframework.core.task.AsyncListenableTaskExecutor
-
getExecutorStatistics
public ExecutorStatisticsView getExecutorStatistics()
Return the view on the statistics.
-
hasDelegate
public boolean hasDelegate(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor executor)
For testing purposes.
-
getActiveCount
public int getActiveCount()
For testing purposes.
-
prefersShortLivedTasks
public boolean prefersShortLivedTasks()
- Specified by:
prefersShortLivedTasksin interfaceorg.springframework.scheduling.SchedulingTaskExecutor
-
-