org.objectweb.speedo.genclass
Class GenClass

java.lang.Object
  extended byorg.objectweb.speedo.genclass.GenClass
All Implemented Interfaces:
SpeedoGenClassCoherence, SpeedoGenClassProxy, SpeedoProxy
Direct Known Subclasses:
CollectionImpl, MapImpl

public abstract class GenClass
extends java.lang.Object
implements SpeedoGenClassProxy

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

Author:
S.Chassande-Barrioz

Field Summary
protected  long age
           
protected  int fix
           
protected  int gcid
          Id of the field that references this gen class instance
protected  boolean jdoIsActive
          This fields indicates if the proxy is active (attached to at least a Proxy Manager)
protected  java.lang.String linkedField
          The linked field associated to this gen class
protected  java.util.List listeners
          List of SpeedoGenClassListener
 Logger logger
          The logger used to trace this generic class
protected  java.lang.String mapperName
          is the name of the mapper inside which the generic class is persistent
protected  PBindingCtrl pbinding
          is the PBinding which permits to store/load the data into/from the support
protected  ProxyManagerFactory pmf
          This is field is null when the proxy is not active
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  PType ptype
          is the type of the generic class
protected  TransactionalPersistenceManager tpm
          This field is the Transactional persistence manager.
 
Constructor Summary
GenClass()
           
 
Method Summary
 void bind(PName name)
           
 void copyAccessor(SpeedoAccessor src, SpeedoAccessor dest)
           
abstract  SpeedoAccessor createAccessor()
           
 boolean elementIsReference()
           
 boolean exist(java.lang.Object o)
           
 PName export(java.lang.Object o)
           
 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 getInner()
           
 java.lang.Object getJormConfig()
          It retrieves an object helping the configuration of the Jorm class.
 Logger getLogger()
           
 LoggerFactory getLoggerFactory()
           
 PClassMapping getPClassMapping()
           
 PName getPName()
           
