|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.javagroups.Message
A Message encapsulates data sent to members of a group. It contains among other things the address of the sender, the destination address, a payload (byte buffer) and a list of headers. Headers are added by protocols on the sender side and removed by protocols on the receiver's side.
Field Summary | |
protected byte[] |
buf
|
protected Address |
dest_addr
|
protected java.util.HashMap |
headers
|
protected Address |
src_addr
|
Constructor Summary | |
Message()
Only used for Externalization (creating an initial object) |
|
Message(Address dest,
Address src,
byte[] buf)
Public constructor |
|
Message(Address dest,
Address src,
java.io.Serializable obj)
Public constructor |
Method Summary | |
protected java.lang.Object |
clone()
|
Message |
copy()
|
byte[] |
getBuffer()
Returns the payload (byte buffer). |
Address |
getDest()
|
Header |
getHeader(java.lang.String key)
|
java.util.Map |
getHeaders()
|
java.lang.Object |
getObject()
|
Address |
getSrc()
|
Message |
makeReply()
|
java.lang.String |
printObjectHeaders()
|
void |
putHeader(java.lang.String key,
Header hdr)
Puts a header given a key into the hashmap. |
void |
readExternal(java.io.ObjectInput in)
|
Header |
removeHeader(java.lang.String key)
|
void |
removeHeaders()
|
void |
reset()
Nulls all fields of this message so that the message can be reused. |
void |
setBuffer(byte[] b)
|
void |
setDest(Address new_dest)
|
void |
setObject(java.io.Serializable obj)
|
void |
setSrc(Address new_src)
|
long |
size()
Returns size of buffer, plus some constant overhead for src and dest, plus number of headers time some estimated size/header. |
java.lang.String |
toString()
|
java.lang.String |
toStringAsObject()
Tries to read an object from the message's buffer and prints it |
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Address dest_addr
protected Address src_addr
protected byte[] buf
protected java.util.HashMap headers
Constructor Detail |
public Message(Address dest, Address src, byte[] buf)
dest
- Address of receiver. If it is null or a string, then
it is sent to the group (either to current group or to the group as given
in the string). If it is a Vector, then it contains a number of addresses
to which it must be sent. Otherwise, it contains a single destination.Addresses are generally untyped (all are of type Object. A channel instance must know what types of addresses it expects and downcast accordingly.
src
- Address of senderbuf
- Message to be sent. Note that this buffer must not be modified (e.g. buf[0]=0 is
not allowed), since we don't copy the contents on clopy() or clone().public Message(Address dest, Address src, java.io.Serializable obj)
dest
- Address of receiver. If it is null or a string, then
it is sent to the group (either to current group or to the group as given
in the string). If it is a Vector, then it contains a number of addresses
to which it must be sent. Otherwise, it contains a single destination.Addresses are generally untyped (all are of type Object. A channel instance must know what types of addresses it expects and downcast accordingly.
src
- Address of senderobj
- The object will be serialized into the byte buffer. Object
has to be serializable ! Note that the resulting buffer must not be modified
(e.g. buf[0]=0 is not allowed), since we don't copy the contents on clopy() or clone().public Message()
Method Detail |
public Address getDest()
public void setDest(Address new_dest)
public Address getSrc()
public void setSrc(Address new_src)
public byte[] getBuffer()
public void setBuffer(byte[] b)
public java.util.Map getHeaders()
public void setObject(java.io.Serializable obj)
public java.lang.Object getObject()
public void reset()
public void putHeader(java.lang.String key, Header hdr)
public Header removeHeader(java.lang.String key)
public void removeHeaders()
public Header getHeader(java.lang.String key)
public Message copy()
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
public Message makeReply()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringAsObject()
public long size()
Size estimations don't have to be very accurate since this is mainly used by FRAG to determine whether to fragment a message or not. Fragmentation will then serialize the message, therefore getting the correct value.
public java.lang.String printObjectHeaders()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |