org.apache.mina.common
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: 596168 $, $Date: 2007-11-19 01:20:24 +0100 (Mon, 19 Nov 2007) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Method Summary
 ConnectFuture addListener(IoFutureListener<?> listener)
          Adds an event listener which is notified when the state of this future changes.
 ConnectFuture await()
          Wait for the asynchronous operation to end.
 ConnectFuture awaitUninterruptibly()
          Wait for the asynchronous operation to end 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 which is notified when the state of this future changes.
 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.common.IoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, isReady, 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 end.

Specified by:
await in interface IoFuture
Throws:
InterruptedException

awaitUninterruptibly

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

Specified by:
awaitUninterruptibly in interface IoFuture

addListener

ConnectFuture 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

ConnectFuture 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.