|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.integration.ip.tcp.AbstractSocketReader
public abstract class AbstractSocketReader
Abstract SocketReader 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
assembleDataCustomFormat()
which is invoked by assembleData()
when the format is MessageFormats.FORMAT_CUSTOM
.
Field Summary | |
---|---|
protected byte[] |
assembledData
The assembled data; must contain a reference when assembleData() returns true; will be set to null when getAssembledData() is called. |
protected int |
maxMessageSize
|
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 | |
---|---|
AbstractSocketReader()
|
Method Summary | |
---|---|
boolean |
assembleData()
Reads the data the socket and assembles packets of data into a complete message, depending on the format of that data. |
protected abstract boolean |
assembleDataCrLfFormat()
Assembles data in format MessageFormats.FORMAT_CRLF . |
protected abstract boolean |
assembleDataCustomFormat()
Assembles data in format MessageFormats.FORMAT_CUSTOM . |
protected abstract boolean |
assembleDataLengthFormat()
Assembles data in format MessageFormats.FORMAT_LENGTH_HEADER . |
protected abstract boolean |
assembleDataStxEtxFormat()
Assembles data in format MessageFormats.FORMAT_STX_ETX . |
protected abstract void |
doClose()
Called after an exception; close the transport. |
void |
setMaxMessageSize(int maxMessageSize)
|
void |
setMessageFormat(int messageFormat)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.integration.ip.tcp.SocketReader |
---|
getAddress, getAssembledData, getSocket |
Field Detail |
---|
protected int messageFormat
protected byte[] assembledData
protected int maxMessageSize
Constructor Detail |
---|
public AbstractSocketReader()
Method Detail |
---|
protected abstract boolean assembleDataLengthFormat() throws java.io.IOException
MessageFormats.FORMAT_LENGTH_HEADER
.
java.io.IOException
protected abstract boolean assembleDataStxEtxFormat() throws java.io.IOException
MessageFormats.FORMAT_STX_ETX
.
java.io.IOException
protected abstract boolean assembleDataCrLfFormat() throws java.io.IOException
MessageFormats.FORMAT_CRLF
.
java.io.IOException
protected abstract boolean assembleDataCustomFormat() throws java.io.IOException
MessageFormats.FORMAT_CUSTOM
. Implementations must
return false until the message is completely assembled, at which time
the implementation must update assembledData to reference the assembled
message.
java.io.IOException
public boolean assembleData() throws java.io.IOException
SocketReader
assembleData
in interface SocketReader
java.io.IOException
protected abstract void doClose()
public void setMessageFormat(int messageFormat)
messageFormat
- the messageFormat to set,public void setMaxMessageSize(int maxMessageSize)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |