|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.commandhandling.callbacks.FutureCallback<R>
R
- the type of result of the command handlingpublic class FutureCallback<R>
Command Handler Callback that allows the dispatching thread to wait for the result of the callback, using the Future mechanism. This callback allows the caller to synchronize calls when an asynchronous command bus is being used.
Constructor Summary | |
---|---|
FutureCallback()
|
Method Summary | |
---|---|
boolean |
awaitCompletion(long timeout,
TimeUnit unit)
Wait for completion of the command, or for the timeout to expire. |
boolean |
cancel(boolean mayInterruptIfRunning)
Always returns false , since command execution cannot be cancelled. |
R |
get()
Waits if necessary for the command handling to complete, and then returns its result. |
R |
get(long timeout,
TimeUnit unit)
Waits if necessary for at most the given time for the command handling to complete, and then retrieves its result, if available. |
R |
getResult()
Waits if necessary for the command handling to complete, and then returns its result. |
R |
getResult(long timeout,
TimeUnit unit)
Waits if necessary for at most the given time for the command handling to complete, and then retrieves its result, if available. |
boolean |
isCancelled()
Always returns false, since command execution cannot be cancelled. |
boolean |
isDone()
Indicates whether command handler execution has finished. |
void |
onFailure(Throwable cause)
Invoked when command handling execution resulted in an error. |
void |
onSuccess(R executionResult)
Invoked when command handling execution was successful. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FutureCallback()
Method Detail |
---|
public void onSuccess(R executionResult)
CommandCallback
onSuccess
in interface CommandCallback<R>
executionResult
- The result of the command handling execution, if any.public void onFailure(Throwable cause)
CommandCallback
onFailure
in interface CommandCallback<R>
cause
- The exception raised during command handlingpublic R get() throws InterruptedException, ExecutionException
get
in interface Future<R>
InterruptedException
- if the current thread is interrupted while waiting
ExecutionException
- if the command handler threw an exceptionpublic R get(long timeout, TimeUnit unit) throws TimeoutException, InterruptedException, ExecutionException
get
in interface Future<R>
timeout
- the maximum time to waitunit
- the time unit of the timeout argument
InterruptedException
- if the current thread is interrupted while waiting
TimeoutException
- if the wait timed out
ExecutionException
- if the command handler threw an exceptiongetResult(long, java.util.concurrent.TimeUnit)
public R getResult()
get(long, java.util.concurrent.TimeUnit)
, this method will throw the original exception. Only
checked exceptions are wrapped in a CommandExecutionException
.
If the thread is interrupted while waiting, the interrupt flag is set back on the thread, and null
is returned. To distinguish between an interrupt and a null
result, use the isDone()
method.
get()
public R getResult(long timeout, TimeUnit unit)
get(long, java.util.concurrent.TimeUnit)
, this method will throw the original exception. Only
checked exceptions are wrapped in a CommandExecutionException
.
If the timeout expired or the thread is interrupted before completion, null
is returned. In case of
an interrupt, the interrupt flag will have been set back on the thread. To distinguish between an interrupt and
a
null
result, use the isDone()
timeout
- the maximum time to waitunit
- the time unit of the timeout argument
public boolean awaitCompletion(long timeout, TimeUnit unit)
timeout
- The amount of time to wait for command processing to completeunit
- The unit in which the timeout is expressed
true
if command processing completed before the timeout expired, otherwise
false
.public boolean cancel(boolean mayInterruptIfRunning)
false
, since command execution cannot be cancelled.
cancel
in interface Future<R>
mayInterruptIfRunning
- true if the thread executing the command should be interrupted; otherwise,
in-progress tasks are allowed to complete
false
public boolean isCancelled()
isCancelled
in interface Future<R>
public boolean isDone()
isDone
in interface Future<R>
true
if command handler execution has finished, otherwise false
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |