|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.integration.ip.tcp.AbstractSocketWriter
org.springframework.integration.ip.tcp.NioSocketWriter
public class NioSocketWriter
A SocketWriter that writes to a SocketChannel. The
data is wrapped in a wire protocol based on the messageFormat property.
| Field Summary | |
|---|---|
protected int |
bufferCount
|
protected java.util.concurrent.BlockingQueue<java.nio.ByteBuffer> |
buffers
If we are using direct buffers, we don't want to churn them using normal heap management. |
protected java.nio.channels.SocketChannel |
channel
|
protected java.nio.ByteBuffer |
crLfPart
A buffer containing the CRLF for when the messageFormat is MessageFormats.FORMAT_CRLF. |
protected java.nio.ByteBuffer |
etxPart
A buffer containing the ETX for when the messageFormat is MessageFormats.FORMAT_STX_ETX. |
protected java.nio.ByteBuffer |
lengthPart
A buffer containing the length part when the messageFormat is MessageFormats.FORMAT_LENGTH_HEADER. |
protected int |
maxBuffers
|
protected java.nio.ByteBuffer |
stxPart
A buffer containing the STX for when the messageFormat is MessageFormats.FORMAT_STX_ETX. |
protected boolean |
usingDirectBuffers
If true, direct buffers are used. |
| Fields inherited from class org.springframework.integration.ip.tcp.AbstractSocketWriter |
|---|
messageFormat |
| Fields inherited from interface org.springframework.integration.ip.tcp.MessageFormats |
|---|
ETX, FORMAT_CRLF, FORMAT_CUSTOM, FORMAT_LENGTH_HEADER, FORMAT_STX_ETX, STX |
| Constructor Summary | |
|---|---|
NioSocketWriter(java.nio.channels.SocketChannel channel,
int maxBuffers,
int sendBufferSize)
|
|
| Method Summary | |
|---|---|
protected void |
doClose()
Called when an IO error |
protected java.nio.ByteBuffer |
getBuffer()
|
protected void |
returnBuffer(java.nio.ByteBuffer buffer)
|
void |
setUsingDirectBuffers(boolean usingDirectBuffers)
|
protected void |
writeCrLfFormat(byte[] bytes)
Write the data, followed by carriage return, line feed ('\r\n'). |
protected void |
writeCustomFormat(byte[] bytes)
Write the data using some custom protocol. |
protected void |
writeLengthFormat(byte[] bytes)
Write the length of the data in a 4 byte integer (in network byte order) before the data itself. |
protected void |
writeStxEtxFormat(byte[] bytes)
Write an STX (0x02) followed by the data, followed by ETX (0x03). |
| Methods inherited from class org.springframework.integration.ip.tcp.AbstractSocketWriter |
|---|
setMessageFormat, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.nio.channels.SocketChannel channel
protected boolean usingDirectBuffers
ByteBuffer} for more information.protected java.nio.ByteBuffer lengthPart
MessageFormats.FORMAT_LENGTH_HEADER.
protected java.nio.ByteBuffer stxPart
MessageFormats.FORMAT_STX_ETX.
protected java.nio.ByteBuffer etxPart
MessageFormats.FORMAT_STX_ETX.
protected java.nio.ByteBuffer crLfPart
MessageFormats.FORMAT_CRLF.
protected java.util.concurrent.BlockingQueue<java.nio.ByteBuffer> buffers
protected int maxBuffers
protected int bufferCount
| Constructor Detail |
|---|
public NioSocketWriter(java.nio.channels.SocketChannel channel,
int maxBuffers,
int sendBufferSize)
socket - | Method Detail |
|---|
public void setUsingDirectBuffers(boolean usingDirectBuffers)
usingDirectBuffers - the usingDirectBuffers to set
protected java.nio.ByteBuffer getBuffer()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionprotected void returnBuffer(java.nio.ByteBuffer buffer)
protected void writeCrLfFormat(byte[] bytes)
throws java.io.IOException
AbstractSocketWriter
writeCrLfFormat in class AbstractSocketWriterjava.io.IOException
protected void writeCustomFormat(byte[] bytes)
throws java.io.IOException
AbstractSocketWriter
writeCustomFormat in class AbstractSocketWriterjava.io.IOException
protected void writeLengthFormat(byte[] bytes)
throws java.io.IOException
AbstractSocketWriter
writeLengthFormat in class AbstractSocketWriterbytes - The bytes to write.
java.io.IOException
protected void writeStxEtxFormat(byte[] bytes)
throws java.io.IOException
AbstractSocketWriter
writeStxEtxFormat in class AbstractSocketWriterbytes - The bytes to write.
java.io.IOExceptionprotected void doClose()
AbstractSocketWriter
doClose in class AbstractSocketWriter
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||