public class TcpNetConnection extends TcpConnectionSupport implements SchedulingAwareRunnable
Socket
.logger
Constructor and Description |
---|
TcpNetConnection(Socket socket,
boolean server,
boolean lookupHost,
ApplicationEventPublisher applicationEventPublisher,
String connectionFactoryName)
Construct 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, getSenders, getSerializer, getSocketInfo, incrementAndGetConnectionSequence, isNoReadErrorOnClose, isServer, publishConnectionCloseEvent, publishConnectionExceptionEvent, publishConnectionOpenEvent, publishEvent, registerListener, registerSender, registerSenders, registerTestListener, sendExceptionToListener, setDeserializer, setMapper, setNeedsTest, setNoReadErrorOnClose, setSerializer, toString
public TcpNetConnection(Socket socket, boolean server, boolean lookupHost, @Nullable 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 SchedulingAwareRunnable
public void close()
close
in interface TcpConnection
close
in class TcpConnectionSupport
public boolean isOpen()
isOpen
in interface TcpConnection
public void send(Message<?> message)
TcpConnection
send
in interface TcpConnection
message
- The message,public Object getPayload()
TcpConnection
getPayload
in interface TcpConnection
public int getPort()
getPort
in interface TcpConnection
@Nullable public Object getDeserializerStateKey()
getDeserializerStateKey
in interface TcpConnection
Deserializer
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 TcpConnection
SSLSession
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 TcpConnection
IOException
- an IO Exception.Socket.shutdownInput()
public void shutdownOutput() throws IOException
shutdownOutput
in interface TcpConnection
IOException
- an IO ExceptionSocket.shutdownOutput()