Class Message

java.lang.Object
i5.las2peer.communication.Message
All Implemented Interfaces:
XmlAble, java.lang.Cloneable

public class Message
extends java.lang.Object
implements XmlAble, java.lang.Cloneable
Base class for sending messages between AgentImpls. The content of the message will be encrypted symmetrically with a randomly generated key, this key will be encrypted asymmetrically for the recipient of the message. Additionally, the contents will be signed with the private key of the sender. Therefore, it is necessary, that the generating Thread has access to the private key of the sending agent. When specifying a topic, the message will be sent to all agents listening to the topic. Since these agents are not known, the message will not be encrypted.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static long DEFAULT_TIMEOUT  
  • Constructor Summary

    Constructors 
    Constructor Description
    Message()
    constructor for the XmlAble facilities
    Message​(Message responseTo, XmlAble data)
    Generate a new message in response to the given one.
    Message​(Message responseTo, XmlAble data, long timeoutMs)
    Generate a new message in response to the given one.
    Message​(Message responseTo, java.io.Serializable data)
    Generate a new message in response to the given one.
    Message​(Message responseTo, java.io.Serializable data, long timeoutMs)
    Generate a new message in response to the given one.
    Message​(AgentImpl from, long topic, java.io.Serializable data)
    create a new message to a topic with default timeout
    Message​(AgentImpl from, long topic, java.io.Serializable data, long timeoutMs)
    create a new message to all agents listening on the given topic
    Message​(AgentImpl from, AgentImpl to, XmlAble data)
    create a new message with default timeout
    Message​(AgentImpl from, AgentImpl to, XmlAble data, long timeoutMs)
    create a new message
    Message​(AgentImpl from, AgentImpl to, java.io.Serializable data)
    create a new message with default timeout
    Message​(AgentImpl from, AgentImpl to, java.io.Serializable data, long timeOutMs)
    create a new message
  • Method Summary

    Modifier and Type Method Description
    Message clone()  
    void close()
    close this message (envelope)
    static Message createFromXml​(java.lang.String xml)
    factory: create a message from an XML document
    java.lang.Object getContent()
    get the content of this message may be Serializable or XmlAble
    long getId()
    Gets the id of this message
    AgentImpl getRecipient()
    get the designated recipient of this message only works after opening or creating of the message
    java.lang.String getRecipientId()
    Gets the id of the recipient agent
    java.lang.Long getResponseToId()  
    AgentImpl getSender()
    get the sending agent of this message only works after opening or creation the message
    java.lang.String getSenderId()
    get the id of the sending agent
    java.io.Serializable getSendingNodeId()
    get the id of the sending node The type depends on on the Node implementation (Long for LocalNode and NodeHandle for PastryNodeImpl
    java.util.Date getTimeoutDate()  
    long getTimeoutTs()  
    long getTimestamp()  
    java.util.Date getTimestampDate()  
    java.lang.Long getTopicId()
    Gets the id of the receiving topic
    long getValidMs()  
    boolean isExpired()  
    boolean isOpen()  
    boolean isResponse()  
    boolean isTopic()
    Check if this message is sent to a topic
    void open​(AgentImpl unlockedRecipient, AgentStorage storage)
    open the message, i.e. decrypt the content with the private key of the receiving agent the private key has to be unlocked first!
    void open​(AgentImpl unlockedRecipient, AgentStorage storage, java.lang.ClassLoader contentClsLoader)
    open the message, i.e. decrypt the content with the private key of the receiving agent the private key has to be unlocked first!
    void open​(AgentStorage storage)
    open the message, i.e. decrypt the content with the private key of the receiving agent The storage has to know an unlocked version of the recipient agent!
    void setRecipientId​(java.lang.String id)
    set the id of the recipient (used by the node when receiving messages from topics)
    void setSendingNodeId​(java.lang.Long id)
    set the id of the node sending this message The long-variant is to use in case of a LocalNode network.
    void setSendingNodeId​(java.lang.Object id)
    set the id of the node sending this message
    void setSendingNodeId​(rice.p2p.commonapi.NodeHandle handle)
    set the if of the node sending this message The NodeHandle-variant is for Pastry based networks.
    void setStateFromXml​(java.lang.String xml)
    for XmlAble: set the state of this object from the given xml document
    java.lang.String toXmlString()
    from XmlAble return a XML representation of this instance
    void verifySignature()
    verify the signature of this message the content has to be available for this

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait