com.sun.grizzly.filter
Class MessageBase
java.lang.Object
com.sun.grizzly.filter.MessageBase
- All Implemented Interfaces:
- Message
- Direct Known Subclasses:
- ClosedMessage, FragmentMessage, InputStreamMessage, MessageError
public abstract class MessageBase
- extends Object
- implements Message
Note idea taken from com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase
Knows how to construct various CustomProtocol Messages out of an ByteBuffer.
- Author:
- John Vieten
Version 1.0
Fields inherited from interface com.sun.grizzly.filter.Message |
APPLICATION_LAYER_ERROR_BIT, CurrentVersion, GZIP_BIT, HeaderLength, Magic, MagicByteLength, Message_Error, Message_Fragment, Message_Reply, Message_Request, MessageMaxLength, MORE_FRAGMENTS_BIT |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
requestId
protected int requestId
sessionId
protected int sessionId
useGzip
protected boolean useGzip
uniqueMessageId
protected int uniqueMessageId
flags
protected byte flags
messageType
protected byte messageType
MessageBase
public MessageBase()
parseHeader
public static MessageBase parseHeader(ByteBuffer buf,
int startPosition,
ReplyMessageFactory replyInputStreamFactory)
throws MessageParseException
- Parses the Header of the Custom Protocol.
The Protocol has the following format:
byte 1 Magic :Used to identify Protocol
byte 2 Magic
byte 3 Magic
byte 4 Magic
byte 5 Version : Version of protocol.
byte 6 Message : RequestMessage,ReplyMessage,FragmentMessage,...
byte 7 Flags : In the moment : MoreFragmentsToFollow, Gzip, ApplicationLayerError
byte 8 Unique Id : Helper for Fragments (Only unique by connection)
byte 9 Unique Id
byte 10 Unique Id
byte 11 Unique Id
byte 12 Size : How many bytes the Message contains (with Header)
byte 13 Size
byte 14 Size
byte 15 Size
byte 16 Request ID : The Request Id of Message (Used to Reply to Requests)
byte 17 Request ID
byte 18 Request ID
byte 19 Request ID
byte 20 Session ID : Session Id of Message (Used to authenticate Client).
byte 21 Session ID
byte 22 Session ID
byte 23 Session ID
- Parameters:
buf
- Bytebuffer with read in bytesstartPosition
- the message beginningreplyInputStreamFactory
- need for creating a replymessage
- Returns:
- a Message based on the Header bytes
- Throws:
MessageParseException
- Indicating a parse Exception
checkMagic
public static void checkMagic(ByteBuffer buf,
int startPosition)
throws MessageParseException
- Checks if the current byteBuffer has a message starting with the
correct <@link Message#Magic>
- Parameters:
buf
- current buffer containing message bytesstartPosition
- start of current message
- Throws:
MessageParseException
setMessageType
protected void setMessageType(byte messageType)
getMessageType
public byte getMessageType()
- Specified by:
getMessageType
in interface Message
getUniqueMessageId
public int getUniqueMessageId()
isError
public boolean isError()
isClean
public boolean isClean()
getMessageSize
public int getMessageSize()
getNeededBytesSize
public int getNeededBytesSize()
moreFragmentsToFollow
public boolean moreFragmentsToFollow()
- Signals that more Messages will follow all belonging to
the first Message with all the same uniqueId.
The last Message will return on
moreFragmentsToFollow()
false.
- Specified by:
moreFragmentsToFollow
in interface Message
- Returns:
- if more fragments are expected
isGzip
public boolean isGzip()
isApplicationLayerException
public boolean isApplicationLayerException()
getRequestId
public int getRequestId()
- Specified by:
getRequestId
in interface Message
getSessionId
public int getSessionId()
Copyright © 2012 Oracle Corporation. All Rights Reserved.