|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.integration.ip.tcp.AbstractSocketWriter
public abstract class AbstractSocketWriter
Abstract SocketWriter that handles data in 3 standard, and one custom
format. The default format is MessageFormats.FORMAT_LENGTH_HEADER
in which
the message consists of a 4 byte integer (in network byte order) containing
the length of data that follows. MessageFormats.FORMAT_STX_ETX
indicates a message where the data begins with STX (0x02) and ends with
ETX (0x03); the STX and ETX are not part of the data. MessageFormats.FORMAT_CRLF
indicates a message followed by carriage return and line feed '\r\n'.
FORMAT_LENGTH_HEADER can be used for Socket
and
SocketChannel
implementations are provided for
the standard formats. Users requiring other formats should subclass the
appropriate implementation, and provide an implementation for
writeCustomFormat(byte[])
which is invoked by write(byte[])
when the format is MessageFormats.FORMAT_CUSTOM
.
Field Summary | |
---|---|
protected int |
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 | |
---|---|
AbstractSocketWriter()
|
Method Summary | |
---|---|
protected abstract void |
doClose()
Called when an IO error |
void |
setMessageFormat(int messageFormat)
|
void |
write(byte[] bytes)
Write the entire buffer to the underlying socket. |
protected abstract void |
writeCrLfFormat(byte[] bytes)
Write the data, followed by carriage return, line feed ('\r\n'). |
protected abstract void |
writeCustomFormat(byte[] bytes)
Write the data using some custom protocol. |
protected abstract void |
writeLengthFormat(byte[] bytes)
Write the length of the data in a 4 byte integer (in network byte order) before the data itself. |
protected abstract void |
writeStxEtxFormat(byte[] bytes)
Write an STX (0x02) followed by the data, followed by ETX (0x03). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int messageFormat
Constructor Detail |
---|
public AbstractSocketWriter()
Method Detail |
---|
public void write(byte[] bytes) throws java.io.IOException
SocketWriter
write
in interface SocketWriter
bytes
- The bytes to write.
java.io.IOException
protected abstract void doClose()
protected abstract void writeLengthFormat(byte[] bytes) throws java.io.IOException
bytes
- The bytes to write.
java.io.IOException
protected abstract void writeStxEtxFormat(byte[] bytes) throws java.io.IOException
bytes
- The bytes to write.
java.io.IOException
protected abstract void writeCrLfFormat(byte[] bytes) throws java.io.IOException
bytes
-
java.io.IOException
protected abstract void writeCustomFormat(byte[] bytes) throws java.io.IOException
bytes
-
java.io.IOException
public void setMessageFormat(int messageFormat)
setMessageFormat
in interface SocketWriter
messageFormat
- the messageFormat to set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |