com.sun.enterprise.mgmt.transport.grizzly.grizzly1_9
Class GrizzlyMessageProtocolParser

java.lang.Object
  extended by com.sun.enterprise.mgmt.transport.grizzly.grizzly1_9.GrizzlyMessageProtocolParser
All Implemented Interfaces:
com.sun.grizzly.ProtocolParser<Message>

public class GrizzlyMessageProtocolParser
extends Object
implements com.sun.grizzly.ProtocolParser<Message>

Message protocol format is: Message Header is MessageImpl.HEADER_LENGTH and composed of following fields. magicNumber integer MessageImpl.MAGIC_NUMBER version integer MessageImpl.VERSION type integer Message.getType() for possible values messageLength integer MessageImpl.maxTotalMessageLength Message Body is composed of following fields. payload byte[messageLen] MessageHeader Message#parseHeader(com.sun.enterprise.mgmt.transport.Buffer, int) MessageBody Message#parseMessage(com.sun.enterprise.mgmt.transport.Buffer, int, int)

Author:
Bongjae Chang, Joe FIalli

Field Summary
 
Fields inherited from interface com.sun.grizzly.ProtocolParser
MESSAGE, PARSER
 
Constructor Summary
protected GrizzlyMessageProtocolParser()
           
protected GrizzlyMessageProtocolParser(com.sun.grizzly.SSLConfig sslConfig)
           
 
Method Summary
static ParserFilter createParserProtocolFilter(com.sun.grizzly.SSLConfig sslConfig)
           
 Message getNextMessage()
          Get the next complete message from the buffer, which can then be processed by the next filter in the protocol chain.
 boolean hasMoreBytesToParse()
          Are there more bytes to be parsed in the ByteBuffer given to this ProtocolParser's ProtocolParser.startBuffer(ByteBuffer) ? This method is typically called after processing the protocol message, to determine if the ByteBuffer has more bytes which need to parsed into a next message.
 boolean hasNextMessage()
          Indicates whether the buffer has a complete message that can be returned from ProtocolParser.getNextMessage().
 boolean isError()
           
 boolean isExpectingMoreData()
          Is this ProtocolParser expecting more data ? This method is typically called after a call to ProtocolParser.hasNextMessage() to determine if the ByteBuffer which has been parsed contains a partial message
 boolean releaseBuffer()
          No more parsing will be done on the buffer passed to ProtocolParser.startBuffer(ByteBuffer).
 void startBuffer(ByteBuffer bb)
          Set the buffer to be parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrizzlyMessageProtocolParser

protected GrizzlyMessageProtocolParser()

GrizzlyMessageProtocolParser

protected GrizzlyMessageProtocolParser(com.sun.grizzly.SSLConfig sslConfig)
Method Detail

createParserProtocolFilter

public static ParserFilter createParserProtocolFilter(com.sun.grizzly.SSLConfig sslConfig)

isError

public boolean isError()

isExpectingMoreData

public boolean isExpectingMoreData()
Is this ProtocolParser expecting more data ? This method is typically called after a call to ProtocolParser.hasNextMessage() to determine if the ByteBuffer which has been parsed contains a partial message

Specified by:
isExpectingMoreData in interface com.sun.grizzly.ProtocolParser<Message>
Returns:
- true if more bytes are needed to construct a message; false, if no additional bytes remain to be parsed into a protocol data unit. Note that if no partial message exists, this method should return false.

hasMoreBytesToParse

public boolean hasMoreBytesToParse()
Are there more bytes to be parsed in the ByteBuffer given to this ProtocolParser's ProtocolParser.startBuffer(ByteBuffer) ? This method is typically called after processing the protocol message, to determine if the ByteBuffer has more bytes which need to parsed into a next message.

Specified by:
hasMoreBytesToParse in interface com.sun.grizzly.ProtocolParser<Message>
Returns:
true if there are more bytes to be parsed. Otherwise false.

getNextMessage

public Message getNextMessage()
Get the next complete message from the buffer, which can then be processed by the next filter in the protocol chain. Because not all filters will understand protocol messages, this method should also set the position and limit of the buffer at the start and end boundaries of the message. Filters in the protocol chain can retrieve this message via context.getAttribute(MESSAGE)

Specified by:
getNextMessage in interface com.sun.grizzly.ProtocolParser<Message>
Returns:
The next message in the buffer. If there isn't such a message, return null.

hasNextMessage

public boolean hasNextMessage()
Indicates whether the buffer has a complete message that can be returned from ProtocolParser.getNextMessage(). Smart implementations of this will set up all the information so that an actual call to ProtocolParser.getNextMessage() doesn't need to re-parse the data.

Specified by:
hasNextMessage in interface com.sun.grizzly.ProtocolParser<Message>

startBuffer

public void startBuffer(ByteBuffer bb)
Set the buffer to be parsed. This method should store the buffer and its state so that subsequent calls to ProtocolParser.getNextMessage() will return distinct messages, and the buffer can be restored after parsing when the ProtocolParser.releaseBuffer() method is called.

Specified by:
startBuffer in interface com.sun.grizzly.ProtocolParser<Message>

releaseBuffer

public boolean releaseBuffer()
No more parsing will be done on the buffer passed to ProtocolParser.startBuffer(ByteBuffer). Set up the buffer so that its position is the first byte that was not part of a full message, and its limit is the original limit of the buffer.

Specified by:
releaseBuffer in interface com.sun.grizzly.ProtocolParser<Message>
Returns:
-- true if the parser has saved some state (e.g. information data in the buffer that hasn't been returned in a full message); otherwise false. If this method returns true, the framework will make sure that the same parser is used to process the buffer after more data has been read.


Copyright © 2012. All Rights Reserved.