Class ConnectionFactoryConnectorPoolImpl
- java.lang.Object
-
- org.opennms.netmgt.provision.support.ConnectionFactory
-
- org.opennms.netmgt.provision.support.ConnectionFactoryConnectorPoolImpl
-
public class ConnectionFactoryConnectorPoolImpl extends ConnectionFactory
Factory for encapsulating a
NioSocketConnector
in such a way as to allow us to reuse the connector for each#connect(SocketAddress, SocketAddress, IoSessionInitializer, IoHandler)
call.There will be one ConnectionFactory for each discrete connection timeout value.
- Author:
- Seth, ranger, Duncan Mackintosh
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConnectionFactoryConnectorPoolImpl(int timeoutInMillis)
Create a new factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.mina.core.future.ConnectFuture
connect(SocketAddress remoteAddress, org.apache.mina.core.session.IoSessionInitializer<? extends org.apache.mina.core.future.ConnectFuture> init, org.apache.mina.core.service.IoHandler handler)
Connect to a remote socket.protected void
dispose()
Dispose of any resources that are held by the connection.org.apache.mina.core.future.ConnectFuture
reConnect(SocketAddress remoteAddress, org.apache.mina.core.session.IoSessionInitializer<? extends org.apache.mina.core.future.ConnectFuture> init, org.apache.mina.core.service.IoHandler handler)
Delegates completely to#connect(SocketAddress, SocketAddress, IoSessionInitializer, IoHandler)
since we are reusing the same connector for all invocations.-
Methods inherited from class org.opennms.netmgt.provision.support.ConnectionFactory
dispose, getFactory, getTimeout
-
-
-
-
Constructor Detail
-
ConnectionFactoryConnectorPoolImpl
protected ConnectionFactoryConnectorPoolImpl(int timeoutInMillis)
Create a new factory. Private because one should useConnectionFactory.getFactory(int)
-
-
Method Detail
-
connect
public org.apache.mina.core.future.ConnectFuture connect(SocketAddress remoteAddress, org.apache.mina.core.session.IoSessionInitializer<? extends org.apache.mina.core.future.ConnectFuture> init, org.apache.mina.core.service.IoHandler handler)
Connect to a remote socket. If org.opennms.netmgt.provision.maxConcurrentConnections is set, this may block until a connection slot is available.
You must dispose both the
ConnectionFactoryConnectorPoolImpl
andConnectFuture
when done by calling#dispose(ConnectionFactoryConnectorPoolImpl, ConnectFuture)
.- Specified by:
connect
in classConnectionFactory
- Parameters:
remoteAddress
- Destination addressinit
- Initialiser for the IoSession- Returns:
- ConnectFuture from a Mina connect call
-
reConnect
public org.apache.mina.core.future.ConnectFuture reConnect(SocketAddress remoteAddress, org.apache.mina.core.session.IoSessionInitializer<? extends org.apache.mina.core.future.ConnectFuture> init, org.apache.mina.core.service.IoHandler handler)
Delegates completely to#connect(SocketAddress, SocketAddress, IoSessionInitializer, IoHandler)
since we are reusing the same connector for all invocations.- Specified by:
reConnect
in classConnectionFactory
- Parameters:
remoteAddress
-localAddress
-init
-handler
-- Returns:
-
dispose
protected void dispose()
Description copied from class:ConnectionFactory
Dispose of any resources that are held by the connection.- Specified by:
dispose
in classConnectionFactory
-
-