org.apache.jdo.impl.state
Class TransientClean

java.lang.Object
  extended byorg.apache.jdo.impl.state.LifeCycleState
      extended byorg.apache.jdo.impl.state.TransientClean

class TransientClean
extends LifeCycleState

This class represents TransientClean state specific state transitions as requested by StateManagerImpl. This state is the result of a call to makeTransactional on a Transient instance, or commit or rollback of a TransientDirty instance.

Author:
Marina Vatkina

Field Summary
protected static int AP_NEW
          Constants to specify the life cycle state type
protected static int AP_NEW_FLUSHED
          Constants to specify the life cycle state type
protected static int AP_NEW_FLUSHED_DIRTY
          Constants to specify the life cycle state type
protected static int AP_PENDING
          Constants to specify the life cycle state type
protected static int HOLLOW
          Constants to specify the life cycle state type
protected  boolean isAutoPersistent
           
protected  boolean isBeforeImageUpdatable
           
protected  boolean isDeleted
           
protected  boolean isDirty
           
protected  boolean isFlushed
           
protected  boolean isNavigable
           
protected  boolean isNew
           
protected  boolean isPersistent
           
protected  boolean isRefreshable
           
protected  boolean isStored
           
protected  boolean isTransactional
           
protected static I18NHelper msg
          I18N message handler
protected  boolean needMerge
           
protected static int P_CLEAN
          Constants to specify the life cycle state type
protected static int P_CLEAN_TX
          Constants to specify the life cycle state type
protected static int P_DELETED
          Constants to specify the life cycle state type
protected static int P_DELETED_FLUSHED
          Constants to specify the life cycle state type
protected static int P_DIRTY
          Constants to specify the life cycle state type
protected static int P_DIRTY_FLUSHED
          Constants to specify the life cycle state type
protected static int P_NEW
          Constants to specify the life cycle state type
protected static int P_NEW_DELETED
          Constants to specify the life cycle state type
protected static int P_NEW_FLUSHED
          Constants to specify the life cycle state type
protected static int P_NEW_FLUSHED_DELETED
          Constants to specify the life cycle state type
protected static int P_NEW_FLUSHED_DIRTY
          Constants to specify the life cycle state type
protected static int P_NON_TX
          Constants to specify the life cycle state type
protected  int stateType
           
protected static int T_CLEAN
          Constants to specify the life cycle state type
protected static int T_DIRTY
          Constants to specify the life cycle state type
protected static int TOTAL
          Constants to specify the life cycle state type
protected static int TRANSIENT
          Constants to specify the life cycle state type
 
Constructor Summary
(package private) TransientClean()
           
 
Method Summary
protected  void assertTransaction(boolean transactionActive)
          Asserts that current transaction is active.
protected  LifeCycleState changeState(int newStateType)
          Changes Life Cycle State.
protected  LifeCycleState flush(java.util.BitSet loadedFields, java.util.BitSet dirtyFields, StoreManager srm, StateManagerImpl sm)
          Performs state specific flush operation and transitions LifeCycleState depending on the result.
protected static LifeCycleState getLifeCycleState(int state)
          Returns the LifeCycleState for the state constant.
protected static void initLifeCycleState()
          Initialises the objects.
protected  boolean isAutoPersistent()
          Return whether the object state is persistent by reachabilty only.
protected  boolean isBeforeImageUpdatable()
          Return whether the beforeImage can be updated.
protected  boolean isDeleted()
          Return whether the state represents a deleted object.
protected  boolean isDirty()
          Return whether the object state is dirty, that is, the object has been changed (created, updated, deleted) in this Tx.
protected  boolean isFlushed()
          Return whether the object has been flushed to the datastore.
protected  boolean isNavigable()
          Return whether the object can dynamically navigate to fields that are not present.
protected  boolean isNew()
          Return whether the state represents a newly created object.
protected  boolean isPersistent()
          Return whether the object state is persistent.
protected  boolean isRefreshable()
          Return whether the object can be refreshed from the datastore.
protected  boolean isStored()
          Return whether the object is stored in the datastore.
protected  boolean isTransactional()
          Return whether the object state is transactional.
protected  boolean needMerge()
          Return whether the merge is needed.
protected  int stateType()
          Returns the type of the life cycle state as an int.
 java.lang.String toString()
           
protected  LifeCycleState transitionCommit(boolean retainValues, StateManagerImpl sm)
          This is a no-op.
protected  LifeCycleState transitionDeletePersistent(StateManagerImpl sm)
          Transitions LifeCycleState on call to deletePersistent
protected  LifeCycleState transitionEvict(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to evict an instance.
protected  LifeCycleState transitionFromAutoPersistent(StateManagerImpl sm)
          Transitions LifeCycleState to transient for AutoPersistent instance that is not referenced anymore (persistence-by-reachability)
protected  LifeCycleState transitionMakeNontransactional(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to makeNontransactional
protected  LifeCycleState transitionMakePersistent(StateManagerImpl sm)
          Transitions LifeCycleState on call to makePersistent
protected  LifeCycleState transitionMakeTransactional(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to makeTransactional
protected  LifeCycleState transitionMakeTransient(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to makeTransient.
protected  LifeCycleState transitionReadField(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to read a field.
protected  LifeCycleState transitionRefresh(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to refresh an instance.
protected  LifeCycleState transitionReload(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to reload an instance.
protected  LifeCycleState transitionReplace(StateManagerImpl sm, javax.jdo.Transaction tx, int[] fields, FieldManager fieldManager)
          Transitions the lifecycle state as if the instance is retrieved from the datastore, but use the specified field values instead of loading them from the datastore.
protected  LifeCycleState transitionRetrieve(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to retrieve an instance.
protected  LifeCycleState transitionRollback(boolean restoreValues, StateManagerImpl sm)
          Transitions LifeCycleState on rollback.
protected  LifeCycleState transitionToAutoPersistent(StateManagerImpl sm)
          Transitions LifeCycleState as a result of call to makePersistent of a referencing instance (persistence-by-reachability)
protected  LifeCycleState transitionWriteField(StateManagerImpl sm, javax.jdo.Transaction tx)
          Transitions LifeCycleState on call to write a field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

msg

protected static final I18NHelper msg
I18N message handler


isPersistent

protected boolean isPersistent

isTransactional

protected boolean isTransactional

isDirty

protected boolean isDirty

isNew

protected boolean isNew

isDeleted

protected boolean isDeleted

isNavigable

protected boolean isNavigable

isRefreshable

protected boolean isRefreshable

isBeforeImageUpdatable

protected boolean isBeforeImageUpdatable

isFlushed

protected boolean isFlushed

isAutoPersistent

protected boolean isAutoPersistent

isStored

protected boolean isStored

needMerge

protected boolean needMerge

stateType

protected int stateType

TRANSIENT

protected static final int TRANSIENT
Constants to specify the life cycle state type

See Also:
Constant Field Values

HOLLOW

protected static final int HOLLOW
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_NON_TX

protected static final int P_NON_TX
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_CLEAN

protected static final int P_CLEAN
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_CLEAN_TX

protected static final int P_CLEAN_TX
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_DIRTY

protected static final int P_DIRTY
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_DIRTY_FLUSHED

protected static final int P_DIRTY_FLUSHED
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_NEW

protected static final int P_NEW
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_NEW_FLUSHED

protected static final int P_NEW_FLUSHED
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_NEW_FLUSHED_DELETED

protected static final int P_NEW_FLUSHED_DELETED
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_NEW_FLUSHED_DIRTY

protected static final int P_NEW_FLUSHED_DIRTY
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_NEW_DELETED

protected static final int P_NEW_DELETED
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_DELETED

protected static final int P_DELETED
Constants to specify the life cycle state type

See Also:
Constant Field Values

P_DELETED_FLUSHED

protected static final int P_DELETED_FLUSHED
Constants to specify the life cycle state type

See Also:
Constant Field Values

T_CLEAN

protected static final int T_CLEAN
Constants to specify the life cycle state type

See Also:
Constant Field Values

T_DIRTY

protected static final int T_DIRTY
Constants to specify the life cycle state type

See Also:
Constant Field Values

AP_NEW

protected static final int AP_NEW
Constants to specify the life cycle state type

See Also:
Constant Field Values

AP_NEW_FLUSHED

protected static final int AP_NEW_FLUSHED
Constants to specify the life cycle state type

See Also:
Constant Field Values

AP_NEW_FLUSHED_DIRTY

protected static final int AP_NEW_FLUSHED_DIRTY
Constants to specify the life cycle state type

See Also:
Constant Field Values

AP_PENDING

protected static final int AP_PENDING
Constants to specify the life cycle state type

See Also:
Constant Field Values

TOTAL

protected static final int TOTAL
Constants to specify the life cycle state type

See Also:
Constant Field Values
Constructor Detail

TransientClean

TransientClean()
Method Detail

transitionMakeTransient

protected LifeCycleState transitionMakeTransient(StateManagerImpl sm,
                                                 javax.jdo.Transaction tx)
Description copied from class: LifeCycleState
Transitions LifeCycleState on call to makeTransient.

Overrides:
transitionMakeTransient in class LifeCycleState
Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
LifeCycleState.transitionMakeTransient(StateManagerImpl sm, Transaction tx)

transitionMakeNontransactional

protected LifeCycleState transitionMakeNontransactional(StateManagerImpl sm,
                                                        javax.jdo.Transaction tx)
Description copied from class: LifeCycleState
Transitions LifeCycleState on call to makeNontransactional

Overrides:
transitionMakeNontransactional in class LifeCycleState
Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
LifeCycleState.transitionMakeNontransactional(StateManagerImpl sm, Transaction tx)

transitionMakePersistent

protected LifeCycleState transitionMakePersistent(StateManagerImpl sm)
Description copied from class: LifeCycleState
Transitions LifeCycleState on call to makePersistent

Overrides:
transitionMakePersistent in class LifeCycleState
Parameters:
sm - StateManagerImpl requested the transition.
Returns:
new LifeCycleState.
See Also:
LifeCycleState.transitionMakePersistent(StateManagerImpl sm)

transitionToAutoPersistent

protected LifeCycleState transitionToAutoPersistent(StateManagerImpl sm)
Description copied from class: LifeCycleState
Transitions LifeCycleState as a result of call to makePersistent of a referencing instance (persistence-by-reachability)

Overrides:
transitionToAutoPersistent in class LifeCycleState
Parameters:
sm - StateManagerImpl requested the transition.
Returns:
new LifeCycleState.
See Also:
LifeCycleState.transitionToAutoPersistent(StateManagerImpl sm)

transitionReadField

protected LifeCycleState transitionReadField(StateManagerImpl sm,
                                             javax.jdo.Transaction tx)
Description copied from class: LifeCycleState
Transitions LifeCycleState on call to read a field.

Overrides:
transitionReadField in class LifeCycleState
Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
LifeCycleState.transitionReadField(StateManagerImpl sm, Transaction tx)

transitionWriteField

protected LifeCycleState transitionWriteField(StateManagerImpl sm,
                                              javax.jdo.Transaction tx)
Description copied from class: LifeCycleState
Transitions LifeCycleState on call to write a field.

Overrides:
transitionWriteField in class LifeCycleState
Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
LifeCycleState.transitionWriteField(StateManagerImpl sm, Transaction tx)

transitionCommit

protected LifeCycleState transitionCommit(boolean retainValues,
                                          StateManagerImpl sm)
This is a no-op.

Overrides:
transitionCommit in class LifeCycleState
Parameters:
retainValues - the value of the flag in the Transaction instance associated with the hashing PersistenceManager
sm - StateManagerImpl requested the transition.
Returns:
new LifeCycleState.
See Also:
LifeCycleState.transitionCommit(boolean retainValues, StateManagerImpl sm)

transitionRollback

protected LifeCycleState transitionRollback(boolean restoreValues,
                                            StateManagerImpl sm)
Description copied from class: LifeCycleState
Transitions LifeCycleState on rollback. Called by TransactionImpl.afterCompletion.

Overrides:
transitionRollback in class LifeCycleState
Parameters:
restoreValues - the value of the flag in the Transaction instance associated with the hashing PersistenceManager
sm - StateManagerImpl requested the transition.
Returns:
new LifeCycleState.
See Also:
LifeCycleState.transitionRollback(boolean restoreValues, StateManagerImpl sm)

initLifeCycleState

protected static void initLifeCycleState()
Initialises the objects. This class implements the "state pattern".


getLifeCycleState

protected static LifeCycleState getLifeCycleState(int state)
Returns the LifeCycleState for the state constant.

Parameters:
state - the state type as integer
Returns:
the type as LifeCycleState object

stateType

protected int stateType()
Returns the type of the life cycle state as an int.

Returns:
the type of this life cycle state as an int.

transitionMakeTransactional

protected LifeCycleState transitionMakeTransactional(StateManagerImpl sm,
                                                     javax.jdo.Transaction tx)
Transitions LifeCycleState on call to makeTransactional

Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
PersistenceManager.makeTransactional(Object pc)

transitionFromAutoPersistent

protected LifeCycleState transitionFromAutoPersistent(StateManagerImpl sm)
Transitions LifeCycleState to transient for AutoPersistent instance that is not referenced anymore (persistence-by-reachability)

Parameters:
sm - StateManagerImpl requested the transition.
Returns:
new LifeCycleState.
See Also:
PersistenceManager.makePersistent(Object pc)

transitionDeletePersistent

protected LifeCycleState transitionDeletePersistent(StateManagerImpl sm)
Transitions LifeCycleState on call to deletePersistent

Parameters:
sm - StateManagerImpl requested the transition.
Returns:
new LifeCycleState.
See Also:
PersistenceManager.deletePersistent(Object pc)

transitionEvict

protected LifeCycleState transitionEvict(StateManagerImpl sm,
                                         javax.jdo.Transaction tx)
Transitions LifeCycleState on call to evict an instance.

Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
PersistenceManager.evict(Object pc)

transitionRefresh

protected LifeCycleState transitionRefresh(StateManagerImpl sm,
                                           javax.jdo.Transaction tx)
Transitions LifeCycleState on call to refresh an instance.

Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
PersistenceManager.refresh(Object pc)

transitionRetrieve

protected LifeCycleState transitionRetrieve(StateManagerImpl sm,
                                            javax.jdo.Transaction tx)
Transitions LifeCycleState on call to retrieve an instance.

Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
PersistenceManager.retrieve(Object pc)

transitionReplace

protected LifeCycleState transitionReplace(StateManagerImpl sm,
                                           javax.jdo.Transaction tx,
                                           int[] fields,
                                           FieldManager fieldManager)
Transitions the lifecycle state as if the instance is retrieved from the datastore, but use the specified field values instead of loading them from the datastore.

Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
fields - Indicates which fields should be replaced in the PC.
fieldManager - FieldManager from which the field's value should be
Returns:
new LifeCycleState.

transitionReload

protected LifeCycleState transitionReload(StateManagerImpl sm,
                                          javax.jdo.Transaction tx)
Transitions LifeCycleState on call to reload an instance. This is the result of a request to validate non-transactional instance.

Parameters:
sm - StateManagerImpl requested the transition.
tx - Transaction associated with the hashing PersistenceManager
Returns:
new LifeCycleState.
See Also:
PersistenceManager.getObjectById(Object oid, boolean validate)

flush

protected LifeCycleState flush(java.util.BitSet loadedFields,
                               java.util.BitSet dirtyFields,
                               StoreManager srm,
                               StateManagerImpl sm)
Performs state specific flush operation and transitions LifeCycleState depending on the result.

Parameters:
loadedFields - BitSet of fields loaded from the database.
dirtyFields - BitSet of changed fields that are to be flushed and/or verified against those in the database, if this flush is within the context of an optimistic transaction. After return, bits will remain set for fields that were not flushed, and in such case the return will be StateManagerInternal.FLUSHED_PARTIAL. If the flush was not performed because of the dependency or other restrictions, the return will be StateManagerInternal.FLUSHED_NONE. If operation was successful, the return will be StateManagerInternal.FLUSHED_COMPLETE.
sm - StateManagerImpl requested the transition.
Returns:
new LifeCycleState.

assertTransaction

protected void assertTransaction(boolean transactionActive)
Asserts that current transaction is active.

Parameters:
transactionActive - true if the current transaction is active
Throws:
javax.jdo.JDOUserException - if transaction is not active

isPersistent

protected boolean isPersistent()
Return whether the object state is persistent.


isTransactional

protected boolean isTransactional()
Return whether the object state is transactional.


isDirty

protected boolean isDirty()
Return whether the object state is dirty, that is, the object has been changed (created, updated, deleted) in this Tx.


isNew

protected boolean isNew()
Return whether the state represents a newly created object.


isDeleted

protected boolean isDeleted()
Return whether the state represents a deleted object.


isNavigable

protected boolean isNavigable()
Return whether the object can dynamically navigate to fields that are not present.


isRefreshable

protected boolean isRefreshable()
Return whether the object can be refreshed from the datastore.


isBeforeImageUpdatable

protected boolean isBeforeImageUpdatable()
Return whether the beforeImage can be updated.


isFlushed

protected boolean isFlushed()
Return whether the object has been flushed to the datastore.


isAutoPersistent

protected boolean isAutoPersistent()
Return whether the object state is persistent by reachabilty only.


isStored

protected boolean isStored()
Return whether the object is stored in the datastore.


needMerge

protected boolean needMerge()
Return whether the merge is needed.


changeState

protected LifeCycleState changeState(int newStateType)
Changes Life Cycle State.

Returns:
new LifeCycleState.

toString

public java.lang.String toString()