Spring Integration

org.springframework.integration.ip.tcp.connection
Class AbstractClientConnectionFactory

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
          extended by org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, NamedComponent, ConnectionFactory
Direct Known Subclasses:
CachingClientConnectionFactory, FailoverClientConnectionFactory, TcpNetClientConnectionFactory, TcpNioClientConnectionFactory

public abstract class AbstractClientConnectionFactory
extends AbstractConnectionFactory

Abstract class for client connection factories; client connection factories establish outgoing connections.

Since:
2.0
Author:
Gary Russell

Field Summary
 
Fields inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
DEFAULT_REPLY_TIMEOUT, lifecycleMonitor
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
AbstractClientConnectionFactory(java.lang.String host, int port)
          Constructs a factory that will established connections to the host and port.
 
Method Summary
 TcpConnection getConnection()
          Obtains a connection - if AbstractConnectionFactory.setSingleUse(boolean) was called with true, a new connection is returned; otherwise a single connection is reused for all requests while the connection remains open.
protected  TcpConnection getTheConnection()
           
protected  void initializeConnection(TcpConnection connection, java.net.Socket socket)
          Transfers attributes such as (de)serializers, singleUse etc to a new connection.
protected abstract  TcpConnection obtainConnection()
           
protected  void setTheConnection(TcpConnection theConnection)
           
 
Methods inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
addConnection, checkActive, close, doAccept, getDeserializer, getHost, getListener, getMapper, getPhase, getPoolSize, getPort, getSender, getSerializer, getSoLinger, getSoReceiveBufferSize, getSoSendBufferSize, getSoTimeout, getSoTrafficClass, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isAutoStartup, isLookupHost, isRunning, isSingleUse, isSoKeepAlive, isSoTcpNoDelay, processNioSelections, registerListener, registerSender, setActive, setDeserializer, setInterceptorFactoryChain, setLookupHost, setMapper, setNioHarvestInterval, setPoolSize, setSerializer, setSingleUse, setSocketAttributes, setSoKeepAlive, setSoLinger, setSoReceiveBufferSize, setSoSendBufferSize, setSoTcpNoDelay, setSoTimeout, setSoTrafficClass, setTaskExecutor, setTcpSocketSupport, start, stop, stop, wrapConnection
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractClientConnectionFactory

public AbstractClientConnectionFactory(java.lang.String host,
                                       int port)
Constructs a factory that will established connections to the host and port.

Parameters:
host - The host.
port - The port.
Method Detail

getConnection

public TcpConnection getConnection()
                            throws java.lang.Exception
Obtains a connection - if AbstractConnectionFactory.setSingleUse(boolean) was called with true, a new connection is returned; otherwise a single connection is reused for all requests while the connection remains open.

Throws:
java.lang.Exception

obtainConnection

protected abstract TcpConnection obtainConnection()
                                           throws java.lang.Exception
Throws:
java.lang.Exception

initializeConnection

protected void initializeConnection(TcpConnection connection,
                                    java.net.Socket socket)
Transfers attributes such as (de)serializers, singleUse etc to a new connection. When the connection factory has a reference to a TCPListener (to read responses), or for single use connections, the connection is executed. Single use connections need to read from the connection in order to close it after the socket timeout.

Parameters:
connection - The new connection.
socket - The new socket.

setTheConnection

protected void setTheConnection(TcpConnection theConnection)
Parameters:
theConnection - the theConnection to set

getTheConnection

protected TcpConnection getTheConnection()
Returns:
the theConnection

Spring Integration