Class SocketListenerManager

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    class SocketListenerManager
    extends java.lang.Object
    implements java.io.Closeable
    The SocketListenerManager contains all the listeners that have been created for a connection. This set is used to hold and manage the listeners that have been created for a connection. All listeners will be closed if the listener manager is closed. This ensures all resources held by the manager can be released.
    See Also:
    SocketConnection
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private TraceAnalyzer analyzer
      This is the analyzer used to create a trace for the sockets.
      private java.util.Set<SocketListener> listeners
      This is the set of active socket listeners for this manager.
      private SocketProcessor processor
      This is the processor that listeners will dispatch sockets to.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      This is used to close all the listeners that have been added to the connection.
      java.net.SocketAddress listen​(java.net.SocketAddress address)
      This creates a new background task that will listen to the specified ServerAddress for incoming TCP connect requests.
      java.net.SocketAddress listen​(java.net.SocketAddress address, javax.net.ssl.SSLContext context)
      This creates a new background task that will listen to the specified ServerAddress for incoming TCP connect requests.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • listeners

        private final java.util.Set<SocketListener> listeners
        This is the set of active socket listeners for this manager.
      • processor

        private final SocketProcessor processor
        This is the processor that listeners will dispatch sockets to.
      • analyzer

        private final TraceAnalyzer analyzer
        This is the analyzer used to create a trace for the sockets.
    • Constructor Detail

      • SocketListenerManager

        public SocketListenerManager​(SocketProcessor processor,
                                     TraceAnalyzer analyzer)
        Constructor for the SocketListenerManager object. This is used to create a manager that will enable listeners to be created to listen to specified sockets for incoming TCP connections, which will be converted to socket objects.
        Parameters:
        processor - this is the processor to hand sockets to
        analyzer - this is the agent used to trace socket events
    • Method Detail

      • listen

        public java.net.SocketAddress listen​(java.net.SocketAddress address)
                                      throws java.io.IOException
        This creates a new background task that will listen to the specified ServerAddress for incoming TCP connect requests. When an connection is accepted it is handed to the internal socket connector.
        Parameters:
        address - this is the address used to accept connections
        Returns:
        this returns the actual local address that is used
        Throws:
        java.io.IOException
      • listen

        public java.net.SocketAddress listen​(java.net.SocketAddress address,
                                             javax.net.ssl.SSLContext context)
                                      throws java.io.IOException
        This creates a new background task that will listen to the specified ServerAddress for incoming TCP connect requests. When an connection is accepted it is handed to the internal socket connector.
        Parameters:
        address - this is the address used to accept connections
        context - this is used for secure SSL connections
        Returns:
        this returns the actual local address that is used
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        This is used to close all the listeners that have been added to the connection. Closing all the listeners in the set ensures that there are no lingering threads or sockets consumed by the connection after the connection is closed.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - thrown if there is an error closing