Class AbstractServerConnectionFactory
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory
- All Implemented Interfaces:
- Runnable,- Aware,- BeanFactoryAware,- BeanNameAware,- InitializingBean,- ApplicationContextAware,- ApplicationEventPublisherAware,- Lifecycle,- ComponentSourceAware,- ExpressionCapable,- OrderlyShutdownCapable,- ConnectionFactory,- TcpServerConnectionFactory,- NamedComponent,- ManageableLifecycle,- SchedulingAwareRunnable
- Direct Known Subclasses:
- TcpNetServerConnectionFactory,- TcpNioServerConnectionFactory
public abstract class AbstractServerConnectionFactory
extends AbstractConnectionFactory
implements TcpServerConnectionFactory, SchedulingAwareRunnable, 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, Artem Bilan, Christian Tzolov
- 
Field SummaryFields inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactoryconnections, connectionsMonitor, DEFAULT_REPLY_TIMEOUT, lifecycleMonitorFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructorsConstructorDescriptionAbstractServerConnectionFactory(int port) The port on which the factory will listen.
- 
Method SummaryModifier and TypeMethodDescriptionintCalled 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.intCalled before shutdown begins.intThe number of sockets in the server connection backlog.Not supported because the factory manages multiple connections and this method cannot discriminate.Return theSocketAddressthat the underlyingServerSocketis bound to.protected voidinitializeConnection(TcpConnectionSupport connection, Socket socket) Transfers attributes such as (de)serializer, mapper etc to a new connection.booleanbooleanprotected booleanprotected voidpostProcessServerSocket(ServerSocket serverSocket) protected voidprotected voidpublishServerListeningEvent(int port) voidsetBacklog(int backlog) The number of sockets in the connection backlog.protected voidsetListening(boolean listening) voidsetLocalAddress(String localAddress) Used on multi-homed systems to enforce the server to listen on a specific network address instead of all network adapters.voidstart()Methods inherited from class org.springframework.integration.ip.tcp.connection.AbstractConnectionFactoryaddConnection, checkActive, closeConnection, delayRead, doAccept, getApplicationEventPublisher, getDelayedReads, getDeserializer, getHost, getLifecycleMonitor, getListener, getMapper, getOpenConnectionIds, getPort, getReadDelay, getSender, getSenders, getSerializer, getSoLinger, getSoReceiveBufferSize, getSoSendBufferSize, getSoTimeout, getSoTrafficClass, getSslHandshakeTimeout, getTaskExecutor, getTcpSocketSupport, harvestClosedConnections, isActive, isLookupHost, isRunning, isSingleUse, isSoKeepAlive, isSoTcpNoDelay, onInit, processNioSelections, registerListener, registerSender, setActive, setApplicationEventPublisher, setDeserializer, setHost, setInterceptorFactoryChain, setLeaveOpen, setLookupHost, setMapper, setNioHarvestInterval, setPort, setReadDelay, setSerializer, setSingleUse, setSocketAttributes, setSoKeepAlive, setSoLinger, setSoReceiveBufferSize, setSoSendBufferSize, setSoTcpNoDelay, setSoTimeout, setSoTrafficClass, setSslHandshakeTimeout, setTaskExecutor, setTcpSocketSupport, stop, toString, unregisterSender, wrapConnectionMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskSchedulerMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.scheduling.SchedulingAwareRunnablegetQualifierMethods inherited from interface org.springframework.integration.ip.tcp.connection.TcpServerConnectionFactorygetPort
- 
Constructor Details- 
AbstractServerConnectionFactorypublic AbstractServerConnectionFactory(int port) The port on which the factory will listen.- Parameters:
- port- The port.
 
 
- 
- 
Method Details- 
isLongLivedpublic boolean isLongLived()- Specified by:
- isLongLivedin interface- SchedulingAwareRunnable
 
- 
getServerSocketAddressDescription copied from interface:TcpServerConnectionFactoryReturn theSocketAddressthat the underlyingServerSocketis bound to.- Specified by:
- getServerSocketAddressin interface- TcpServerConnectionFactory
- Returns:
- the socket address.
 
- 
startpublic void start()- Specified by:
- startin interface- Lifecycle
- Specified by:
- startin interface- ManageableLifecycle
- Overrides:
- startin class- AbstractConnectionFactory
 
- 
getConnectionNot supported because the factory manages multiple connections and this method cannot discriminate.- Specified by:
- getConnectionin interface- ConnectionFactory
 
- 
setListeningprotected void setListening(boolean listening) - Parameters:
- listening- the listening to set
 
- 
isListeningpublic boolean isListening()- Returns:
- true if the server is listening on the port.
 
- 
isShuttingDownprotected boolean isShuttingDown()
- 
initializeConnectionTransfers attributes such as (de)serializer, mapper etc to a new connection. For single use sockets, enforces a socket timeout (default 10 seconds) to prevent DoS attacks.- Parameters:
- connection- The new connection.
- socket- The new socket.
 
- 
postProcessServerSocket
- 
getLocalAddress- Returns:
- the localAddress
 
- 
setLocalAddressUsed on multi-homed systems to enforce the server to listen on a specific network address instead of all network adapters.- Parameters:
- localAddress- the ip address of the required adapter.
 
- 
getBacklogpublic int getBacklog()The number of sockets in the server connection backlog.- Returns:
- The backlog.
 
- 
setBacklogpublic void setBacklog(int backlog) The number of sockets in the connection backlog. Default 5; increase if you expect high connection rates.- Parameters:
- backlog- The backlog to set.
 
- 
beforeShutdownpublic int beforeShutdown()Description copied from interface:OrderlyShutdownCapableCalled before shutdown begins. Implementations should stop accepting new messages. Can optionally return the number of active messages in process.- Specified by:
- beforeShutdownin interface- OrderlyShutdownCapable
- Returns:
- The number of active messages if available.
 
- 
afterShutdownpublic int afterShutdown()Description copied from interface:OrderlyShutdownCapableCalled 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:
- afterShutdownin interface- OrderlyShutdownCapable
- Returns:
- The number of active messages if available.
 
- 
publishServerExceptionEvent
- 
publishServerListeningEventprotected void publishServerListeningEvent(int port) 
 
-