org.apache.openjpa.kernel
Class PCState

java.lang.Object
  extended by org.apache.openjpa.kernel.PCState
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ECleanState, ECopyState, EDeletedState, EDirtyState, ENonTransState, HollowState, PCleanState, PDeletedState, PDirtyState, PNewDeletedState, PNewFlushedDeletedState, PNewProvisionalState, PNewState, PNonTransDeletedState, PNonTransDirtyState, PNonTransNewState, PNonTransState, TCleanState, TDirtyState, TLoadedState, TransientState

public class PCState
extends Object
implements Serializable

Base class for all lifecycle states. Each instance is managed by a OpenJPAStateManager, which in turn keeps a reference to its current state. The state governs the behavior of the instance during all lifecycle events. The class itself is stateless, and is provided its context on each method call. This base class provides no-op implementations of all methods and maintains static singelton shared references to each possible state.

Author:
Abe White
See Also:
Serialized Form

Field Summary
static PCState ECLEAN
          Embedded-Clean
static PCState ECOPY
          Embedded-Copy
static PCState EDELETED
          Embedded-Deleted
static PCState EDIRTY
          Embedded-Dirty
static PCState ENONTRANS
          Embedded-Nontransactional
static PCState HOLLOW
          Hollow; exists in data store
static PCState PCLEAN
          Persistent-Clean
static PCState PDELETED
          Persistent-Deleted
static PCState PDELETEDFLUSHED
          Persistent-Deleted-Flushed
static PCState PDIRTY
          Persistent-Dirty
static PCState PNEW
          Persistent-New
static PCState PNEWDELETED
          Persistent-New-Deleted
static PCState PNEWFLUSHEDDELETED
          Persistent-New-Flushed-Deleted
static PCState PNEWFLUSHEDDELETEDFLUSHED
          Persistent-New-Flushed-Deleted-Flushed
static PCState PNEWPROVISIONAL
          Persistent-New-Provisional
static PCState PNONTRANS
          Persistent-Nontransactinoal
static PCState PNONTRANSDELETED
          Persistent-Deleted-Nontransactional
static PCState PNONTRANSDIRTY
          Persistent-Dirty-Nontransactinoal
static PCState PNONTRANSNEW
          Persistent-New-Nontransactional
static PCState TCLEAN
          Transient-Clean
static PCState TDIRTY
          Transient-Dirty
static PCState TLOADED
          Transient-Loaded
static PCState TRANSIENT
          Transient; unmanaged instance
 
Constructor Summary
PCState()
           
 
Method Summary
(package private)  PCState afterNontransactionalRefresh()
          Return the state to transition to after refresh.
(package private)  PCState afterOptimisticRefresh()
          Return the state to transition to after refresh.
(package private)  PCState afterRefresh()
          Return the state to transition to after refresh.
(package private)  void beforeFlush(StateManagerImpl context, boolean logical, OpCallbacks call)
          Called before the state is flushed.
(package private)  PCState beforeNontransactionalRead(StateManagerImpl context, int field)
          Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being read outside of an active transaction.
(package private)  PCState beforeNontransactionalWrite(StateManagerImpl context, int field, boolean mutate)
          Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being written outside of an active transaction.
(package private)  PCState beforeOptimisticRead(StateManagerImpl context, int field)
          Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being read in an optimistic transaction.
(package private)  PCState beforeOptimisticWrite(StateManagerImpl context, int field, boolean mutate)
          Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being written within an optimistic transaction.
(package private)  PCState beforeRead(StateManagerImpl context, int field)
          Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being read within an active transaction.
(package private)  PCState beforeWrite(StateManagerImpl context, int field, boolean mutate)
          Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being written within an active transaction.
