org.apache.mina.core.future

## Class DefaultConnectFuture

- java.lang.Object
- - org.apache.mina.core.future.DefaultIoFuture
  - - org.apache.mina.core.future.DefaultConnectFuture

- All Implemented Interfaces:
    ConnectFuture, IoFuture
  Direct Known Subclasses:
    AbstractPollingIoConnector.ConnectionRequest

      public class DefaultConnectFuture
      extends DefaultIoFuture
      implements ConnectFuture

  A default implementation of `ConnectFuture`.
  Author:
    Apache MINA Project

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultConnectFuture()` Creates a new instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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 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` 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 class org.apache.mina.core.future.DefaultIoFuture

      `await, await, awaitUninterruptibly, awaitUninterruptibly, getValue, isDone, 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.core.future.IoFuture

      `await, await, awaitUninterruptibly, awaitUninterruptibly, isDone, 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 class: `DefaultIoFuture`
      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 class: `DefaultIoFuture`
      Wait for the asynchronous operation to complete. The attached listeners will be notified when the operation is completed.
      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 class: `DefaultIoFuture`
      Wait for the asynchronous operation to complete uninterruptibly. The attached listeners will be notified when the operation is completed.
      Specified by:
        `awaitUninterruptibly` in interface `ConnectFuture`
      Specified by:
        `awaitUninterruptibly` in interface `IoFuture`
      Overrides:
        `awaitUninterruptibly` in class `DefaultIoFuture`
      Returns:
        the current IoFuture

    - #### addListener

          public ConnectFuture addListener(IoFutureListener<?> listener)

      Description copied from class: `DefaultIoFuture`
      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 `ConnectFuture`
      Specified by:
        `addListener` in interface `IoFuture`
      Overrides:
        `addListener` in class `DefaultIoFuture`

    - #### removeListener

          public ConnectFuture removeListener(IoFutureListener<?> listener)

      Description copied from class: `DefaultIoFuture`
      Removes an existing event `listener` so it won't be notified when the future is completed.
      Specified by:
        `removeListener` in interface `ConnectFuture`
      Specified by:
        `removeListener` in interface `IoFuture`
      Overrides:
        `removeListener` in class `DefaultIoFuture`

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