|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.enterprise.mgmt.transport.MessageImpl
public class MessageImpl
This is a default Message's implementation
The byte array or ByteBuffer which represent this message's low level data will be cached if this message is not modified
Here are this message's structure
----
[packet]
magic(4) + version(4) + type(4) + messages_length(4) + messages(message_length)
[messages]
message_count(4) + message_key1 + message_value1 + message_key2 + message_value2 + ...(message_count)
----
| Field Summary | |
|---|---|
static int |
DEFAULT_MAX_TOTAL_MESSAGE_LENGTH
|
static int |
HEADER_LENGTH
|
static int |
UNSPECIFIED_MESSAGE_LENGTH
|
| Fields inherited from interface com.sun.enterprise.mgmt.transport.Message |
|---|
SOURCE_PEER_ID_TAG, TARGET_PEER_ID_TAG, TYPE_CLUSTER_MANAGER_MESSAGE, TYPE_HEALTH_MONITOR_MESSAGE, TYPE_MASTER_NODE_MESSAGE, TYPE_MCAST_MESSAGE, TYPE_PING_MESSAGE, TYPE_PONG_MESSAGE |
| Constructor Summary | |
|---|---|
MessageImpl()
|
|
MessageImpl(int type)
|
|
MessageImpl(int type,
Map<String,Serializable> messages)
|
|
| Method Summary | |
|---|---|
Object |
addMessageElement(String key,
Serializable value)
Adds a special element to this message with key-value pair |
static int |
getMaxMessageLength()
|
Object |
getMessageElement(String key)
Returns the value to which the specified key is mapped, or null if this message contains no mapping for the key |
Set<Map.Entry<String,Serializable>> |
getMessageElements()
Returns a Set element view of the mappings contained in this message |
Buffer |
getPlainBuffer(ExpandableBufferWriterFactory bufferWriterFactory)
Returns a Buffer of this message |
ByteBuffer |
getPlainByteBuffer()
Returns a ByteBuffer of this message |
byte[] |
getPlainBytes()
Returns a byte array of this message |
static String |
getStringType(int type)
|
int |
getType()
Returns the message's type i.g. |
int |
getVersion()
Returns the message's version |
void |
initialize(int type,
Map<String,Serializable> messages)
Initializes this message with initial type and key-value pair's map |
int |
parseHeader(Buffer buffer,
int offset)
Parses the message's header from given ByteBuffer |
int |
parseHeader(byte[] bytes,
int offset)
Parses the message's header from given byte array |
void |
parseMessage(Buffer buffer,
int offset,
int length)
Parses the message's body from given ByteBuffer |
void |
parseMessage(byte[] bytes,
int offset,
int length)
Parses the message's body from given byte array |
Object |
removeMessageElement(String key)
Removes the mapping for a key from this message if it is present |
static void |
setMaxMessageLength(int maxMsgLength)
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_MAX_TOTAL_MESSAGE_LENGTH
public static final int UNSPECIFIED_MESSAGE_LENGTH
public static final int HEADER_LENGTH
| Constructor Detail |
|---|
public MessageImpl()
public MessageImpl(int type)
public MessageImpl(int type,
Map<String,Serializable> messages)
| Method Detail |
|---|
public static int getMaxMessageLength()
public static void setMaxMessageLength(int maxMsgLength)
public void initialize(int type,
Map<String,Serializable> messages)
throws IllegalArgumentException
initialize in interface Messagetype - message typemessages - key-value pair's message
IllegalArgumentException - if the argument is not valid
public int parseHeader(byte[] bytes,
int offset)
throws IllegalArgumentException
parseHeader in interface Messagebytes - byte array which should be parsedoffset - offset from which the message should be parsed
IllegalArgumentException - if the argument is not valid or an unexpected error occurs
public int parseHeader(Buffer buffer,
int offset)
throws IllegalArgumentException
parseHeader in interface Messagebuffer - ByteBuffer which should be parsedoffset - offset from which the message should be parsed
IllegalArgumentException - if the argument is not valid or an unexpected error occurs
public void parseMessage(byte[] bytes,
int offset,
int length)
throws IllegalArgumentException,
MessageIOException
parseMessage in interface Messagebytes - byte array which should be parsedoffset - offset from which the message should be parsedlength - the message's length(body length)
IllegalArgumentException - if the argument is not valid or an unexpected error occurs
MessageIOException - if an I/O error occurs
public void parseMessage(Buffer buffer,
int offset,
int length)
throws IllegalArgumentException,
MessageIOException
parseMessage in interface Messagebuffer - ByteBuffer which should be parsedoffset - offset from which the message should be parsedlength - the message's length(body length)
IllegalArgumentException - if the argument is not valid or an unexpected error occurs
MessageIOException - if an I/O error occurspublic int getVersion()
getVersion in interface Messagepublic int getType()
TYPE_CLUSTER_MANAGER_MESSAGE or TYPE_HEALTH_MONITOR_MESSAGE's integer value or etc...
getType in interface Message
public Object addMessageElement(String key,
Serializable value)
addMessageElement in interface Messagekey - key with which the specified value is to be associatedvalue - serializable value to be associated with the specified key
public Object getMessageElement(String key)
null if this message contains no mapping for the key
getMessageElement in interface Messagekey - the key whose associated value is to be returned
null if this message contains no mapping for the keypublic Object removeMessageElement(String key)
removeMessageElement in interface Messagekey - key whose mapping is to be removed from the message
public Set<Map.Entry<String,Serializable>> getMessageElements()
Set element view of the mappings contained in this message
getMessageElements in interface Message
public ByteBuffer getPlainByteBuffer()
throws MessageIOException
ByteBuffer of this message
getPlainByteBuffer in interface MessageMessageIOException - if an I/O error occurs
public byte[] getPlainBytes()
throws MessageIOException
getPlainBytes in interface MessageMessageIOException - if an I/O error occurs
public Buffer getPlainBuffer(ExpandableBufferWriterFactory bufferWriterFactory)
throws MessageIOException
MessageBuffer of this message
getPlainBuffer in interface MessagebufferWriterFactory - ExpandableBufferWriterFactory.
MessageIOException - if an I/O error occurspublic static String getStringType(int type)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||