org.apache.mina.common
Class AbstractIoConnector

java.lang.Object
  extended by org.apache.mina.common.AbstractIoService
      extended by org.apache.mina.common.AbstractIoConnector
All Implemented Interfaces:
IoConnector, IoService
Direct Known Subclasses:
AbstractPollingIoConnector, VmPipeConnector

public abstract class AbstractIoConnector
extends AbstractIoService
implements IoConnector

A base implementation of IoConnector.

Version:
$Rev: 607163 $, $Date: 2007-12-28 04:20:07 +0100 (Fri, 28 Dec 2007) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.mina.common.AbstractIoService
AbstractIoService.ServiceOperationFuture
 
Constructor Summary
protected AbstractIoConnector(IoSessionConfig sessionConfig)
           
 
Method Summary
 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 IoFutureListeners related with event notifications to the specified session and future.
 int getConnectTimeout()
          Returns the connect timeout in seconds.
 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)
          Sets the connect timeout in seconds.
 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.common.AbstractIoService
addListener, broadcast, decreaseScheduledWriteMessages, dispose, dispose0, finishSessionInitialization, getActivationTime, getBothIdleCount, getBothIdleTime, getBothIdleTimeInMillis, getCumulativeManagedSessionCount, getFilterChain, getFilterChainBuilder, getHandler, getIdleCount, getIdleTime, getIdleTimeInMillis, getLargestManagedSessionCount, getLargestReadBytesThroughput, getLargestReadMessagesThroughput, getLargestWrittenBytesThroughput, getLargestWrittenMessagesThroughput, getLastBothIdleTime, getLastIdleTime, getLastIoTime, getLastReaderIdleTime, getLastReadTime, getLastWriterIdleTime, getLastWriteTime, getListeners, getManagedSessionCount, getManagedSessions, getReadBytes, getReadBytesThroughput, getReaderIdleCount, getReaderIdleTime, getReaderIdleTimeInMillis, getReadMessages, getReadMessagesThroughput, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getThroughputCalculationInterval, getThroughputCalculationIntervalInMillis, getWriterIdleCount, getWriterIdleTime, getWriterIdleTimeInMillis, getWrittenBytes, getWrittenBytesThroughput, getWrittenMessages, getWrittenMessagesThroughput, increaseReadBytes, increaseReadMessages, increaseScheduledWriteBytes, increaseScheduledWriteMessages, increaseWrittenBytes, increaseWrittenMessages, isActive, isBothIdle, isDisposed, isDisposing, isIdle, isReaderIdle, isWriterIdle, notifyIdleness, removeListener, setBothIdleTime, setFilterChainBuilder, setHandler, setIdleTime, setLastReadTime, setLastWriteTime, setReaderIdleTime, setSessionDataStructureFactory, setThroughputCalculationInterval, setWriterIdleTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.mina.common.IoService
addListener, broadcast, dispose, getActivationTime, getBothIdleCount, getBothIdleTime, getBothIdleTimeInMillis, getCumulativeManagedSessionCount, getFilterChain, getFilterChainBuilder, getHandler, getIdleCount, getIdleTime, getIdleTimeInMillis, getLargestManagedSessionCount, getLargestReadBytesThroughput, getLargestReadMessagesThroughput, getLargestWrittenBytesThroughput, getLargestWrittenMessagesThroughput, getLastBothIdleTime, getLastIdleTime, getLastIoTime, getLastReaderIdleTime, getLastReadTime, getLastWriterIdleTime, getLastWriteTime, getManagedSessionCount, getManagedSessions, getReadBytes, getReadBytesThroughput, getReaderIdleCount, getReaderIdleTime, getReaderIdleTimeInMillis, getReadMessages, getReadMessagesThroughput, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getThroughputCalculationInterval, getThroughputCalculationIntervalInMillis, getTransportMetadata, getWriterIdleCount, getWriterIdleTime, getWriterIdleTimeInMillis, getWrittenBytes, getWrittenBytesThroughput, getWrittenMessages, getWrittenMessagesThroughput, isActive, isBothIdle, isDisposed, isDisposing, isIdle, isReaderIdle, isWriterIdle, removeListener, setBothIdleTime, setFilterChainBuilder, setHandler, setIdleTime, setReaderIdleTime, setSessionDataStructureFactory, setThroughputCalculationInterval, setWriterIdleTime
 

Constructor Detail

AbstractIoConnector

protected AbstractIoConnector(IoSessionConfig sessionConfig)
Method Detail

getConnectTimeout

public final int getConnectTimeout()
Description copied from interface: IoConnector
Returns the connect timeout in seconds. The default value is 1 minute.

Specified by:
getConnectTimeout in interface IoConnector

getConnectTimeoutMillis

public final long getConnectTimeoutMillis()
Description copied from interface: IoConnector
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)
Description copied from interface: IoConnector
Sets the connect timeout in seconds. The default value is 1 minute.

Specified by:
setConnectTimeout in interface IoConnector

getDefaultRemoteAddress

public SocketAddress getDefaultRemoteAddress()
Description copied from interface: IoConnector
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)
Description copied from interface: IoConnector
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()
Description copied from interface: IoConnector
Connects to the default remote address.

Specified by:
connect in interface IoConnector

connect

public ConnectFuture connect(IoSessionInitializer<? extends ConnectFuture> sessionInitializer)
Description copied from interface: IoConnector
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)
Description copied from interface: IoConnector
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)
Description copied from interface: IoConnector
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)
Description copied from interface: IoConnector
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)
Description copied from interface: IoConnector
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 IoFutureListeners related with event notifications to the specified session and future. Do not call this method directly; AbstractIoService.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-2009 Apache MINA Project. All Rights Reserved.