public class TcpNetConnection extends TcpConnectionSupport
Socket
.logger
Constructor and Description |
---|
TcpNetConnection(java.net.Socket socket,
boolean server,
boolean lookupHost)
Deprecated.
Use
TcpNetConnection(Socket, boolean, boolean, ApplicationEventPublisher, String)
TODO: Remove in 3.1/4.0 |
TcpNetConnection(java.net.Socket socket,
boolean server,
boolean lookupHost,
org.springframework.context.ApplicationEventPublisher applicationEventPublisher,
java.lang.String connectionFactoryName)
Constructs a TcpNetConnection for the socket.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this connection.
|
java.lang.Object |
getDeserializerStateKey() |
java.lang.Object |
getPayload()
Uses the deserializer to obtain the message payload
from the connection's input stream.
|
int |
getPort() |
protected boolean |
handleReadException(java.lang.Exception e) |
boolean |
isOpen() |
void |
run()
If there is no listener, and this connection is not for single use,
this method exits.
|
void |
send(Message<?> message)
Converts and sends the message.
|
afterSend, closeConnection, getConnectionId, getDeserializer, getHostAddress, getHostName, getListener, getMapper, getSender, getSerializer, incrementAndGetConnectionSequence, isNoReadErrorOnClose, isServer, isSingleUse, publishConnectionCloseEvent, publishConnectionExceptionEvent, publishConnectionOpenEvent, publishEvent, registerListener, registerSender, sendExceptionToListener, setDeserializer, setMapper, setNoReadErrorOnClose, setSerializer, setSingleUse
@Deprecated public TcpNetConnection(java.net.Socket socket, boolean server, boolean lookupHost)
TcpNetConnection(Socket, boolean, boolean, ApplicationEventPublisher, String)
TODO: Remove in 3.1/4.0socket
- 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.public TcpNetConnection(java.net.Socket socket, boolean server, boolean lookupHost, org.springframework.context.ApplicationEventPublisher applicationEventPublisher, java.lang.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 void close()
close
in interface TcpConnection
close
in class TcpConnectionSupport
public boolean isOpen()
public void send(Message<?> message) throws java.lang.Exception
TcpConnection
message
- The messagejava.lang.Exception
public java.lang.Object getPayload() throws java.lang.Exception
TcpConnection
java.lang.Exception
public int getPort()
public java.lang.Object getDeserializerStateKey()
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.public void run()
Deserializer
and the listener's
TcpListener.onMessage(Message)
method is called. For single use
connections with no listener, the socket is closed after its timeout
expires. If data is received on a single use socket with no listener,
a warning is logged.protected boolean handleReadException(java.lang.Exception e)