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, VmPipeConnector
A base implementation of
IoConnector.-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractIoService
AbstractIoService.ServiceOperationFuture -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longThe minimum timeout value that is supported (in milliseconds).private longprivate SocketAddressThe local addressprivate SocketAddressThe remote address we are connected toFields inherited from class AbstractIoService
disposalLock, LOGGER, sessionConfig -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractIoConnector(IoSessionConfig sessionConfig, Executor executor) Constructor forAbstractIoConnector. -
Method Summary
Modifier and TypeMethodDescriptionfinal ConnectFutureconnect()Connects to thedefault remote address.final ConnectFutureconnect(SocketAddress remoteAddress) Connects to the specified remote address.connect(SocketAddress remoteAddress, SocketAddress localAddress) Connects to the specified remote address binding to the specified local address.final ConnectFutureconnect(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer) Connects to the specified remote address binding to the specified local address and and invokes theioSessionInitializerwhen the IoSession is created but beforeIoHandler.sessionCreated(IoSession)is invoked.connect(SocketAddress remoteAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer) Connects to the specified remote address and invokes theioSessionInitializerwhen the IoSession is created but beforeIoHandler.sessionCreated(IoSession)is invoked.connect(IoSessionInitializer<? extends ConnectFuture> sessionInitializer) Connects to thedefault remote addressand invokes theioSessionInitializerwhen the IoSession is created but beforeIoHandler.sessionCreated(IoSession)is invoked.protected abstract ConnectFutureconnect0(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer) Implement this method to perform the actual connect operation.protected final voidfinishSessionInitialization0(IoSession session, IoFuture future) Adds required internal attributes andIoFutureListeners related with event notifications to the specifiedsessionandfuture.final intDeprecated.longfinal longfinal SocketAddressfinal voidsetConnectTimeout(int connectTimeout) Deprecated.Take a look atsetConnectTimeoutMillis(long)voidsetConnectTimeoutCheckInterval(long minimumConnectTimeout) Sets the timeout for the connection checkfinal voidsetConnectTimeoutMillis(long connectTimeoutInMillis) Sets the connect timeout value in milliseconds.final voidsetDefaultLocalAddress(SocketAddress localAddress) Sets the default local addressfinal voidsetDefaultRemoteAddress(SocketAddress defaultRemoteAddress) Sets the default remote address to connect to when no argument is specified inIoConnector.connect()method.toString()Methods inherited from class AbstractIoService
addListener, broadcast, dispose, dispose, dispose0, executeWorker, executeWorker, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactoryMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface IoService
addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, getTransportMetadata, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
-
Field Details
-
connectTimeoutCheckInterval
private long connectTimeoutCheckIntervalThe minimum timeout value that is supported (in milliseconds). -
connectTimeoutInMillis
private long connectTimeoutInMillis -
defaultRemoteAddress
The remote address we are connected to -
defaultLocalAddress
The local address
-
-
Constructor Details
-
AbstractIoConnector
Constructor forAbstractIoConnector. You need to provide a default session configuration and anExecutorfor handling I/O events. If nullExecutoris provided, a default one will be created usingExecutors.newCachedThreadPool().
-
-
Method Details
-
getConnectTimeoutCheckInterval
public long getConnectTimeoutCheckInterval()- Returns:
- The minimum time that this connector can have for a connection timeout in milliseconds.
-
setConnectTimeoutCheckInterval
public void setConnectTimeoutCheckInterval(long minimumConnectTimeout) Sets the timeout for the connection check- Parameters:
minimumConnectTimeout- The delay we wait before checking the connection
-
getConnectTimeout
Deprecated.Take a look atgetConnectTimeoutMillis()- Specified by:
getConnectTimeoutin interfaceIoConnector- Returns:
- the connect timeout in seconds. The default value is 1 minute.
-
getConnectTimeoutMillis
public final long getConnectTimeoutMillis()- Specified by:
getConnectTimeoutMillisin interfaceIoConnector- Returns:
- the connect timeout in milliseconds. The default value is 1 minute.
-
setConnectTimeout
Deprecated.Take a look atsetConnectTimeoutMillis(long)Description copied from interface:IoConnectorSets the connect timeout in seconds. The default value is 1 minute.- Specified by:
setConnectTimeoutin interfaceIoConnector- Parameters:
connectTimeout- The time out for the connection
-
setConnectTimeoutMillis
public final void setConnectTimeoutMillis(long connectTimeoutInMillis) Sets the connect timeout value in milliseconds.- Specified by:
setConnectTimeoutMillisin interfaceIoConnector- Parameters:
connectTimeoutInMillis- The time out for the connection
-
getDefaultRemoteAddress
- Specified by:
getDefaultRemoteAddressin interfaceIoConnector- Returns:
- the default remote address to connect to when no argument
is specified in
IoConnector.connect()method.
-
setDefaultLocalAddress
Sets the default local address- Specified by:
setDefaultLocalAddressin interfaceIoConnector- Parameters:
localAddress- The default local address
-
getDefaultLocalAddress
- Specified by:
getDefaultLocalAddressin interfaceIoConnector- Returns:
- the default local address
-
setDefaultRemoteAddress
Sets the default remote address to connect to when no argument is specified inIoConnector.connect()method.- Specified by:
setDefaultRemoteAddressin interfaceIoConnector- Parameters:
defaultRemoteAddress- The default remote address
-
connect
Connects to thedefault remote address.- Specified by:
connectin interfaceIoConnector- Returns:
- the
ConnectFutureinstance which is completed when the connection attempt initiated by this call succeeds or fails.
-
connect
Connects to thedefault remote addressand invokes theioSessionInitializerwhen the IoSession is created but beforeIoHandler.sessionCreated(IoSession)is invoked. There is no guarantee that theioSessionInitializerwill be invoked before this method returns.- Specified by:
connectin interfaceIoConnector- Parameters:
sessionInitializer- the callback to invoke when theIoSessionobject is created- Returns:
- the
ConnectFutureinstance which is completed when the connection attempt initiated by this call succeeds or fails.
-
connect
Connects to the specified remote address.- Specified by:
connectin interfaceIoConnector- Parameters:
remoteAddress- The remote address to connect to- Returns:
- the
ConnectFutureinstance 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 theioSessionInitializerwhen the IoSession is created but beforeIoHandler.sessionCreated(IoSession)is invoked. There is no guarantee that theioSessionInitializerwill be invoked before this method returns.- Specified by:
connectin interfaceIoConnector- Parameters:
remoteAddress- the remote address to connect tosessionInitializer- the callback to invoke when theIoSessionobject is created- Returns:
- the
ConnectFutureinstance which is completed when the connection attempt initiated by this call succeeds or fails.
-
connect
Connects to the specified remote address binding to the specified local address.- Specified by:
connectin interfaceIoConnector- Parameters:
remoteAddress- The remote address to connectlocalAddress- The local address to bind- Returns:
- the
ConnectFutureinstance 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 theioSessionInitializerwhen the IoSession is created but beforeIoHandler.sessionCreated(IoSession)is invoked. There is no guarantee that theioSessionInitializerwill be invoked before this method returns.- Specified by:
connectin interfaceIoConnector- Parameters:
remoteAddress- the remote address to connect tolocalAddress- the local interface to bind tosessionInitializer- the callback to invoke when theIoSessionobject is created- Returns:
- the
ConnectFutureinstance 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:
remoteAddress- The remote address to connect fromlocalAddress-nullif no local address is specifiedsessionInitializer- The IoSessionInitializer to use when the connection s successful- Returns:
- The ConnectFuture associated with this asynchronous operation
-
finishSessionInitialization0
Adds required internal attributes andIoFutureListeners related with event notifications to the specifiedsessionandfuture. Do not call this method directly;- Overrides:
finishSessionInitialization0in classAbstractIoService- Parameters:
session- The session to initializefuture- The Future to use
-
toString
-
getConnectTimeoutMillis()