org.objectweb.speedo.genclass
Class GenClassAccessor

java.lang.Object
  extended byorg.objectweb.speedo.mim.lib.BasicSpeedoAccessor
      extended byorg.objectweb.speedo.genclass.GenClassAccessor
All Implemented Interfaces:
org.objectweb.jorm.api.PAccessor, org.objectweb.jorm.api.PGenClassAccessor, org.objectweb.jorm.api.PIndexedElemFactory, java.io.Serializable, SpeedoAccessor, SpeedoGenClassCoherence, org.objectweb.perseus.persistence.api.State
Direct Known Subclasses:
CollectionAccessor, MapAccessor

public abstract class GenClassAccessor
extends BasicSpeedoAccessor
implements org.objectweb.jorm.api.PGenClassAccessor, SpeedoGenClassCoherence

This class represents an accessor of a genclass structure. This accessor is used in case of the generic class is persistent.

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

Field Summary
 java.util.List deltaForMerge
           
 java.util.List elements
          The ArrayList used to store the indexed elements of the genclass.
 SpeedoGenClassProxy jdoProxy
          The SpeedoProxy attached to this state representation.
protected  org.objectweb.util.monolog.api.Logger logger
           
 boolean supportDelta
          Indicates if this accessor support the dela mode
protected  GenClassElement tmpelem
          A temporary variable which is used to search an element into the "elements" list.
 
Fields inherited from class org.objectweb.speedo.mim.lib.BasicSpeedoAccessor
detachedStatus, hasBeenFlush, isToMerge, jdoStatus, proxy
 
Constructor Summary
GenClassAccessor(SpeedoGenClassProxy _jdoProxy)
           
 
Method Summary
abstract  void attachCopy(ProxyManager pm, java.util.Map map, SpeedoAccessor fieldsClone, boolean makeTransactional)
          This method is used during the attach operation.
 org.objectweb.jorm.api.PIndexedElem createPIndexedElem()
           
abstract  org.objectweb.jorm.api.PIndexedElem createPIndexedElem(GenClassAccessor gca)
           
abstract  void deletePersistent(ProxyManager pm)
          Deletes persistent all inner elements of the persistent instance.
abstract  void detachCopy(ProxyManager pm, java.util.Map map, SpeedoAccessor fieldsClone, java.util.Collection fgHints)
          This method is used during the detach operation.
 org.objectweb.util.monolog.api.Logger getLogger()
           
 java.lang.Object getMemoryInstance()
           
 void loadFields(ProxyManager pm, long[] fields)
          Askes the loading of the some fields identified by the long array.
abstract  void loadFieldsFromAccessor(SpeedoAccessor sa)
           
abstract  void makePersistent(ProxyManager pm)
          Makes persistent all inner elements of the persistent instance.
 void makeToMerge(java.lang.Object thinLock)
          Mark the current state with the flag 'toMerge'.
 org.objectweb.perseus.persistence.api.State merge(org.objectweb.perseus.persistence.api.State oldState)
          This action updates the old state with the change (delta) done in the transaction on this state.
 void paAdd(org.objectweb.jorm.api.PIndexedElem elem, java.lang.Object conn)
           
 boolean paDeltaSupported()
           
 int paGetNbElem()
           
 java.util.Iterator paIterator()
           
 void paSetNbElem(int nbelem)
           
abstract  void refresh(ProxyManager pm, java.util.Map map, java.util.Collection fgHints)
          This method is used during the refresh operation.
abstract  void retrieve(ProxyManager pm, java.util.Map map, java.util.Collection fgHints)
          This method is used during the retrieve operation.
abstract  void setElements(java.lang.Object o)
           
 void setFlushed(boolean val)
          When the gen class is flushed to the data support (parameter = true), the internal structure is clean: - really remove the deleted element - mark the genclass as supporting the delta
abstract  boolean speedoAdd(java.lang.Object elemToAdd, java.lang.Object hints)
          Askes the adding of an element into a generic class.
abstract  boolean speedoRemove(java.lang.Object elemToRemove, java.lang.Object hints)
          Askes the removing of an element from a generic class.
 void unSwizzle()
           
 void workingSetClosed()
          At the end of the working set, the writing mode is initialized (deltaSupported), and the reference to the persistent are unswilled
 
