Package org.somda.sdc.common.util
Class ExecutorWrapperService
-
- All Implemented Interfaces:
-
com.google.common.util.concurrent.Service
public class ExecutorWrapperService<T extends ExecutorService> extends AbstractIdleServiceWraps an ExecutorService into a guava AbstractIdleService.
Wrapping ExecutorServices into guava services allows orchestrating thread pool instances, especially shutting them down properly when shutting down a parent service instance.
-
-
Constructor Summary
Constructors Constructor Description ExecutorWrapperService(Callable<T> serviceCreator, String serviceName, String frameworkIdentifier)Creates a wrapper around an ExecutorService.
-
Method Summary
Modifier and Type Method Description Tget()Gets the ExecutorService instance when service is running. StringtoString()-
Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ExecutorWrapperService
ExecutorWrapperService(Callable<T> serviceCreator, String serviceName, String frameworkIdentifier)
Creates a wrapper around an ExecutorService.- Parameters:
serviceCreator- Callable which returns an ExecutorService.serviceName- name for the service, used in logging.frameworkIdentifier- identifier used for logging
-
-
Method Detail
-
get
T get()
Gets the ExecutorService instance when service is running.
Only ever access this once the service has been started!
- Returns:
wrapped ExecutorService instance.
-
-
-
-