Class SocketConnector
- java.lang.Object
-
- org.apache.mina.common.support.BaseIoService
-
- org.apache.mina.common.support.BaseIoConnector
-
- org.apache.mina.transport.socket.nio.SocketConnector
-
- All Implemented Interfaces:
IoConnector,IoService
public class SocketConnector extends BaseIoConnector
IoConnectorfor socket transport (TCP/IP).
-
-
Constructor Summary
Constructors Constructor Description SocketConnector()Create a connector with a single processing thread using a NewThreadExecutorSocketConnector(int processorCount, java.util.concurrent.Executor executor)Create a connector with the desired number of processing threads
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectFutureconnect(java.net.SocketAddress address, java.net.SocketAddress localAddress, IoHandler handler, IoServiceConfig config)Connects to the specifiedaddress.ConnectFutureconnect(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config)Connects to the specifiedaddress.SocketConnectorConfiggetDefaultConfig()Returns the default configuration which is used when you didn't specify any configuration.intgetWorkerTimeout()How many seconds to keep the connection thread alive between connection requestsvoidsetDefaultConfig(SocketConnectorConfig defaultConfig)Sets the config this connector will use by default.voidsetWorkerTimeout(int workerTimeout)Set how many seconds the connection worker thread should remain alive once idle before terminating itself.-
Methods inherited from class org.apache.mina.common.support.BaseIoConnector
connect, connect
-
Methods inherited from class org.apache.mina.common.support.BaseIoService
addListener, getFilterChain, getFilterChainBuilder, getListeners, getManagedServiceAddresses, getManagedSessions, isManaged, removeListener, setFilterChainBuilder
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.mina.common.IoService
addListener, getFilterChain, getFilterChainBuilder, getManagedServiceAddresses, getManagedSessions, isManaged, removeListener, setFilterChainBuilder
-
-
-
-
Constructor Detail
-
SocketConnector
public SocketConnector()
Create a connector with a single processing thread using a NewThreadExecutor
-
SocketConnector
public SocketConnector(int processorCount, java.util.concurrent.Executor executor)Create a connector with the desired number of processing threads- Parameters:
processorCount- Number of processing threadsexecutor- Executor to use for launching threads
-
-
Method Detail
-
getWorkerTimeout
public int getWorkerTimeout()
How many seconds to keep the connection thread alive between connection requests- Returns:
- the number of seconds to keep connection thread alive. 0 means that the connection thread will terminate immediately when there's no connection to make.
-
setWorkerTimeout
public void setWorkerTimeout(int workerTimeout)
Set how many seconds the connection worker thread should remain alive once idle before terminating itself.- Parameters:
workerTimeout- the number of seconds to keep thread alive. Must be >=0. If 0 is specified, the connection worker thread will terminate immediately when there's no connection to make.
-
connect
public ConnectFuture connect(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config)
Description copied from interface:IoConnectorConnects to the specifiedaddress. If communication starts successfully, events are fired to the specifiedhandler.config- the configuration- Returns:
ConnectFuturethat will tell the result of the connection attempt
-
connect
public ConnectFuture connect(java.net.SocketAddress address, java.net.SocketAddress localAddress, IoHandler handler, IoServiceConfig config)
Description copied from interface:IoConnectorConnects to the specifiedaddress. If communication starts successfully, events are fired to the specifiedhandler.config- the configuration- Returns:
ConnectFuturethat will tell the result of the connection attempt
-
getDefaultConfig
public SocketConnectorConfig getDefaultConfig()
Description copied from interface:IoServiceReturns the default configuration which is used when you didn't specify any configuration.
-
setDefaultConfig
public void setDefaultConfig(SocketConnectorConfig defaultConfig)
Sets the config this connector will use by default.- Parameters:
defaultConfig- the default config.- Throws:
java.lang.NullPointerException- if the specified value isnull.
-
-