Spring Integration

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

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.AbstractServerConnectionFactory
All Implemented Interfaces:
java.lang.Runnable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, NamedComponent, OrderlyShutdownCapable, ConnectionFactory
Direct Known Subclasses:
TcpNetServerConnectionFactory, TcpNioServerConnectionFactory

public abstract class AbstractServerConnectionFactory
extends AbstractConnectionFactory
implements java.lang.Runnable, OrderlyShutdownCapable

Base class for all server connection factories. Server connection factories listen on a port for incoming connections and create new TcpConnection objects for each new connection.

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
AbstractServerConnectionFactory(int port)
          The port on which the factory will listen.
 
Method Summary
 int afterShutdown()
          Called after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.
 int beforeShutdown()
          Called before shutdown begins.
 int getBacklog()
          The number of sockets in the server connection backlog.
 TcpConnection getConnection()
          Not supported because the factory manages multiple connections and this method cannot discriminate.
 java.lang.String getLocalAddress()
           
protected  void initializeConnection(TcpConnectionSupport connection, java.net.Socket socket)
          Transfers attributes such as (de)serializer, singleUse etc to a new connection.
 boolean isListening()
           
protected  boolean isShuttingDown()
           
protected  void postProcessServerSocket(java.net.ServerSocket serverSocket)
           
 void setBacklog(int backlog)
          The number of sockets in the connection backlog.
protected  void setListening(boolean listening)
           
 void setLocalAddress(java.lang.String localAddress)
          Used on multi-homed systems to enforce the server to listen on a specfic network address instead of all network adapters.
 void start()
           
 
Methods inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
addConnection, checkActive, close, closeConnection, doAccept, getApplicationEventPublisher, getDeserializer, getHost, getListener, getMapper, getOpenConnectionIds, getPhase, getPort, getSender, getSerializer, getSoLinger, getSoReceiveBufferSize, getSoSendBufferSize, getSoTimeout, getSoTrafficClass, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isAutoStartup, isLookupHost, isRunning, isSingleUse, isSoKeepAlive, isSoTcpNoDelay, processNioSelections, registerListener, registerSender, setActive, setApplicationEventPublisher, setDeserializer, setInterceptorFactoryChain, setLookupHost, setMapper, setNioHarvestInterval, setSerializer, setSingleUse, setSocketAttributes, setSoKeepAlive, setSoLinger, setSoReceiveBufferSize, setSoSendBufferSize, setSoTcpNoDelay, setSoTimeout, setSoTrafficClass, setTaskExecutor, setTcpSocketSupport, 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
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

AbstractServerConnectionFactory

public AbstractServerConnectionFactory(int port)
The port on which the factory will listen.

Parameters:
port -
Method Detail

start

public void start()
Specified by:
start in interface org.springframework.context.Lifecycle
Overrides:
start in class AbstractConnectionFactory

getConnection

public TcpConnection getConnection()
                            throws java.lang.Exception
Not supported because the factory manages multiple connections and this method cannot discriminate.

Specified by:
getConnection in interface ConnectionFactory
Throws:
java.lang.Exception

setListening

protected void setListening(boolean listening)
Parameters:
listening - the listening to set

isListening

public boolean isListening()
Returns:
true if the server is listening on the port.

isShuttingDown

protected boolean isShuttingDown()

initializeConnection

protected void initializeConnection(TcpConnectionSupport connection,
                                    java.net.Socket socket)
Transfers attributes such as (de)serializer, singleUse etc to a new connection. For single use sockets, enforces a socket timeout (default 10 seconds).

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

postProcessServerSocket

protected void postProcessServerSocket(java.net.ServerSocket serverSocket)

getLocalAddress

public java.lang.String getLocalAddress()
Returns:
the localAddress

setLocalAddress

public void setLocalAddress(java.lang.String localAddress)
Used on multi-homed systems to enforce the server to listen on a specfic network address instead of all network adapters.

Parameters:
localAddress - the ip address of the required adapter.

getBacklog

public int getBacklog()
The number of sockets in the server connection backlog.

Returns:
The backlog.

setBacklog

public void setBacklog(int backlog)
The number of sockets in the connection backlog. Default 5; increase if you expect high connection rates.

Parameters:
backlog -

beforeShutdown

public int beforeShutdown()
Description copied from interface: OrderlyShutdownCapable
Called before shutdown begins. Implementations should stop accepting new messages. Can optionally return the number of active messages in process.

Specified by:
beforeShutdown in interface OrderlyShutdownCapable
Returns:
The number of active messages if available.

afterShutdown

public int afterShutdown()
Description copied from interface: OrderlyShutdownCapable
Called after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.

Specified by:
afterShutdown in interface OrderlyShutdownCapable
Returns:
The number of active messages if available.

Spring Integration