org.apache.mina.core.future
Class DefaultReadFuture

java.lang.Object
  extended by org.apache.mina.core.future.DefaultIoFuture
      extended by org.apache.mina.core.future.DefaultReadFuture
All Implemented Interfaces:
IoFuture, ReadFuture

public class DefaultReadFuture
extends DefaultIoFuture
implements ReadFuture

A default implementation of WriteFuture.

Version:
$Rev:671827 $, $Date:2008-06-26 09:49:48 +0100 (jeu., 26 juin 2008) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
DefaultReadFuture(IoSession session)
          Creates a new instance.
 
Method Summary
 ReadFuture addListener(IoFutureListener<?> listener)
          Adds an event listener which is notified when this future is completed.
 ReadFuture await()
          Wait for the asynchronous operation to complete.
 ReadFuture awaitUninterruptibly()
          Wait for the asynchronous operation to complete uninterruptibly.
 Throwable getException()
          Returns the cause of the read failure if and only if the read operation has failed due to an Exception.
 Object getMessage()
          Returns the received message.
 boolean isClosed()
          Returns true if the IoSession associated with this future has been closed.
 boolean isRead()
          Returns true if a message was received successfully.
 ReadFuture removeListener(IoFutureListener<?> listener)
          Removes an existing event listener so it won't be notified when the future is completed.
 void setClosed()
          Sets the associated IoSession is closed.
 void setException(Throwable exception)
          Sets the cause of the read failure, and notifies all threads waiting for this future.
 void setRead(Object message)
          Sets the message is written, and notifies all threads waiting for this future.
 
Methods inherited from class org.apache.mina.core.future.DefaultIoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, getValue, isDone, join, join, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.mina.core.future.IoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, isDone, join, join
 

Constructor Detail

DefaultReadFuture

public DefaultReadFuture(IoSession session)
Creates a new instance.

Method Detail

getMessage

public Object getMessage()
Description copied from interface: ReadFuture
Returns the received message. It returns null if this future is not ready or the associated IoSession has been closed.

Specified by:
getMessage in interface ReadFuture

isRead

public boolean isRead()
Description copied from interface: ReadFuture
Returns true if a message was received successfully.

Specified by:
isRead in interface ReadFuture

isClosed

public boolean isClosed()
Description copied from interface: ReadFuture
Returns true if the IoSession associated with this future has been closed.

Specified by:
isClosed in interface ReadFuture

getException

public Throwable getException()
Description copied from interface: ReadFuture
Returns the cause of the read failure if and only if the read operation has failed due to an Exception. Otherwise, null is returned.

Specified by:
getException in interface ReadFuture

setClosed

public void setClosed()
Description copied from interface: ReadFuture
Sets the associated IoSession is closed. This method is invoked by MINA internally. Please do not call this method directly.

Specified by:
setClosed in interface ReadFuture

setRead

public void setRead(Object message)
Description copied from interface: ReadFuture
Sets the message is written, and notifies all threads waiting for this future. This method is invoked by MINA internally. Please do not call this method directly.

Specified by:
setRead in interface ReadFuture

setException

public void setException(Throwable exception)
Description copied from interface: ReadFuture
Sets the cause of the read failure, and notifies all threads waiting for this future. This method is invoked by MINA internally. Please do not call this method directly.

Specified by:
setException in interface ReadFuture

await

public ReadFuture await()
                 throws InterruptedException
Description copied from class: DefaultIoFuture
Wait for the asynchronous operation to complete. The attached listeners will be notified when the operation is completed.

Specified by:
await in interface IoFuture
Specified by:
await in interface ReadFuture
Overrides:
await in class DefaultIoFuture
Throws:
InterruptedException

awaitUninterruptibly

public ReadFuture awaitUninterruptibly()
Description copied from class: DefaultIoFuture
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
Specified by:
awaitUninterruptibly in interface ReadFuture
Overrides:
awaitUninterruptibly in class DefaultIoFuture
Returns:
the current IoFuture

addListener

public ReadFuture addListener(IoFutureListener<?> listener)
Description copied from class: DefaultIoFuture
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
Specified by:
addListener in interface ReadFuture
Overrides:
addListener in class DefaultIoFuture

removeListener

public ReadFuture removeListener(IoFutureListener<?> listener)
Description copied from class: DefaultIoFuture
Removes an existing event listener so it won't be notified when the future is completed.

Specified by:
removeListener in interface IoFuture
Specified by:
removeListener in interface ReadFuture
Overrides:
removeListener in class DefaultIoFuture


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