org.apache.mina.core.future
Class DefaultIoFuture

java.lang.Object
  extended by org.apache.mina.core.future.DefaultIoFuture
All Implemented Interfaces:
IoFuture
Direct Known Subclasses:
AbstractIoService.ServiceOperationFuture, CompositeIoFuture, DefaultCloseFuture, DefaultConnectFuture, DefaultReadFuture, DefaultWriteFuture

public class DefaultIoFuture
extends Object
implements IoFuture

A default implementation of IoFuture associated with an IoSession.

Author:
Apache MINA Project

Constructor Summary
DefaultIoFuture(IoSession session)
          Creates a new instance associated with an IoSession.
 
Method Summary
 IoFuture addListener(IoFutureListener<?> listener)
          Adds an event listener which is notified when this future is completed.
 IoFuture 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.
 IoFuture 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.
 IoSession getSession()
          Returns the IoSession which is associated with this future.
protected  Object getValue()
          Returns the result of the asynchronous operation.
 boolean isDone()
          Returns if the asynchronous operation is completed.
 void join()
          Deprecated. Replaced with awaitUninterruptibly().
 boolean join(long timeoutMillis)
          Deprecated. Replaced with awaitUninterruptibly(long).
 IoFuture removeListener(IoFutureListener<?> 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

DefaultIoFuture

public DefaultIoFuture(IoSession session)
Creates a new instance associated with an IoSession.

Parameters:
session - an IoSession which is associated with this future
Method Detail

getSession

public IoSession getSession()
Returns the IoSession which is associated with this future.

Specified by:
getSession in interface IoFuture

join

@Deprecated
public void join()
Deprecated. Replaced with awaitUninterruptibly().

Specified by:
join in interface IoFuture

join

@Deprecated
public boolean join(long timeoutMillis)
Deprecated. Replaced with awaitUninterruptibly(long).

Specified by:
join in interface IoFuture

await

public IoFuture 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 IoFuture
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 IoFuture
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 IoFuture
Returns:
true if the operation is completed.
Throws:
InterruptedException

awaitUninterruptibly

public IoFuture 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 IoFuture
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 IoFuture
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 IoFuture
Returns:
true if the operation is finished.

isDone

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

Specified by:
isDone in interface IoFuture

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 IoFuture addListener(IoFutureListener<?> 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 IoFuture

removeListener

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

Specified by:
removeListener in interface IoFuture


Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.