Class SocketListenerManager

java.lang.Object
org.simpleframework.transport.connect.SocketListenerManager
All Implemented Interfaces:
Closeable, AutoCloseable

class SocketListenerManager extends Object implements 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:
  • Field Details

    • listeners

      private final 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 Details

    • 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 Details

    • listen

      public SocketAddress listen(SocketAddress address) throws 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:
      IOException
    • listen

      public SocketAddress listen(SocketAddress address, SSLContext context) throws 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:
      IOException
    • close

      public void close() throws 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 AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - thrown if there is an error closing