org.objectweb.speedo.mim.lib
Class AbstractStateImpl

java.lang.Object
  extended by org.objectweb.speedo.mim.lib.AbstractStateImpl
All Implemented Interfaces:
java.io.Serializable, org.objectweb.jorm.api.PAccessor, State, StateItf
Direct Known Subclasses:
GenClassAccessor

public abstract class AbstractStateImpl
extends java.lang.Object
implements StateItf

This class is the basic implementation of the StateItf interface. It is used at the top of the XXXFields class inheritance.

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

Field Summary
 byte detachedStatus
           
 boolean hasBeenFlush
           
protected  boolean isToMerge
           
protected  byte jdoStatus
          This version is allocated: - before attach - before detach - before commit
 PersistentObjectItf speedoPO
           
 
Constructor Summary
AbstractStateImpl()
           
AbstractStateImpl(PersistentObjectItf thepo)
           
 
Method Summary
 boolean checkVersion(StateItf sa)
          check the validity of the version of sa compared to the persistent object this.
 CacheEntry getCacheEntry()
           
 byte getDetachedStatus()
          Gets the current status of this detached object
 java.lang.Object getMemoryInstance()
           
 PersistentObjectItf getSpeedoPO()
           
 java.lang.Object getUserKey(int cacheId)
           
 long getVersion()
          Return the version of the object as a long
 boolean hasBeenFlush()
          indicates if the object has been flushed on the support in a writing before the end of the working set (commit | rollback | close).
 void indexFieldModified(int cacheId, boolean rebind)
          The field uses in user cache, has been modified.
 boolean isToMerge()
          indicates if the StateItf has to be merge with the reference state at commit time.
 void makeToMerge(java.lang.Object thinLock)
          Mark the current state with the flag 'toMerge'.
 State merge(State oldState)
          This action updates the old state with the change (delta) done in the transaction on this state.
 void prepareWrite()
          Prepare to write (relations consistency management)
 void setCacheEntry(CacheEntry ce)
           
 void setDetachedStatus(byte newValue)
          Forces the new value of the detached status
 void setFlushed(boolean val)
          Assignates a boolean value to indicate if the object has been flushed on the support in a writing before the end of the working set (commit | rollback | close).
 void setSpeedoPO(PersistentObjectItf sp)
          It assignes the PersistentObjectItf attached to this state representation.
 void speedoChangeStatus(byte action)
          Changes the status of this object
 void speedoChangeVersion()
          change the version of this only if needed The version is computed by this method A call to changeVersion can have no effect.
 byte speedoGetStatus()
          Gets the current status of this object
 void speedoSetStatus(byte newValue)
          Forces the new value of the status
 void workingSetClosed()
          The context has been closed (ex: transaction end).
 
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.StateItf
attachCopy, deletePersistent, detachCopy, forceDetachedDirty, loadFields, makePersistent, makePersistentOnAttach, refresh, restoreDetachedNone, retrieve, unSwizzle
 

Field Detail

jdoStatus

protected byte jdoStatus
This version is allocated: - before attach - before detach - before commit


detachedStatus

public byte detachedStatus

isToMerge

protected boolean isToMerge

speedoPO

public PersistentObjectItf speedoPO

hasBeenFlush

public boolean hasBeenFlush
Constructor Detail

AbstractStateImpl

public AbstractStateImpl()

AbstractStateImpl

public AbstractStateImpl(PersistentObjectItf thepo)
Method Detail

getCacheEntry

public CacheEntry getCacheEntry()
Specified by:
getCacheEntry in interface State

setCacheEntry

public void setCacheEntry(CacheEntry ce)
Specified by:
setCacheEntry in interface State

getMemoryInstance

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

speedoChangeStatus

public void speedoChangeStatus(byte action)
Changes the status of this object

Specified by:
speedoChangeStatus in interface StateItf
Parameters:
action - the action that may change the status
See Also:
LifeCycle

speedoGetStatus

public byte speedoGetStatus()
Gets the current status of this object

Specified by:
speedoGetStatus in interface StateItf
Returns:
the current state in the life cycle
See Also:
LifeCycle

speedoSetStatus

public void speedoSetStatus(byte newValue)
Forces the new value of the status

Specified by:
speedoSetStatus in interface StateItf
Parameters:
newValue - the new status of this object
See Also:
LifeCycle

getDetachedStatus

public byte getDetachedStatus()
Description copied from interface: StateItf
Gets the current status of this detached object

Specified by:
getDetachedStatus in interface StateItf
Returns:
the current state in the life cycle

setDetachedStatus

public void setDetachedStatus(byte newValue)
Description copied from interface: StateItf
Forces the new value of the detached status

Specified by:
setDetachedStatus in interface StateItf
Parameters:
newValue - the new status of this object

getSpeedoPO

public PersistentObjectItf getSpeedoPO()
Specified by:
getSpeedoPO in interface StateItf
Returns:
The PersistentObjectItf attached to this state representation.

setSpeedoPO

public void setSpeedoPO(PersistentObjectItf sp)
It assignes the PersistentObjectItf attached to this state representation.

Specified by:
setSpeedoPO in interface StateItf

prepareWrite

public void prepareWrite()
Description copied from interface: StateItf
Prepare to write (relations consistency management)

Specified by:
prepareWrite in interface StateItf

workingSetClosed

public void workingSetClosed()
Description copied from interface: StateItf
The context has been closed (ex: transaction end).

Specified by:
workingSetClosed in interface StateItf

hasBeenFlush

public boolean hasBeenFlush()
Description copied from interface: StateItf
indicates if the object has been flushed on the support in a writing before the end of the working set (commit | rollback | close).

Specified by:
hasBeenFlush in interface StateItf

setFlushed

public void setFlushed(boolean val)
Description copied from interface: StateItf
Assignates a boolean value to indicate if the object has been flushed on the support in a writing before the end of the working set (commit | rollback | close).

Specified by:
setFlushed in interface StateItf
Parameters:
val - is the boolean which must be assigned.

speedoChangeVersion

public void speedoChangeVersion()
Description copied from interface: StateItf
change the version of this only if needed The version is computed by this method A call to changeVersion can have no effect.

Specified by:
speedoChangeVersion in interface StateItf

checkVersion

public boolean checkVersion(StateItf sa)
Description copied from interface: StateItf
check the validity of the version of sa compared to the persistent object this.

Specified by:
checkVersion in interface StateItf

getVersion

public long getVersion()
Description copied from interface: StateItf
Return the version of the object as a long

Specified by:
getVersion in interface StateItf

isToMerge

public boolean isToMerge()
Description copied from interface: StateItf
indicates if the StateItf has to be merge with the reference state at commit time.

Specified by:
isToMerge in interface StateItf

makeToMerge

public void makeToMerge(java.lang.Object thinLock)
Description copied from interface: StateItf
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 StateItf
Parameters:
thinLock - is an object representing the thin lock

merge

public State merge(State oldState)
Description copied from interface: StateItf
This action updates the old state with the change (delta) done in the transaction on this state.

Specified by:
merge in interface StateItf
Parameters:
oldState - is the state which has to be updated
Returns:
the updated state.

getUserKey

public java.lang.Object getUserKey(int cacheId)

indexFieldModified

public void indexFieldModified(int cacheId,
                               boolean rebind)
Description copied from interface: StateItf
The field uses in user cache, has been modified.

Specified by:
indexFieldModified in interface StateItf
Parameters:
cacheId - is the cache identifier. The value Integer.MAX_VALUE means that all user cache must be updated.
rebind - if true, the speedoAcessor is rebound