public class TcpNioConnection extends TcpConnectionSupport
SocketChannel
.logger
Constructor and Description |
---|
TcpNioConnection(SocketChannel socketChannel,
boolean server,
boolean lookupHost,
ApplicationEventPublisher applicationEventPublisher,
String connectionFactoryName)
Constructs a TcpNetConnection for the SocketChannel.
|
Modifier and Type | Method and Description |
---|---|
protected ByteBuffer |
allocate(int length)
Allocates a ByteBuffer of the requested length using normal or
direct buffers, depending on the usingDirectBuffers field.
|
void |
close()
Closes this connection.
|
protected org.springframework.integration.ip.tcp.connection.TcpNioConnection.ChannelOutputStream |
getChannelOutputStream() |
Object |
getDeserializerStateKey() |
long |
getLastRead() |
long |
getLastSend() |
Object |
getPayload()
Uses the deserializer to obtain the message payload
from the connection's input stream.
|
int |
getPort() |
SSLSession |
getSslSession() |
protected InputStream |
inputStream()
Subclasses can override this, for example to wrap the input stream.
|
boolean |
isOpen() |
protected boolean |
isUsingDirectBuffers() |
void |
readPacket()
Invoked by the factory when there is data to be read.
|
void |
run()
If there is no listener,
this method exits.
|
void |
send(Message<?> message)
Converts and sends the message.
|
protected void |
sendToPipe(ByteBuffer rawBufferToSend) |
void |
setLastRead(long lastRead) |
void |
setPipeTimeout(long pipeTimeout) |
void |
setTaskExecutor(Executor taskExecutor) |
void |
setUsingDirectBuffers(boolean usingDirectBuffers)
If true, connection will attempt to use direct buffers where possible.
|
void |
shutdownInput()
Set the socket's input stream to end of stream.
|
void |
shutdownOutput()
Disable the socket's output stream.
|
closeConnection, enableManualListenerRegistration, getConnectionFactoryName, getConnectionId, getDeserializer, getHostAddress, getHostName, getListener, getMapper, getSender, getSenders, getSerializer, getSocketInfo, incrementAndGetConnectionSequence, isNoReadErrorOnClose, isServer, publishConnectionCloseEvent, publishConnectionExceptionEvent, publishConnectionOpenEvent, publishEvent, registerListener, registerSender, registerSenders, registerTestListener, sendExceptionToListener, setDeserializer, setMapper, setNeedsTest, setNoReadErrorOnClose, setSerializer, setWrapped, setWrapper, toString
public TcpNioConnection(SocketChannel socketChannel, boolean server, boolean lookupHost, @Nullable ApplicationEventPublisher applicationEventPublisher, @Nullable String connectionFactoryName)
socketChannel
- The socketChannel.server
- If true, this connection was created as
a result of an incoming request.lookupHost
- true to perform reverse lookups.applicationEventPublisher
- The event publisher.connectionFactoryName
- The name of the connection factory creating this connection.public void setPipeTimeout(long pipeTimeout)
public void close()
TcpConnectionSupport
close
in interface TcpConnection
close
in class TcpConnectionSupport
public boolean isOpen()
public void send(Message<?> message)
TcpConnection
message
- The message,public Object getPayload()
TcpConnection
public int getPort()
public Object getDeserializerStateKey()
Deserializer
that
maintains state for this connection. Currently, this would be the InputStream
associated with the connection, but the object should be treated as opaque
and ONLY used as a key.@Nullable public SSLSession getSslSession()
SSLSession
associated with this connection, if SSL is in use,
null otherwise.protected InputStream inputStream()
protected ByteBuffer allocate(int length)
length
- The buffer length.public void run()
protected void sendToPipe(ByteBuffer rawBufferToSend) throws IOException
IOException
public void readPacket()
public void setTaskExecutor(Executor taskExecutor)
taskExecutor
- the taskExecutor to setpublic void setUsingDirectBuffers(boolean usingDirectBuffers)
usingDirectBuffers
- the usingDirectBuffers to set.protected boolean isUsingDirectBuffers()
protected org.springframework.integration.ip.tcp.connection.TcpNioConnection.ChannelOutputStream getChannelOutputStream()
public long getLastRead()
public void setLastRead(long lastRead)
lastRead
- The time of the last read.public long getLastSend()
public void shutdownInput() throws IOException
IOException
- an IO Exception.SocketChannel.shutdownInput()
public void shutdownOutput() throws IOException
IOException
- an IO ExceptionSocketChannel.shutdownOutput()