Agent System POND 1.0 (1.7.2000)

PkgAgentSystem.Messaging
Class Message

java.lang.Object
  |
  +--PkgAgentSystem.Messaging.Message
Direct Known Subclasses:
AcceptMessage, BroadcastMessage, ChallengeIdentityMessage, DeclineMessage, MessageReply, RejectMessage, ResultMessage, SendStatementsMessage, SignedMessage, TerminateAgentMessage

public abstract class Message
extends Object
implements Serializable, Cloneable

A message, which can be sent from one agent to another.
Subclasses MUST be serializable, else messaging will NOT work!

ATTENTION: The following is NOT allowed:
If a message contains a system class or an agent-system class, this class MUST NOT store a contained agent-class in binary form. It may contain it as an field.
If the data is automatically restored from the stream during deserialization or read through readObject, there is no problem. Not allowed is reading it in as an byte array and restoring it from a different (self created) ObjectInputStream (via a ByteArrayInputStream).
The problem is the following: When the class is deserialized through the classloader of the receiving agent, this class will be loaded (ot tried to be loaded) by the classloader of the system-class/agent-system class, which is the primordial classloader. If this is successful, there will be no possibility to cast it to the local type of the agent (which is loaded through the agents classloader!). The data will not be available for the receiver.
Example: java.security.SignedObject will not work.
Example: SignedMessage PkgAgentSystem.Messaging.SignedMessage does work.

Version:
1.0, 1.7.2000
Author:
Michael Sonntag
See Also:
AgentBase, AgentSystem.sendMessage(AgentBase,Message), Serialized Form

Field Summary
protected  AgentIdentity addressee
          The recipient of the message.
protected  long convTypeID
          ID of the type of the conversation, which handles this message.
protected  long destConvID
          ID of the conversation at the destination of the message.
protected  AgentIdentity sender
          The sender of the message
protected  long srcConvID
          ID of the conversation at the source of the message.
 
Constructor Summary
protected Message()
          Create a new and empty message.
protected Message(AgentIdentity sender, AgentIdentity addressee, long convTypeID, long srcConvID, long destConvID)
          Creates a new message from one agent to another.
protected Message(Message inReplyTo)
          Create a new message in reply to another one.
 
Method Summary
 Message copy()
          Returns a shallow copy of this message.
 AgentIdentity getAddressee()
          Returns the identity of the recipient of the message.
 long getConversationTypeID()
          Returns the ID of the type of conversations handling this message.
 long getDestConversationID()
          Returns the ID of the conversation at the recipient of the message.
 AgentIdentity getSender()
          Returns the identity of the sender of the message.
 long getSrcConversationID()
          Returns the ID of the conversation at the sender of the message.
 void setDestConversationID(long id)
          Set the ID for the conversation at the destination.
 void setSrcConversationID(long id)
          Set the ID for the conversation at the sender.
 String toString()
          Returns a string representation of this message.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

srcConvID

protected long srcConvID
ID of the conversation at the source of the message.

destConvID

protected long destConvID
ID of the conversation at the destination of the message.

convTypeID

protected long convTypeID
ID of the type of the conversation, which handles this message.

sender

protected transient AgentIdentity sender
The sender of the message

addressee

protected transient AgentIdentity addressee
The recipient of the message. This might be null, although this is not allowed in the constructor. The subclass BroadcastMessage has a constructor where this is allowed/necessary (broadcasts have no single recipient).
Constructor Detail

Message

protected Message()
Create a new and empty message. Necessary, so we get no default public constructor. No class should be able to create a message without the necessary parameters.

Message

protected Message(AgentIdentity sender,
                  AgentIdentity addressee,
                  long convTypeID,
                  long srcConvID,
                  long destConvID)
Creates a new message from one agent to another.
Parameters:
sender - the identity of the sender. Must be provided.
addressee - the identity of the recipient. Must be provided.
convTypeID - ID of the type of the conversation. Must not be 0.
srcConvID - ID of the conversation at the source. May be 0 for replies to unknown conversations, ... (there is no conversation with those).
destConvID - ID of the conversation at the recipient. May be 0 for initial messages (starting a conversation) and broadcasts.

Message

protected Message(Message inReplyTo)
Create a new message in reply to another one. The addressee is copied to the sender and the sender to the recipient. The conversation type ID stays the same. The source conversation ID is copied to the destionation conversation ID and reverse.
Method Detail

setDestConversationID

public void setDestConversationID(long id)
Set the ID for the conversation at the destination. Only allowed if the ID is currently 0.
Parameters:
id - the id of the conversation at the destination (may not be 0)

setSrcConversationID

public void setSrcConversationID(long id)
Set the ID for the conversation at the sender. Only allowed if the ID is currently 0.
Parameters:
id - the id of the conversation at the sender (may not be 0)

getSrcConversationID

public long getSrcConversationID()
Returns the ID of the conversation at the sender of the message.
Returns:
conversation ID of the sender

getDestConversationID

public long getDestConversationID()
Returns the ID of the conversation at the recipient of the message.
Returns:
conversation ID of the recipient

getConversationTypeID

public long getConversationTypeID()
Returns the ID of the type of conversations handling this message.
Returns:
conversation type ID of this message

getSender

public AgentIdentity getSender()
Returns the identity of the sender of the message.
Returns:
identity of the sender

getAddressee

public AgentIdentity getAddressee()
Returns the identity of the recipient of the message.
Returns:
identity of the recipient

copy

public Message copy()
             throws MessageException
Returns a shallow copy of this message.
Returns:
a clone of this message
Throws:
MessageException - if this message cannot be cloned

toString

public String toString()
Returns a string representation of this message. The representation is the name of the actual class of the message and the names of the sender and the recipient.
Returns:
string representation of this message
Overrides:
toString in class Object

Agent System POND 1.0 (1.7.2000)

Submit a bug

Copyright 2000 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.