Methods inherited from class org.objectweb.speedo.mim.lib.BasicSpeedoAccessor
changeVersion, checkVersion, getCacheEntry, getDetachedStatus, getSpeedoProxy, getUserKey, getVersion, hasBeenFlush, indexFieldModified, isToMerge, jdoChangeStatus, jdoGetStatus, jdoSetStatus, prepareWrite, setDetachedStatus, setSpeedoProxy
 
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.mim.api.SpeedoAccessor
forceDetachedDirty, restoreDetachedNone
 

Field Detail

jdoProxy

public SpeedoGenClassProxy jdoProxy
The SpeedoProxy attached to this state representation.


supportDelta

public boolean supportDelta
Indicates if this accessor support the dela mode


tmpelem

protected GenClassElement tmpelem
A temporary variable which is used to search an element into the "elements" list.


logger

protected org.objectweb.util.monolog.api.Logger logger

elements

public java.util.List elements
The ArrayList used to store the indexed elements of the genclass. Then this list contains also the deleted elements.


deltaForMerge

public java.util.List deltaForMerge
Constructor Detail

GenClassAccessor

public GenClassAccessor(SpeedoGenClassProxy _jdoProxy)
Method Detail

loadFieldsFromAccessor

public abstract void loadFieldsFromAccessor(SpeedoAccessor sa)

createPIndexedElem

public abstract org.objectweb.jorm.api.PIndexedElem createPIndexedElem(GenClassAccessor gca)

setElements

public abstract void setElements(java.lang.Object o)

getLogger

public org.objectweb.util.monolog.api.Logger getLogger()

setFlushed

public void setFlushed(boolean val)
When the gen class is flushed to the data support (parameter = true), the internal structure is clean: - really remove the deleted element - mark the genclass as supporting the delta

Specified by:
setFlushed in interface SpeedoAccessor
Overrides:
setFlushed in class BasicSpeedoAccessor

workingSetClosed

public void workingSetClosed()
At the end of the working set, the writing mode is initialized (deltaSupported), and the reference to the persistent are unswilled

Specified by:
workingSetClosed in interface SpeedoAccessor
Overrides:
workingSetClosed in class BasicSpeedoAccessor

unSwizzle

public void unSwizzle()
Specified by:
unSwizzle in interface SpeedoAccessor

merge

public org.objectweb.perseus.persistence.api.State merge(org.objectweb.perseus.persistence.api.State oldState)
Description copied from interface: SpeedoAccessor
This action updates the old state with the change (delta) done in the transaction on this state.

Specified by:
merge in interface SpeedoAccessor
Overrides:
merge in class BasicSpeedoAccessor

makeToMerge

public void makeToMerge(java.lang.Object thinLock)
Description copied from interface: SpeedoAccessor
Mark the current state with the flag 'toMerge'. This status means at commit time this state has to be merge with the referenceState (cache). Since this method call and until the transaction end, the implementation could register the change for the merge.

Specified by:
makeToMerge in interface SpeedoAccessor
Overrides:
makeToMerge in class BasicSpeedoAccessor

loadFields

public void loadFields(ProxyManager pm,
                       long[] fields)
Description copied from interface: SpeedoAccessor
Askes the loading of the some fields identified by the long array.

Specified by:
loadFields in interface SpeedoAccessor
Parameters:
pm - is the Proxy manager to use to load references
fields - is an array of long. Each long is a bit mask indicating fields to load. As a long is stored over 64 bits, each long of the array can represent only 64 persistent fields. If the class has 70 persistent field, the parameter could be a long array size is 2. This parameter can be null if no field loading is required.

deletePersistent

public abstract void deletePersistent(ProxyManager pm)
Description copied from interface: SpeedoAccessor
Deletes persistent all inner elements of the persistent instance. For a class, it means deleting persistent all objects referenced by a persistent field. For a genclass it means deleting persistent element of the genclass. This method is called when a deletePersistent is called on the persistent class (Proxy) linked to this accessor.

Specified by:
deletePersistent in interface SpeedoAccessor
Parameters:
pm - is the proxy manager for making persistent inner element.

makePersistent

public abstract void makePersistent(ProxyManager pm)
Description copied from interface: SpeedoAccessor
Makes persistent all inner elements of the persistent instance. For a class, it means making persistent all objects referenced by a persistent field. For a genclass it means making persistent element of the genclass. This method is called when a makePersistent is called on the persistent class (Proxy) linked to this accessor.

Specified by:
makePersistent in interface SpeedoAccessor
Parameters:
pm - is the proxy manager for making persistent inner element.

detachCopy

public abstract void detachCopy(ProxyManager pm,
                                java.util.Map map,
                                SpeedoAccessor fieldsClone,
                                java.util.Collection fgHints)
Description copied from interface: SpeedoAccessor
This method is used during the detach operation. A call to this method copy the field of the state into the the cloned state. When a field references a persistent object, according to the fetch plan, the referenced can be detached too.

Specified by:
detachCopy in interface SpeedoAccessor
Parameters:
pm - is the proxy manager used during the detach operation
map - is the map of the detached object. The use of this map permits to support cycle in the object graph.
fieldsClone - is a clone of the current state
fgHints - represents the fetch plan.

attachCopy

public abstract void attachCopy(ProxyManager pm,
                                java.util.Map map,
                                SpeedoAccessor fieldsClone,
                                boolean makeTransactional)
Description copied from interface: SpeedoAccessor
This method is used during the attach operation. A call to this method copy the field of the cloned state into the the current state. When a field references a persistent object, according to the fetch plan, the referenced can be attached too.

Specified by:
attachCopy in interface SpeedoAccessor
Parameters:
pm - is the proxy manager used during the attach operation
map - is the map of the atttached object. The use of this map permits to support cycle in the object graph.
fieldsClone - is the detached state used to update the current state
makeTransactional - ??? TODO comment the parameter

refresh

public abstract void refresh(ProxyManager pm,
                             java.util.Map map,
                             java.util.Collection fgHints)
Description copied from interface: SpeedoAccessor
This method is used during the refresh operation. A call to this method refreshes the fields of the current state. When a field references a persistent object, according to the fetch plan, the referenced can be refreshed too.

Specified by:
refresh in interface SpeedoAccessor
Parameters:
pm - is the proxy manager used during the refresh operation
map - is the map of the refreshed object. The use of this map permits to support cycle in the object graph.
fgHints - represents the fetch plan.

retrieve

public abstract void retrieve(ProxyManager pm,
                              java.util.Map map,
                              java.util.Collection fgHints)
Description copied from interface: SpeedoAccessor
This method is used during the retrieve operation. A call to this method retrieves the fields of the current state. When a field references a persistent object, according to the fetch plan, the referenced can be retrieved too.

Specified by:
retrieve in interface SpeedoAccessor
Parameters:
pm - is the proxy manager used during the retrieve operation
map - is the map of the retrieved object. The use of this map permits to support cycle in the object graph.
fgHints - represents the fetch plan.

speedoAdd

public abstract 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 abstract 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

createPIndexedElem

public org.objectweb.jorm.api.PIndexedElem createPIndexedElem()
Specified by:
createPIndexedElem in interface org.objectweb.jorm.api.PIndexedElemFactory

getMemoryInstance

public java.lang.Object getMemoryInstance()
Specified by:
getMemoryInstance in interface org.objectweb.jorm.api.PAccessor
Overrides:
getMemoryInstance in class BasicSpeedoAccessor

paAdd

public void paAdd(org.objectweb.jorm.api.PIndexedElem elem,
                  java.lang.Object conn)
           throws org.objectweb.jorm.api.PExceptionIO
Specified by:
paAdd in interface org.objectweb.jorm.api.PGenClassAccessor
Throws:
org.objectweb.jorm.api.PExceptionIO

paGetNbElem

public int paGetNbElem()
Specified by:
paGetNbElem in interface org.objectweb.jorm.api.PGenClassAccessor

paIterator

public java.util.Iterator paIterator()
Specified by:
paIterator in interface org.objectweb.jorm.api.PGenClassAccessor

paDeltaSupported

public boolean paDeltaSupported()
Specified by:
paDeltaSupported in interface org.objectweb.jorm.api.PGenClassAccessor

paSetNbElem

public void paSetNbElem(int nbelem)
Specified by:
paSetNbElem in interface org.objectweb.jorm.api.PGenClassAccessor