org.apache.mina.common
Class DefaultConnectFuture

java.lang.Object
  extended by org.apache.mina.common.DefaultIoFuture
      extended by org.apache.mina.common.DefaultConnectFuture
All Implemented Interfaces:
ConnectFuture, IoFuture
Direct Known Subclasses:
AbstractPollingIoConnector.ConnectionRequest

public class DefaultConnectFuture
extends DefaultIoFuture
implements ConnectFuture

A default implementation of ConnectFuture.

Version:
$Rev: 599745 $, $Date: 2007-11-30 10:04:47 +0100 (Fri, 30 Nov 2007) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
DefaultConnectFuture()
          Creates a new instance.
 
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 the IoSession which is associated with this future.
 boolean isCanceled()
          Returns true if the connect operation has been canceled by ConnectFuture.cancel() method.
 boolean isConnected()
          Returns true if the connect operation is finished successfully.
static ConnectFuture newFailedFuture(Throwable exception)
          Returns a new ConnectFuture which is already marked as 'failed to connect'.
 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 class org.apache.mina.common.DefaultIoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getValue, isReady, 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.common.IoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, isReady, join, join
 

Constructor Detail

DefaultConnectFuture

public DefaultConnectFuture()
Creates a new instance.

Method Detail

newFailedFuture

public static ConnectFuture newFailedFuture(Throwable exception)
Returns a new ConnectFuture which is already marked as 'failed to connect'.


getSession

public IoSession getSession()
Description copied from interface: IoFuture
Returns the IoSession which is associated with this future.

Specified by:
getSession in interface ConnectFuture
Specified by:
getSession in interface IoFuture
Overrides:
getSession in class DefaultIoFuture
Returns:
null if the connect operation is not finished yet

getException

public Throwable getException()
Description copied from interface: ConnectFuture
Returns the cause of the connection failure.

Specified by:
getException in interface ConnectFuture
Returns:
null if the connect operation is not finished yet, or if the connection attempt is successful.

isConnected

public boolean isConnected()
Description copied from interface: ConnectFuture
Returns true if the connect operation is finished successfully.

Specified by:
isConnected in interface ConnectFuture

isCanceled

public boolean isCanceled()
Description copied from interface: ConnectFuture
Returns true if the connect operation has been canceled by ConnectFuture.cancel() method.

Specified by:
isCanceled in interface ConnectFuture

setSession

public void setSession(IoSession session)
Description copied from interface: ConnectFuture
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.

Specified by:
setSession in interface ConnectFuture

setException

public void setException(Throwable exception)
Description copied from interface: ConnectFuture
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.

Specified by:
setException in interface ConnectFuture

cancel

public void cancel()
Description copied from interface: ConnectFuture
Cancels the connection attempt and notifies all threads waiting for this future.

Specified by:
cancel in interface ConnectFuture

await

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

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

awaitUninterruptibly

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

Specified by:
awaitUninterruptibly in interface ConnectFuture
Specified by:
awaitUninterruptibly in interface IoFuture
Overrides:
awaitUninterruptibly in class DefaultIoFuture

addListener

public 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 ConnectFuture
Specified by:
addListener in interface IoFuture
Overrides:
addListener in class DefaultIoFuture

removeListener

public 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 ConnectFuture
Specified by:
removeListener in interface IoFuture
Overrides:
removeListener in class DefaultIoFuture


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