public abstract class AbstractConnectionFactory extends IntegrationObjectSupport implements ConnectionFactory, ApplicationEventPublisherAware
| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_REPLY_TIMEOUT |
protected Object |
lifecycleMonitor |
EXPRESSION_PARSER, logger| Constructor and Description |
|---|
AbstractConnectionFactory(int port) |
AbstractConnectionFactory(String host,
int port) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addConnection(TcpConnectionSupport connection) |
protected void |
checkActive() |
boolean |
closeConnection(String connectionId)
Close a connection with the specified connection id.
|
protected void |
delayRead(Selector selector,
long now,
SelectionKey key) |
protected void |
doAccept(Selector selector,
ServerSocketChannel server,
long now) |
ApplicationEventPublisher |
getApplicationEventPublisher() |
protected BlockingQueue<org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory.PendingIO> |
getDelayedReads() |
Deserializer<?> |
getDeserializer() |
String |
getHost() |
protected Object |
getLifecycleMonitor() |
TcpListener |
getListener() |
TcpMessageMapper |
getMapper() |
List<String> |
getOpenConnectionIds()
Returns a list of (currently) open
TcpConnection connection ids; allows,
for example, broadcast operations to all open connections. |
int |
getPort() |
protected long |
getReadDelay() |
TcpSender |
getSender() |
Serializer<?> |
getSerializer() |
int |
getSoLinger() |
int |
getSoReceiveBufferSize() |
int |
getSoSendBufferSize() |
int |
getSoTimeout() |
int |
getSoTrafficClass() |
protected Integer |
getSslHandshakeTimeout() |
protected Executor |
getTaskExecutor()
Creates a taskExecutor (if one was not provided).
|
protected TcpSocketSupport |
getTcpSocketSupport() |
protected void |
harvestClosedConnections()
Cleans up this.connections by removing any closed connections.
|
protected boolean |
isActive() |
boolean |
isLookupHost() |
boolean |
isRunning() |
boolean |
isSingleUse() |
boolean |
isSoKeepAlive() |
boolean |
isSoTcpNoDelay() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected void |
processNioSelections(int selectionCount,
Selector selector,
ServerSocketChannel server,
Map<SocketChannel,TcpNioConnection> connectionMap)
Times out any expired connections then, if
selectionCount > 0,
processes the selected keys. |
void |
registerListener(TcpListener listenerToRegister)
Registers a TcpListener to receive messages after
the payload has been converted from the input data.
|
void |
registerSender(TcpSender senderToRegister)
Registers a TcpSender; for server sockets, used to
provide connection information so a sender can be used
to reply to incoming messages.
|
protected void |
setActive(boolean active) |
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setDeserializer(Deserializer<?> deserializer) |
void |
setHost(String host)
Set the host; requires the factory to be stopped.
|
void |
setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain) |
void |
setLeaveOpen(boolean leaveOpen)
If true, sockets created by this factory will be reused.
|
void |
setLookupHost(boolean lookupHost)
If true, DNS reverse lookup is done on the remote ip address.
|
void |
setMapper(TcpMessageMapper mapper) |
void |
setNioHarvestInterval(int nioHarvestInterval)
How often we clean up closed NIO connections if soTimeout is 0.
|
void |
setPort(int port)
Set the port; requires the factory to be stopped.
|
void |
setReadDelay(long readDelay)
The delay (in milliseconds) before retrying a read after the previous attempt
failed due to insufficient threads.
|
void |
setSerializer(Serializer<?> serializer) |
void |
setSingleUse(boolean singleUse)
If true, sockets created by this factory will be used once.
|
protected void |
setSocketAttributes(Socket socket)
Sets socket attributes on the socket.
|
void |
setSoKeepAlive(boolean soKeepAlive) |
void |
setSoLinger(int soLinger) |
void |
setSoReceiveBufferSize(int soReceiveBufferSize) |
void |
setSoSendBufferSize(int soSendBufferSize) |
void |
setSoTcpNoDelay(boolean soTcpNoDelay) |
void |
setSoTimeout(int soTimeout) |
void |
setSoTrafficClass(int soTrafficClass) |
void |
setSslHandshakeTimeout(int sslHandshakeTimeout)
Set the handshake timeout used when waiting for SSL handshake data; only applies
to SSL connections, when using NIO.
|
void |
setTaskExecutor(Executor taskExecutor) |
void |
setTcpSocketSupport(TcpSocketSupport tcpSocketSupport) |
void |
start() |
void |
stop()
Stops the server.
|
String |
toString() |
protected TcpConnectionSupport |
wrapConnection(TcpConnectionSupport connectionArg) |
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskSchedulerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetConnectionprotected static final int DEFAULT_REPLY_TIMEOUT
protected final Object lifecycleMonitor
public AbstractConnectionFactory(int port)
public AbstractConnectionFactory(String host, int port)
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface ApplicationEventPublisherAwarepublic ApplicationEventPublisher getApplicationEventPublisher()
protected void setSocketAttributes(Socket socket) throws SocketException
socket - The socket.SocketException - Any SocketException.public int getSoTimeout()
public void setSoTimeout(int soTimeout)
soTimeout - the soTimeout to setpublic int getSoReceiveBufferSize()
public void setSoReceiveBufferSize(int soReceiveBufferSize)
soReceiveBufferSize - the soReceiveBufferSize to setpublic int getSoSendBufferSize()
public void setSoSendBufferSize(int soSendBufferSize)
soSendBufferSize - the soSendBufferSize to setpublic boolean isSoTcpNoDelay()
public void setSoTcpNoDelay(boolean soTcpNoDelay)
soTcpNoDelay - the soTcpNoDelay to setpublic int getSoLinger()
public void setSoLinger(int soLinger)
soLinger - the soLinger to setpublic boolean isSoKeepAlive()
public void setSoKeepAlive(boolean soKeepAlive)
soKeepAlive - the soKeepAlive to setpublic int getSoTrafficClass()
public void setSoTrafficClass(int soTrafficClass)
soTrafficClass - the soTrafficClass to setpublic void setHost(String host)
host - the host.public String getHost()
public void setPort(int port)
port - the port.public int getPort()
@Nullable public TcpListener getListener()
public Serializer<?> getSerializer()
public Deserializer<?> getDeserializer()
public TcpMessageMapper getMapper()
public void registerListener(TcpListener listenerToRegister)
listenerToRegister - the TcpListener.public void registerSender(TcpSender senderToRegister)
senderToRegister - The senderpublic void setTaskExecutor(Executor taskExecutor)
taskExecutor - the taskExecutor to setpublic void setDeserializer(Deserializer<?> deserializer)
deserializer - the deserializer to setpublic void setSerializer(Serializer<?> serializer)
serializer - the serializer to setpublic void setMapper(TcpMessageMapper mapper)
mapper - the mapper to set; defaults to a TcpMessageMapperpublic boolean isSingleUse()
public void setSingleUse(boolean singleUse)
singleUse - The singleUse to set.public void setLeaveOpen(boolean leaveOpen)
setSingleUse(boolean).leaveOpen - The keepOpen to set.public void setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain)
public void setLookupHost(boolean lookupHost)
lookupHost - the lookupHost to setpublic boolean isLookupHost()
public void setNioHarvestInterval(int nioHarvestInterval)
soTimeout > 0 because the clean up
process is run as part of the timeout handling.
Default 2000 milliseconds.nioHarvestInterval - The interval in milliseconds.public void setSslHandshakeTimeout(int sslHandshakeTimeout)
sslHandshakeTimeout - the timeout.@Nullable protected Integer getSslHandshakeTimeout()
setSslHandshakeTimeout(int)protected BlockingQueue<org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory.PendingIO> getDelayedReads()
protected long getReadDelay()
public void setReadDelay(long readDelay)
readDelay - the readDelay to set.protected Object getLifecycleMonitor()
protected void onInit()
IntegrationObjectSupportonInit in class IntegrationObjectSupportprotected Executor getTaskExecutor()
protected TcpConnectionSupport wrapConnection(TcpConnectionSupport connectionArg)
protected void processNioSelections(int selectionCount,
Selector selector,
@Nullable
ServerSocketChannel server,
Map<SocketChannel,TcpNioConnection> connectionMap)
selectionCount > 0,
processes the selected keys.
Removes closed connections from the connections field, and from the connections parameter.selectionCount - Number of IO Events, if 0 we were probably woken up by a close.selector - The selector.server - The server socket channel.connectionMap - Map of connections.protected void delayRead(Selector selector, long now, SelectionKey key)
protected void doAccept(Selector selector, ServerSocketChannel server, long now)
selector - The selector.server - The server socket channel.now - The current time.protected void addConnection(TcpConnectionSupport connection)
protected void harvestClosedConnections()
protected boolean isActive()
protected void setActive(boolean active)
active - the active to setprotected void checkActive()
protected TcpSocketSupport getTcpSocketSupport()
public void setTcpSocketSupport(TcpSocketSupport tcpSocketSupport)
public List<String> getOpenConnectionIds()
TcpConnection connection ids; allows,
for example, broadcast operations to all open connections.public boolean closeConnection(String connectionId)
connectionId - the connection id.public String toString()
toString in class IntegrationObjectSupport