org.apache.sshd.common.future
Class DefaultSshFuture<T extends SshFuture>

java.lang.Object
  extended by org.apache.sshd.common.future.DefaultSshFuture<T>
All Implemented Interfaces:
SshFuture<T>
Direct Known Subclasses:
DefaultAuthFuture, DefaultCloseFuture, DefaultConnectFuture, DefaultOpenFuture

public class DefaultSshFuture<T extends SshFuture>
extends Object
implements SshFuture<T>

A default implementation of SshFuture.

Author:
Apache MINA SSHD Project

Constructor Summary
DefaultSshFuture(Object lock)
          Creates a new instance.
 
Method Summary
 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.
 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()
          Returns the result of the asynchronous operation.
 boolean isCanceled()
           
 boolean isDone()
          Returns if the asynchronous operation is completed.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSshFuture

public DefaultSshFuture(Object lock)
Creates a new instance.

Method Detail

await

public T await()
                          throws InterruptedException
Wait for the asynchronous operation to complete. The attached listeners will be notified when the operation is completed.

Specified by:
await in interface SshFuture<T extends SshFuture>
Throws:
InterruptedException

await

public boolean await(long timeout,
                     TimeUnit unit)
              throws InterruptedException
Wait for the asynchronous operation to complete with the specified timeout.

Specified by:
await in interface SshFuture<T extends SshFuture>
Returns:
true if the operation is completed.
Throws:
InterruptedException

await

public boolean await(long timeoutMillis)
              throws InterruptedException
Wait for the asynchronous operation to complete with the specified timeout.

Specified by:
await in interface SshFuture<T extends SshFuture>
Returns:
true if the operation is completed.
Throws:
InterruptedException

awaitUninterruptibly

public T awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly. The attached listeners will be notified when the operation is completed.

Specified by:
awaitUninterruptibly in interface SshFuture<T extends SshFuture>
Returns:
the current IoFuture

awaitUninterruptibly

public boolean awaitUninterruptibly(long timeout,
                                    TimeUnit unit)
Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.

Specified by:
awaitUninterruptibly in interface SshFuture<T extends SshFuture>
Returns:
true if the operation is completed.

awaitUninterruptibly

public boolean awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.

Specified by:
awaitUninterruptibly in interface SshFuture<T extends SshFuture>
Returns:
true if the operation is finished.

isDone

public boolean isDone()
Returns if the asynchronous operation is completed.

Specified by:
isDone in interface SshFuture<T extends SshFuture>

setValue

public void setValue(Object newValue)
Sets the result of the asynchronous operation, and mark it as finished.


getValue

protected Object getValue()
Returns the result of the asynchronous operation.


addListener

public T addListener(SshFutureListener<T> listener)
Adds an event listener which is notified when this future is completed. If the listener is added after the completion, the listener is directly notified.

Specified by:
addListener in interface SshFuture<T extends SshFuture>

removeListener

public T removeListener(SshFutureListener<T> listener)
Removes an existing event listener so it won't be notified when the future is completed.

Specified by:
removeListener in interface SshFuture<T extends SshFuture>

isCanceled

public boolean isCanceled()

cancel

public void cancel()


Copyright © 2008-2012 Apache Software Foundation. All Rights Reserved.