org.apache.mina.core.service

## Class AbstractIoConnector

- java.lang.Object
- - org.apache.mina.core.service.AbstractIoService
  - - org.apache.mina.core.service.AbstractIoConnector

- All Implemented Interfaces:
    IoConnector, IoService
  Direct Known Subclasses:
    AbstractPollingIoConnector, ProxyConnector, SerialConnector, VmPipeConnector

      public abstract class AbstractIoConnector
      extends AbstractIoService
      implements IoConnector

  A base implementation of `IoConnector`.
  Author:
    Apache MINA Project

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.mina.core.service.AbstractIoService

      `AbstractIoService.ServiceOperationFuture`

  - ### Field Summary

    - ### Fields inherited from class org.apache.mina.core.service.AbstractIoService

      `disposalLock`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractIoConnector(IoSessionConfig sessionConfig, Executor executor)` Constructor for `AbstractIoConnector`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ConnectFuture` | `connect()` Connects to the `default remote address`.
    `ConnectFuture` | `connect(IoSessionInitializer<? extends ConnectFuture> sessionInitializer)` Connects to the `default remote address` and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked.
    `ConnectFuture` | `connect(SocketAddress remoteAddress)` Connects to the specified remote address.
    `ConnectFuture` | `connect(SocketAddress remoteAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer)` Connects to the specified remote address and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked.
    `ConnectFuture` | `connect(SocketAddress remoteAddress, SocketAddress localAddress)` Connects to the specified remote address binding to the specified local address.
    `ConnectFuture` | `connect(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer)` Connects to the specified remote address binding to the specified local address and and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked.
    `protected abstract ConnectFuture` | `connect0(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer)` Implement this method to perform the actual connect operation.
    `protected void` | `finishSessionInitialization0(IoSession session, IoFuture future)` Adds required internal attributes and `IoFutureListener`s related with event notifications to the specified `session` and `future`.
    `int` | `getConnectTimeout()` Deprecated. Take a look at `getConnectTimeoutMillis()`
    `long` | `getConnectTimeoutCheckInterval()` Returns the minimum connection timeout value for this connector
    `long` | `getConnectTimeoutMillis()` Returns the connect timeout in milliseconds.
    `SocketAddress` | `getDefaultRemoteAddress()` Returns the default remote address to connect to when no argument is specified in `IoConnector.connect()` method.
    `void` | `setConnectTimeout(int connectTimeout)` Deprecated. Take a look at `setConnectTimeoutMillis(long)`
    `void` | `setConnectTimeoutCheckInterval(long minimumConnectTimeout)`
    `void` | `setConnectTimeoutMillis(long connectTimeoutInMillis)` Sets the connect timeout value in milliseconds.
    `void` | `setDefaultRemoteAddress(SocketAddress defaultRemoteAddress)` Sets the default remote address to connect to when no argument is specified in `IoConnector.connect()` method.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.mina.core.service.AbstractIoService

      `addListener, broadcast, dispose, dispose, dispose0, executeWorker, executeWorker, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.mina.core.service.IoService

      `addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, getTransportMetadata, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory`

- - ### Constructor Detail

    - #### AbstractIoConnector

          protected AbstractIoConnector(IoSessionConfig sessionConfig,
                             Executor executor)

      Constructor for `AbstractIoConnector`. You need to provide a default session configuration and an `Executor` for handling I/O events. If null `Executor` is provided, a default one will be created using `Executors.newCachedThreadPool()`. `AbstractIoService.AbstractIoService(IoSessionConfig, Executor)`
      Parameters:
        `sessionConfig` - the default configuration for the managed `IoSession`
        `executor` - the `Executor` used for handling execution of I/O events. Can be `null`.

  - ### Method Detail

    - #### getConnectTimeoutCheckInterval

          public long getConnectTimeoutCheckInterval()

      Returns the minimum connection timeout value for this connector
      Returns:
        The minimum time that this connector can have for a connection timeout in milliseconds.

    - #### setConnectTimeoutCheckInterval

          public void setConnectTimeoutCheckInterval(long minimumConnectTimeout)

    - #### getConnectTimeout

          public final int getConnectTimeout()

      Deprecated. Take a look at `getConnectTimeoutMillis()`
      Description copied from interface: `IoConnector`
      Returns the connect timeout in seconds. The default value is 1 minute.
      Specified by:
        `getConnectTimeout` in interface `IoConnector`
      See Also:
        `IoConnector.getConnectTimeoutMillis()`

    - #### getConnectTimeoutMillis

          public final long getConnectTimeoutMillis()

      Returns the connect timeout in milliseconds. The default value is 1 minute.
      Specified by:
        `getConnectTimeoutMillis` in interface `IoConnector`

    - #### setConnectTimeout

          public final void setConnectTimeout(int connectTimeout)

      Deprecated. Take a look at `setConnectTimeoutMillis(long)`
      Description copied from interface: `IoConnector`
      Sets the connect timeout in seconds. The default value is 1 minute.
      Specified by:
        `setConnectTimeout` in interface `IoConnector`
      See Also:
        `setConnectTimeoutMillis()`

    - #### setConnectTimeoutMillis

          public final void setConnectTimeoutMillis(long connectTimeoutInMillis)

      Sets the connect timeout value in milliseconds.
      Specified by:
        `setConnectTimeoutMillis` in interface `IoConnector`

    - #### getDefaultRemoteAddress

          public SocketAddress getDefaultRemoteAddress()

      Returns the default remote address to connect to when no argument is specified in `IoConnector.connect()` method.
      Specified by:
        `getDefaultRemoteAddress` in interface `IoConnector`

    - #### setDefaultRemoteAddress

          public final void setDefaultRemoteAddress(SocketAddress defaultRemoteAddress)

      Sets the default remote address to connect to when no argument is specified in `IoConnector.connect()` method.
      Specified by:
        `setDefaultRemoteAddress` in interface `IoConnector`

    - #### connect

          public final ConnectFuture connect()

      Connects to the `default remote address`.
      Specified by:
        `connect` in interface `IoConnector`

    - #### connect

          public ConnectFuture connect(IoSessionInitializer<? extends ConnectFuture> sessionInitializer)

      Connects to the `default remote address` and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked. There is no guarantee that the `ioSessionInitializer` will be invoked before this method returns.
      Specified by:
        `connect` in interface `IoConnector`
      Parameters:
        `sessionInitializer` - the callback to invoke when the `IoSession` object is created

    - #### connect

          public final ConnectFuture connect(SocketAddress remoteAddress)

      Connects to the specified remote address.
      Specified by:
        `connect` in interface `IoConnector`
      Returns:
        the `ConnectFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

    - #### connect

          public ConnectFuture connect(SocketAddress remoteAddress,
                              IoSessionInitializer<? extends ConnectFuture> sessionInitializer)

      Connects to the specified remote address and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked. There is no guarantee that the `ioSessionInitializer` will be invoked before this method returns.
      Specified by:
        `connect` in interface `IoConnector`
      Parameters:
        `remoteAddress` - the remote address to connect to
        `sessionInitializer` - the callback to invoke when the `IoSession` object is created
      Returns:
        the `ConnectFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

    - #### connect

          public ConnectFuture connect(SocketAddress remoteAddress,
                              SocketAddress localAddress)

      Connects to the specified remote address binding to the specified local address.
      Specified by:
        `connect` in interface `IoConnector`
      Returns:
        the `ConnectFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

    - #### connect

          public final ConnectFuture connect(SocketAddress remoteAddress,
                              SocketAddress localAddress,
                              IoSessionInitializer<? extends ConnectFuture> sessionInitializer)

      Connects to the specified remote address binding to the specified local address and and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked. There is no guarantee that the `ioSessionInitializer` will be invoked before this method returns.
      Specified by:
        `connect` in interface `IoConnector`
      Parameters:
        `remoteAddress` - the remote address to connect to
        `localAddress` - the local interface to bind to
        `sessionInitializer` - the callback to invoke when the `IoSession` object is created
      Returns:
        the `ConnectFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

    - #### connect0

          protected abstract ConnectFuture connect0(SocketAddress remoteAddress,
                               SocketAddress localAddress,
                               IoSessionInitializer<? extends ConnectFuture> sessionInitializer)

      Implement this method to perform the actual connect operation.
      Parameters:
        `localAddress` - `null` if no local address is specified

    - #### finishSessionInitialization0

          protected final void finishSessionInitialization0(IoSession session,
                                          IoFuture future)

      Adds required internal attributes and `IoFutureListener`s related with event notifications to the specified `session` and `future`. Do not call this method directly; `#finishSessionInitialization(IoSession, IoFuture, IoSessionInitializer)` will call this method instead.
      Overrides:
        `finishSessionInitialization0` in class `AbstractIoService`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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