org.apache.mina.core.future
Interface ConnectFuture

All Superinterfaces:
IoFuture
All Known Implementing Classes:
AbstractPollingIoConnector.ConnectionRequest, DefaultConnectFuture

public interface ConnectFuture
extends IoFuture

An IoFuture for asynchronous connect requests.

Example

 IoConnector connector = ...;
 ConnectFuture future = connector.connect(...);
 future.join(); // Wait until the connection attempt is finished.
 IoSession session = future.getSession();
 session.write(...);
 

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

Method Summary
 ConnectFuture addListener(IoFutureListener<?> listener)
          Adds an event listener which is notified when this future is completed.
 ConnectFuture await()
          Wait for the asynchronous operation to complete.
 ConnectFuture awaitUninterruptibly()
          Wait for the asynchronous operation to complete uninterruptibly.
 void cancel()
          Cancels the connection attempt and notifies all threads waiting for this future.
 Throwable getException()
          Returns the cause of the connection failure.
 IoSession getSession()
          Returns IoSession which is the result of connect operation.
 boolean isCanceled()
          Returns true if the connect operation has been canceled by cancel() method.
 boolean isConnected()
          Returns true if the connect operation is finished successfully.
 ConnectFuture removeListener(IoFutureListener<?> listener)
          Removes an existing event listener so it won't be notified when the future is completed.
 void setException(Throwable exception)
          Sets the exception caught due to connection failure and notifies all threads waiting for this future.
 void setSession(IoSession session)
          Sets the newly connected session and notifies all threads waiting for this future.
 
Methods inherited from interface org.apache.mina.core.future.IoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, isDone, join, join
 

Method Detail

getSession

IoSession getSession()
Returns IoSession which is the result of connect operation.

Specified by:
getSession in interface IoFuture
Returns:
null if the connect operation is not finished yet
Throws:
RuntimeException - if connection attempt failed by an exception

getException

Throwable getException()
Returns the cause of the connection failure.

Returns:
null if the connect operation is not finished yet, or if the connection attempt is successful.

isConnected

boolean isConnected()
Returns true if the connect operation is finished successfully.


isCanceled

boolean isCanceled()
Returns true if the connect operation has been canceled by cancel() method.


setSession

void setSession(IoSession session)
Sets the newly connected session 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 exception)
Sets the exception caught due to connection failure and notifies all threads waiting for this future. This method is invoked by MINA internally. Please do not call this method directly.


cancel

void cancel()
Cancels the connection attempt and notifies all threads waiting for this future.


await

ConnectFuture await()
                    throws InterruptedException
Description copied from interface: IoFuture
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

awaitUninterruptibly

ConnectFuture awaitUninterruptibly()
Description copied from interface: IoFuture
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

addListener

ConnectFuture addListener(IoFutureListener<?> listener)
Description copied from interface: IoFuture
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

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

Specified by:
removeListener in interface IoFuture


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