fr.dyade.aaa.agent
Class Message

java.lang.Object
  extended by fr.dyade.aaa.agent.Message
All Implemented Interfaces:
java.io.Serializable

final class Message
extends java.lang.Object
implements java.io.Serializable

The internal message structure. A message is divided in 2 parts:


Field Summary
(package private)  short dest
          The unique id. of destination server
(package private) static byte DETACHABLE
           
(package private)  AgentId from
          AgentId of sender.
(package private) static int LENGTH
           
(package private)  Notification not
          The notification.
(package private) static byte NOTNULL
           
(package private) static byte NULL
           
(package private) static byte PERSISTENT
           
private static Pool pool
           
(package private) static long serialVersionUID
          define serialVersionUID for interoperability
(package private)  short source
          The unique id. of source server
(package private)  int stamp
          The current stamp of the message
private  java.lang.String stringId
           
(package private)  AgentId to
          AgentId of destination agent.
 
Constructor Summary
private Message()
          Construct a new message.
 
Method Summary
(package private) static Message alloc()
          Allocates a message from the pool.
(package private) static Message alloc(AgentId from, AgentId to, Notification not)
          Allocates a message from the pool.
 java.lang.StringBuffer appendToString(java.lang.StringBuffer strbuf)
          Adds a string representation for this object in the StringBuffer parameter.
(package private)  void delete()
          Deletes the current object in persistent storage.
(package private)  void free()
          Frees the message to the pool.
(package private)  short getDest()
          Get the unique server id. of the addressee of this message
(package private)  short getSource()
          Get the unique server id. of the sender of this message
(package private)  int getStamp()
          Get the stamp of this message
(package private)  boolean isPersistent()
          Tests if the associated notification is persistent or not.
(package private) static Message load(java.lang.String name)
          Restores the object state from the persistent storage.
(package private)  void optFromByte(byte opt)
           
(package private)  byte optToByte()
           
private  void readObject(java.io.ObjectInputStream in)
          The readObject method is responsible for reading from the stream and restoring the classes fields.
(package private)  void save()
          Saves the object state on persistent storage.
private  void set(AgentId from, AgentId to, Notification not)
           
 java.lang.String toString()
          Returns a string representation for this object.
(package private)  java.lang.String toStringId()
           
private  void writeObject(java.io.ObjectOutputStream out)
          The writeObject method is responsible for writing the state of the object for its particular class so that the corresponding readObject method can restore it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
define serialVersionUID for interoperability

See Also:
Constant Field Values

from

transient AgentId from
AgentId of sender.


to

transient AgentId to
AgentId of destination agent.


not

transient Notification not
The notification.


source

transient short source
The unique id. of source server


dest

transient short dest
The unique id. of destination server


stamp

transient int stamp
The current stamp of the message


LENGTH

static final int LENGTH
See Also:
Constant Field Values

NULL

static final byte NULL
See Also:
Constant Field Values

NOTNULL

static final byte NOTNULL
See Also:
Constant Field Values

PERSISTENT

static final byte PERSISTENT
See Also:
Constant Field Values

DETACHABLE

static final byte DETACHABLE
See Also:
Constant Field Values

stringId

private transient java.lang.String stringId

pool

private static Pool pool
Constructor Detail

Message

private Message()
Construct a new message.

Method Detail

getSource

short getSource()
Get the unique server id. of the sender of this message


getDest

short getDest()
Get the unique server id. of the addressee of this message


getStamp

int getStamp()
Get the stamp of this message


toString

public java.lang.String toString()
Returns a string representation for this object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this object.

appendToString

public java.lang.StringBuffer appendToString(java.lang.StringBuffer strbuf)
Adds a string representation for this object in the StringBuffer parameter.

Returns:
A string representation of this object.

optToByte

byte optToByte()

optFromByte

void optFromByte(byte opt)

writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException
The writeObject method is responsible for writing the state of the object for its particular class so that the corresponding readObject method can restore it. Be careful this method should only be used for saving messages in persistent storage, sending messages will be done by another way. It is also used for HA synchronization.

Throws:
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
The readObject method is responsible for reading from the stream and restoring the classes fields. Be careful this method should only be used for restoring messages from persistent storage, receiving messages will be done by another way.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

toStringId

final java.lang.String toStringId()

isPersistent

boolean isPersistent()
Tests if the associated notification is persistent or not.

Returns:
true if the associated notification is persistent.

save

void save()
    throws java.io.IOException
Saves the object state on persistent storage.

Throws:
java.io.IOException

load

static Message load(java.lang.String name)
             throws java.io.IOException,
                    java.lang.ClassNotFoundException
Restores the object state from the persistent storage.

Throws:
java.io.IOException - when accessing the stored image
java.lang.ClassNotFoundException - if the stored image class may not be found

delete

void delete()
Deletes the current object in persistent storage.


alloc

static Message alloc()
Allocates a message from the pool.


alloc

static Message alloc(AgentId from,
                     AgentId to,
                     Notification not)
Allocates a message from the pool.

Parameters:
from - id of source Agent.
to - id of destination Agent.
not - Notification to be signaled.

free

void free()
Frees the message to the pool.


set

private void set(AgentId from,
                 AgentId to,
                 Notification not)


Copyright © 2010 ScalAgent D.T.. All Rights Reserved.