- 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
ConstructorsConstructorDescriptionManagedExecutorService(ExecutorService eExecutorService) Instantiates a new managed executor service. -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long aTimeout, TimeUnit aUnit) voidinvokeAll(Collection<? extends Callable<T>> aTasks) invokeAll(Collection<? extends Callable<T>> aTasks, long aTimeout, TimeUnit aUnit) <T> TinvokeAny(Collection<? extends Callable<T>> aTasks) <T> TinvokeAny(Collection<? extends Callable<T>> aTasks, long aTimeout, TimeUnit aUnit) booleanbooleanvoidshutdown()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:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
execute
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> aTasks, long aTimeout, TimeUnit aUnit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> aTasks) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> aTasks, long aTimeout, TimeUnit aUnit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> aTasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-