public final class Services
extends java.lang.Object
| Constructor and Description |
|---|
Services() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isTerminating(Service.State state)
Determines whether the given Service.State indicates the Service is either in the process of Stopping or already
Terminated or Failed.
|
static void |
onStop(Service service,
java.lang.Runnable terminatedCallback,
java.util.function.Consumer<java.lang.Throwable> failureCallback,
java.util.concurrent.Executor executor)
Attaches the given callbacks which will be invoked when the given Service enters a TERMINATED or FAILED state.
|
static java.util.concurrent.CompletableFuture<java.lang.Void> |
startAsync(Service service,
java.util.concurrent.Executor executor)
Asynchronously starts a Service and returns a CompletableFuture that will indicate when it is running.
|
static java.util.concurrent.CompletableFuture<java.lang.Void> |
stopAsync(Service service,
java.util.concurrent.Executor executor)
Asynchronously stops a Service and returns a CompletableFuture that will indicate when it is stopped.
|
public static java.util.concurrent.CompletableFuture<java.lang.Void> startAsync(Service service,
java.util.concurrent.Executor executor)
service - The Service to start.executor - An Executor to use for callback invocations.public static java.util.concurrent.CompletableFuture<java.lang.Void> stopAsync(Service service,
java.util.concurrent.Executor executor)
service - The Service to stop.executor - An Executor to use for callback invocations.public static void onStop(Service service,
java.lang.Runnable terminatedCallback,
java.util.function.Consumer<java.lang.Throwable> failureCallback,
java.util.concurrent.Executor executor)
service - The Service to attach to.terminatedCallback - (Optional) A Runnable that will be invoked if the Service enters a TERMINATED state.failureCallback - (Optional) A Runnable that will be invoked if the Service enters a FAILED state.executor - An Executor to use for callback invocations.public static boolean isTerminating(Service.State state)
state - The Service.State to test.