Spring Integration

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

All Superinterfaces:
Runnable
All Known Implementing Classes:
AbstractTcpConnection, TcpNetConnection, TcpNioConnection

public interface TcpConnection
extends Runnable

An abstraction over Socket and SocketChannel that sends Message objects by converting 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.
 String getConnectionId()
           
 String getHostAddress()
           
 String getHostName()
           
 Object getPayload()
          Uses the input converter to obtain the message payload from the connection's input stream.
 int getPort()
           
 boolean isOpen()
           
 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 setInputConverter(InputStreamingConverter<?> inputConverter)
           
 void setMapper(TcpMessageMapper mapper)
           
 void setOutputConverter(OutputStreamingConverter<?> outputConverter)
           
 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 Exception
Converts and sends the message.

Parameters:
message - The message
Throws:
Exception

getPayload

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

Returns:
The payload
Throws:
Exception

getHostName

String getHostName()
Returns:
the host name

getHostAddress

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

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.

setMapper

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

setInputConverter

void setInputConverter(InputStreamingConverter<?> inputConverter)
Parameters:
inputConverter - the inputConverter to set

setOutputConverter

void setOutputConverter(OutputStreamingConverter<?> outputConverter)
Parameters:
outputConverter - the outputConverter to set

Spring Integration

Copyright © 2010. All Rights Reserved.