Save This Page
Home » apache-openjpa-1.1.0-source » org.apache.openjpa » kernel » [javadoc | source]
org.apache.openjpa.kernel
public class: StateManagerImpl [javadoc | source]
java.lang.Object
   org.apache.openjpa.kernel.StateManagerImpl

All Implemented Interfaces:
    Serializable, OpenJPAStateManager

Implementation of the OpenJPAStateManager interface for use with this runtime. Each state manager manages the state of a single persistence capable instance. The state manager is also responsible for all communications about the instance to the StoreManager . The state manager uses the State pattern in both its interaction with the governed instance and its interaction with the broker. In its interactions with the persistence capable instance, it uses the FieldManager interface. Similarly, when interacting with the broker, it uses the PCState singleton that represents the current lifecycle state of the instance.
Field Summary
public static final  int LOAD_FGS     
public static final  int LOAD_ALL     
public static final  int LOAD_SERIALIZE     
Constructor:
 protected StateManagerImpl(Object id,
    ClassMetaData meta,
    BrokerImpl broker) 
    Constructor; supply id, type metadata, and owning persistence manager.
Method from org.apache.openjpa.kernel.StateManagerImpl Summary:
accessingField,   afterFlush,   afterRefresh,   assertNotManagedObjectId,   assignObjectId,   beforeAccessField,   beforeFlush,   beforeRead,   beforeRefresh,   cascadeDelete,   cascadePersist,   clearFields,   clearSavedFields,   commit,   delete,   dirty,   dirty,   dirtyCheck,   eraseFlush,   evict,   fetch,   fetchBoolean,   fetchBooleanField,   fetchByte,   fetchByteField,   fetchChar,   fetchCharField,   fetchDouble,   fetchDoubleField,   fetchField,   fetchFloat,   fetchFloatField,   fetchInitialField,   fetchInt,   fetchIntField,   fetchLong,   fetchLongField,   fetchObject,   fetchObjectField,   fetchObjectId,   fetchShort,   fetchShortField,   fetchString,   fetchStringField,   gatherCascadeRefresh,   getBroker,   getContext,   getDirty,   getFlushed,   getGenericContext,   getId,   getImplData,   getImplData,   getIntermediate,   getLoadVersion,   getLoaded,   getLock,   getManagedInstance,   getMetaData,   getObjectId,   getOwner,   getOwnerIndex,   getPCPrimaryKey,   getPCState,   getPersistenceCapable,   getSaveFieldManager,   getUnloaded,   getVersion,   initialize,   initialize,   isDefaultValue,   isDeleted,   isDetached,   isDirty,   isEmbedded,   isFlushed,   isFlushedDirty,   isImplDataCacheable,   isImplDataCacheable,   isIntercepting,   isLoading,   isNew,   isPendingTransactional,   isPersistent,   isProvisional,   isTransactional,   isVersionCheckRequired,   isVersionUpdateRequired,   load,   load,   loadField,   loadFields,   lock,   newFieldProxy,   newProxy,   nonprovisional,   nontransactional,   persist,   preDelete,   preFlush,   provideField,   providedBooleanField,   providedByteField,   providedCharField,   providedDoubleField,   providedFloatField,   providedIntField,   providedLongField,   providedObjectField,   providedShortField,   providedStringField,   proxyDetachedDeserialized,   proxyFields,   readLocked,   readPC,   release,   release,   removed,   replaceBooleanField,   replaceByteField,   replaceCharField,   replaceDoubleField,   replaceField,   replaceFlags,   replaceFloatField,   replaceIntField,   replaceLongField,   replaceObjectField,   replaceShortField,   replaceStateManager,   replaceStringField,   restoreFields,   rollback,   rollbackToSavepoint,   saveFields,   serializing,   setCheckVersion,   setDereferencedDependent,   setDirty,   setImplData,   setImplData,   setIntermediate,   setLoaded,   setLoading,   setLock,   setNextVersion,   setObjectId,   setOwner,   setRemote,   setUpdateVersion,   setVersion,   settingBooleanField,   settingByteField,   settingCharField,   settingDoubleField,   settingFloatField,   settingIntField,   settingLongField,   settingObjectField,   settingShortField,   settingStringField,   store,   storeBoolean,   storeBooleanField,   storeByte,   storeByteField,   storeChar,   storeCharField,   storeDouble,   storeDoubleField,   storeField,   storeFloat,   storeFloatField,   storeInt,   storeIntField,   storeLong,   storeLongField,   storeObject,   storeObjectField,   storeShort,   storeShortField,   storeString,   storeStringField,   transactional,   translate,   unlock,   unproxyFields,   writeDetached,   writePC
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.openjpa.kernel.StateManagerImpl Detail:
 public  void accessingField(int field) 
  void afterFlush(int reason) 
    Delegates to the current state.
  void afterRefresh() 
    Perform state transitions after refresh. This method is only called if #beforeRefresh returns true.
  void assertNotManagedObjectId(Object val) 
    Disallows setting an object id field to a managed instance.
 public boolean assignObjectId(boolean flush) 
 protected  void beforeAccessField(int field) 
    Load the given field before access.
  void beforeFlush(int reason,
    OpCallbacks call) 
    Delegates to the current state.
  void beforeRead(int field) 
    Notification that the object is about to be accessed.
 public boolean beforeRefresh(boolean refreshAll) 
  void cascadeDelete(OpCallbacks call) 
    Cascade deletes and dereference dependent fields.
  void cascadePersist(OpCallbacks call) 
  void clearFields() 
    Executes pre-clear callbacks, clears all managed fields, and calls the #setLoaded method with a value of false. Primary key fields are not cleared.
  void clearSavedFields() 
    Notification that the state will not need to be rolled back to that of the last call to #saveFields .
  void commit() 
    Delegates to the current state after checking the value of the RetainState flag.
  void delete() 
    Delegates to the current state.
 public  void dirty(String field) 
 public  void dirty(int field) 
 public  void dirtyCheck() 

    Checks whether or not _pc is dirty. In the cases where field tracking is not happening (see below), this method will do a state comparison to find whether _pc is dirty, and will update this instance with this information. In the cases where field tracking is happening, this method is a no-op.

    Fields are tracked for all classes that are run through the OpenJPA enhancer prior to or during deployment, and all classes (enhanced or unenhanced) in a Java 6 environment or newer.

    In a Java 5 VM or older:
    - instances of unenhanced classes that use property access and obey the property access limitations are tracked when the instances are loaded from the database by OpenJPA, and are not tracked when the instances are created by application code.
    - instances of unenhanced classes that use field access are never tracked.

  void eraseFlush() 
    Erase the fact that this instance has been flushed.
  void evict() 
    Delegates to the current state.
 public Object fetch(int field) 
 public boolean fetchBoolean(int field) 
 public boolean fetchBooleanField(int field) 
 public byte fetchByte(int field) 
 public byte fetchByteField(int field) 
 public char fetchChar(int field) 
 public char fetchCharField(int field) 
 public double fetchDouble(int field) 
 public double fetchDoubleField(int field) 
 public Object fetchField(int field,
    boolean transitions) 
 public float fetchFloat(int field) 
 public float fetchFloatField(int field) 
 public Object fetchInitialField(int field) 
 public int fetchInt(int field) 
 public int fetchIntField(int field) 
 public long fetchLong(int field) 
 public long fetchLongField(int field) 
 public Object fetchObject(int field) 
 public Object fetchObjectField(int field) 
 public Object fetchObjectId() 
 public short fetchShort(int field) 
 public short fetchShortField(int field) 
 public String fetchString(int field) 
 public String fetchStringField(int field) 
  void gatherCascadeRefresh(OpCallbacks call) 
 BrokerImpl getBroker() 
    Managing broker.
 public StoreContext getContext() 
 public BitSet getDirty() 
 public BitSet getFlushed() 
 public Object getGenericContext() 
 public Object getId() 
 public synchronized Object getImplData() 
 public Object getImplData(int field) 
 public Object getIntermediate(int field) 
 Object getLoadVersion() 
 public BitSet getLoaded() 
 public Object getLock() 
 public Object getManagedInstance() 
 public ClassMetaData getMetaData() 
 public Object getObjectId() 
 public OpenJPAStateManager getOwner() 
 public int getOwnerIndex() 
 public Object getPCPrimaryKey(Object oid,
    int field) 
 public PCState getPCState() 
 public PersistenceCapable getPersistenceCapable() 
 public SaveFieldManager getSaveFieldManager() 
 public BitSet getUnloaded(FetchConfiguration fetch) 
 public Object getVersion() 
 public  void initialize(Class cls,
    PCState state) 
 protected  void initialize(PersistenceCapable pc,
    PCState state) 
    Initialize with the given instance and state.
 public boolean isDefaultValue(int field) 
 public boolean isDeleted() 
 public boolean isDetached() 
 public boolean isDirty() 
 public boolean isEmbedded() 
 public boolean isFlushed() 
 public boolean isFlushedDirty() 
 public boolean isImplDataCacheable() 
 public synchronized boolean isImplDataCacheable(int field) 
 public boolean isIntercepting() 
    Whether or not data access in this instance is intercepted. This differs from ClassMetaData#isIntercepting() in that it checks for property access + subclassing in addition to the redefinition / enhancement checks.
 boolean isLoading() 
    Whether this state manager is in the middle of a load.
 public boolean isNew() 
 public boolean isPendingTransactional() 
 public boolean isPersistent() 
 public boolean isProvisional() 
 public boolean isTransactional() 
 public boolean isVersionCheckRequired() 
    Returns whether this instance needs a version check.
 public boolean isVersionUpdateRequired() 
    Returns whether this instance needs a version update.
 public  void load(FetchConfiguration fetch) 
 protected boolean load(FetchConfiguration fetch,
    int loadMode,
    BitSet exclude,
    Object sdata,
    boolean forWrite) 
    Load the state of this instance based on the given fetch configuration and load mode. Return true if any data was loaded, false otherwise.
 protected  void loadField(int field,
    int lockLevel,
    boolean forWrite,
    boolean fgs) 
    Load the given field's fetch group; the field itself may already be loaded if it is being set by the user.
 boolean loadFields(BitSet fields,
    FetchConfiguration fetch,
    int lockLevel,
    Object sdata) 
    Load the given field set from the data store into the instance. Return true if any data is loaded, false otherwise.
 protected  void lock() 
    Lock the state manager if the multithreaded option is set.
 public Object newFieldProxy(int field) 
 public Object newProxy(int field) 
  void nonprovisional(boolean logical,
    OpCallbacks call) 
    Delegates to the current state.
  void nontransactional() 
    Delegates to the current state.
  void persist() 
    Delegates to the current state.
  void preDelete() 
    Make callbacks for deletion.
  void preFlush(boolean logical,
    OpCallbacks call) 
    Get ready for a flush. Persists all persistence-capable object fields, and checks for illegal null values. Also assigns oids and field values for all strategies that don't require flushing.
  void provideField(PersistenceCapable pc,
    FieldManager store,
    int field) 
    Helper method to provide the given field number to the given field manager.
 public  void providedBooleanField(PersistenceCapable pc,
    int field,
    boolean curVal) 
 public  void providedByteField(PersistenceCapable pc,
    int field,
    byte curVal) 
 public  void providedCharField(PersistenceCapable pc,
    int field,
    char curVal) 
 public  void providedDoubleField(PersistenceCapable pc,
    int field,
    double curVal) 
 public  void providedFloatField(PersistenceCapable pc,
    int field,
    float curVal) 
 public  void providedIntField(PersistenceCapable pc,
    int field,
    int curVal) 
 public  void providedLongField(PersistenceCapable pc,
    int field,
    long curVal) 
 public  void providedObjectField(PersistenceCapable pc,
    int field,
    Object curVal) 
 public  void providedShortField(PersistenceCapable pc,
    int field,
    short curVal) 
 public  void providedStringField(PersistenceCapable pc,
    int field,
    String curVal) 
 public  void proxyDetachedDeserialized(int idx) 
  void proxyFields(boolean reset,
    boolean replaceNull) 
    Replaces all second class object fields with fresh proxied instances containing the same information as the originals.
  void readLocked(int readLockLevel,
    int writeLockLevel) 
    Notification that we've been read-locked. Pass in the level at which we were locked and the level at which we should write lock ourselves on dirty.
 PersistenceCapable readPC(ObjectInputStream in) throws IOException, ClassNotFoundException 
    Converts the deserialized o to a PersistenceCapable instance appropriate for storing in _pc.
  void release(boolean unproxy) 
    Delegates to the current state.
  void release(boolean unproxy,
    boolean force) 
 public  void removed(int field,
    Object removed,
    boolean key) 
 public boolean replaceBooleanField(PersistenceCapable pc,
    int field) 
 public byte replaceByteField(PersistenceCapable pc,
    int field) 
 public char replaceCharField(PersistenceCapable pc,
    int field) 
 public double replaceDoubleField(PersistenceCapable pc,
    int field) 
  void replaceField(PersistenceCapable pc,
    FieldManager load,
    int field) 
    Helper method to replace the given field number to the given field manager.
 public byte replaceFlags() 
 public float replaceFloatField(PersistenceCapable pc,
    int field) 
 public int replaceIntField(PersistenceCapable pc,
    int field) 
 public long replaceLongField(PersistenceCapable pc,
    int field) 
 public Object replaceObjectField(PersistenceCapable pc,
    int field) 
 public short replaceShortField(PersistenceCapable pc,
    int field) 
 public StateManager replaceStateManager(StateManager sm) 
 public String replaceStringField(PersistenceCapable pc,
    int field) 
  void restoreFields() 
    Rollback the state of the instance to the saved state from the last call to #saveFields , or to default values if never saved.
  void rollback() 
    Delegates to the current state after checking the value of the RetainState flag.
  void rollbackToSavepoint(SavepointFieldManager savepoint) 
    Rollback state of the managed instance to the given savepoint.
  void saveFields(boolean immediate) 
    Record that we should save any fields that change from this point forward.
 public boolean serializing() 
  void setCheckVersion(boolean versionCheck) 
    Set whether this instance requires a version check on the next flush.
  void setDereferencedDependent(boolean deref,
    boolean notify) 
    Mark this object as a dereferenced dependent object.
  void setDirty(boolean val) 
    Records that all instance fields are/are not dirty, and changes the flags of the instance accordingly.
 public synchronized Object setImplData(Object data,
    boolean cacheable) 
 public Object setImplData(int field,
    Object data) 
 public  void setIntermediate(int field,
    Object data) 
  void setLoaded(boolean val) 
    Records that all instance fields are/are not loaded. Primary key and non-persistent fields are not affected.
  void setLoading(boolean loading) 
    Whether this state manager is in the middle of a load initiated by outside code; for any internal methods that cause loading, the loading flag is set automatically.
 public  void setLock(Object lock) 
 public  void setNextVersion(Object version) 
 public  void setObjectId(Object oid) 
  void setOwner(StateManagerImpl owner,
    ValueMetaData ownerMeta) 
    Set the owning state and field if this is an embedded instance.
 public  void setRemote(int field,
    Object value) 
  void setUpdateVersion(boolean versionUpdate) 
    Set whether this instance requires a version update on the next flush.
 public  void setVersion(Object version) 
 public  void settingBooleanField(PersistenceCapable pc,
    int field,
    boolean curVal,
    boolean newVal,
    int set) 
 public  void settingByteField(PersistenceCapable pc,
    int field,
    byte curVal,
    byte newVal,
    int set) 
 public  void settingCharField(PersistenceCapable pc,
    int field,
    char curVal,
    char newVal,
    int set) 
 public  void settingDoubleField(PersistenceCapable pc,
    int field,
    double curVal,
    double newVal,
    int set) 
 public  void settingFloatField(PersistenceCapable pc,
    int field,
    float curVal,
    float newVal,
    int set) 
 public  void settingIntField(PersistenceCapable pc,
    int field,
    int curVal,
    int newVal,
    int set) 
 public  void settingLongField(PersistenceCapable pc,
    int field,
    long curVal,
    long newVal,
    int set) 
 public  void settingObjectField(PersistenceCapable pc,
    int field,
    Object curVal,
    Object newVal,
    int set) 
 public  void settingShortField(PersistenceCapable pc,
    int field,
    short curVal,
    short newVal,
    int set) 
 public  void settingStringField(PersistenceCapable pc,
    int field,
    String curVal,
    String newVal,
    int set) 
 public  void store(int field,
    Object val) 
 public  void storeBoolean(int field,
    boolean externalVal) 
 public  void storeBooleanField(int field,
    boolean curVal) 
 public  void storeByte(int field,
    byte externalVal) 
 public  void storeByteField(int field,
    byte curVal) 
 public  void storeChar(int field,
    char externalVal) 
 public  void storeCharField(int field,
    char curVal) 
 public  void storeDouble(int field,
    double externalVal) 
 public  void storeDoubleField(int field,
    double curVal) 
 public  void storeField(int field,
    Object val) 
 public  void storeFloat(int field,
    float externalVal) 
 public  void storeFloatField(int field,
    float curVal) 
 public  void storeInt(int field,
    int externalVal) 
 public  void storeIntField(int field,
    int curVal) 
 public  void storeLong(int field,
    long externalVal) 
 public  void storeLongField(int field,
    long curVal) 
 public  void storeObject(int field,
    Object externalVal) 
 public  void storeObjectField(int field,
    Object curVal) 
 public  void storeShort(int field,
    short externalVal) 
 public  void storeShortField(int field,
    short curVal) 
 public  void storeString(int field,
    String externalVal) 
 public  void storeStringField(int field,
    String curVal) 
  void transactional() 
    Delegates to the current state.
 protected RuntimeException translate(RuntimeException re) 
    Translate the given exception based on the broker's implicit behavior. Translation only occurs if the exception is initiated by a user action on an instance, and therefore will not be caught and translated by the broker.
 protected  void unlock() 
    Unlock the state manager.
  void unproxyFields() 
    Unproxy all fields.
 public boolean writeDetached(ObjectOutput out) throws IOException 
  void writePC(ObjectOutputStream oos,
    PersistenceCapable pc) throws IOException 
    Write pc to oos, handling internal-form serialization. pc must be of the same type that this state manager manages.