Executor
, ExecutorService
public class ManagedExecutorService extends Object implements ExecutorService
ExecutorService
instances originating from an application
server are wrapped with this ManagedExecutorService
.
The ManagedExecutorService
wraps an ExecutorService
and
prevents execution of the ExecutorService.shutdown()
and
ExecutorService.shutdownNow()
methods (them methods are not delegated
and therewith disabled).
This is helpful when you either expect an ExecutorService
passed by
an application server or, if none is passed, you retrieve a private
ExecutorService
yourself:
In the second case, you might want to shutdown your ExecutorService
after usage, in the first case you do not want to do so as the application
server is to take care on shutdown. You then do not wrap your private
ExecutorService
; you do wrap any ExecutorService
being passed
to you (by an application server).
Wrapping the ExecutorService
being passed from the application server
and not wrapping the one you create yourself will enable you to shutdown the
ExecutorService
in any case; in case it is your private one, it will
be shutdown; in case it is the one from the application server, the shutdown
calls are just ignored.
Constructor | Description |
---|---|
ManagedExecutorService(ExecutorService eExecutorService) |
Instantiates a new managed executor service.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
awaitTermination(long aTimeout,
TimeUnit aUnit) |
|
void |
execute(Runnable aArg0) |
|
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> aTasks) |
|
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> aTasks,
long aTimeout,
TimeUnit aUnit) |
|
<T> T |
invokeAny(Collection<? extends Callable<T>> aTasks) |
|
<T> T |
invokeAny(Collection<? extends Callable<T>> aTasks,
long aTimeout,
TimeUnit aUnit) |
|
boolean |
isShutdown() |
|
boolean |
isTerminated() |
|
void |
shutdown() |
|
List<Runnable> |
shutdownNow() |
|
Future<?> |
submit(Runnable aTask) |
|
<T> Future<T> |
submit(Runnable aTask,
T aResult) |
|
<T> Future<T> |
submit(Callable<T> aTask) |
public ManagedExecutorService(ExecutorService eExecutorService)
eExecutorService
- the e executor servicepublic boolean awaitTermination(long aTimeout, TimeUnit aUnit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> aTasks, long aTimeout, TimeUnit aUnit) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> aTasks) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> T invokeAny(Collection<? extends Callable<T>> aTasks, long aTimeout, TimeUnit aUnit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
TimeoutException
public <T> T invokeAny(Collection<? extends Callable<T>> aTasks) throws InterruptedException, ExecutionException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
public boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public void shutdown()
shutdown
in interface ExecutorService
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
public <T> Future<T> submit(Callable<T> aTask)
submit
in interface ExecutorService
public <T> Future<T> submit(Runnable aTask, T aResult)
submit
in interface ExecutorService
public Future<?> submit(Runnable aTask)
submit
in interface ExecutorService
Copyright © 2018. All rights reserved.