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() |
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, and this connection is not for single use,
this method exits.
|
void |
send(Message<?> message)
Converts and sends the message.
|
protected void |
sendToPipe(ByteBuffer rawBuffer) |
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.
|
afterSend, closeConnection, getConnectionId, getDeserializer, getHostAddress, getHostName, getListener, getMapper, getSender, getSerializer, incrementAndGetConnectionSequence, isNoReadErrorOnClose, isServer, isSingleUse, publishConnectionCloseEvent, publishConnectionExceptionEvent, publishConnectionOpenEvent, publishEvent, registerListener, registerSender, sendExceptionToListener, setDeserializer, setMapper, setNoReadErrorOnClose, setSerializer, setSingleUse
public TcpNioConnection(SocketChannel socketChannel, boolean server, boolean lookupHost, ApplicationEventPublisher applicationEventPublisher, String connectionFactoryName) throws Exception
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.Exception
- Any Exception.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) throws Exception
TcpConnection
message
- The message,Exception
- Any Exception.public Object getPayload() throws Exception
TcpConnection
Exception
- Any Exception.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.protected ByteBuffer allocate(int length)
length
- The buffer length.public void run()
protected void sendToPipe(ByteBuffer rawBuffer) 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()