Class TcpConnectionInterceptorSupport
java.lang.Object
org.springframework.integration.ip.tcp.connection.TcpConnectionSupport
org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorSupport
- All Implemented Interfaces:
Runnable,TcpConnection,TcpConnectionInterceptor,TcpListener,TcpSender
public abstract class TcpConnectionInterceptorSupport extends TcpConnectionSupport implements TcpConnectionInterceptor
Base class for
TcpConnectionInterceptors; passes all method calls through
to the underlying TcpConnection.- Since:
- 2.0
- Author:
- Gary Russell
-
Field Summary
Fields inherited from class org.springframework.integration.ip.tcp.connection.TcpConnectionSupport
logger -
Constructor Summary
Constructors Constructor Description TcpConnectionInterceptorSupport()TcpConnectionInterceptorSupport(ApplicationEventPublisher applicationEventPublisher) -
Method Summary
Modifier and Type Method Description voidaddNewConnection(TcpConnection connection)When we are using sockets owned by aTcpListener, this method is called each time a new connection is made.voidclose()Closes this connection.StringgetConnectionFactoryName()StringgetConnectionId()Deserializer<?>getDeserializer()ObjectgetDeserializerStateKey()StringgetHostAddress()StringgetHostName()TcpListenergetListener()ObjectgetPayload()Uses the deserializer to obtain the message payload from the connection's input stream.intgetPort()TcpSendergetSender()Serializer<?>getSerializer()SocketInfogetSocketInfo()Provides getters forSocketproperties.SSLSessiongetSslSession()TcpConnectionSupportgetTheConnection()Returns the underlying connection (or next interceptor)protected booleanhasRealSender()longincrementAndGetConnectionSequence()booleanisOpen()booleanisServer()booleanonMessage(Message<?> message)Called by a TCPConnection when a new message arrives.voidregisterListener(TcpListener listener)Set the listener that will receive incoming Messages.voidregisterSender(TcpSender sender)Registers a sender.voidremoveDeadConnection(TcpConnection connection)When we are using sockets owned by aTcpListener, this method is called each time a connection is closed.voidrun()voidsend(Message<?> message)Converts and sends the message.voidsetDeserializer(Deserializer<?> deserializer)voidsetMapper(TcpMessageMapper mapper)voidsetSerializer(Serializer<?> serializer)voidsetTheConnection(TcpConnectionSupport theConnection)Sets the underlying connection (or next interceptor)Methods inherited from class org.springframework.integration.ip.tcp.connection.TcpConnectionSupport
closeConnection, enableManualListenerRegistration, getMapper, getSenders, isNoReadErrorOnClose, publishConnectionCloseEvent, publishConnectionExceptionEvent, publishConnectionOpenEvent, publishEvent, registerSenders, registerTestListener, sendExceptionToListener, setNeedsTest, setNoReadErrorOnClose, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.ip.tcp.connection.TcpConnection
shutdownInput, shutdownOutput
-
Constructor Details
-
TcpConnectionInterceptorSupport
public TcpConnectionInterceptorSupport() -
TcpConnectionInterceptorSupport
-
-
Method Details
-
close
public void close()Description copied from class:TcpConnectionSupportCloses this connection.- Specified by:
closein interfaceTcpConnection- Overrides:
closein classTcpConnectionSupport
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceTcpConnection- Returns:
- true if the connection is open.
-
getPayload
Description copied from interface:TcpConnectionUses the deserializer to obtain the message payload from the connection's input stream.- Specified by:
getPayloadin interfaceTcpConnection- Returns:
- The payload.
-
getHostName
- Specified by:
getHostNamein interfaceTcpConnection- Overrides:
getHostNamein classTcpConnectionSupport- Returns:
- the host name
-
getHostAddress
- Specified by:
getHostAddressin interfaceTcpConnection- Overrides:
getHostAddressin classTcpConnectionSupport- Returns:
- the host address
-
getPort
public int getPort()- Specified by:
getPortin interfaceTcpConnection- Returns:
- the port
-
getDeserializerStateKey
- Specified by:
getDeserializerStateKeyin interfaceTcpConnection- Returns:
- a key that can be used to reference state in a
Deserializerthat 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.
-
registerListener
Description copied from class:TcpConnectionSupportSet the listener that will receive incoming Messages.- Overrides:
registerListenerin classTcpConnectionSupport- Parameters:
listener- The listener.
-
registerSender
Description copied from class:TcpConnectionSupportRegisters a sender. Used on server side connections so a sender can determine which connection to send a reply to.- Overrides:
registerSenderin classTcpConnectionSupport- Parameters:
sender- the sender.
-
getConnectionId
- Specified by:
getConnectionIdin interfaceTcpConnection- Overrides:
getConnectionIdin classTcpConnectionSupport- Returns:
- a string uniquely representing a connection.
-
getSocketInfo
Description copied from interface:TcpConnectionProvides getters forSocketproperties.- Specified by:
getSocketInfoin interfaceTcpConnection- Overrides:
getSocketInfoin classTcpConnectionSupport- Returns:
- the socketInfo - may be null, for example in interceptors; interceptors should override and delegate to the actual TcpConnection.
-
getConnectionFactoryName
- Overrides:
getConnectionFactoryNamein classTcpConnectionSupport
-
run
public void run() -
setMapper
- Overrides:
setMapperin classTcpConnectionSupport- Parameters:
mapper- the mapper to set
-
getDeserializer
- Specified by:
getDeserializerin interfaceTcpConnection- Overrides:
getDeserializerin classTcpConnectionSupport- Returns:
- the deserializer
-
setDeserializer
- Overrides:
setDeserializerin classTcpConnectionSupport- Parameters:
deserializer- the deserializer to set
-
getSerializer
- Specified by:
getSerializerin interfaceTcpConnection- Overrides:
getSerializerin classTcpConnectionSupport- Returns:
- the serializer
-
setSerializer
- Overrides:
setSerializerin classTcpConnectionSupport- Parameters:
serializer- the serializer to set
-
isServer
public boolean isServer()- Specified by:
isServerin interfaceTcpConnection- Overrides:
isServerin classTcpConnectionSupport- Returns:
- True if connection is used once.
-
getSslSession
- Specified by:
getSslSessionin interfaceTcpConnection- Returns:
- the
SSLSessionassociated with this connection, if SSL is in use, null otherwise.
-
onMessage
Description copied from interface:TcpListenerCalled by a TCPConnection when a new message arrives.- Specified by:
onMessagein interfaceTcpListener- Parameters:
message- The message.- Returns:
- true if the message was intercepted
-
send
Description copied from interface:TcpConnectionConverts and sends the message.- Specified by:
sendin interfaceTcpConnection- Parameters:
message- The message,
-
getTheConnection
Returns the underlying connection (or next interceptor)- Returns:
- the connection
-
setTheConnection
Sets the underlying connection (or next interceptor)- Parameters:
theConnection- the connection
-
getListener
- Specified by:
getListenerin interfaceTcpConnection- Overrides:
getListenerin classTcpConnectionSupport- Returns:
- the listener
-
addNewConnection
Description copied from interface:TcpSenderWhen we are using sockets owned by aTcpListener, this method is called each time a new connection is made.- Specified by:
addNewConnectionin interfaceTcpSender- Parameters:
connection- The connection.
-
removeDeadConnection
Description copied from interface:TcpSenderWhen we are using sockets owned by aTcpListener, this method is called each time a connection is closed.- Specified by:
removeDeadConnectionin interfaceTcpSender- Parameters:
connection- The connection.
-
incrementAndGetConnectionSequence
public long incrementAndGetConnectionSequence()- Specified by:
incrementAndGetConnectionSequencein interfaceTcpConnection- Overrides:
incrementAndGetConnectionSequencein classTcpConnectionSupport- Returns:
- the next sequence number for a message received on this socket
-
getSender
- Overrides:
getSenderin classTcpConnectionSupport- Returns:
- the first sender, if present.
-
hasRealSender
protected boolean hasRealSender()
-