Class SocketListenerManager
java.lang.Object
org.simpleframework.transport.connect.SocketListenerManager
- All Implemented Interfaces:
Closeable
,AutoCloseable
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final TraceAnalyzer
This is the analyzer used to create a trace for the sockets.private final Set
<SocketListener> This is the set of active socket listeners for this manager.private final SocketProcessor
This is the processor that listeners will dispatch sockets to. -
Constructor Summary
ConstructorsConstructorDescriptionSocketListenerManager
(SocketProcessor processor, TraceAnalyzer analyzer) Constructor for theSocketListenerManager
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This is used to close all the listeners that have been added to the connection.listen
(SocketAddress address) This creates a new background task that will listen to the specifiedServerAddress
for incoming TCP connect requests.listen
(SocketAddress address, SSLContext context) This creates a new background task that will listen to the specifiedServerAddress
for incoming TCP connect requests.
-
Field Details
-
listeners
This is the set of active socket listeners for this manager. -
processor
This is the processor that listeners will dispatch sockets to. -
analyzer
This is the analyzer used to create a trace for the sockets.
-
-
Constructor Details
-
SocketListenerManager
Constructor for theSocketListenerManager
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 toanalyzer
- this is the agent used to trace socket events
-
-
Method Details
-
listen
This creates a new background task that will listen to the specifiedServerAddress
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
This creates a new background task that will listen to the specifiedServerAddress
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 connectionscontext
- this is used for secure SSL connections- Returns:
- this returns the actual local address that is used
- Throws:
IOException
-
close
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- thrown if there is an error closing
-