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 void
execute(Runnable task)
void
execute(Runnable task, long startTimeout)
int
getActiveCount()
For testing purposes.ExecutorStatisticsView
getExecutorStatistics()
Return the view on the statistics.boolean
hasDelegate(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor executor)
For testing purposes.boolean
prefersShortLivedTasks()
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
SharedTaskContextHolder
before delegating execution.
-
execute
public void execute(@NonNull Runnable task, long startTimeout)
Configures a
SharedTaskContextHolder
before delegating execution.- Specified by:
execute
in interfaceorg.springframework.core.task.AsyncTaskExecutor
-
submit
public Future<?> submit(@NonNull Runnable task)
Configures a
SharedTaskContextHolder
before delegating execution.- Specified by:
submit
in interfaceorg.springframework.core.task.AsyncTaskExecutor
-
submit
public <T> Future<T> submit(@NonNull Callable<T> task)
Configures a
SharedTaskContextHolder
before delegating execution.- Specified by:
submit
in interfaceorg.springframework.core.task.AsyncTaskExecutor
-
submitListenable
public org.springframework.util.concurrent.ListenableFuture<?> submitListenable(Runnable task)
Configures a
SharedTaskContextHolder
before delegating execution.- Specified by:
submitListenable
in interfaceorg.springframework.core.task.AsyncListenableTaskExecutor
-
submitListenable
public <T> org.springframework.util.concurrent.ListenableFuture<T> submitListenable(Callable<T> task)
Configures a
SharedTaskContextHolder
before delegating execution.- Specified by:
submitListenable
in 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:
prefersShortLivedTasks
in interfaceorg.springframework.scheduling.SchedulingTaskExecutor
-
-