Class DefaultWriteFuture
java.lang.Object
org.apache.mina.core.future.DefaultIoFuture
org.apache.mina.core.future.DefaultWriteFuture
- All Implemented Interfaces:
IoFuture, WriteFuture
A default implementation of
WriteFuture.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddListener(IoFutureListener<?> listener) Adds an eventlistenerwhich is notified when this future is completed.await()Wait for the asynchronous operation to complete.Wait for the asynchronous operation to complete uninterruptibly.booleanstatic WriteFuturenewNotWrittenFuture(IoSession session, Throwable cause) Returns a newDefaultWriteFuturewhich is already marked as 'not written'.static WriteFuturenewWrittenFuture(IoSession session) Returns a newDefaultWriteFuturewhich is already marked as 'written'.removeListener(IoFutureListener<?> listener) Removes an existing eventlistenerso it won't be notified when the future is completed.voidsetException(Throwable exception) Sets the cause of the write failure, and notifies all threads waiting for this future.voidSets the message is written, and notifies all threads waiting for this future.Methods inherited from class DefaultIoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, getValue, isDone, join, join, setValueMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, isDone, join, join
-
Constructor Details
-
DefaultWriteFuture
Creates a new instance.- Parameters:
session- The associated session
-
-
Method Details
-
newWrittenFuture
Returns a newDefaultWriteFuturewhich is already marked as 'written'.- Parameters:
session- The associated session- Returns:
- A new future for a written message
-
newNotWrittenFuture
Returns a newDefaultWriteFuturewhich is already marked as 'not written'.- Parameters:
session- The associated sessioncause- The reason why the message has not be written- Returns:
- A new future for not written message
-
isWritten
public boolean isWritten()- Specified by:
isWrittenin interfaceWriteFuture- Returns:
trueif the write operation is finished successfully.
-
getException
- Specified by:
getExceptionin interfaceWriteFuture- Returns:
- the cause of the write failure if and only if the write
operation has failed due to an
Exception. Otherwise,nullis returned.
-
setWritten
public 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.- Specified by:
setWrittenin interfaceWriteFuture
-
setException
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.- Specified by:
setExceptionin interfaceWriteFuture- Parameters:
exception- The exception to store in the Future instance
-
await
Wait for the asynchronous operation to complete. The attached listeners will be notified when the operation is completed.- Specified by:
awaitin interfaceIoFuture- Specified by:
awaitin interfaceWriteFuture- Overrides:
awaitin classDefaultIoFuture- Returns:
- The instance of IoFuture that we are waiting for
- Throws:
InterruptedException- If the thread is interrupted while waiting
-
awaitUninterruptibly
Wait for the asynchronous operation to complete uninterruptibly. The attached listeners will be notified when the operation is completed.- Specified by:
awaitUninterruptiblyin interfaceIoFuture- Specified by:
awaitUninterruptiblyin interfaceWriteFuture- Overrides:
awaitUninterruptiblyin classDefaultIoFuture- Returns:
- the current IoFuture
-
addListener
Adds an eventlistenerwhich is notified when this future is completed. If the listener is added after the completion, the listener is directly notified.- Specified by:
addListenerin interfaceIoFuture- Specified by:
addListenerin interfaceWriteFuture- Overrides:
addListenerin classDefaultIoFuture- Parameters:
listener- The listener to add- Returns:
- the current IoFuture
-
removeListener
Removes an existing eventlistenerso it won't be notified when the future is completed.- Specified by:
removeListenerin interfaceIoFuture- Specified by:
removeListenerin interfaceWriteFuture- Overrides:
removeListenerin classDefaultIoFuture- Parameters:
listener- The listener to remove- Returns:
- the current IoFuture
-