public abstract class ConnectionFactory extends Object
Factory that controls creation of MINA NioSocketConnector
connections.
This will allow us to reuse NioSocketConnector
instances to improve
performance and avoid file handle leaks caused by using too many NioSocketConnector
instances simultaneously.
Because of the way that the MINA API works, there will be one ConnectionFactory
for each discrete connection timeout value.
Modifier | Constructor and Description |
---|---|
protected |
ConnectionFactory(int timeoutInMillis)
Create a new factory.
|
Modifier and Type | Method and Description |
---|---|
abstract 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 abstract void |
dispose()
Dispose of any resources that are held by the connection.
|
static void |
dispose(ConnectionFactory factory)
Free up the resources used by a connection and connection factory.
|
static ConnectionFactory |
getFactory(int timeoutInMillis)
Get a new ConnectionFactory.
|
long |
getTimeout() |
abstract 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)
Retry a connection.
|
protected ConnectionFactory(int timeoutInMillis)
getFactory(int)
public final long getTimeout()
public static final ConnectionFactory getFactory(int timeoutInMillis)
Get a new ConnectionFactory. If there is already a Factory with the desired timeout, you will get that one; otherwise a new one is created.
If org.opennms.netmgt.provision.maxConcurrentConnectors is set, this may block until a connector is available.
timeoutInMillis
- Connection timeoutpublic abstract 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 the ConnectionFactory
when done
by calling dispose(ConnectionFactory)
.
remoteAddress
- Destination addressinit
- Initialiser for the IoSessionpublic abstract 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)
InterruptedException
. Use only if you have already
acquired a connection slot using #connect(SocketAddress, IoSessionInitializer)
.remoteAddress
- init
- protected abstract void dispose()
public static final void dispose(ConnectionFactory factory)
factory
- connection
- Copyright © 2021. All rights reserved.