T - the type of value that the operation will produce.public interface Command<T> extends Callable<T>
synchronously. Prior to performing the operation, timeouts may
be set to control how long the operation is allowed to run without producing output or processing input (the
its idle timeout or to provide an absolute limit how long the operation is allowed to
run (the execution timeout.
When the operation completes, it will return an object of type T. If T is Void, the operation
will return null on completion. Typically this means the operation uses some form of callback, allowing the
caller to process the results as they are produced rather than returning them on completion.
| Modifier and Type | Method and Description |
|---|---|
AsyncCommand<T> |
asynchronous()
Transforms this
Command into an AsyncCommand which may be called asynchronously. |
T |
call()
Executes a command
|
default void |
setExecutionTimeout(Duration timeout)
Sets the maximum duration the operation is allowed to run.
|
void |
setExecutionTimeout(long timeoutInSecs)
Sets the maximum time, in seconds, the operation is allowed to run.
|
default void |
setIdleTimeout(Duration timeout)
Sets the maximum duration the operation is allowed to run without either producing output or
processing input.
|
void |
setIdleTimeout(long timeoutInSecs)
Sets the maximum time, in seconds, the operation is allowed to run without either producing output or
processing input.
|
default void |
setTimeout(Duration timeout)
|
default void |
setTimeout(long timeoutInSecs)
|
@Nonnull AsyncCommand<T> asynchronous()
Command into an AsyncCommand which may be called asynchronously. Any timeouts
applied this command will not be applied to the resulting AsyncCommand.
Once an Command has been transformed for asynchronous use, it may no longer be used
synchronously.
AsyncCommand for executing this Command asynchronouslyUnsupportedOperationException - if the implementation cannot internally convert the operation for
asynchronous execution@Nullable T call()
call in interface Callable<T>CommandCanceledException - if command execution is canceledServiceException - if an error occurs while performing the operationvoid setExecutionTimeout(long timeoutInSecs)
timeoutInSecs - the maximum time the operation is allowed to run, in secondsUnsupportedOperationException - if the implementation does not support configuring an execution timeoutdefault void setExecutionTimeout(@Nonnull Duration timeout)
timeout - the maximum duration the operation is allowed to runUnsupportedOperationException - if the implementation does not support configuring an execution timeoutvoid setIdleTimeout(long timeoutInSecs)
timeoutInSecs - the maximum time the operation is allowed to be idle, in secondsUnsupportedOperationException - if the implementation does not support configuring an idle timeoutdefault void setIdleTimeout(@Nonnull Duration timeout)
timeout - the maximum duration the operation is allowed to be idleUnsupportedOperationException - if the implementation does not support configuring an idle timeoutdefault void setTimeout(long timeoutInSecs)
idle and execution timeouts, in
seconds, for the operation. This is useful for commands that do their processing up-front and may not produce
any output until processing is complete. Setting the idle timeout to the same value as the execution timeout
effectively disables the idle timeout.timeoutInSecs - the maximum time the operation is allowed to run or be idle, in secondsdefault void setTimeout(@Nonnull Duration timeout)
idle and execution timeouts
to the specified duration. This is useful for commands that do their processing up-front and may not produce
any output until processing is complete. Setting the idle timeout to the same value as the execution timeout
effectively disables the idle timeout.timeout - the maximum duration the operation is allowed to run or be idleCopyright © 2019 Atlassian. All rights reserved.