Class TcpConnectionSupport
java.lang.Object
org.springframework.integration.ip.tcp.connection.TcpConnectionSupport
- All Implemented Interfaces:
- Runnable,- TcpConnection
- Direct Known Subclasses:
- TcpConnectionInterceptorSupport,- TcpNetConnection,- TcpNioConnection
Base class for TcpConnections. TcpConnections are established by
 client connection factories (outgoing) or server connection factories
 (incoming).
- Since:
- 2.0
- Author:
- Gary Russell, Artem Bilan
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionTcpConnectionSupport(Socket socket, boolean server, boolean lookupHost, ApplicationEventPublisher applicationEventPublisher, String connectionFactoryName) Create aTcpConnectionSupportobject and publishes aTcpConnectionOpenEvent, if an event publisher is provided.TcpConnectionSupport(ApplicationEventPublisher applicationEventPublisher) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close this connection.protected voidcloseConnection(boolean isException) If we have been intercepted, propagate the close from the outermost interceptor; otherwise, just call close().voidSet whether or not automatic or manual registration of theTcpListeneris to be used.Deserializer<?> Return the list of senders.Serializer<?> Provides getters forSocketproperties.longprotected booleanbooleanisServer()protected voidprotected voidprotected voidvoidpublishEvent(TcpConnectionEvent event) Allow interceptors etc to publish events, perhaps subclasses of TcpConnectionEvent.voidregisterListener(TcpListener listener) Set the listener that will receive incoming Messages.voidregisterSender(TcpSender senderToRegister) Register a sender.voidregisterSenders(List<TcpSender> sendersToRegister) Register the senders.voidregisterTestListener(TcpListener tListener) Set a temporary listener to receive just the first incoming message.protected final voidvoidsetDeserializer(Deserializer<?> deserializer) voidsetMapper(TcpMessageMapper mapper) voidsetNeedsTest(boolean needsTest) Set to true to use a temporary listener for just the first incoming message.protected voidsetNoReadErrorOnClose(boolean noReadErrorOnClose) voidsetSerializer(Serializer<?> serializer) voidsetWrapped(boolean wrapped) Set to true if intercepted.voidsetWrapper(TcpConnectionSupport wrapper) Set the wrapper.toString()Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.ip.tcp.connection.TcpConnectiongetDeserializerStateKey, getPayload, getPort, getSslSession, isOpen, send, shutdownInput, shutdownOutput
- 
Field Details- 
logger
 
- 
- 
Constructor Details- 
TcpConnectionSupportpublic TcpConnectionSupport()
- 
TcpConnectionSupport
- 
TcpConnectionSupportpublic TcpConnectionSupport(Socket socket, boolean server, boolean lookupHost, @Nullable ApplicationEventPublisher applicationEventPublisher, @Nullable String connectionFactoryName) Create aTcpConnectionSupportobject and publishes aTcpConnectionOpenEvent, if an event publisher is provided.- Parameters:
- socket- the underlying socket.
- server- true if this connection is a server connection
- lookupHost- 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.
 
 
- 
- 
Method Details- 
close
- 
closeConnectionprotected void closeConnection(boolean isException) If we have been intercepted, propagate the close from the outermost interceptor; otherwise, just call close().- Parameters:
- isException- true when this call is the result of an Exception.
 
- 
getMapper- Returns:
- the mapper
 
- 
setMapper- Parameters:
- mapper- the mapper to set
 
- 
getDeserializer- Specified by:
- getDeserializerin interface- TcpConnection
- Returns:
- the deserializer
 
- 
setDeserializer- Parameters:
- deserializer- the deserializer to set
 
- 
getSerializer- Specified by:
- getSerializerin interface- TcpConnection
- Returns:
- the serializer
 
- 
setSerializer- Parameters:
- serializer- the serializer to set
 
- 
setNeedsTestpublic void setNeedsTest(boolean needsTest) Set to true to use a temporary listener for just the first incoming message.- Parameters:
- needsTest- true for a temporary listener.
- Since:
- 5.3
 
- 
registerListenerSet the listener that will receive incoming Messages.- Parameters:
- listener- The listener.
 
- 
registerTestListenerSet a temporary listener to receive just the first incoming message. Used in conjunction with a connectionTest in a client connection factory.- Parameters:
- tListener- the test listener.
- Since:
- 5.3
 
- 
enableManualListenerRegistrationpublic void enableManualListenerRegistration()Set whether or not automatic or manual registration of theTcpListeneris to be used. (Default automatic). When manual registration is in place, incoming messages will be delayed until the listener is registered.- Since:
- 1.4.5
 
- 
registerSender
- 
registerSenders
- 
getListener- Specified by:
- getListenerin interface- TcpConnection
- Returns:
- the listener
 
- 
getSender
- 
getSenders
- 
isServerpublic boolean isServer()- Specified by:
- isServerin interface- TcpConnection
- Returns:
- True if connection is used once.
 
- 
incrementAndGetConnectionSequencepublic long incrementAndGetConnectionSequence()- Specified by:
- incrementAndGetConnectionSequencein interface- TcpConnection
- Returns:
- the next sequence number for a message received on this socket
 
- 
getHostAddress- Specified by:
- getHostAddressin interface- TcpConnection
- Returns:
- the host address
 
- 
getHostName- Specified by:
- getHostNamein interface- TcpConnection
- Returns:
- the host name
 
- 
getConnectionId- Specified by:
- getConnectionIdin interface- TcpConnection
- Returns:
- a string uniquely representing a connection.
 
- 
getSocketInfoDescription copied from interface:TcpConnectionProvides getters forSocketproperties.- Specified by:
- getSocketInfoin interface- TcpConnection
- Returns:
- the socketInfo - may be null, for example in interceptors; interceptors should override and delegate to the actual TcpConnection.
- Since:
- 4.2.5
 
- 
setWrappedpublic void setWrapped(boolean wrapped) Set to true if intercepted.- Parameters:
- wrapped- true if wrapped.
- Since:
- 5.4.5
 
- 
setWrapperSet the wrapper.- Parameters:
- wrapper- the wrapper.
- Since:
- 5.4.6
 
- 
getConnectionFactoryName
- 
isNoReadErrorOnCloseprotected boolean isNoReadErrorOnClose()
- 
setNoReadErrorOnCloseprotected void setNoReadErrorOnClose(boolean noReadErrorOnClose) 
- 
sendExceptionToListener
- 
publishConnectionOpenEventprotected void publishConnectionOpenEvent()
- 
publishConnectionCloseEventprotected void publishConnectionCloseEvent()
- 
publishConnectionExceptionEvent
- 
publishEventAllow interceptors etc to publish events, perhaps subclasses of TcpConnectionEvent. The event source must be this connection.- Parameters:
- event- the event to publish.
 
- 
toString
 
-