- All Implemented Interfaces:
Executor
,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 Summary
ConstructorDescriptionManagedExecutorService
(ExecutorService eExecutorService) Instantiates a new managed executor service. -
Method Summary
Modifier and TypeMethodDescriptionboolean
awaitTermination
(long aTimeout, TimeUnit aUnit) void
invokeAll
(Collection<? extends Callable<T>> aTasks) 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
boolean
void
shutdown()
Future<?>
<T> Future<T>
<T> Future<T>
-
Constructor Details
-
ManagedExecutorService
Instantiates a new managed executor service.- Parameters:
eExecutorService
- the e executor service
-
-
Method Details
-
awaitTermination
- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-
execute
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> aTasks, long aTimeout, TimeUnit aUnit) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> aTasks) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> aTasks, long aTimeout, TimeUnit aUnit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> aTasks) throws InterruptedException, ExecutionException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminated
in interfaceExecutorService
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNow
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-