Package org.apache.sshd.common.future
Class DefaultCancellableSshFuture<T extends SshFuture<T>>
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.future.AbstractSshFuture<T>
-
- org.apache.sshd.common.future.DefaultSshFuture<T>
-
- org.apache.sshd.common.future.DefaultVerifiableSshFuture<T>
-
- org.apache.sshd.common.future.DefaultCancellableSshFuture<T>
-
- Type Parameters:
T
- Type of future
- All Implemented Interfaces:
Cancellable
,HasException
,SshFuture<T>
,VerifiableFuture<T>
,WaitableFuture
,WithException
- Direct Known Subclasses:
DefaultAuthFuture
,DefaultConnectFuture
,DefaultIoConnectFuture
,DefaultOpenFuture
public abstract class DefaultCancellableSshFuture<T extends SshFuture<T>> extends DefaultVerifiableSshFuture<T> implements Cancellable
A defaultCancellable
future implementation.
-
-
Field Summary
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultCancellableSshFuture(java.lang.Object id, java.lang.Object lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CancelFuture
cancel()
Attempts to cancel the operation.protected CancelFuture
createCancellation()
Creates aCancelFuture
if this future can be canceled.CancelFuture
getCancellation()
Retrieves theCancelFuture
, ifCancellable.cancel()
had been called.java.lang.Throwable
getException()
Returns the cause of the failure.boolean
isCanceled()
Tells whether this operation was canceled.void
setException(java.lang.Throwable exception)
Sets the exception that caused the operation to fail.-
Methods inherited from class org.apache.sshd.common.future.DefaultSshFuture
addListener, await0, getNumRegisteredListeners, getValue, isDone, notifyListeners, onValueSet, removeListener, setValue, toString
-
Methods inherited from class org.apache.sshd.common.future.AbstractSshFuture
asListener, asT, await, awaitUninterruptibly, formatExceptionMessage, getId, notifyListener, verifyResult
-
Methods 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, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.future.VerifiableFuture
verify, verify, verify, verify, verify, verify, verify, verify
-
Methods inherited from interface org.apache.sshd.common.future.WaitableFuture
await, await, await, await, await, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly
-
-
-
-
Method Detail
-
isCanceled
public boolean isCanceled()
Description copied from interface:Cancellable
Tells whether this operation was canceled.- Specified by:
isCanceled
in interfaceCancellable
- Returns:
true
if the operation was cancelled,false
otherwise.
-
createCancellation
protected CancelFuture createCancellation()
Description copied from class:DefaultSshFuture
Creates aCancelFuture
if this future can be canceled.This doesn't cancel this future yet.
- Overrides:
createCancellation
in classDefaultSshFuture<T extends SshFuture<T>>
- Returns:
- A
CancelFuture
that can be used to wait for the cancellation to have been effected, ornull
if the future cannot be canceled.
-
cancel
public CancelFuture cancel()
Description copied from interface:Cancellable
Attempts to cancel the operation.- Specified by:
cancel
in interfaceCancellable
- Returns:
- A
CancelFuture
that can be used to wait for the cancellation to have been effected, ornull
if the future cannot be canceled or is already completed.
-
getCancellation
public CancelFuture getCancellation()
Description copied from interface:Cancellable
Retrieves theCancelFuture
, ifCancellable.cancel()
had been called.- Specified by:
getCancellation
in interfaceCancellable
- Returns:
- The
CancelFuture
if theCancellable
has already been canceled, ornull
otherwise
-
getException
public java.lang.Throwable getException()
Description copied from interface:HasException
Returns the cause of the failure.- Specified by:
getException
in interfaceHasException
- Returns:
- the
Throwable
of the failure, ornull
if not failed (yet).
-
setException
public void setException(java.lang.Throwable exception)
Sets the exception that caused the operation to fail. If theexception
cannot be set but the future is already canceled, the exception will be reported through this future'sCancelFuture
.- Specified by:
setException
in interfaceWithException
- Parameters:
exception
- TheThrowable
to set; must be non-null
-
-