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, Kazuki Shimizu, Christian Tzolov, Ngoc Nhan
-
Field Summary
Fields inherited from class org.springframework.integration.ip.tcp.connection.TcpConnectionSupport
logger -
Constructor Summary
ConstructorsConstructorDescriptionTcpConnectionInterceptorSupport(ApplicationEventPublisher applicationEventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNewConnection(TcpConnection connection) When we are using sockets owned by aTcpListener, this method is called each time a new connection is made.voidclose()Close this connection.Deserializer<?> Uses the deserializer to obtain the message payload from the connection's input stream.intgetPort()Return the list of senders.Serializer<?> Provides getters forSocketproperties.Return the underlying connection (or next interceptor).protected booleanlongbooleanisOpen()booleanisServer()booleanCalled by a TCPConnection when a new message arrives.voidregisterListener(TcpListener listener) Set the listener that will receive incoming Messages.voidregisterSender(TcpSender sender) Register a sender.voidregisterSenders(List<TcpSender> sendersToRegister) Register the senders.voidremoveDeadConnection(TcpConnection connection) When we are using sockets owned by aTcpListener, this method is called each time a connection is closed.voidrun()voidConverts and sends the message.voidsetDeserializer(Deserializer<?> deserializer) voidsetMapper(TcpMessageMapper mapper) voidsetSerializer(Serializer<?> serializer) voidsetTheConnection(TcpConnectionSupport theConnection) Set the underlying connection (or next interceptor).Methods inherited from class org.springframework.integration.ip.tcp.connection.TcpConnectionSupport
closeConnection, enableManualListenerRegistration, getMapper, isNoReadErrorOnClose, publishConnectionCloseEvent, publishConnectionExceptionEvent, publishConnectionOpenEvent, publishEvent, registerTestListener, sendExceptionToListener, setNeedsTest, setNoReadErrorOnClose, setWrapped, setWrapper, 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:TcpConnectionSupportClose 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:TcpConnectionSupportRegister 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.
-
registerSenders
Description copied from class:TcpConnectionSupportRegister the senders. Used on server side connections so a sender can determine which connection to send a reply to.- Overrides:
registerSendersin classTcpConnectionSupport- Parameters:
sendersToRegister- the sender.
-
getConnectionId
IMPORTANT: Do not override this method in your interceptor implementation if the intercepted connection is created by a server connection factory, because the connection id of the underlying connection is used for routing when arbitrary outbound messaging is being used. The method is not final because client-side interceptors can override it without any issues.
- 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
-
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
Return the underlying connection (or next interceptor).- Returns:
- the connection
-
setTheConnection
Set 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.
-
getSenders
Description copied from class:TcpConnectionSupportReturn the list of senders.- Overrides:
getSendersin classTcpConnectionSupport- Returns:
- the senders.
-
hasRealSender
protected boolean hasRealSender()
-