abstract  SpeedoAccessor getReferenceAccessor()
           
 SpeedoAccessor getSpeedoAccessor()
          It retrieves the SpeedoAccessor instance used in the current context.
 java.util.Collection getSpeedoAccessors()
           
 byte getStatus()
           
 void init(PClassMapping mapping)
           
 void init(PType ptype, java.lang.String linkedField, java.lang.Object pnameHints, java.lang.String mapperName, Logger logger)
          Initializes a Genclass instance
 void jdoCopyFields(java.lang.Object pc, int[] fieldNumbers)
           
 void jdoCopyKeyFieldsFromObjectId(PersistenceCapable.ObjectIdFieldConsumer objectIdFieldConsumer, java.lang.Object o)
           
 void jdoCopyKeyFieldsToObjectId(java.lang.Object o)
           
 void jdoCopyKeyFieldsToObjectId(PersistenceCapable.ObjectIdFieldSupplier objectIdFieldSupplier, java.lang.Object o)
           
 void jdoDeletePersistent(ProxyManager pm, SpeedoAccessor sa)
           
 java.lang.Object jdoGePNameHints()
          Retrieves the hints needed to build the PName of the persistent object during the export action.
 java.lang.String jdoGetGenClassId()
           
 java.lang.String jdoGetJdoFileName()
           
 java.lang.String jdoGetMapperName()
           
 java.lang.Object jdoGetObjectId()
           
 PBinding jdoGetPBinding()
           
 PersistenceManager jdoGetPersistenceManager()
           
 java.lang.String jdoGetProjectName()
           
 ProxyManagerFactory jdoGetProxyManagerFactory()
           
 PType jdoGetPType()
           
 java.lang.Object jdoGetTransactionalObjectId()
           
 TransactionalPersistenceManager jdoGetTransactionalPersistenceManager()
           
 boolean jdoIsActive()
          Tests whether the Proxy infrastructure has already been set.
 void jdoIsActive(boolean newvalue)
          Sets the new value of the proxy flags
 boolean jdoIsDeleted()
           
 boolean jdoIsDirty()
           
 boolean jdoIsNew()
           
 boolean jdoIsPersistent()
           
 boolean jdoIsTransactional()
           
 void jdoMakeDirty(java.lang.String fieldName)
           
 void jdoMakePersistent(ProxyManager pm, java.util.Iterator it)
           
 void jdoMakePersistent(ProxyManager pm, SpeedoProxy sp)
          Askes to the SpeedoGenClassProxy to make persistent an element of the gen class.
 PersistenceCapable jdoNewInstance(StateManager sm)
           
 PersistenceCapable jdoNewInstance(StateManager sm, java.lang.Object oid)
           
 java.lang.Object jdoNewObjectIdInstance()
           
 java.lang.Object jdoNewObjectIdInstance(java.lang.String s)
           
 void jdoProvideField(int fieldNumber)
           
 void jdoProvideFields(int[] fieldNumbers)
           
 SpeedoAccessor jdoReadIntention()
          Askes the read access on the genclass.
 void jdoReplaceField(int fieldNumber)
           
 void jdoReplaceFields(int[] fieldNumbers)
           
 void jdoReplaceFlags()
           
 void jdoReplaceStateManager(StateManager sm)
           
 void jdoSetLinkedField(java.lang.String lf)
          Assignes the linked field name for this generic class.
 void jdoSetMapperName(java.lang.String mn)
           
 void jdoSetPBinding(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 jdoSetPNameHints(java.lang.Object hints)
          Assignes the hints needed to build the PName of the persistent object during the export action.
 void jdoSetProxyManagerFactory(ProxyManagerFactory pmf)
          It assignes a ProxyManagerFactory
 void jdoSetPType(PType ptype)
          Assignes the PType of the generic class.
 void jdoSetTransactionalPersistenceManager(TransactionalPersistenceManager tpm)
          It assignes a TransactionalPersistenceManager
 SpeedoAccessor jdoWriteIntention()
          Askes the write access on the genclass.
 void read(java.lang.Object o, PAccessor accessor)
           
 void read(java.lang.Object o, PAccessor pAccessor, java.lang.Object o1)
           
 void removeSpeedoAccessor(SpeedoAccessor sa)
           
 void setCeAge(long l)
           
 void setInner(java.lang.Object o)
          Assignes the new value of the generic class (Collection, Map or Array or ...).
 void setLogger(Logger _logger)
           
 void setLoggerFactory(LoggerFactory loggerfactory)
           
 void setPName(PName pName)
           
abstract  void setReferenceAccessor(SpeedoAccessor refAcc)
           
 void setStatus(byte b)
           
 boolean speedoAdd(java.lang.Object elemToAdd)
          Askes the adding of an element into a generic class.
 void speedoAdd(java.lang.Object elem, int gcFieldNumber)
          Adds an element in the gen class field whose number is given.
 void speedoAddGenClassListener(SpeedoGenClassListener l)
          Adds a listener to this gen class instance.
 boolean speedoRemove(java.lang.Object elemToRemove)
          Askes the removing of an element from a generic class.
 void speedoSetGcId(int gcid)
          Sets the id of this gen class instance (id of the field that references this instance).
 void unbind()
           
 void unexport(java.lang.Object o)
           
 void unfixCe()
           
 void write(java.lang.Object o, 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.SpeedoGenClassProxy
clear, createGenClass
 
Methods inherited from interface org.objectweb.speedo.mim.api.SpeedoProxy
jdoMakePersistent
 

Field Detail

jdoIsActive

protected boolean jdoIsActive
This fields indicates if the proxy is active (attached to at least a Proxy Manager)


pmf

protected ProxyManagerFactory pmf
This is field is null when the proxy is not active


tpm

protected TransactionalPersistenceManager tpm
This field is the Transactional persistence manager.


pbinding

protected PBindingCtrl pbinding
is the PBinding which permits to store/load the data into/from the support


logger

public Logger logger
The logger used to trace this generic class


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 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
Constructor Detail

GenClass

public GenClass()
Method Detail

init

public void init(PType ptype,
                 java.lang.String linkedField,
                 java.lang.Object pnameHints,
                 java.lang.String mapperName,
                 Logger logger)
Description copied from interface: SpeedoGenClassProxy
Initializes a Genclass instance

Specified by:
init in interface SpeedoGenClassProxy
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)
mapperName - is the name of the mapper where the gen class is persistent
logger - is the logger instance for logging.

elementIsReference

public boolean elementIsReference()

jdoMakePersistent

public void jdoMakePersistent(ProxyManager pm,
                              SpeedoProxy sp)
Description copied from interface: SpeedoGenClassProxy
Askes to the SpeedoGenClassProxy to make persistent an element of the gen class. If the speedo proxy is already active, then nothing is done.

Specified by:
jdoMakePersistent in interface SpeedoGenClassProxy
Parameters:
pm - is the persistence manager to use for making persistent the speedo proxy. If this parameter is null a pm will be fetched on the pmf if needed.
sp - is the speedo proxy to make persistent. null value is not supported.

jdoMakePersistent

public void jdoMakePersistent(ProxyManager pm,
                              java.util.Iterator it)

speedoSetGcId

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

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

speedoAddGenClassListener

public void speedoAddGenClassListener(SpeedoGenClassListener l)
Description copied from interface: SpeedoGenClassProxy
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 SpeedoGenClassProxy
Parameters:
l - a gen class listener.

speedoAdd

public void speedoAdd(java.lang.Object elem,
                      int gcFieldNumber)
Description copied from interface: SpeedoProxy
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 SpeedoProxy

speedoAdd

public boolean speedoAdd(java.lang.Object elemToAdd)
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)
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: SpeedoGenClassProxy
Notifies the listeners of this gen class that an element has been added to this gen class.

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

fireSpeedoElementRemoved

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

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

createAccessor

public abstract SpeedoAccessor createAccessor()
Specified by:
createAccessor in interface SpeedoProxy

getReferenceAccessor

public abstract SpeedoAccessor getReferenceAccessor()
Specified by:
getReferenceAccessor in interface SpeedoProxy

setReferenceAccessor

public abstract void setReferenceAccessor(SpeedoAccessor refAcc)
Specified by:
setReferenceAccessor in interface SpeedoProxy

bind

public void bind(PName name)
          throws PException
Throws:
PException

exist

public boolean exist(java.lang.Object o)
              throws PException
Throws:
PException

export

public PName export(java.lang.Object o)
             throws PException
Throws:
PException

export

public PName export(java.lang.Object o,
                    java.lang.Object o1)
             throws PException
Throws:
PException

getPClassMapping

public PClassMapping getPClassMapping()

getPName

public PName getPName()

getStatus

public byte getStatus()

setPName

public void setPName(PName pName)

setStatus

public void setStatus(byte b)

init

public void init(PClassMapping mapping)
          throws PException
Throws:
PException

read

public void read(java.lang.Object o,
                 PAccessor accessor)
          throws PException
Throws:
PException

read

public void read(java.lang.Object o,
                 PAccessor pAccessor,
                 java.lang.Object o1)
          throws PException
Throws:
PException

unbind

public void unbind()
            throws PException
Throws:
PException

unexport

public void unexport(java.lang.Object o)
              throws PException
Throws:
PException

write

public void write(java.lang.Object o,
                  PAccessor accessor)
           throws PException
Throws:
PException

jdoGetPersistenceManager

public PersistenceManager jdoGetPersistenceManager()

jdoReplaceFlags

public void jdoReplaceFlags()

jdoNewInstance

public PersistenceCapable jdoNewInstance(StateManager sm)

jdoNewInstance

public PersistenceCapable jdoNewInstance(StateManager sm,
                                         java.lang.Object oid)

jdoNewObjectIdInstance

public java.lang.Object jdoNewObjectIdInstance()

jdoGetObjectId

public java.lang.Object jdoGetObjectId()

jdoGetTransactionalObjectId

public java.lang.Object jdoGetTransactionalObjectId()

jdoReplaceField

public void jdoReplaceField(int fieldNumber)

jdoReplaceFields

public void jdoReplaceFields(int[] fieldNumbers)

jdoProvideField

public void jdoProvideField(int fieldNumber)

jdoProvideFields

public void jdoProvideFields(int[] fieldNumbers)

jdoCopyFields

public void jdoCopyFields(java.lang.Object pc,
                          int[] fieldNumbers)

jdoMakeDirty

public void jdoMakeDirty(java.lang.String fieldName)

jdoIsDirty

public boolean jdoIsDirty()

jdoIsTransactional

public boolean jdoIsTransactional()

jdoIsPersistent

public boolean jdoIsPersistent()

jdoIsNew

public boolean jdoIsNew()

jdoIsDeleted

public boolean jdoIsDeleted()

jdoReplaceStateManager

public void jdoReplaceStateManager(StateManager sm)

jdoNewObjectIdInstance

public java.lang.Object jdoNewObjectIdInstance(java.lang.String s)

jdoCopyKeyFieldsToObjectId

public void jdoCopyKeyFieldsToObjectId(java.lang.Object o)

jdoCopyKeyFieldsToObjectId

public void jdoCopyKeyFieldsToObjectId(PersistenceCapable.ObjectIdFieldSupplier objectIdFieldSupplier,
                                       java.lang.Object o)

jdoCopyKeyFieldsFromObjectId

public void jdoCopyKeyFieldsFromObjectId(PersistenceCapable.ObjectIdFieldConsumer objectIdFieldConsumer,
                                         java.lang.Object o)

jdoSetMapperName

public void jdoSetMapperName(java.lang.String mn)
Specified by:
jdoSetMapperName in interface SpeedoGenClassProxy
Parameters:
mn - is the mapper name by which the instance is persistent.

jdoSetPType

public void jdoSetPType(PType ptype)
Assignes the PType of the generic class.

Specified by:
jdoSetPType in interface SpeedoGenClassProxy
Parameters:
ptype - of the generic class

jdoGetPType

public PType jdoGetPType()
Specified by:
jdoGetPType in interface SpeedoGenClassProxy
Returns:
the PType of the generic class.

jdoSetPBinding

public void jdoSetPBinding(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:
jdoSetPBinding in interface SpeedoGenClassProxy
Parameters:
pb - is the PBinding.

jdoGetPBinding

public PBinding jdoGetPBinding()
Specified by:
jdoGetPBinding in interface SpeedoGenClassProxy
Returns:
the pbinding associated to the generic class. The value is if the generic class is not persistent.

jdoGetGenClassId

public java.lang.String jdoGetGenClassId()
Specified by:
jdoGetGenClassId in interface SpeedoGenClassProxy
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'

jdoSetLinkedField

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

Specified by:
jdoSetLinkedField in interface SpeedoGenClassProxy
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'

setInner

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

Specified by:
setInner in interface SpeedoGenClassProxy

getInner

public java.lang.Object getInner()

copyAccessor

public void copyAccessor(SpeedoAccessor src,
                         SpeedoAccessor dest)
Specified by:
copyAccessor in interface SpeedoProxy

jdoGePNameHints

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

Specified by:
jdoGePNameHints in interface SpeedoProxy

jdoSetPNameHints

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

Specified by:
jdoSetPNameHints in interface SpeedoProxy

jdoGetMapperName

public java.lang.String jdoGetMapperName()
Specified by:
jdoGetMapperName in interface SpeedoProxy
Returns:
return the mapper name by which the instance is persistent.

jdoGetProjectName

public java.lang.String jdoGetProjectName()
Specified by:
jdoGetProjectName in interface SpeedoProxy
Returns:
return the mapper name by which the instance is persistent.

jdoIsActive

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

Specified by:
jdoIsActive in interface SpeedoProxy
Returns:
true if this object is a Proxy.

jdoIsActive

public void jdoIsActive(boolean newvalue)
Description copied from interface: SpeedoProxy
Sets the new value of the proxy flags

Specified by:
jdoIsActive in interface SpeedoProxy
Parameters:
newvalue - the new value of the proxy flag
See Also:
SpeedoProxy.jdoIsActive()

getSpeedoAccessor

public SpeedoAccessor getSpeedoAccessor()
Description copied from interface: SpeedoProxy
It retrieves the SpeedoAccessor instance used in the current context. If the proxy is not active then the reference state is returned. otherwise a $classNameFields is returned

Specified by:
getSpeedoAccessor in interface SpeedoProxy

getSpeedoAccessors

public java.util.Collection getSpeedoAccessors()

removeSpeedoAccessor

public void removeSpeedoAccessor(SpeedoAccessor sa)

jdoGetProxyManagerFactory

public ProxyManagerFactory jdoGetProxyManagerFactory()
Specified by:
jdoGetProxyManagerFactory in interface SpeedoProxy
Returns:
the ProxyManagerFactory which represents the data support inside which the proxy is persistent.

jdoSetProxyManagerFactory

public void jdoSetProxyManagerFactory(ProxyManagerFactory pmf)
Description copied from interface: SpeedoProxy
It assignes a ProxyManagerFactory

Specified by:
jdoSetProxyManagerFactory in interface SpeedoProxy
Parameters:
pmf - is the ProxyManagerFactory which represents the data support inside which the proxy is persistent.

jdoGetTransactionalPersistenceManager

public TransactionalPersistenceManager jdoGetTransactionalPersistenceManager()
Specified by:
jdoGetTransactionalPersistenceManager in interface SpeedoProxy
Returns:
the TransactionalPersistenceManager which manage the concurrency, loading, ... of the proxy.

jdoSetTransactionalPersistenceManager

public void jdoSetTransactionalPersistenceManager(TransactionalPersistenceManager tpm)
Description copied from interface: SpeedoProxy
It assignes a TransactionalPersistenceManager

Specified by:
jdoSetTransactionalPersistenceManager in interface SpeedoProxy
Parameters:
tpm - is the TransactionalPersistenceManager which manage the concurrency, loading, ... of the proxy.

jdoReadIntention

public SpeedoAccessor jdoReadIntention()
Description copied from interface: SpeedoGenClassProxy
Askes the read access on the genclass.

Specified by:
jdoReadIntention in interface SpeedoGenClassProxy
Returns:
the SpeedoAccessor representing the state of the gen class

jdoWriteIntention

public SpeedoAccessor jdoWriteIntention()
Description copied from interface: SpeedoGenClassProxy
Askes the write access on the genclass.

Specified by:
jdoWriteIntention in interface SpeedoGenClassProxy
Returns:
the SpeedoAccessor representing the state of the gen class

getJormConfig

public java.lang.Object getJormConfig()
Description copied from interface: SpeedoProxy
It retrieves an object helping the configuration of the Jorm class. Currently Jorm is not fractalize then the returned object is the PBinder class name.

Specified by:
getJormConfig in interface SpeedoProxy

jdoGetJdoFileName

public java.lang.String jdoGetJdoFileName()
Specified by:
jdoGetJdoFileName in interface SpeedoProxy
Returns:
The file name of the jdo descriptor. This file must be availlable in the class at runtime.

jdoDeletePersistent

public void jdoDeletePersistent(ProxyManager pm,
                                SpeedoAccessor sa)
Specified by:
jdoDeletePersistent in interface SpeedoProxy

getCeObject

public java.lang.Object getCeObject()

getCeIdentifier

public java.lang.Object getCeIdentifier()

fixCe

public void fixCe()

unfixCe

public void unfixCe()
             throws UnFixProtocolException
Throws:
UnFixProtocolException

getCeFixCount

public int getCeFixCount()

getCeAge

public long getCeAge()

setCeAge

public void setCeAge(long l)

setLogger

public void setLogger(Logger _logger)

setLoggerFactory

public void setLoggerFactory(LoggerFactory loggerfactory)

getLogger

public Logger getLogger()

getLoggerFactory

public LoggerFactory getLoggerFactory()