T
- Type of futurepublic abstract class AbstractSshFuture<T extends SshFuture> extends AbstractLoggingBean implements SshFuture<T>
Modifier and Type | Field and Description |
---|---|
protected static java.lang.Object |
CANCELED
A default value to indicate the future has been canceled
|
protected boolean |
debugEnabled |
private java.lang.Object |
id |
protected boolean |
traceEnabled |
log
Modifier | Constructor and Description |
---|---|
protected |
AbstractSshFuture(java.lang.Object id) |
Modifier and Type | Method and Description |
---|---|
protected SshFutureListener<T> |
asListener(java.lang.Object o) |
protected T |
asT() |
boolean |
await(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout.
|
protected abstract java.lang.Object |
await0(long timeoutMillis,
boolean interruptable)
Wait for the Future to be ready.
|
boolean |
awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout
uninterruptibly.
|
protected <E extends java.lang.Throwable> |
formatExceptionMessage(java.util.function.Function<? super java.lang.String,? extends E> exceptionCreator,
java.lang.String format,
java.lang.Object... args)
Generates an exception whose message is prefixed by the future simple class name +
identifier
as a hint to the context of the failure. |
java.lang.Object |
getId() |
protected void |
notifyListener(SshFutureListener<T> l) |
java.lang.String |
toString() |
protected <R> R |
verifyResult(java.lang.Class<? extends R> expectedType,
long timeout)
Waits (interruptible) for the specified timeout (msec.) and then checks
the result:
|
getSimplifiedLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addListener, removeListener
await, await, awaitUninterruptibly, awaitUninterruptibly, isDone
protected static final java.lang.Object CANCELED
protected final boolean debugEnabled
protected final boolean traceEnabled
private final java.lang.Object id
protected AbstractSshFuture(java.lang.Object id)
id
- Some identifier useful as toString()
valuepublic java.lang.Object getId()
getId
in interface WaitableFuture
#toString()
valuepublic boolean await(long timeoutMillis) throws java.io.IOException
WaitableFuture
await
in interface WaitableFuture
timeoutMillis
- Wait time in millisecondstrue
if the operation is completed.java.io.IOException
- if failed - specifically InterruptedIOException
if waiting was interruptedpublic boolean awaitUninterruptibly(long timeoutMillis)
WaitableFuture
awaitUninterruptibly
in interface WaitableFuture
timeoutMillis
- Wait time in millisecondstrue
if the operation is finished.protected <R> R verifyResult(java.lang.Class<? extends R> expectedType, long timeout) throws java.io.IOException
Waits (interruptible) for the specified timeout (msec.) and then checks the result:
If result is null
then timeout is assumed to have expired - throw
an appropriate IOException
If the result is of the expected type, then cast and return it
If the result is an IOException
then re-throw it
If the result is a Throwable
then throw an IOException
whose cause is the original exception
Otherwise (should never happen), throw a StreamCorruptedException
with the name of the result type
R
- The generic result typeexpectedType
- The expected result typetimeout
- The timeout (millis) to wait for a resultnull
) resultjava.io.IOException
- If failed to retrieve the expected result on timeprotected abstract java.lang.Object await0(long timeoutMillis, boolean interruptable) throws java.io.InterruptedIOException
timeoutMillis
- The delay we will wait for the Future to be readyinterruptable
- Tells if the wait can be interrupted or not.
If true
and the thread is interrupted then an InterruptedIOException
is thrown.null
result object if the Future is ready,
null
if the timeout expired and no result was receivedjava.io.InterruptedIOException
- If the thread has been interrupted when it's not allowed.protected SshFutureListener<T> asListener(java.lang.Object o)
protected void notifyListener(SshFutureListener<T> l)
protected T asT()
protected <E extends java.lang.Throwable> E formatExceptionMessage(java.util.function.Function<? super java.lang.String,? extends E> exceptionCreator, java.lang.String format, java.lang.Object... args)
identifier
as a hint to the context of the failure.E
- Type of Throwable
being generatedexceptionCreator
- The exception creator from the formatted messageformat
- The extra payload format as per String.format(String, Object...)
args
- The formatting argumentspublic java.lang.String toString()
toString
in class java.lang.Object