fr.dyade.aaa.agent
Class MessageSoftRef

java.lang.Object
  extended by fr.dyade.aaa.agent.MessageSoftRef

public final class MessageSoftRef
extends java.lang.Object


Nested Class Summary
(package private) static class MessageSoftRef.TransactionError
           
 
Field Summary
private static org.objectweb.util.monolog.api.Logger logmon
           
private  java.lang.String messageId
          If the notification is stored independently of its containing message, messageId contains the persistent name of this notification.
private  java.lang.String name
          Name for persistent message, used to retrieve garbaged message from persistent storage.
private  Message ref
          Reference for transient message, used to pin non persistent in memory.
private  java.lang.ref.SoftReference softRef
          The SoftReference to the message, which permits to the message to be garbaged in response to memory demand.
private  int stamp
          The stamp of the referenced message.
 
Constructor Summary
MessageSoftRef(Message msg)
           
 
Method Summary
 void delete()
          Deletes the message in persistent storage.
 Message getMessage()
          Returns this reference message's referent.
 int getStamp()
          Returns the stamp of the message backed by this MessageSoftRef, without reloading it if it has been swapped.
 Message loadMessage()
          Loads from disk this reference message's referent if the message has been swapped out.
 java.lang.String toString()
          Returns a string representation of this MessageSoftRef object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logmon

private static final org.objectweb.util.monolog.api.Logger logmon

name

private java.lang.String name
Name for persistent message, used to retrieve garbaged message from persistent storage.


ref

private Message ref
Reference for transient message, used to pin non persistent in memory.


softRef

private java.lang.ref.SoftReference softRef
The SoftReference to the message, which permits to the message to be garbaged in response to memory demand.


stamp

private int stamp
The stamp of the referenced message. It is useful to avoid reloading messages from disk when looking for a particular message.


messageId

private java.lang.String messageId
If the notification is stored independently of its containing message, messageId contains the persistent name of this notification.

Constructor Detail

MessageSoftRef

MessageSoftRef(Message msg)
Method Detail

getMessage

public Message getMessage()
Returns this reference message's referent. If the message has been swap out it returns null.

Returns:
The message to which this reference refers.

getStamp

public int getStamp()
Returns the stamp of the message backed by this MessageSoftRef, without reloading it if it has been swapped.

Returns:
the stamp of the message.

loadMessage

public Message loadMessage()
                    throws MessageSoftRef.TransactionError
Loads from disk this reference message's referent if the message has been swapped out. It should be called only after a getMessage returning null. The SoftReference is renewed to avoid reloading the message from disk each time this method is called.

Returns:
The message to which this reference refers.
Throws:
MessageSoftRef.TransactionError

delete

public void delete()
Deletes the message in persistent storage. This method must be called during a Transaction.


toString

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

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


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