Spring Integration

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

All Superinterfaces:
Runnable
All Known Subinterfaces:
TcpConnectionInterceptor
All Known Implementing Classes:
AbstractTcpConnection, AbstractTcpConnectionInterceptor, 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()
           
 org.springframework.commons.serializer.InputStreamingConverter<?> getInputConverter()
           
 TcpListener getListener()
           
 org.springframework.commons.serializer.OutputStreamingConverter<?> getOutputConverter()
           
 Object getPayload()
          Uses the input converter to obtain the message payload from the connection's input stream.
 int getPort()
           
 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 setInputConverter(org.springframework.commons.serializer.InputStreamingConverter<?> inputConverter)
           
 void setMapper(TcpMessageMapper mapper)
           
 void setOutputConverter(org.springframework.commons.serializer.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.

isServer

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

setMapper

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

getInputConverter

org.springframework.commons.serializer.InputStreamingConverter<?> getInputConverter()
Returns:
the input converter

setInputConverter

void setInputConverter(org.springframework.commons.serializer.InputStreamingConverter<?> inputConverter)
Parameters:
inputConverter - the inputConverter to set

getOutputConverter

org.springframework.commons.serializer.OutputStreamingConverter<?> getOutputConverter()
Returns:
the output converter

setOutputConverter

void setOutputConverter(org.springframework.commons.serializer.OutputStreamingConverter<?> outputConverter)
Parameters:
outputConverter - the outputConverter to set

getListener

TcpListener getListener()
Returns:
this connection's listener

Spring Integration

Copyright © 2010. All Rights Reserved.