Class AprSocketAcceptor

    • Constructor Detail

      • AprSocketAcceptor

        public AprSocketAcceptor()
        Constructor for AprSocketAcceptor using default parameters (multiple thread model).
      • AprSocketAcceptor

        public AprSocketAcceptor​(int processorCount)
        Constructor for AprSocketAcceptor using default parameters, and given number of AprIoProcessor for multithreading I/O operations.
        Parameters:
        processorCount - the number of processor to create and place in a SimpleIoProcessorPool
      • AprSocketAcceptor

        public AprSocketAcceptor​(IoProcessor<AprSession> processor)
        Constructor for AprSocketAcceptor with default configuration but a specific AprIoProcessor, useful for sharing the same processor over multiple IoService of the same type.
        Parameters:
        processor - the processor to use for managing I/O events
      • AprSocketAcceptor

        public AprSocketAcceptor​(java.util.concurrent.Executor executor,
                                 IoProcessor<AprSession> processor)
        Constructor for AprSocketAcceptor with a given Executor for handling connection events and a given AprIoProcessor for handling I/O events, useful for sharing the same processor and executor over multiple IoService of the same type.
        Parameters:
        executor - the executor for connection
        processor - the processor for I/O operations
    • Method Detail

      • open

        protected java.lang.Long open​(java.net.SocketAddress localAddress)
                               throws java.lang.Exception
        Open a server socket for a given local address.
        Specified by:
        open in class AbstractPollingIoAcceptor<AprSession,​java.lang.Long>
        Parameters:
        localAddress - the associated local address
        Returns:
        the opened server socket
        Throws:
        java.lang.Exception - any exception thrown by the underlying systems calls
      • init

        protected void init()
                     throws java.lang.Exception
        Initialize the polling system, will be called at construction time.
        Specified by:
        init in class AbstractPollingIoAcceptor<AprSession,​java.lang.Long>
        Throws:
        java.lang.Exception - any exception thrown by the underlying system calls
      • destroy

        protected void destroy()
                        throws java.lang.Exception
        Destroy the polling system, will be called when this IoAcceptor implementation will be disposed.
        Specified by:
        destroy in class AbstractPollingIoAcceptor<AprSession,​java.lang.Long>
        Throws:
        java.lang.Exception - any exception thrown by the underlying systems calls
      • localAddress

        protected java.net.SocketAddress localAddress​(java.lang.Long handle)
                                               throws java.lang.Exception
        Get the local address associated with a given server socket
        Specified by:
        localAddress in class AbstractPollingIoAcceptor<AprSession,​java.lang.Long>
        Parameters:
        handle - the server socket
        Returns:
        the local SocketAddress associated with this handle
        Throws:
        java.lang.Exception - any exception thrown by the underlying systems calls
      • select

        protected int select()
                      throws java.lang.Exception
        Check for acceptable connections, interrupt when at least a server is ready for accepting. All the ready server socket descriptors need to be returned by AbstractPollingIoAcceptor.selectedHandles()
        Specified by:
        select in class AbstractPollingIoAcceptor<AprSession,​java.lang.Long>
        Returns:
        The number of sockets having got incoming client
        Throws:
        java.lang.Exception - any exception thrown by the underlying systems calls
      • close

        protected void close​(java.lang.Long handle)
                      throws java.lang.Exception
        Close a server socket.
        Specified by:
        close in class AbstractPollingIoAcceptor<AprSession,​java.lang.Long>
        Parameters:
        handle - the server socket
        Throws:
        java.lang.Exception - any exception thrown by the underlying systems calls
      • getLocalAddress

        public java.net.InetSocketAddress getLocalAddress()
        Returns the local address which is bound currently. If more than one address are bound, only one of them will be returned, but it's not necessarily the firstly bound address.
        Specified by:
        getLocalAddress in interface IoAcceptor
        Overrides:
        getLocalAddress in class AbstractIoAcceptor
        Returns:
        The bound LocalAddress
      • init

        protected void init​(java.nio.channels.spi.SelectorProvider selectorProvider)
                     throws java.lang.Exception
        Description copied from class: AbstractPollingIoAcceptor
        Initialize the polling system, will be called at construction time.
        Specified by:
        init in class AbstractPollingIoAcceptor<AprSession,​java.lang.Long>
        Parameters:
        selectorProvider - The Selector Provider that will be used by this polling acceptor
        Throws:
        java.lang.Exception - any exception thrown by the underlying system calls