org.springframework.core.task.support
Class ExecutorServiceAdapter
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- org.springframework.core.task.support.ExecutorServiceAdapter
-
- All Implemented Interfaces:
- Executor, ExecutorService
public class ExecutorServiceAdapter extends AbstractExecutorService
Adapter that takes a SpringTaskExecutor
) and exposes a fulljava.util.concurrent.ExecutorService
for it.This is primarily for adapting to client components that communicate via the
java.util.concurrent.ExecutorService
API. It can also be used as common ground between a local SpringTaskExecutor
backend and a JNDI-locatedManagedExecutorService
in a Java EE 6 environment.NOTE: This ExecutorService adapter does not support the lifecycle methods in the
java.util.concurrent.ExecutorService
API ("shutdown()" etc), similar to a server-wideManagedExecutorService
in a Java EE 6 environment. The lifecycle is always up to the backend pool, with this adapter acting as an access-only proxy for that target pool.- Since:
- 3.0
- Author:
- Juergen Hoeller
- See Also:
-
ExecutorService
-
Constructor Summary
Constructors Constructor and Description ExecutorServiceAdapter(TaskExecutor taskExecutor)
Create a new ExecutorServiceAdapter, using the given target executor.
Method Summary
Methods Modifier and Type Method and Description boolean
awaitTermination(long timeout, TimeUnit unit)
void
execute(Runnable task)
boolean
isShutdown()
boolean
isTerminated()
void
shutdown()
List<Runnable>
shutdownNow()
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Constructor Detail
ExecutorServiceAdapter
public ExecutorServiceAdapter(TaskExecutor taskExecutor)
Create a new ExecutorServiceAdapter, using the given target executor.- Parameters:
-
taskExecutor
- the target executor to delegate to
Method Detail
execute
public void execute(Runnable task)
shutdown
public void shutdown()
awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
- Throws:
-
InterruptedException
isShutdown
public boolean isShutdown()
isTerminated
public boolean isTerminated()