public abstract class AbstractConnectionFactory extends org.springframework.integration.context.IntegrationObjectSupport implements ConnectionFactory, org.springframework.context.ApplicationEventPublisherAware
| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_REPLY_TIMEOUT |
protected java.lang.Object |
lifecycleMonitor |
| Constructor and Description |
|---|
AbstractConnectionFactory(int port) |
AbstractConnectionFactory(java.lang.String host,
int port) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addConnection(TcpConnectionSupport connection) |
protected void |
checkActive() |
boolean |
closeConnection(java.lang.String connectionId)
Close a connection with the specified connection id.
|
protected void |
delayRead(java.nio.channels.Selector selector,
long now,
java.nio.channels.SelectionKey key) |
protected void |
doAccept(java.nio.channels.Selector selector,
java.nio.channels.ServerSocketChannel server,
long now) |
org.springframework.context.ApplicationEventPublisher |
getApplicationEventPublisher() |
protected java.util.concurrent.BlockingQueue<org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory.PendingIO> |
getDelayedReads() |
org.springframework.core.serializer.Deserializer<?> |
getDeserializer() |
java.lang.String |
getHost() |
TcpListener |
getListener() |
TcpMessageMapper |
getMapper() |
java.util.List<java.lang.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() |
org.springframework.core.serializer.Serializer<?> |
getSerializer() |
int |
getSoLinger() |
int |
getSoReceiveBufferSize() |
int |
getSoSendBufferSize() |
int |
getSoTimeout() |
int |
getSoTrafficClass() |
protected java.lang.Integer |
getSslHandshakeTimeout() |
protected java.util.concurrent.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() |
protected void |
processNioSelections(int selectionCount,
java.nio.channels.Selector selector,
java.nio.channels.ServerSocketChannel server,
java.util.Map<java.nio.channels.SocketChannel,TcpNioConnection> connections)
Times out any expired connections then, if
selectionCount > 0,
processes the selected keys. |
void |
registerListener(TcpListener listener)
Registers a TcpListener to receive messages after
the payload has been converted from the input data.
|
void |
registerSender(TcpSender sender)
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(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
void |
setDeserializer(org.springframework.core.serializer.Deserializer<?> deserializer) |
void |
setHost(java.lang.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(org.springframework.core.serializer.Serializer<?> serializer) |
void |
setSingleUse(boolean singleUse)
If true, sockets created by this factory will be used once.
|
protected void |
setSocketAttributes(java.net.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(java.util.concurrent.Executor taskExecutor) |
void |
setTcpSocketSupport(TcpSocketSupport tcpSocketSupport) |
void |
start() |
void |
stop()
Stops the server.
|
java.lang.String |
toString() |
protected TcpConnectionSupport |
wrapConnection(TcpConnectionSupport connection) |
afterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, 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 java.lang.Object lifecycleMonitor
public AbstractConnectionFactory(int port)
public AbstractConnectionFactory(java.lang.String host,
int port)
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAwarepublic org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()
protected void setSocketAttributes(java.net.Socket socket)
throws java.net.SocketException
socket - The socket.java.net.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(java.lang.String host)
host - the host.public java.lang.String getHost()
public void setPort(int port)
port - the port.public int getPort()
public TcpListener getListener()
public TcpSender getSender()
public org.springframework.core.serializer.Serializer<?> getSerializer()
public org.springframework.core.serializer.Deserializer<?> getDeserializer()
public TcpMessageMapper getMapper()
public void registerListener(TcpListener listener)
listener - the TcpListener.public void registerSender(TcpSender sender)
sender - The senderpublic void setTaskExecutor(java.util.concurrent.Executor taskExecutor)
taskExecutor - the taskExecutor to setpublic void setDeserializer(org.springframework.core.serializer.Deserializer<?> deserializer)
deserializer - the deserializer to setpublic void setSerializer(org.springframework.core.serializer.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.protected java.lang.Integer getSslHandshakeTimeout()
setSslHandshakeTimeout(int)protected java.util.concurrent.BlockingQueue<org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory.PendingIO> getDelayedReads()
protected long getReadDelay()
public void setReadDelay(long readDelay)
readDelay - the readDelay to set.protected void onInit()
throws java.lang.Exception
onInit in class org.springframework.integration.context.IntegrationObjectSupportjava.lang.Exceptionpublic void start()
start in interface org.springframework.context.Lifecycleprotected java.util.concurrent.Executor getTaskExecutor()
public void stop()
stop in interface org.springframework.context.Lifecycleprotected TcpConnectionSupport wrapConnection(TcpConnectionSupport connection) throws java.lang.Exception
java.lang.Exceptionprotected void processNioSelections(int selectionCount,
java.nio.channels.Selector selector,
java.nio.channels.ServerSocketChannel server,
java.util.Map<java.nio.channels.SocketChannel,TcpNioConnection> connections)
throws java.io.IOException
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.connections - Map of connections.java.io.IOException - Any IOException.protected void delayRead(java.nio.channels.Selector selector,
long now,
java.nio.channels.SelectionKey key)
protected void doAccept(java.nio.channels.Selector selector,
java.nio.channels.ServerSocketChannel server,
long now)
throws java.io.IOException
selector - The selector.server - The server socket channel.now - The current time.java.io.IOException - Any IOException.protected void addConnection(TcpConnectionSupport connection)
protected void harvestClosedConnections()
public boolean isRunning()
isRunning in interface org.springframework.context.Lifecycleprotected boolean isActive()
protected void setActive(boolean active)
active - the active to setprotected void checkActive()
throws java.io.IOException
java.io.IOExceptionprotected TcpSocketSupport getTcpSocketSupport()
public void setTcpSocketSupport(TcpSocketSupport tcpSocketSupport)
public java.util.List<java.lang.String> getOpenConnectionIds()
TcpConnection connection ids; allows,
for example, broadcast operations to all open connections.public boolean closeConnection(java.lang.String connectionId)
connectionId - the connection id.public java.lang.String toString()
toString in class org.springframework.integration.context.IntegrationObjectSupport