Spring Integration

org.springframework.integration.ip.tcp.connection
Interface TcpConnection

All Superinterfaces:
java.lang.Runnable
All Known Subinterfaces:
TcpConnectionInterceptor
All Known Implementing Classes:
AbstractTcpConnection, AbstractTcpConnectionInterceptor, TcpNetConnection, TcpNioConnection, TcpNioSSLConnection

public interface TcpConnection
extends java.lang.Runnable

An abstraction over Socket and SocketChannel that sends Message objects by serializing the payload and streaming it to the destination. Requires a TcpListener to receive incoming messages.

Since:
2.0
Author:
Gary Russell

Method Summary
 void close()
          Closes the connection.
 java.lang.String getConnectionId()
           
 org.springframework.core.serializer.Deserializer<?> getDeserializer()
           
 java.lang.String getHostAddress()
           
 java.lang.String getHostName()
           
 TcpListener getListener()
           
 java.lang.Object getPayload()
          Uses the deserializer to obtain the message payload from the connection's input stream.
 int getPort()
           
 org.springframework.core.serializer.Serializer<?> getSerializer()
           
 long incrementAndGetConnectionSequence()
           
 boolean isOpen()
           
 boolean isServer()
           
 boolean isSingleUse()
           
 void registerListener(TcpListener listener)
          Sets the listener that will receive incoming Messages.
 void registerSender(TcpSender sender)
          Registers a sender.
 void send(Message<?> message)
          Converts and sends the message.
 void setDeserializer(org.springframework.core.serializer.Deserializer<?> deserializer)
           
 void setMapper(TcpMessageMapper mapper)
           
 void setSerializer(org.springframework.core.serializer.Serializer<?> serializer)
           
 void setSingleUse(boolean singleUse)
          When true, the socket is used once and discarded.
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

close

void close()
Closes the connection.


isOpen

boolean isOpen()
Returns:
true if the connection is open.

send

void send(Message<?> message)
          throws java.lang.Exception
Converts and sends the message.

Parameters:
message - The message
Throws:
java.lang.Exception

getPayload

java.lang.Object getPayload()
                            throws java.lang.Exception
Uses the deserializer to obtain the message payload from the connection's input stream.

Returns:
The payload
Throws:
java.lang.Exception

getHostName

java.lang.String getHostName()
Returns:
the host name

getHostAddress

java.lang.String getHostAddress()
Returns:
the host address

getPort

int getPort()
Returns:
the port

registerListener

void registerListener(TcpListener listener)
Sets the listener that will receive incoming Messages.

Parameters:
listener - The listener

registerSender

void registerSender(TcpSender sender)
Registers a sender. Used on server side sockets so a sender can determine which connection to send a reply to.

Parameters:
sender - the sender

getConnectionId

java.lang.String getConnectionId()
Returns:
a string uniquely representing a connection.

setSingleUse

void setSingleUse(boolean singleUse)
When true, the socket is used once and discarded.

Parameters:
singleUse - the singleUse

isSingleUse

boolean isSingleUse()
Returns:
True if connection is used once.

isServer

boolean isServer()
Returns:
True if connection is used once.

setMapper

void setMapper(TcpMessageMapper mapper)
Parameters:
mapper - the mapper

getDeserializer

org.springframework.core.serializer.Deserializer<?> getDeserializer()
Returns:
the deserializer

setDeserializer

void setDeserializer(org.springframework.core.serializer.Deserializer<?> deserializer)
Parameters:
deserializer - the deserializer to set

getSerializer

org.springframework.core.serializer.Serializer<?> getSerializer()
Returns:
the serializer

setSerializer

void setSerializer(org.springframework.core.serializer.Serializer<?> serializer)
Parameters:
serializer - the serializer to set

getListener

TcpListener getListener()
Returns:
this connection's listener

incrementAndGetConnectionSequence

long incrementAndGetConnectionSequence()
Returns:
the next sequence number for a message received on this socket

Spring Integration