Class NetworkFactory


  • public class NetworkFactory
    extends Object
    A factory class for creating network-related objects such as acceptors, socket connectors, and TCP connections.
    • 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 services
        spinningTimeout - the timeout to use for spinning in services
        isDaemon - 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 new Acceptor object.
        Parameters:
        externalService - external service to handle acceptor events
        Returns:
        a new Acceptor object
      • makeSocketConnector

        public SocketConnector makeSocketConnector​(String host,
                                                   int port,
                                                   long timeout,
                                                   TimeUnit timeUnit,
                                                   PortRange localPortRange,
                                                   SocketAddress bindAddr,
                                                   ProxySettings proxySettings)
        Creates a new SocketConnector object with the specified parameters.
        Parameters:
        host - the hostname or IP address to connect to
        port - the port to connect to
        timeout - the timeout for the connection attempt
        timeUnit - the time unit for the timeout
        localPortRange - the local port range to use for the connection
        bindAddr - the local address to bind to
        proxySettings - the ProxySettings to be used, null if no proxy needed
        Returns:
        a new SocketConnector object