|
Spring Integration | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 Object |
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.SocketReader |
---|
MESSAGE_COMPLETE, MESSAGE_INCOMPLETE, SOCKET_CLOSED |
Fields inherited from interface org.springframework.integration.ip.tcp.MessageFormats |
---|
ETX, FORMAT_CRLF, FORMAT_CUSTOM, FORMAT_IMPLICIT, FORMAT_JAVA_SERIALIZED, FORMAT_LENGTH_HEADER, FORMAT_STX_ETX, STX |
Constructor Summary | |
---|---|
AbstractSocketReader()
|
Method Summary | |
---|---|
int |
assembleData()
Reads the data the socket and assembles packets of data into a complete message, depending on the format of that data. |
protected abstract int |
assembleDataCrLfFormat()
Assembles data in format MessageFormats.FORMAT_CRLF . |
protected abstract int |
assembleDataCustomFormat()
Assembles data in format MessageFormats.FORMAT_CUSTOM . |
protected abstract int |
assembleDataLengthFormat()
Assembles data in format MessageFormats.FORMAT_LENGTH_HEADER . |
protected abstract int |
assembleDataSerializedFormat()
Assembles data in format MessageFormats.FORMAT_JAVA_SERIALIZED |
protected abstract int |
assembleDataStxEtxFormat()
Assembles data in format MessageFormats.FORMAT_STX_ETX . |
protected abstract void |
doClose()
Called after an exception; close the transport. |
Object |
getAssembledData()
Retrieves the assembled tcp data or null if the data is not yet assembled. |
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, getSocket |
Field Detail |
---|
protected int messageFormat
protected Object assembledData
protected int maxMessageSize
Constructor Detail |
---|
public AbstractSocketReader()
Method Detail |
---|
protected abstract int assembleDataLengthFormat() throws IOException
MessageFormats.FORMAT_LENGTH_HEADER
.
IOException
protected abstract int assembleDataStxEtxFormat() throws IOException
MessageFormats.FORMAT_STX_ETX
.
IOException
protected abstract int assembleDataCrLfFormat() throws IOException
MessageFormats.FORMAT_CRLF
.
IOException
protected abstract int assembleDataSerializedFormat() throws IOException
MessageFormats.FORMAT_JAVA_SERIALIZED
IOException
protected abstract int assembleDataCustomFormat() throws 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.
IOException
public int assembleData() throws IOException
SocketReader
assembleData
in interface SocketReader
IOException
public Object getAssembledData()
SocketReader
getAssembledData
in interface SocketReader
protected abstract void doClose()
public void setMessageFormat(int messageFormat)
messageFormat
- the messageFormat to set,public void setMaxMessageSize(int maxMessageSize)
|
Spring Integration | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |