xmlBlaster 2.2.0 API

org.xmlBlaster.engine.queuemsg
Class ReferenceEntry

java.lang.Object
  extended by org.xmlBlaster.util.queuemsg.MsgQueueEntry
      extended by org.xmlBlaster.engine.queuemsg.ReferenceEntry
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, I_Entry, I_QueueEntry
Direct Known Subclasses:
MsgQueueHistoryEntry, MsgQueueUpdateEntry

public class ReferenceEntry
extends MsgQueueEntry

Wraps an publish() message into an entry for a sorted queue.

Author:
michele@laghi.eu, xmlBlaster@marcelruff.info
See Also:
Serialized Form

Field Summary
protected  ServerScope glob
           
protected  java.lang.String keyOid
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
protected  long msgUnitWrapperUniqueId
           
protected  SessionName receiver
           
private static long serialVersionUID
           
static boolean STRICT_REFERENCE_COUNTING
           
static boolean STRICT_REFERENCE_COUNTING_COMPATIBLE
           
private  java.lang.ref.WeakReference weakMsgUnitWrapper
          Weak reference on the MsgUnit with key/content/qos (raw struct)
 
Fields inherited from class org.xmlBlaster.util.queuemsg.MsgQueueEntry
entryType, persistent, priority, redeliverCounter, refToCloneOrigin, returnObj, storageId, uniqueIdString, uniqueIdTimestamp, wantReturnObj
 
Constructor Summary
ReferenceEntry(java.lang.String ME, ServerScope glob, java.lang.String entryType, MsgUnitWrapper msgUnitWrapper, StorageId storageId)
          A new message object is fed by method publish().
ReferenceEntry(java.lang.String ME, ServerScope glob_, java.lang.String entryType, MsgUnitWrapper msgUnitWrapper, Timestamp timestamp, StorageId storageId, SessionName receiver)
          A new message object is fed by method update().
ReferenceEntry(java.lang.String ME, ServerScope glob, java.lang.String entryType, PriorityEnum priority, StorageId storageId, Timestamp entryTimestamp, java.lang.String keyOid, long msgUnitWrapperUniqueId, boolean persistent, SessionName receiver, java.lang.String qos, java.lang.String key, byte[] content)
          For persistence recovery
 
Method Summary
 void added(StorageId storageId)
          Notification if this entry is added to queue.
 java.lang.Object clone()
          Returns a shallow clone
 void embeddedObjectToXml(java.io.OutputStream out, java.util.Properties props)
          Dump content to xml representation
 java.lang.Object getEmbeddedObject()
          The embedded object for this implementing class is an Object[2]
 ServerScope getGlobal()
           
 java.lang.String getInfoWithoutMeat()
          For logging, don't access meat to avoid recursion.
 java.lang.String getKeyOid()
           
 XBMeat getMeat()
          Shall return null since it is a reference
 MsgKeyData getMsgKeyData()
           
 MsgQosData getMsgQosData()
           
 MsgUnit getMsgUnit()
          Gets the message unit but is for read only (dirty read)
 MsgUnit getMsgUnitOrNull()
          Gets the message unit but is for read only (dirty read)
 MsgUnitWrapper getMsgUnitWrapper()
          The caller needs to synchronize over msgCache
 long getMsgUnitWrapperUniqueId()
           
 long getRcvTimestamp()
           
 SessionName getReceiver()
           
 SessionName getSender()
          TODO? make sender persistent?
private  void incrementReferenceCounter(int incr, StorageId storageId)
           
 boolean isDestroyed()
          Flag which marks the entry as destroyed, you should take it from queue and ignore/discard it
 boolean isExpired()
          Flag which marks the entry as outdated
protected  boolean isForceDestroy()
           
 boolean isInternal()
           
private  MsgUnitWrapper lookup()
           
 void removed(StorageId storageId)
          Notification if this entry is removed from queue
 void setMsgUnitWrapper(MsgUnitWrapper msgUnitWrapper)
           
 void setReceiver(SessionName receiver)
           
 void setStorageId(StorageId storageId)
          Used during conversion from xb_entries to xbstore (OneToThree.java)
 
Methods inherited from class org.xmlBlaster.util.queuemsg.MsgQueueEntry
compare, equals, finalize, getEmbeddedType, getLogId, getMethodName, getPriority, getPriorityEnum, getRedeliverCounter, getRef, getReturnObj, getSizeInBytes, getStorageId, getUniqueId, getUniqueIdLong, incrRedeliverCounter, isPersistent, isStored, setGlobal, setPersistent, setReturnObj, setStored, setWantReturnObject, toString, toXml, toXml, wantReturnObj
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

ME

private final java.lang.String ME

glob

protected final transient ServerScope glob

weakMsgUnitWrapper

private transient java.lang.ref.WeakReference weakMsgUnitWrapper
Weak reference on the MsgUnit with key/content/qos (raw struct)


keyOid

protected java.lang.String keyOid

msgUnitWrapperUniqueId

protected long msgUnitWrapperUniqueId

receiver

protected SessionName receiver

STRICT_REFERENCE_COUNTING

public static final boolean STRICT_REFERENCE_COUNTING
See Also:
Constant Field Values

STRICT_REFERENCE_COUNTING_COMPATIBLE

public static final boolean STRICT_REFERENCE_COUNTING_COMPATIBLE
See Also:
Constant Field Values
Constructor Detail

ReferenceEntry

public ReferenceEntry(java.lang.String ME,
                      ServerScope glob_,
                      java.lang.String entryType,
                      MsgUnitWrapper msgUnitWrapper,
                      Timestamp timestamp,
                      StorageId storageId,
                      SessionName receiver)
               throws XmlBlasterException
