public abstract class TcpConnectionSupport extends Object implements TcpConnection
Constructor and Description |
---|
TcpConnectionSupport() |
TcpConnectionSupport(ApplicationEventPublisher applicationEventPublisher) |
TcpConnectionSupport(Socket socket,
boolean server,
boolean lookupHost,
ApplicationEventPublisher applicationEventPublisher,
String connectionFactoryName)
Creates a
TcpConnectionSupport object and publishes a
TcpConnectionOpenEvent , if an event publisher is provided. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this connection.
|
protected void |
closeConnection(boolean isException)
If we have been intercepted, propagate the close from the outermost interceptor;
otherwise, just call close().
|
void |
enableManualListenerRegistration()
Set whether or not automatic or manual registration of the
TcpListener is to be
used. |
String |
getConnectionFactoryName() |
String |
getConnectionId() |
Deserializer<?> |
getDeserializer() |
String |
getHostAddress() |
String |
getHostName() |
TcpListener |
getListener() |
TcpMessageMapper |
getMapper() |
TcpSender |
getSender() |
List<TcpSender> |
getSenders()
Return the list of senders.
|
Serializer<?> |
getSerializer() |
SocketInfo |
getSocketInfo()
Provides getters for
Socket properties. |
long |
incrementAndGetConnectionSequence() |
protected boolean |
isNoReadErrorOnClose() |
boolean |
isServer() |
protected void |
publishConnectionCloseEvent() |
protected void |
publishConnectionExceptionEvent(Throwable t) |
protected void |
publishConnectionOpenEvent() |
void |
publishEvent(TcpConnectionEvent event)
Allow interceptors etc to publish events, perhaps subclasses of
TcpConnectionEvent.
|
void |
registerListener(TcpListener listener)
Set the listener that will receive incoming Messages.
|
void |
registerSender(TcpSender senderToRegister)
Registers a sender.
|
void |
registerSenders(List<TcpSender> sendersToRegister)
Registers the senders.
|
void |
registerTestListener(TcpListener tListener)
Set a temporary listener to receive just the first incoming message.
|
protected void |
sendExceptionToListener(Exception e) |
void |
setDeserializer(Deserializer<?> deserializer) |
void |
setMapper(TcpMessageMapper mapper) |
void |
setNeedsTest(boolean needsTest)
Set to true to use a temporary listener for just the first incoming message.
|
protected void |
setNoReadErrorOnClose(boolean noReadErrorOnClose) |
void |
setSerializer(Serializer<?> serializer) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDeserializerStateKey, getPayload, getPort, getSslSession, isOpen, send, shutdownInput, shutdownOutput
protected final Log logger
public TcpConnectionSupport()
public TcpConnectionSupport(@Nullable ApplicationEventPublisher applicationEventPublisher)
public TcpConnectionSupport(Socket socket, boolean server, boolean lookupHost, @Nullable ApplicationEventPublisher applicationEventPublisher, @Nullable String connectionFactoryName)
TcpConnectionSupport
object and publishes a
TcpConnectionOpenEvent
, if an event publisher is provided.socket
- the underlying socket.server
- true if this connection is a server connectionlookupHost
- true if reverse lookup of the host name should be performed,
otherwise, the ip address will be used for identification purposes.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
protected void closeConnection(boolean isException)
isException
- true when this call is the result of an Exception.public TcpMessageMapper getMapper()
public void setMapper(TcpMessageMapper mapper)
mapper
- the mapper to setpublic Deserializer<?> getDeserializer()
getDeserializer
in interface TcpConnection
public void setDeserializer(Deserializer<?> deserializer)
deserializer
- the deserializer to setpublic Serializer<?> getSerializer()
getSerializer
in interface TcpConnection
public void setSerializer(Serializer<?> serializer)
serializer
- the serializer to setpublic void setNeedsTest(boolean needsTest)
needsTest
- true for a temporary listener.public void registerListener(@Nullable TcpListener listener)
listener
- The listener.public void registerTestListener(TcpListener tListener)
tListener
- the test listener.public void enableManualListenerRegistration()
TcpListener
is to be
used. (Default automatic). When manual registration is in place, incoming messages will
be delayed until the listener is registered.public void registerSender(@Nullable TcpSender senderToRegister)
senderToRegister
- the sender.public void registerSenders(List<TcpSender> sendersToRegister)
sendersToRegister
- the sender.public TcpListener getListener()
getListener
in interface TcpConnection
public List<TcpSender> getSenders()
public boolean isServer()
isServer
in interface TcpConnection
public long incrementAndGetConnectionSequence()
incrementAndGetConnectionSequence
in interface TcpConnection
public String getHostAddress()
getHostAddress
in interface TcpConnection
public String getHostName()
getHostName
in interface TcpConnection
public String getConnectionId()
getConnectionId
in interface TcpConnection
public SocketInfo getSocketInfo()
TcpConnection
Socket
properties.getSocketInfo
in interface TcpConnection
public String getConnectionFactoryName()
protected boolean isNoReadErrorOnClose()
protected void setNoReadErrorOnClose(boolean noReadErrorOnClose)
protected final void sendExceptionToListener(Exception e)
protected void publishConnectionOpenEvent()
protected void publishConnectionCloseEvent()
protected void publishConnectionExceptionEvent(Throwable t)
public void publishEvent(TcpConnectionEvent event)
event
- the event to publish.