|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectspread.SpreadMessage
public class SpreadMessage
A SpreadMessage object represents either an incoming or outgoing spread message.
An outgoing message is one being sent with SpreadConnection.multicast(SpreadMessage)
.
An incoming message is one received with SpreadConnection.receive()
.
To send a message on a spread connection, first create a message object:
SpreadMessage message = new SpreadMessage();
Then set the data with either setData(byte[])
, setObject(Serializable)
,
or digest(Serializable)
:
message.setData(data);
Select which group(s) to send the message to with addGroup(SpreadGroup)
:
message.setGroup(group);
When the message is read to be sent, send it with SpreadConnection.multicast(SpreadMessage)
:
connection.multicast(message);
Field Summary | |
---|---|
protected static int |
AGREED_MESS
|
protected static int |
CAUSAL_MESS
|
protected static int |
CAUSED_BY_DISCONNECT
|
protected static int |
CAUSED_BY_JOIN
|
protected static int |
CAUSED_BY_LEAVE
|
protected static int |
CAUSED_BY_NETWORK
|
protected int |
content
|
private static int |
CONTENT_DATA
|
private static int |
CONTENT_DIGEST
|
private static int |
CONTENT_OBJECT
|
private byte[] |
data
|
protected java.io.ByteArrayOutputStream |
digestBytes
|
protected java.io.ObjectOutputStream |
digestOutput
|
private boolean |
endianMismatch
|
protected static int |
FIFO_MESS
|
protected java.util.Vector |
groups
|
protected static int |
GROUPS_MESS
|
protected static int |
JOIN_MESS
|
protected static int |
KILL_MESS
|
protected static int |
LEAVE_MESS
|
protected static int |
MEMBERSHIP_MESS
|
private MembershipInfo |
membershipInfo
|
private boolean |
outgoing
|
protected static int |
REG_MEMB_MESS
|
protected static int |
REGULAR_MESS
|
protected static int |
REJECT_MESS
|
protected static int |
RELIABLE_MESS
|
protected static int |
SAFE_MESS
|
protected static int |
SELF_DISCARD
|
private SpreadGroup |
sender
|
private int |
serviceType
|
protected static int |
TRANSITION_MESS
|
private short |
type
|
protected static int |
UNRELIABLE_MESS
|
Constructor Summary | |
---|---|
|
SpreadMessage()
Initializes a new outgoing SpreadMessage object. |
protected |
SpreadMessage(int serviceType,
java.util.Vector groups,
SpreadGroup sender,
byte[] data,
short type,
boolean endianMismatch,
MembershipInfo membershipInfo)
|
Method Summary | |
---|---|
void |
addGroup(SpreadGroup group)
Adds this group to the list this message will be sent to. |
void |
addGroup(java.lang.String group)
Adds this group to the list this message will be sent to. |
void |
addGroups(SpreadGroup[] groups)
Adds these groups to the list this message will be sent to. |
void |
addGroups(java.lang.String[] groups)
Adds these groups to the list this message will be sent to. |
java.lang.Object |
clone()
Creates a copy of this message. |
void |
digest(java.io.Serializable object)
Adds this message to the digest. |
byte[] |
getData()
Gets the message data as an array of bytes. |
java.util.Vector |
getDigest()
Gets the message data as a digest. |
boolean |
getEndianMismatch()
Checks for an endian mismatch. |
SpreadGroup[] |
getGroups()
Gets an array containing the SpreadGroup's to which this message was sent. |
MembershipInfo |
getMembershipInfo()
Get the membership info for this message. |
java.lang.Object |
getObject()
Gets the message data as a java object. |
SpreadGroup |
getSender()
Gets the message sender's private group. |
int |
getServiceType()
Get the message's service type. |
short |
getType()
Gets the message type. |
boolean |
isAgreed()
Checks if this is an agreed message. |
boolean |
isCausal()
Checks if this is a causal message. |
boolean |
isFifo()
Checks if this is a fifo message. |
boolean |
isIncoming()
Check if this is an incoming message. |
boolean |
isMembership()
Checks if this is a membership message. |
protected static boolean |
isMembership(int serviceType)
|
boolean |
isOutgoing()
Check if this is an outgoing message. |
boolean |
isRegular()
Checks if this is a regular message. |
protected static boolean |
isRegular(int serviceType)
|
boolean |
isReject()
Checks if this is a rejected message. |
protected static boolean |
isReject(int serviceType)
|
boolean |
isReliable()
Checks if this is a reliable message. |
boolean |
isSafe()
Checks if this is a safe message. |
boolean |
isSelfDiscard()
Checks if this is a self-discard message. |
boolean |
isUnreliable()
Checks if this is an unreliable message. |
void |
setAgreed()
Sets the message to be agreed. |
void |
setCausal()
Sets the message to be causal. |
void |
setData(byte[] data)
Sets the message's data to this array of bytes. |
void |
setFifo()
Sets the message to be fifo. |
void |
setObject(java.io.Serializable object)
Sets the message's data to this object, in serialized form. |
void |
setReliable()
Sets the message to be reliable. |
void |
setSafe()
Sets the message to be safe. |
void |
setSelfDiscard(boolean selfDiscard)
If selfDiscard is true, sets the self discard flag for the message, otherwise
clears the flag. |
void |
setServiceType(int serviceType)
Sets the service type. |
void |
setType(short type)
Set's the message type. |
void |
setUnreliable()
Sets the message to be unreliable. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int UNRELIABLE_MESS
protected static final int RELIABLE_MESS
protected static final int FIFO_MESS
protected static final int CAUSAL_MESS
protected static final int AGREED_MESS
protected static final int SAFE_MESS
protected static final int REGULAR_MESS
protected static final int SELF_DISCARD
protected static final int REG_MEMB_MESS
protected static final int TRANSITION_MESS
protected static final int CAUSED_BY_JOIN
protected static final int CAUSED_BY_LEAVE
protected static final int CAUSED_BY_DISCONNECT
protected static final int CAUSED_BY_NETWORK
protected static final int MEMBERSHIP_MESS
protected static final int REJECT_MESS
protected static final int JOIN_MESS
protected static final int LEAVE_MESS
protected static final int KILL_MESS
protected static final int GROUPS_MESS
private static final int CONTENT_DATA
private static final int CONTENT_OBJECT
private static final int CONTENT_DIGEST
private boolean outgoing
protected int content
private int serviceType
protected java.util.Vector groups
private SpreadGroup sender
private byte[] data
private short type
private boolean endianMismatch
private MembershipInfo membershipInfo
protected java.io.ByteArrayOutputStream digestBytes
protected java.io.ObjectOutputStream digestOutput
Constructor Detail |
---|
protected SpreadMessage(int serviceType, java.util.Vector groups, SpreadGroup sender, byte[] data, short type, boolean endianMismatch, MembershipInfo membershipInfo)
public SpreadMessage()
Method Detail |
---|
public boolean isIncoming()
SpreadConnection.receive()
.
public boolean isOutgoing()
SpreadConnection.multicast(SpreadMessage)
.
public int getServiceType()
public boolean isRegular()
getGroups()
,
getSender()
,
getData()
,
getObject()
,
getDigest()
,
getType()
,
getEndianMismatch()
protected static boolean isRegular(int serviceType)
public boolean isReject()
getGroups()
,
getSender()
,
getData()
,
getObject()
,
getDigest()
,
getType()
,
getEndianMismatch()
protected static boolean isReject(int serviceType)
public boolean isMembership()
getMembershipInfo()
can
be used to get more information on the membership change.
getMembershipInfo()
protected static boolean isMembership(int serviceType)
public boolean isUnreliable()
public boolean isReliable()
public boolean isFifo()
public boolean isCausal()
public boolean isAgreed()
public boolean isSafe()
public boolean isSelfDiscard()
public void setServiceType(int serviceType)
serviceType
- the new service typepublic void setUnreliable()
public void setReliable()
public void setFifo()
public void setCausal()
public void setAgreed()
public void setSafe()
public void setSelfDiscard(boolean selfDiscard)
selfDiscard
is true, sets the self discard flag for the message, otherwise
clears the flag. If the self discard flag is set, the message will not be received at the
connection it is multicast on.
selfDiscard
- if true, set the self discard flag, if false, clear the self discard flagpublic SpreadGroup[] getGroups()
public SpreadGroup getSender()
public byte[] getData()
setData(byte[])
or from an application using the C library.
setData(byte[])
public java.lang.Object getObject() throws SpreadException
setObject(Serializable)
. Regardless of the type of
object passed to setObject(Serializable)
, this method returns
an object of type Object, so it must be cast to the correct type.
SpreadException
- if there is an error reading the objectsetObject(Serializable)
public java.util.Vector getDigest() throws SpreadException
digest(Serializable)
. This method returns a Vector containing
all of the objects passed to digest(Serializable)
, in the order
they were passed.
SpreadException
- if there is an error reading the objectsdigest(Serializable)
public short getType()
setType(short)
.
setType(short)
public boolean getEndianMismatch()
public void addGroup(SpreadGroup group)
group
- a group to send this message topublic void addGroups(SpreadGroup[] groups)
groups
- a list of groups to send this message topublic void addGroup(java.lang.String group)
group
- a group to send this message topublic void addGroups(java.lang.String[] groups)
groups
- a list of groups to send this message topublic void setData(byte[] data)
setData(byte[])
, setObject(Serializable)
,
digest(Serializable)
.
data
- the new message datagetData()
public void setObject(java.io.Serializable object) throws SpreadException
setData(byte[])
, setObject(Serializable)
,
digest(Serializable)
. This should not be used if an application using
the C library needs to read this message.
object
- the object to set the data to
SpreadException
getObject()
public void digest(java.io.Serializable object) throws SpreadException
setData(byte[])
or setObject(Serializable)
.
This should not be used if an application using the C library needs to read this message.
When the message is sent, all of the objects that have been passed to this method get
sent as the message data.
object
- the object to add to the digets
SpreadException
getDigest()
public void setType(short type)
type
- the message typegetType()
public MembershipInfo getMembershipInfo()
isMembership()
is true).
public java.lang.Object clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |