Package biz.onixs.util.network
Class NetworkFactory
- java.lang.Object
-
- biz.onixs.util.network.NetworkFactory
-
public class NetworkFactory extends Object
A factory class for creating network-related objects such as acceptors, socket connectors, and TCP connections.
-
-
Constructor Summary
Constructors Constructor Description NetworkFactory(int threadCount, long spinningTimeout, boolean isDaemon)Creates a new NetworkFactory with the specified number of threads, spinning timeout, and daemon thread flag for the services network-related object use.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Shuts down the factory, releasing any resources that were created by it.AcceptormakeAcceptor(ExternalService externalService)Creates a newAcceptorobject.SocketConnectormakeSocketConnector(String host, int port, long timeout, TimeUnit timeUnit, PortRange localPortRange, SocketAddress bindAddr, ProxySettings proxySettings)Creates a newSocketConnectorobject with the specified parameters.TcpConnectionmakeTcpConnection(Socket socket, SSLEngine sslEngine, ConnectionMode mode, ExternalService externalService)Creates a newTcpConnectionobject with the specified parameters.
-
-
-
Constructor Detail
-
NetworkFactory
public NetworkFactory(int threadCount, long spinningTimeout, boolean isDaemon)Creates a new NetworkFactory with the specified number of threads, spinning timeout, and daemon thread flag for the services network-related object use.- Parameters:
threadCount- the number of threads to use for servicesspinningTimeout- the timeout to use for spinning in servicesisDaemon- a flag indicating whether the services threads should be daemon threads
-
-
Method Detail
-
close
public void close()
Shuts down the factory, releasing any resources that were created by it.
-
makeAcceptor
public Acceptor makeAcceptor(ExternalService externalService)
Creates a newAcceptorobject.- Parameters:
externalService- external service to handle acceptor events- Returns:
- a new
Acceptorobject
-
makeSocketConnector
public SocketConnector makeSocketConnector(String host, int port, long timeout, TimeUnit timeUnit, PortRange localPortRange, SocketAddress bindAddr, ProxySettings proxySettings)
Creates a newSocketConnectorobject with the specified parameters.- Parameters:
host- the hostname or IP address to connect toport- the port to connect totimeout- the timeout for the connection attempttimeUnit- the time unit for the timeoutlocalPortRange- the local port range to use for the connectionbindAddr- the local address to bind toproxySettings- theProxySettingsto be used, null if no proxy needed- Returns:
- a new
SocketConnectorobject
-
makeTcpConnection
public TcpConnection makeTcpConnection(Socket socket, SSLEngine sslEngine, ConnectionMode mode, ExternalService externalService)
Creates a newTcpConnectionobject with the specified parameters.- Parameters:
socket- theSocketto use for the connectionsslEngine- the SSLEngine to use for SSL/TLS connectionsmode- the connection mode (seeConnectionMode)externalService- the external service to handle connection events- Returns:
- a new
TcpConnectionobject
-
-