|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- The type returned by await()
and await(long, TimeUnit)
. Use Void
if there is no return value.public interface BlockingCommand<T>
Command that allows the calling thread to block until the command is completed.
Method Summary | |
---|---|
T |
await()
Waits indefinitely for the command to complete. |
T |
await(long timeout,
TimeUnit unit)
Waits for the specified amount of time for the command to complete |
void |
cancel()
Cancels the command causes await() or await(long, TimeUnit) to throw an MqttCommandCancelledException .This should only be
called by the same thread that calls execute() . |
void |
complete()
Called when the command is complete. |
void |
execute()
Executes the command. |
void |
setFailureCause(Throwable cause)
Sets the cause if the command fails. |
void |
setResult(T result)
Sets the result of this command. |
Method Detail |
---|
T await() throws MqttCommandCancelledException, MqttInterruptedException, MqttException, RuntimeException
MqttCommandCancelledException
- Thrown if the command was cancelled
MqttInterruptedException
- Thrown when the SynchronousMqttClient
implementation is used and the calling thread is interrupted
.
MqttException
- Any checked exception thrown by the command will be wrapped in an MqttException
RuntimeException
- Of course, any RuntimeException
may be thrownT await(long timeout, TimeUnit unit) throws MqttCommandCancelledException, MqttInterruptedException, MqttTimeoutException, MqttException, RuntimeException
timeout
- The maximum time to wait. If this is Long.MAX_VALUE
is used then the unit arg is ignored and this is the same as invoking
await()
.unit
- The time unit of the timeout argument
MqttCommandCancelledException
- Thrown if the command was cancelled
MqttInterruptedException
- Thrown when the SynchronousMqttClient
implementation is used and the calling thread is interrupted
.
MqttTimeoutException
- Thrown when the SynchronousMqttClient
implementation is used and this method has blocked for approximately the configured timeout.
MqttException
- Any checked exception thrown by the command will be wrapped in an MqttException
RuntimeException
- Of course, any RuntimeException
may be thrownvoid execute()
Executes the command. This is called by the thread responsible for processing the command, not the thread creating or waiting on the command. If an
exception occurs setFailureCause(Throwable)
is called with the thrown exception and complete()
is invoked to complete the command. If
the command returns a result use setResult(Object)
to set it.
void setResult(T result)
await()
and await(long, TimeUnit)
. This must be set before
complete()
is called. The last value set before complete()
is called is returned from await()
or
await(long, TimeUnit)
. This should only be called by the same thread that calls complete()
.
void setFailureCause(Throwable cause)
await()
or
await(long, TimeUnit)
after complete()
is called. If cause is a checked exception it will be wrapped in MqttException
before
being thrown by await()
or await(long, TimeUnit)
.This should only be called by the same thread that calls execute()
.
void complete()
await()
or await(long, TimeUnit)
to return.This should only be called by the same thread
that calls execute()
.
void cancel()
await()
or await(long, TimeUnit)
to throw an MqttCommandCancelledException
.This should only be
called by the same thread that calls execute()
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |