org.objectweb.speedo.genclass
Class GenClass

java.lang.Object
  extended by org.objectweb.speedo.genclass.GenClass
All Implemented Interfaces:
java.io.Serializable, org.objectweb.jorm.api.PBinding, org.objectweb.jorm.api.PBindingCtrl, org.objectweb.jorm.util.api.Loggable, CacheEntry, FixableCacheEntry, ReplaceableCacheEntry, SpeedoGenClassCoherence, SpeedoGenClassPO, SpeedoGenClassSerializable, PersistentObjectItf
Direct Known Subclasses:
CollectionImpl, EJBGenClass, JDOGenClass, MapImpl

public abstract class GenClass
extends java.lang.Object
implements SpeedoGenClassPO, SpeedoGenClassSerializable, org.objectweb.jorm.util.api.Loggable, org.objectweb.jorm.api.PBindingCtrl

This class is a basic implementation of the SpeedoGenClassPO interface. It uses a delegate PBinding.

Author:
S.Chassande-Barrioz
See Also:
Serialized Form

Field Summary
protected  long age
           
protected  java.lang.Object encodedPName
           
protected  int fix
           
protected  int gcid
          Id of the field that references this gen class instance
protected  java.lang.String linkedField
          The linked field associated to this gen class
protected  java.util.List listeners
          List of SpeedoGenClassListener
 org.objectweb.util.monolog.api.Logger logger
          The logger used to trace this generic class Defined as transient.
protected  java.lang.String mapperName
          is the name of the mapper inside which the generic class is persistent
protected  org.objectweb.jorm.api.PBindingCtrl pbinding
          is the PBinding which permits to store/load the data into/from the support
protected  java.lang.Object pnameHints
          Is the PName which
protected  java.lang.String projectName
          is the name of the project name inside which the generic class is used.
protected  org.objectweb.jorm.type.api.PType ptype
          is the type of the generic class
protected  boolean speedoIsActive
          This fields indicates if the po is active
 
Fields inherited from interface org.objectweb.jorm.api.PBinding
ACTION_BIND, ACTION_EXIST, ACTION_EXPORT, ACTION_READ, ACTION_UNBIND, ACTION_UNEXPORT, ACTION_WRITE, LIFECYCLE_ACTIVEFORIO, LIFECYCLE_DELTOWRITE, LIFECYCLE_ERROR, LIFECYCLE_NEWTOWRITE, LIFECYCLE_NOTBOUND
 
Constructor Summary
GenClass()
           
 
Method Summary
 void bind(org.objectweb.jorm.naming.api.PName name)
           
 boolean elementIsReference()
           
 boolean exist(java.lang.Object o)
           
 org.objectweb.jorm.naming.api.PName export(java.lang.Object o)
           
 org.objectweb.jorm.naming.api.PName export(java.lang.Object o, java.lang.Object o1)
           
 void fireSpeedoElementAdded(java.lang.Object elem)
          Notifies the listeners of this gen class that an element has been added to this gen class.
 void fireSpeedoElementRemoved(java.lang.Object elem)
          Notifies the listeners of this gen class that an element has been removed to this gen class.
 void fixCe()
           
 long getCeAge()
           
 int getCeFixCount()
           
 java.lang.Object getCeIdentifier()
           
 java.lang.Object getCeObject()
           
 java.lang.Object getDataIdentifier(java.lang.Object o)
           
 java.util.Collection getDataIdentifiers(java.util.Collection os)
           
 org.objectweb.util.monolog.api.Logger getLogger()
           
 org.objectweb.util.monolog.api.LoggerFactory getLoggerFactory()
           
 org.objectweb.jorm.api.PClassMapping getPClassMapping()
           
 org.objectweb.jorm.naming.api.PName getPName()
           
 java.util.Collection getSpeedoAccessors()
           
 byte getStatus()
           
 void init(org.objectweb.jorm.api.PClassMapping mapping)
           
 void init(org.objectweb.jorm.type.api.PType _ptype, java.lang.String _linkedField, java.lang.Object _pnameHints, org.objectweb.util.monolog.api.Logger _logger)
          Initializes a Genclass instance
 void read(java.lang.Object o, org.objectweb.jorm.api.PAccessor accessor)
           
 void read(java.lang.Object o, org.objectweb.jorm.api.PAccessor pAccessor, java.lang.Object o1)
           
 void read(java.lang.Object o, org.objectweb.jorm.api.PAccessor pAccessor, java.lang.Object o1, boolean forUpdate)
           
 void removeSpeedoAccessor(StateItf sa)
           
 void setCeAge(long l)
           
 void setElements(java.lang.Object o)
          Assignes the new value of the generic class (Collection, Map or Array or ...).
 void setLogger(org.objectweb.util.monolog.api.Logger _logger)
           
 void setLoggerFactory(org.objectweb.util.monolog.api.LoggerFactory loggerfactory)
           
 void setPName(org.objectweb.jorm.naming.api.PName pName)
           
 void setStatus(byte b)
           
 void speedoAdd(java.lang.Object elem, int gcFieldNumber)
          Adds an element in the gen class field whose number is given.
 boolean speedoAdd(java.lang.Object elemToAdd, java.lang.Object hints)
          Askes the adding of an element into a generic class.
 void speedoAddGenClassListener(SpeedoGenClassListener l)
          Adds a listener to this gen class instance.
 void speedoCopyState(StateItf src, StateItf dest)
          Copies persistent fields from an accessor to another.
abstract  StateItf speedoCreateState()
           
 java.lang.Object speedoGetEncodedPName()
           
 java.lang.String speedoGetGenClassId()
           
 HomeItf speedoGetHome()
           
 org.objectweb.jorm.api.PBinding speedoGetPBinding()
           
 java.lang.Object speedoGetPNameHints()
          Retrieves the hints needed to build the PName of the persistent object during the export action.
 POManagerItf speedoGetPOManager()
           
 org.objectweb.jorm.type.api.PType speedoGetPType()
           
abstract  StateItf speedoGetReferenceState()
           
 StateItf speedoGetState()
          It retrieves the StateItf instance used in the current context.
 boolean speedoIsActive()
          Tests whether the po infrastructure has already been set.
 void speedoIsActive(boolean newvalue)
          Sets the new value of the po flags
 boolean speedoIsPersistent()
           
 boolean speedoRemove(java.lang.Object elemToRemove, java.lang.Object hints)
          Askes the removing of an element from a generic class.
 void speedoSetEncodedPName(java.lang.Object _encodedPName)
          Set the encoded PName of the detach copy to allow serialization.
 void speedoSetGcId(int _gcid)
          Sets the id of this gen class instance (id of the field that references this instance).
 void speedoSetLinkedField(java.lang.String lf)
          Assignes the linked field name for this generic class.
 void speedoSetPBinding(org.objectweb.jorm.api.PBinding pb)
          assignes the PBinding to use to load/store the generic class Call this method with null value means that the generic is no more persistent.
 void speedoSetPNameHints(java.lang.Object hints)
          Assignes the hints needed to build the PName of the persistent object during the export action.
 void speedoSetPType(org.objectweb.jorm.type.api.PType _ptype)
          Assignes the PType of the generic class.
abstract  void speedoSetReferenceState(StateItf refAcc)
          Assignes the reference accessor to the PersistentObjectItf The Reference accessor is used for non persistent instance, as cache value and for pessimistic policy.
 void unbind()
           
 void unexport(java.lang.Object o)
           
 void unfixCe()
           
 void write(java.lang.Object o, org.objectweb.jorm.api.PAccessor accessor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.speedo.genclass.api.SpeedoGenClassPO
clear, createGenClass
 

Field Detail

speedoIsActive

protected boolean speedoIsActive
This fields indicates if the po is active


pbinding

protected org.objectweb.jorm.api.PBindingCtrl pbinding
is the PBinding which permits to store/load the data into/from the support


logger

public transient org.objectweb.util.monolog.api.Logger logger
The logger used to trace this generic class Defined as transient.


mapperName

protected java.lang.String mapperName
is the name of the mapper inside which the generic class is persistent


projectName

protected java.lang.String projectName
is the name of the project name inside which the generic class is used.


ptype

protected org.objectweb.jorm.type.api.PType ptype
is the type of the generic class


linkedField

protected java.lang.String linkedField
The linked field associated to this gen class


pnameHints

protected java.lang.Object pnameHints
Is the PName which


gcid

protected int gcid
Id of the field that references this gen class instance


listeners

protected java.util.List listeners
List of SpeedoGenClassListener


age

protected long age

fix

protected int fix

encodedPName

protected java.lang.Object encodedPName
Constructor Detail

GenClass

public GenClass()
Method Detail

init

public void init(org.objectweb.jorm.type.api.PType _ptype,
                 java.lang.String _linkedField,
                 java.lang.Object _pnameHints,
                 org.objectweb.util.monolog.api.Logger _logger)
Description copied from interface: SpeedoGenClassPO
Initializes a Genclass instance

Specified by:
init in interface SpeedoGenClassPO
Parameters:
_ptype - is the PType of the genclass
_linkedField - is the name of the field referencing the genclass
_pnameHints - is a helper using for the identifier allocation (export) persistent
_logger - is the logger instance for logging.

speedoSetPNameHints

public void speedoSetPNameHints(java.lang.Object hints)
Description copied from interface: SpeedoGenClassPO
Assignes the hints needed to build the PName of the persistent object during the export action.

Specified by:
speedoSetPNameHints in interface SpeedoGenClassPO

elementIsReference

public boolean elementIsReference()

speedoSetGcId

public void speedoSetGcId(int _gcid)
Description copied from interface: SpeedoGenClassPO
Sets the id of this gen class instance (id of the field that references this instance).

Specified by:
speedoSetGcId in interface SpeedoGenClassPO
Parameters:
_gcid - the new id of this gen class instance.

speedoAddGenClassListener

public void speedoAddGenClassListener(SpeedoGenClassListener l)
Description copied from interface: SpeedoGenClassPO
Adds a listener to this gen class instance. This listener will be notified each time an element is added or removed for this gen class.

Specified by:
speedoAddGenClassListener in interface SpeedoGenClassPO
Parameters:
l - a gen class listener.

speedoAdd

public void speedoAdd(java.lang.Object elem,
                      int gcFieldNumber)
Description copied from interface: PersistentObjectItf
Adds an element in the gen class field whose number is given. This method must call the speedoAdd method of the SpeedoGenClassCoherence interface, or the Collection.add method (if the field contains a collection that does implement the previous interface). If the field is null, a new (speedo) collection must be created first.

Specified by:
speedoAdd in interface PersistentObjectItf

speedoAdd

public boolean speedoAdd(java.lang.Object elemToAdd,
                         java.lang.Object hints)
Description copied from interface: SpeedoGenClassCoherence
Askes the adding of an element into a generic class. The consistency of relations must not be managed: this is done by the caller of this method.

Specified by:
speedoAdd in interface SpeedoGenClassCoherence
Parameters:
elemToAdd - is the element to add

speedoRemove

public boolean speedoRemove(java.lang.Object elemToRemove,
                            java.lang.Object hints)
Description copied from interface: SpeedoGenClassCoherence
Askes the removing of an element from a generic class. The consistency of relations must not be managed: this is done by the caller of this method.

Specified by:
speedoRemove in interface SpeedoGenClassCoherence
Parameters:
elemToRemove - is the element to remove

fireSpeedoElementAdded

public void fireSpeedoElementAdded(java.lang.Object elem)
Description copied from interface: SpeedoGenClassPO
Notifies the listeners of this gen class that an element has been added to this gen class.

Specified by:
fireSpeedoElementAdded in interface SpeedoGenClassPO
Parameters:
elem - the element that has been added.

fireSpeedoElementRemoved

public void fireSpeedoElementRemoved(java.lang.Object elem)
Description copied from interface: SpeedoGenClassPO
Notifies the listeners of this gen class that an element has been removed to this gen class.

Specified by:
fireSpeedoElementRemoved in interface SpeedoGenClassPO
Parameters:
elem - the element that has been removed.

getDataIdentifier

public java.lang.Object getDataIdentifier(java.lang.Object o)

getDataIdentifiers

public java.util.Collection getDataIdentifiers(java.util.Collection os)

speedoCreateState

public abstract StateItf speedoCreateState()
Specified by:
speedoCreateState in interface PersistentObjectItf
Returns:
a new StateItf instance.

speedoGetReferenceState

public abstract StateItf speedoGetReferenceState()
Specified by:
speedoGetReferenceState in interface PersistentObjectItf
Returns:
the reference accessor of the PersistentObjectItf instance. It can be * null. The Reference accessor is used for non persistent instance, as cache value and for pessimistic policy.

speedoSetReferenceState

public abstract void speedoSetReferenceState(StateItf refAcc)
Description copied from interface: PersistentObjectItf
Assignes the reference accessor to the PersistentObjectItf The Reference accessor is used for non persistent instance, as cache value and for pessimistic policy.

Specified by:
speedoSetReferenceState in interface PersistentObjectItf
Parameters:
refAcc - the new reference accessor

bind

public void bind(org.objectweb.jorm.naming.api.PName name)
          throws org.objectweb.jorm.api.PException
Specified by:
bind in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

exist

public boolean exist(java.lang.Object o)
              throws org.objectweb.jorm.api.PException
Specified by:
exist in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

export

public org.objectweb.jorm.naming.api.PName export(java.lang.Object o)
                                           throws org.objectweb.jorm.api.PException
Specified by:
export in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

export

public org.objectweb.jorm.naming.api.PName export(java.lang.Object o,
                                                  java.lang.Object o1)
                                           throws org.objectweb.jorm.api.PException
Specified by:
export in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

getPClassMapping

public org.objectweb.jorm.api.PClassMapping getPClassMapping()
Specified by:
getPClassMapping in interface org.objectweb.jorm.api.PBinding

getPName

public org.objectweb.jorm.naming.api.PName getPName()
Specified by:
getPName in interface org.objectweb.jorm.api.PBinding

getStatus

public byte getStatus()
Specified by:
getStatus in interface org.objectweb.jorm.api.PBinding

setPName

public void setPName(org.objectweb.jorm.naming.api.PName pName)
Specified by:
setPName in interface org.objectweb.jorm.api.PBindingCtrl

setStatus

public void setStatus(byte b)
Specified by:
setStatus in interface org.objectweb.jorm.api.PBindingCtrl

init

public void init(org.objectweb.jorm.api.PClassMapping mapping)
          throws org.objectweb.jorm.api.PException
Specified by:
init in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

read

public void read(java.lang.Object o,
                 org.objectweb.jorm.api.PAccessor accessor)
          throws org.objectweb.jorm.api.PException
Specified by:
read in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

read

public void read(java.lang.Object o,
                 org.objectweb.jorm.api.PAccessor pAccessor,
                 java.lang.Object o1)
          throws org.objectweb.jorm.api.PException
Specified by:
read in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

read

public void read(java.lang.Object o,
                 org.objectweb.jorm.api.PAccessor pAccessor,
                 java.lang.Object o1,
                 boolean forUpdate)
          throws org.objectweb.jorm.api.PException
Specified by:
read in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

unbind

public void unbind()
            throws org.objectweb.jorm.api.PException
Specified by:
unbind in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

unexport

public void unexport(java.lang.Object o)
              throws org.objectweb.jorm.api.PException
Specified by:
unexport in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

write

public void write(java.lang.Object o,
                  org.objectweb.jorm.api.PAccessor accessor)
           throws org.objectweb.jorm.api.PException
Specified by:
write in interface org.objectweb.jorm.api.PBinding
Throws:
org.objectweb.jorm.api.PException

speedoSetPType

public void speedoSetPType(org.objectweb.jorm.type.api.PType _ptype)
Assignes the PType of the generic class.

Specified by:
speedoSetPType in interface SpeedoGenClassPO
Parameters:
_ptype - of the generic class

speedoGetPType

public org.objectweb.jorm.type.api.PType speedoGetPType()
Specified by:
speedoGetPType in interface SpeedoGenClassPO
Returns:
the PType of the generic class.

speedoSetPBinding

public void speedoSetPBinding(org.objectweb.jorm.api.PBinding pb)
assignes the PBinding to use to load/store the generic class Call this method with null value means that the generic is no more persistent.

Specified by:
speedoSetPBinding in interface SpeedoGenClassPO
Parameters:
pb - is the PBinding.

speedoGetPBinding

public org.objectweb.jorm.api.PBinding speedoGetPBinding()
Specified by:
speedoGetPBinding in interface SpeedoGenClassPO
Returns:
the pbinding associated to the generic class. The value is if the generic class is not persistent.

speedoGetGenClassId

public java.lang.String speedoGetGenClassId()
Specified by:
speedoGetGenClassId in interface SpeedoGenClassPO
Returns:
a string which represents the fully path of the persistent field of the class with wich the generic class is persistent. If the linked fiekf is the 'f1' provided by the class 'com.foo.Bar' then the returned string will be 'com.foo.Bar/f1'

speedoSetLinkedField

public void speedoSetLinkedField(java.lang.String lf)
Assignes the linked field name for this generic class.

Specified by:
speedoSetLinkedField in interface SpeedoGenClassPO
Parameters:
lf - is tring which represents the fully path of the persistent field of the class with wich the generic class is persistent. If the linked fiekf is the 'f1' provided by the class 'com.foo.Bar' then the expected string is 'com.foo.Bar/f1'

setElements

public void setElements(java.lang.Object o)
Assignes the new value of the generic class (Collection, Map or Array or ...).

Specified by:
setElements in interface SpeedoGenClassPO

speedoIsPersistent

public boolean speedoIsPersistent()
Specified by:
speedoIsPersistent in interface PersistentObjectItf

speedoCopyState

public void speedoCopyState(StateItf src,
                            StateItf dest)
Description copied from interface: PersistentObjectItf
Copies persistent fields from an accessor to another.

Specified by:
speedoCopyState in interface PersistentObjectItf
Parameters:
src - is the accessor containing peristent fields to copy
dest - is the accessor where persistent fields have to be copied

speedoGetPNameHints

public java.lang.Object speedoGetPNameHints()
Description copied from interface: PersistentObjectItf
Retrieves the hints needed to build the PName of the persistent object during the export action.

Specified by:
speedoGetPNameHints in interface PersistentObjectItf

speedoIsActive

public boolean speedoIsActive()
Description copied from interface: PersistentObjectItf
Tests whether the po infrastructure has already been set. A po has a correct PClassMapping linked to a PBinder, a PName obtained thanks to this PClassMapping.

Specified by:
speedoIsActive in interface PersistentObjectItf

speedoIsActive

public void speedoIsActive(boolean newvalue)
Description copied from interface: PersistentObjectItf
Sets the new value of the po flags

Specified by:
speedoIsActive in interface PersistentObjectItf
Parameters:
newvalue - the new value of the po flag
See Also:
PersistentObjectItf.speedoIsActive()

speedoGetState

public StateItf speedoGetState()
Description copied from interface: PersistentObjectItf
It retrieves the StateItf instance used in the current context. If the po is not active then the reference state is returned. otherwise a $classNameFields is returned

Specified by:
speedoGetState in interface PersistentObjectItf

getSpeedoAccessors

public java.util.Collection getSpeedoAccessors()

removeSpeedoAccessor

public void removeSpeedoAccessor(StateItf sa)

speedoSetEncodedPName

public void speedoSetEncodedPName(java.lang.Object _encodedPName)
Description copied from interface: PersistentObjectItf
Set the encoded PName of the detach copy to allow serialization.

Specified by:
speedoSetEncodedPName in interface PersistentObjectItf
Parameters:
_encodedPName - : the encoded PName of the persistent object

speedoGetEncodedPName

public java.lang.Object speedoGetEncodedPName()
Specified by:
speedoGetEncodedPName in interface PersistentObjectItf
Returns:
the encoded PName of the detached copy

speedoGetHome

public HomeItf speedoGetHome()
Specified by:
speedoGetHome in interface PersistentObjectItf

speedoGetPOManager

public POManagerItf speedoGetPOManager()
Specified by:
speedoGetPOManager in interface PersistentObjectItf

getCeObject

public java.lang.Object getCeObject()
Specified by:
getCeObject in interface CacheEntry

getCeIdentifier

public java.lang.Object getCeIdentifier()
Specified by:
getCeIdentifier in interface CacheEntry

fixCe

public void fixCe()
Specified by:
fixCe in interface FixableCacheEntry

unfixCe

public void unfixCe()
             throws UnFixProtocolException
Specified by:
unfixCe in interface FixableCacheEntry
Throws:
UnFixProtocolException

getCeFixCount

public int getCeFixCount()
Specified by:
getCeFixCount in interface FixableCacheEntry

getCeAge

public long getCeAge()
Specified by:
getCeAge in interface ReplaceableCacheEntry

setCeAge

public void setCeAge(long l)
Specified by:
setCeAge in interface ReplaceableCacheEntry

setLogger

public void setLogger(org.objectweb.util.monolog.api.Logger _logger)
Specified by:
setLogger in interface org.objectweb.jorm.util.api.Loggable

setLoggerFactory

public void setLoggerFactory(org.objectweb.util.monolog.api.LoggerFactory loggerfactory)
Specified by:
setLoggerFactory in interface org.objectweb.jorm.util.api.Loggable

getLogger

public org.objectweb.util.monolog.api.Logger getLogger()
Specified by:
getLogger in interface org.objectweb.jorm.util.api.Loggable

getLoggerFactory

public org.objectweb.util.monolog.api.LoggerFactory getLoggerFactory()
Specified by:
getLoggerFactory in interface org.objectweb.jorm.util.api.Loggable