Class SocketListenerManager
- java.lang.Object
-
- org.simpleframework.transport.connect.SocketListenerManager
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
class SocketListenerManager extends java.lang.Object implements java.io.CloseableTheSocketListenerManagercontains 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 TraceAnalyzeranalyzerThis is the analyzer used to create a trace for the sockets.private java.util.Set<SocketListener>listenersThis is the set of active socket listeners for this manager.private SocketProcessorprocessorThis is the processor that listeners will dispatch sockets to.
-
Constructor Summary
Constructors Constructor Description SocketListenerManager(SocketProcessor processor, TraceAnalyzer analyzer)Constructor for theSocketListenerManagerobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This is used to close all the listeners that have been added to the connection.java.net.SocketAddresslisten(java.net.SocketAddress address)This creates a new background task that will listen to the specifiedServerAddressfor incoming TCP connect requests.java.net.SocketAddresslisten(java.net.SocketAddress address, javax.net.ssl.SSLContext context)This creates a new background task that will listen to the specifiedServerAddressfor incoming TCP connect requests.
-
-
-
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 theSocketListenerManagerobject. 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 Detail
-
listen
public java.net.SocketAddress listen(java.net.SocketAddress address) throws java.io.IOExceptionThis creates a new background task that will listen to the specifiedServerAddressfor 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.IOExceptionThis creates a new background task that will listen to the specifiedServerAddressfor 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:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionThis 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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException- thrown if there is an error closing
-
-