(package private)  PCState commit(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on transaction commit.
(package private)  PCState commitRetain(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on transaction commit with the retainValues flag set.
(package private)  PCState delete(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on a call to Broker.delete(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance.
(package private)  PCState error(String key, StateManagerImpl context)
          Throw an error with a localized message identified by the given key.
(package private)  PCState evict(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on a call to Broker.evict(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance.
(package private)  PCState flush(StateManagerImpl context)
          Perform any actions necessary and return the proper lifecycle state on fush.
(package private)  void initialize(StateManagerImpl context)
          Called when this state is first assigned to the given state manager.
(package private)  boolean isDeleted()
          Return whether this is a deleted state.
(package private)  boolean isDirty()
          Return whether this is a dirty state.
(package private)  boolean isNew()
          Return whether this is a new state.
(package private)  boolean isPendingTransactional()
          Return whether this is a state that will become transactional upon the begin of the next transaction.
(package private)  boolean isPersistent()
          Return whether this is a persistent state.
(package private)  boolean isProvisional()
          Return whether this is a state that will become transient at the end of the next transaction.
(package private)  boolean isTransactional()
          Return whether this is a transactional state.
(package private)  boolean isVersionCheckRequired(StateManagerImpl context)
          Whether this state requires a version check when being flushed, assuming the system is configured for version checks.
(package private)  PCState nonprovisional(StateManagerImpl context, boolean logical, OpCallbacks call)
          Return the state to transition to after making no longer provisional.
(package private)  PCState nontransactional(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on a call to StoreContext.nontransactional(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance.
(package private)  PCState persist(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on a call to Broker.persist(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance.
protected  Object readResolve()
           
(package private)  PCState release(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on a call to Broker#makeTransient with the given instance.
(package private)  PCState rollback(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on transaction rollback.
(package private)  PCState rollbackRestore(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on transaction rollback with the restoreValues flag set.
(package private)  PCState transactional(StateManagerImpl context)
          Perform any actions necesssary and return the proper lifecycle state on a call to StoreContext.nontransactional(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PNEW

public static final PCState PNEW
Persistent-New


PCLEAN

public static final PCState PCLEAN
Persistent-Clean


PDIRTY

public static final PCState PDIRTY
Persistent-Dirty


PDELETED

public static final PCState PDELETED
Persistent-Deleted


PNEWDELETED

public static final PCState PNEWDELETED
Persistent-New-Deleted


PNEWPROVISIONAL

public static final PCState PNEWPROVISIONAL
Persistent-New-Provisional


PNONTRANS

public static final PCState PNONTRANS
Persistent-Nontransactinoal


PNONTRANSDIRTY

public static final PCState PNONTRANSDIRTY
Persistent-Dirty-Nontransactinoal


PNONTRANSNEW

public static final PCState PNONTRANSNEW
Persistent-New-Nontransactional


PNONTRANSDELETED

public static final PCState PNONTRANSDELETED
Persistent-Deleted-Nontransactional


HOLLOW

public static final PCState HOLLOW
Hollow; exists in data store


TRANSIENT

public static final PCState TRANSIENT
Transient; unmanaged instance


TCLEAN

public static final PCState TCLEAN
Transient-Clean


TDIRTY

public static final PCState TDIRTY
Transient-Dirty


TLOADED

public static final PCState TLOADED
Transient-Loaded


ECOPY

public static final PCState ECOPY
Embedded-Copy


ECLEAN

public static final PCState ECLEAN
Embedded-Clean


EDIRTY

public static final PCState EDIRTY
Embedded-Dirty


EDELETED

public static final PCState EDELETED
Embedded-Deleted


ENONTRANS

public static final PCState ENONTRANS
Embedded-Nontransactional


PNEWFLUSHEDDELETED

public static final PCState PNEWFLUSHEDDELETED
Persistent-New-Flushed-Deleted


PNEWFLUSHEDDELETEDFLUSHED

public static final PCState PNEWFLUSHEDDELETEDFLUSHED
Persistent-New-Flushed-Deleted-Flushed


PDELETEDFLUSHED

public static final PCState PDELETEDFLUSHED
Persistent-Deleted-Flushed

Constructor Detail

PCState

public PCState()
Method Detail

initialize

void initialize(StateManagerImpl context)
Called when this state is first assigned to the given state manager.


beforeFlush

void beforeFlush(StateManagerImpl context,
                 boolean logical,
                 OpCallbacks call)
Called before the state is flushed.


flush

PCState flush(StateManagerImpl context)
Perform any actions necessary and return the proper lifecycle state on fush. Returns the this pointer by default.


commit

PCState commit(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on transaction commit. Returns the this pointer by default.


commitRetain

PCState commitRetain(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on transaction commit with the retainValues flag set. Returns the this pointer by default.


rollback

PCState rollback(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on transaction rollback. Returns the this pointer by default.


rollbackRestore

PCState rollbackRestore(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on transaction rollback with the restoreValues flag set. Returns the this pointer by default.


persist

PCState persist(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on a call to Broker.persist(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance. Returns the this pointer by default. Note: this method is not called for embedded states, and is only called when an existing managed instance is the target of a persist call.


delete

PCState delete(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on a call to Broker.delete(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance. Returns the this pointer by default.


nonprovisional

PCState nonprovisional(StateManagerImpl context,
                       boolean logical,
                       OpCallbacks call)
Return the state to transition to after making no longer provisional. Returns the this pointer by default.


nontransactional

PCState nontransactional(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on a call to StoreContext.nontransactional(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance. Returns the this pointer by default.


transactional

PCState transactional(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on a call to StoreContext.nontransactional(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance. Returns the this pointer by default.


release

PCState release(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on a call to Broker#makeTransient with the given instance. Returns the this pointer by default.


evict

PCState evict(StateManagerImpl context)
Perform any actions necesssary and return the proper lifecycle state on a call to Broker.evict(java.lang.Object, org.apache.openjpa.kernel.OpCallbacks) with the given instance. Returns the this pointer by default.


afterRefresh

PCState afterRefresh()
Return the state to transition to after refresh. The context is not given because no actions should be taken.


afterOptimisticRefresh

PCState afterOptimisticRefresh()
Return the state to transition to after refresh. The context is not given because no actions should be taken.


afterNontransactionalRefresh

PCState afterNontransactionalRefresh()
Return the state to transition to after refresh. The context is not given because no actions should be taken.


beforeRead

PCState beforeRead(StateManagerImpl context,
                   int field)
Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being read within an active transaction. The given field number can be -1 if it is a general object read. Returns the this pointer by default.


beforeNontransactionalRead

PCState beforeNontransactionalRead(StateManagerImpl context,
                                   int field)
Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being read outside of an active transaction. The given field number can be -1 if it is a general object read. Returns the this pointer by default.


beforeOptimisticRead

PCState beforeOptimisticRead(StateManagerImpl context,
                             int field)
Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being read in an optimistic transaction. The given field number can be -1 if it is a general object read. Returns the this pointer by default.


beforeWrite

PCState beforeWrite(StateManagerImpl context,
                    int field,
                    boolean mutate)
Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being written within an active transaction. The mutate parameter tells if it is a direct mutation on an SCO field. Returns the this pointer by default.


beforeOptimisticWrite

PCState beforeOptimisticWrite(StateManagerImpl context,
                              int field,
                              boolean mutate)
Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being written within an optimistic transaction. The mutate parameter tells if it is a direct mutation on an SCO field. Returns the this pointer by default.


beforeNontransactionalWrite

PCState beforeNontransactionalWrite(StateManagerImpl context,
                                    int field,
                                    boolean mutate)
Perform any actions necesssary and return the proper lifecycle state prior to the state of the given instance being written outside of an active transaction. The mutate parameter tells if it is a direct mutation on an SCO field. Returns the this pointer by default.


isTransactional

boolean isTransactional()
Return whether this is a transactional state. Returns false by default.


isPersistent

boolean isPersistent()
Return whether this is a persistent state. Returns false by default.


isNew

boolean isNew()
Return whether this is a new state. Returns false by default.


isDeleted

boolean isDeleted()
Return whether this is a deleted state. Returns false by default.


isDirty

boolean isDirty()
Return whether this is a dirty state. Returns false by default.


isPendingTransactional

boolean isPendingTransactional()
Return whether this is a state that will become transactional upon the begin of the next transaction. Returns false by default.


isProvisional

boolean isProvisional()
Return whether this is a state that will become transient at the end of the next transaction. Returns false by default.


isVersionCheckRequired

boolean isVersionCheckRequired(StateManagerImpl context)
Whether this state requires a version check when being flushed, assuming the system is configured for version checks.


error

PCState error(String key,
              StateManagerImpl context)
Throw an error with a localized message identified by the given key.


readResolve

protected Object readResolve()
                      throws ObjectStreamException
Throws:
ObjectStreamException


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.