public class DefaultSshFuture<T extends SshFuture> extends AbstractLoggingBean implements SshFuture<T>
SshFuture.log| Constructor and Description |
|---|
DefaultSshFuture(Object lock)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
T |
addListener(SshFutureListener<T> listener)
Adds an event listener which is notified when
this future is completed.
|
T |
await()
Wait for the asynchronous operation to complete.
|
boolean |
await(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout.
|
boolean |
await(long timeout,
TimeUnit unit)
Wait for the asynchronous operation to complete with the specified timeout.
|
protected Object |
await0(long timeoutMillis,
boolean interruptable)
Wait for the Future to be ready.
|
T |
awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly.
|
boolean |
awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout
uninterruptibly.
|
boolean |
awaitUninterruptibly(long timeout,
TimeUnit unit)
Wait for the asynchronous operation to complete with the specified timeout
uninterruptibly.
|
void |
cancel() |
protected Object |
getValue() |
boolean |
isCanceled() |
boolean |
isDone() |
T |
removeListener(SshFutureListener<T> listener)
Removes an existing event listener so it won't be notified when
the future is completed.
|
void |
setValue(Object newValue)
Sets the result of the asynchronous operation, and mark it as finished.
|
protected <R> R |
verifyResult(Class<? extends R> expectedType,
long timeout)
Waits (interruptible) for the specified timeout (msec.) and then checks
the result:
|
public DefaultSshFuture(Object lock)
lock - A synchronization object for locking access - if null
then synchronization occurs on this instancepublic T await() throws IOException
SshFutureawait in interface SshFuture<T extends SshFuture>this instanceIOException - if failed - specifically InterruptedIOException
if waiting was interruptedpublic boolean await(long timeout,
TimeUnit unit)
throws IOException
SshFutureawait in interface SshFuture<T extends SshFuture>timeout - The number of time units to waitunit - The TimeUnit for waitingtrue if the operation is completed.IOException - if failed - specifically InterruptedIOException
if waiting was interruptedpublic boolean await(long timeoutMillis)
throws IOException
SshFutureawait in interface SshFuture<T extends SshFuture>timeoutMillis - Wait time in millisecondstrue if the operation is completed.IOException - if failed - specifically InterruptedIOException
if waiting was interruptedpublic T awaitUninterruptibly()
SshFutureawaitUninterruptibly in interface SshFuture<T extends SshFuture>public boolean awaitUninterruptibly(long timeout,
TimeUnit unit)
SshFutureawaitUninterruptibly in interface SshFuture<T extends SshFuture>timeout - The number of time units to waitunit - The TimeUnit for waitingtrue if the operation is completed.public boolean awaitUninterruptibly(long timeoutMillis)
SshFutureawaitUninterruptibly in interface SshFuture<T extends SshFuture>timeoutMillis - Wait time in millisecondstrue if the operation is finished.protected <R> R verifyResult(Class<? extends R> expectedType, long timeout) throws 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) resultIOException - If failed to retrieve the expected result on timeprotected Object await0(long timeoutMillis, boolean interruptable) throws 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 receivedInterruptedIOException - If the thread has been interrupted
when it's not allowed.public boolean isDone()
public void setValue(Object newValue)
newValue - The operation resultprotected Object getValue()
public T addListener(SshFutureListener<T> listener)
SshFutureaddListener in interface SshFuture<T extends SshFuture>listener - The SshFutureListener instance to addpublic T removeListener(SshFutureListener<T> listener)
SshFutureremoveListener in interface SshFuture<T extends SshFuture>listener - The SshFutureListener instance to removepublic boolean isCanceled()
public void cancel()
Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.