A new message object is fed by method update().

Parameters:
msgUnit - The raw data, we keep a weak reference only on this data so it can be garbage collected
Throws:
XmlBlasterException

ReferenceEntry

public ReferenceEntry(java.lang.String ME,
                      ServerScope glob,
                      java.lang.String entryType,
                      MsgUnitWrapper msgUnitWrapper,
                      StorageId storageId)
               throws XmlBlasterException
A new message object is fed by method publish().

Parameters:
msgUnit - The raw data, we keep a weak reference only on this data so it can be garbage collected
Throws:
XmlBlasterException

ReferenceEntry

public ReferenceEntry(java.lang.String ME,
                      ServerScope glob,
                      java.lang.String entryType,
                      PriorityEnum priority,
                      StorageId storageId,
                      Timestamp entryTimestamp,
                      java.lang.String keyOid,
                      long msgUnitWrapperUniqueId,
                      boolean persistent,
                      SessionName receiver,
                      java.lang.String qos,
                      java.lang.String key,
                      byte[] content)
               throws XmlBlasterException
For persistence recovery

Parameters:
msgUnitWrapperUniqueId - The unique timestamp of the MsgUnitWrapper instance (need to lookup MsgUnitWrapper)
Throws:
XmlBlasterException
Method Detail

isForceDestroy

protected boolean isForceDestroy()

getGlobal

public final ServerScope getGlobal()

setStorageId

public void setStorageId(StorageId storageId)
Used during conversion from xb_entries to xbstore (OneToThree.java)

Parameters:
storageId -

getMsgUnitWrapper

public MsgUnitWrapper getMsgUnitWrapper()
The caller needs to synchronize over msgCache

Returns:
the MsgUnitWrapper or null if not found

getInfoWithoutMeat

public java.lang.String getInfoWithoutMeat()
For logging, don't access meat to avoid recursion.

Returns:

incrementReferenceCounter

private void incrementReferenceCounter(int incr,
                                       StorageId storageId)

added

public void added(StorageId storageId)
Notification if this entry is added to queue. It can be added to several queues simultaneously, the reference counter will be incremented each time

Specified by:
added in interface I_Entry
Overrides:
added in class MsgQueueEntry
See Also:
I_Entry.added(StorageId)

removed

public void removed(StorageId storageId)
Notification if this entry is removed from queue

Specified by:
removed in interface I_Entry
Overrides:
removed in class MsgQueueEntry
Parameters:
storageId - The storage id
See Also:
I_Entry.removed(StorageId)

isExpired

public boolean isExpired()
Description copied from class: MsgQueueEntry
Flag which marks the entry as outdated

Specified by:
isExpired in class MsgQueueEntry
Returns:
true for EXPIRED messages

isDestroyed

public boolean isDestroyed()
Description copied from class: MsgQueueEntry
Flag which marks the entry as destroyed, you should take it from queue and ignore/discard it

Specified by:
isDestroyed in class MsgQueueEntry
Returns:
true if no MsgUnitWrapper is found (the 'meat' is not available anymore)
or for msgUnitWrapper in state=DESTROYED

getMsgQosData

public MsgQosData getMsgQosData()
                         throws XmlBlasterException
Throws:
XmlBlasterException

getMsgUnitOrNull

public MsgUnit getMsgUnitOrNull()
Gets the message unit but is for read only (dirty read)

Returns:
null if expired->destroyed
Throws:
XmlBlasterException

getMsgUnit

public MsgUnit getMsgUnit()
                   throws XmlBlasterException
Gets the message unit but is for read only (dirty read)

Specified by:
getMsgUnit in class MsgQueueEntry
Returns:
Throws:
XmlBlasterException - if not found (e.g. forceDestroy and expired)

setMsgUnitWrapper

public void setMsgUnitWrapper(MsgUnitWrapper msgUnitWrapper)
                       throws XmlBlasterException
Throws:
XmlBlasterException

getMsgUnitWrapperUniqueId

public long getMsgUnitWrapperUniqueId()

getKeyOid

public java.lang.String getKeyOid()
Specified by:
getKeyOid in class MsgQueueEntry
Returns:
The message key oid or null

getRcvTimestamp

public long getRcvTimestamp()

getMsgKeyData

public final MsgKeyData getMsgKeyData()
                               throws XmlBlasterException
Throws:
XmlBlasterException

isInternal

public boolean isInternal()
Specified by:
isInternal in class MsgQueueEntry
Returns:
If it is an internal message (oid starting with "_").

getSender

public final SessionName getSender()
TODO? make sender persistent?

Specified by:
getSender in class MsgQueueEntry
Returns:
can be null

getReceiver

public final SessionName getReceiver()
Specified by:
getReceiver in class MsgQueueEntry
Returns:
null

setReceiver

public final void setReceiver(SessionName receiver)

lookup

private MsgUnitWrapper lookup()
Returns:
the MsgUnitWrapper or null if not found

getEmbeddedObject

public java.lang.Object getEmbeddedObject()
The embedded object for this implementing class is an Object[2]


embeddedObjectToXml

public final void embeddedObjectToXml(java.io.OutputStream out,
                                      java.util.Properties props)
                               throws java.io.IOException
Description copied from interface: I_Entry
Dump content to xml representation

Parameters:
out - The stream to dump to
props - Control porperties
Throws:
java.io.IOException

clone

public java.lang.Object clone()
Returns a shallow clone

Overrides:
clone in class MsgQueueEntry

getMeat

public XBMeat getMeat()
Shall return null since it is a reference

Specified by:
getMeat in interface I_Entry
Overrides:
getMeat in class MsgQueueEntry

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.