public class TcpNetConnection extends TcpConnectionSupport implements SchedulingAwareRunnable
Socket.logger| Constructor and Description |
|---|
TcpNetConnection(Socket socket,
boolean server,
boolean lookupHost,
ApplicationEventPublisher applicationEventPublisher,
String connectionFactoryName)
Constructs a TcpNetConnection for the socket.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this connection.
|
Object |
getDeserializerStateKey() |
Object |
getPayload()
Uses the deserializer to obtain the message payload
from the connection's input stream.
|
int |
getPort() |
SSLSession |
getSslSession() |
protected boolean |
handleReadException(Exception exception) |
protected InputStream |
inputStream()
Subclasses can override this, for example to wrap the input stream.
|
boolean |
isLongLived() |
boolean |
isOpen() |
void |
run()
If there is no listener, this method exits.
|
void |
send(Message<?> message)
Converts and sends the message.
|
void |
shutdownInput()
Set the socket's input stream to end of stream.
|
void |
shutdownOutput()
Disable the socket's output stream.
|
closeConnection, enableManualListenerRegistration, getConnectionFactoryName, getConnectionId, getDeserializer, getHostAddress, getHostName, getListener, getMapper, getSender, getSerializer, getSocketInfo, incrementAndGetConnectionSequence, isNoReadErrorOnClose, isServer, publishConnectionCloseEvent, publishConnectionExceptionEvent, publishConnectionOpenEvent, publishEvent, registerListener, registerSender, sendExceptionToListener, setDeserializer, setMapper, setNoReadErrorOnClose, setSerializer, toStringpublic TcpNetConnection(Socket socket, boolean server, boolean lookupHost, ApplicationEventPublisher applicationEventPublisher, String connectionFactoryName)
socket - the socketserver - if true this connection was created as
a result of an incoming request.lookupHost - true if hostname lookup should be performed, otherwise the connection will
be identified using the ip address.applicationEventPublisher - the publisher to which OPEN, CLOSE and EXCEPTION events will
be sent; may be null if event publishing is not required.connectionFactoryName - the name of the connection factory creating this connection; used
during event publishing, may be null, in which case "unknown" will be used.public boolean isLongLived()
isLongLived in interface SchedulingAwareRunnablepublic void close()
close in interface TcpConnectionclose in class TcpConnectionSupportpublic boolean isOpen()
isOpen in interface TcpConnectionpublic void send(Message<?> message)
TcpConnectionsend in interface TcpConnectionmessage - The message,public Object getPayload()
TcpConnectiongetPayload in interface TcpConnectionpublic int getPort()
getPort in interface TcpConnection@Nullable public Object getDeserializerStateKey()
getDeserializerStateKey in interface TcpConnectionDeserializer that
maintains state for this connection. Currently, this would be the InputStream
associated with the connection, but the object should be treated as opaque
and ONLY used as a key.@Nullable public SSLSession getSslSession()
getSslSession in interface TcpConnectionSSLSession associated with this connection, if SSL is in use,
null otherwise.protected InputStream inputStream() throws IOException
IOException - if an exception occurs.public void run()
Deserializer and the
listener's TcpListener.onMessage(Message) method is called.protected boolean handleReadException(Exception exception)
public void shutdownInput()
throws IOException
shutdownInput in interface TcpConnectionIOException - an IO Exception.Socket.shutdownInput()public void shutdownOutput()
throws IOException
shutdownOutput in interface TcpConnectionIOException - an IO ExceptionSocket.shutdownOutput()