org.apache.mina.common
Interface WriteFuture

All Superinterfaces:
IoFuture
All Known Implementing Classes:
DefaultWriteFuture

public interface WriteFuture
extends IoFuture

An IoFuture for asynchronous write requests.

Example

 IoSession session = ...;
 WriteFuture future = session.write(...);
 // Wait until the message is completely written out to the O/S buffer.
 future.join();
 if( future.isWritten() )
 {
     // The message has been written successfully.
 }
 else
 {
     // The messsage couldn't be written out completely for some reason.
     // (e.g. Connection is closed)
 }
 

Version:
$Rev: 591310 $, $Date: 2007-11-02 12:57:00 +0100 (Fri, 02 Nov 2007) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Method Summary
 WriteFuture addListener(IoFutureListener<?> listener)
          Adds an event listener which is notified when the state of this future changes.
 WriteFuture await()
          Wait for the asynchronous operation to end.
 WriteFuture awaitUninterruptibly()
          Wait for the asynchronous operation to end uninterruptibly.
 Throwable getException()
          Returns the cause of the write failure if and only if the write operation has failed due to an Exception.
 boolean isWritten()
          Returns true if the write operation is finished successfully.
 WriteFuture removeListener(IoFutureListener<?> listener)
          Removes an existing event listener which is notified when the state of this future changes.
 void setException(Throwable cause)
          Sets the cause of the write failure, and notifies all threads waiting for this future.
 void setWritten()
          Sets the message is written, and notifies all threads waiting for this future.
 
Methods inherited from interface org.apache.mina.common.IoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, isReady, join, join
 

Method Detail

isWritten

boolean isWritten()
Returns true if the write operation is finished successfully.


getException

Throwable getException()
Returns the cause of the write failure if and only if the write operation has failed due to an Exception. Otherwise, null is returned.


setWritten

void setWritten()
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.


setException

void setException(Throwable cause)
Sets the cause of the write failure, and notifies all threads waiting for this future. This method is invoked by MINA internally. Please do not call this method directly.


await

WriteFuture await()
                  throws InterruptedException
Description copied from interface: IoFuture
Wait for the asynchronous operation to end.

Specified by:
await in interface IoFuture
Throws:
InterruptedException

awaitUninterruptibly

WriteFuture awaitUninterruptibly()
Description copied from interface: IoFuture
Wait for the asynchronous operation to end uninterruptibly.

Specified by:
awaitUninterruptibly in interface IoFuture

addListener

WriteFuture addListener(IoFutureListener<?> listener)
Description copied from interface: IoFuture
Adds an event listener which is notified when the state of this future changes.

Specified by:
addListener in interface IoFuture

removeListener

WriteFuture removeListener(IoFutureListener<?> listener)
Description copied from interface: IoFuture
Removes an existing event listener which is notified when the state of this future changes.

Specified by:
removeListener in interface IoFuture


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