Package org.apache.sshd.common.future
Class DefaultSshFuture<T extends SshFuture>
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.common.future.AbstractSshFuture<T>
org.apache.sshd.common.future.DefaultSshFuture<T>
- Type Parameters:
T- Type of future
- All Implemented Interfaces:
SshFuture<T>,WaitableFuture
- Direct Known Subclasses:
DefaultCloseFuture,DefaultVerifiableSshFuture
A default implementation of
SshFuture.- Author:
- Apache MINA SSHD Project
-
Field Summary
Fields inherited from class org.apache.sshd.common.future.AbstractSshFuture
CANCELEDFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddListener(SshFutureListener<T> listener) Adds an event listener which is notified when this future is completed.protected Objectawait0(long timeoutMillis, boolean interruptable) Wait for the Future to be ready.voidcancel()intgetValue()booleanbooleanisDone()protected voidremoveListener(SshFutureListener<T> listener) Removes an existing event listener so it won't be notified when the future is completed.voidSets the result of the asynchronous operation, and mark it as finished.toString()Methods inherited from class org.apache.sshd.common.future.AbstractSshFuture
asListener, asT, await, awaitUninterruptibly, formatExceptionMessage, getId, notifyListener, verifyResultMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.future.WaitableFuture
await, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly
-
Constructor Details
-
DefaultSshFuture
Creates a new instance.- Parameters:
id- Some identifier useful astoString()valuelock- A synchronization object for locking access - ifnullthen synchronization occurs onthisinstance
-
-
Method Details
-
await0
Description copied from class:AbstractSshFutureWait for the Future to be ready. If the requested delay is 0 or negative, this method returns immediately.- Specified by:
await0in classAbstractSshFuture<T extends SshFuture>- Parameters:
timeoutMillis- The delay we will wait for the Future to be readyinterruptable- Tells if the wait can be interrupted or not. Iftrueand the thread is interrupted then anInterruptedIOExceptionis thrown.- Returns:
- The non-
nullresult object if the Future is ready,nullif the timeout expired and no result was received - Throws:
InterruptedIOException- If the thread has been interrupted when it's not allowed.
-
isDone
public boolean isDone()- Returns:
trueif the asynchronous operation is completed. Note: it is up to the caller to determine whether it was a successful or failed completion.
-
setValue
Sets the result of the asynchronous operation, and mark it as finished.- Parameters:
newValue- The operation result
-
getNumRegisteredListeners
public int getNumRegisteredListeners() -
getValue
- Returns:
- The result of the asynchronous operation - or
nullif none set.
-
addListener
Description copied from interface:SshFutureAdds an event listener which is notified when this future is completed. If the listener is added after the completion, the listener is directly notified.- Parameters:
listener- TheSshFutureListenerinstance to add- Returns:
- The future instance
-
removeListener
Description copied from interface:SshFutureRemoves an existing event listener so it won't be notified when the future is completed.- Parameters:
listener- TheSshFutureListenerinstance to remove- Returns:
- The future instance
-
notifyListeners
protected void notifyListeners() -
isCanceled
public boolean isCanceled() -
cancel
public void cancel() -
toString
- Overrides:
toStringin classAbstractSshFuture<T extends SshFuture>
-