public final class ExecutionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static ExecutorService |
create(OrchestrationConfig.ExecutorConfig config,
Object... nameFormatArgs)
Create
ExecutorService. |
static Callable<Object> |
createCallable(Object impl,
Method method,
Object[] args)
Create
Callable. |
static <T> T |
invoke(Callable<T> callable,
int time,
TimeUnit timeUnit,
ExecutorService executor)
Invoke callable on
ExecutorService.RejectedExecutionException will be thrown if executor couldn't accept task for execution.TimeoutException will be thrown if maximum time to wait is reached.InterruptedException will be thrown if task execution is interrupted. |
static Object |
invoke(Object instance,
Method method,
Object[] args,
ExecutionInfo info)
Invoke on executor.
|
static <T> void |
invokeAsync(Callable<T> callable,
int time,
TimeUnit timeUnit,
ExecutorService executor)
Invoke callable on
ExecutorService in 'ASYNC' thread without blocking current thread.All exceptions would be logged with error log level. |
static String |
methodId(Object obj,
Method method)
Get unique
Method identifier. |
static String |
objectId(Object obj)
Get unique
Object identifier. |
static void |
shutdown(ExecutorService service,
boolean terminate,
boolean wait,
long timeout,
TimeUnit unit)
Shutdown
ExecutorService.ExecutorService.shutdownNow() will be used if:- terminate is false;- wait is true;- timeout is reached. |
static void |
shutdown(ExecutorService service,
boolean wait,
long timeout,
TimeUnit unit)
Shutdown
ExecutorService using ExecutorService.shutdown(). |
static void |
terminate(ExecutorService service)
Terminate
ExecutorService using ExecutorService.shutdownNow(). |
public static String objectId(Object obj)
Object identifier.obj - object instanceStringpublic static String methodId(Object obj, Method method)
Method identifier.obj - object instancemethod - object method instanceStringpublic static Callable<Object> createCallable(Object impl, Method method, Object[] args)
Callable.impl - implementationmethod - methodargs - method argumentsCallablepublic static Object invoke(Object instance, Method method, Object[] args, ExecutionInfo info) throws Exception
method - execution methodargs - method argumentsinfo - ExecutionInfoExceptionpublic static <T> void invokeAsync(Callable<T> callable, int time, TimeUnit timeUnit, ExecutorService executor)
ExecutorService in 'ASYNC' thread without blocking current thread.callable - Callabletime - maximum execution timetimeUnit - maximum execution time unitexecutor - ExecutorServicepublic static <T> T invoke(Callable<T> callable, int time, TimeUnit timeUnit, ExecutorService executor) throws Exception
ExecutorService.RejectedExecutionException will be thrown if executor couldn't accept task for execution.TimeoutException will be thrown if maximum time to wait is reached.InterruptedException will be thrown if task execution is interrupted.callable - Callabletime - maximum execution timetimeUnit - maximum execution time unitexecutor - ExecutorServiceExceptionpublic static ExecutorService create(OrchestrationConfig.ExecutorConfig config, Object... nameFormatArgs)
ExecutorService.config - OrchestrationConfig.ExecutorConfignameFormatArgs - thread name format argumentsExecutorServicepublic static void terminate(ExecutorService service)
ExecutorService using ExecutorService.shutdownNow().service - servicepublic static void shutdown(ExecutorService service, boolean wait, long timeout, TimeUnit unit)
ExecutorService using ExecutorService.shutdown().service - servicewait - is need to waittimeout - waiting timeoutunit - waiting timeout unitpublic static void shutdown(ExecutorService service, boolean terminate, boolean wait, long timeout, TimeUnit unit)
ExecutorService.ExecutorService.shutdownNow() will be used if:terminate is false;wait is true;timeout is reached.service - serviceterminate - ExecutorService.shutdownNow() will be used instead of ExecutorService.shutdown() and waiting will be skippedwait - is need to waittimeout - waiting timeoutunit - waiting timeout unitCopyright © 2013–2019 BB Corp. All rights reserved.