org.apache.jdo.state
Interface StateManagerInternal

All Superinterfaces:
javax.jdo.spi.StateManager

public interface StateManagerInternal
extends javax.jdo.spi.StateManager

Extends the StateManager interface for JDO-internal use. Provides additional information about the state of particular fields. Provides a means to give a field's value to an object that can cause that value to be stored.

Author:
Dave Bristor

Field Summary
static int FLUSHED_COMPLETE
           
static int FLUSHED_NONE
           
static int FLUSHED_PARTIAL
          Return values for flush operations
 
Method Summary
 void afterCompletion(boolean abort, boolean retainValues, boolean restoreValues)
          Transitions lifecycle state in afterCompletion callback
 void deletePersistent()
          Transitions lifecycle state in to PERSISTENT_DELETED
 void evictInstance()
          Transitions lifecycle state to HOLLOW
 boolean flush(StoreManager srm)
          Causes the state manager to send itself to the store manager for insert, update, and so on as per its own state.
 java.lang.Object getDependency()
          Returns dependency object that contains dependency information specific to this instance of the StateManager
 java.lang.Object getExternalObjectId()
          Returns external representation of the object id associated with this statemanager.
 java.lang.String getFieldName(int fieldNumber)
          Returns field name for the field number.
 java.lang.Object getInternalObjectId()
          Returns internal representation of the object id associated with this statemanager.
 javax.jdo.spi.PersistenceCapable getObject()
          Provides the object managed by this state manager.
 java.lang.Class getPCClass()
          Returns PC Class known to this StateManager.
 PersistenceManagerInternal getPersistenceManager()
          Returns PersistenceManager associated with this StateManager instance
 void handleReachability(boolean flag)
          Processes relationships for reachability algorithm and define the dependencies
 boolean isBeforeImageRequired()
          Returns true, if a before image must be created.
 boolean isFlushed()
          Returns true if the instance has been flushed to the datastore.
 boolean isNew()
          Tests whether this StateManager represents a instance made persistent object.
 boolean isStored()
          Returns true if the instance exists in a datastore.
 void makeDirty(int fieldNumber)
          Mark the associated PersistenceCapable field dirty.
 void makeNontransactional()
          Transitions lifecycle state in to nontransactional
 void makePersistent()
          Transitions lifecycle state in to PERSISTENT_NEW
 void makeTransactional()
          Transitions lifecycle state in to transactional
 void makeTransient()
          Transitions lifecycle state in to TRANSIENT
 void preStore()
          Calls preStore on the associated object if necessary.
 void provideField(int fieldNumber, FieldManager fieldManager, boolean identifying)
          Causes the values of the field indicated by the specified field number be given to the FieldManager.
 void provideFields(int[] fields, FieldManager fieldManager, boolean identifying)
          Causes the values of the fields indicated by the specified fields to be given to the FieldManager.
 void refreshInstance()
          Transitions lifecycle state to P_CLEAN or P_NON_TX
 void reload()
          Fetch or refresh object from the data store.
 void replace(int[] fields, FieldManager fieldManager)
          Transition 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.
 void replaceFields(int[] fields, FieldManager fieldManager)
          For replacing field values in a PC with the ones that is provided by the FieldManager.
 void replaceSCOFields()
          Replaces field values that are regular SCO instances with tracked SCOs.
 void retrieve()
          Retrieve an instance from the store.
 java.lang.Object setDependency(java.lang.Object dependency)
          Sets dependency object containing dependency information specific to this instance of the StateManager
 void setObjectId(java.lang.Object objectId)
          Allows a client to change this state manager's object Id.
 void setPCClass(java.lang.Class pcClass)
          Allows StateManager to set the actual PC Class if it was not available at the constructor time and create a hollow instnce of that type.
 void trackUpdates(int fieldNumber, SCO sco)
          Processes changes to the Tracked SCO instance owned by this StateManager.
 
Methods inherited from interface javax.jdo.spi.StateManager
getBooleanField, getByteField, getCharField, getDoubleField, getFloatField, getIntField, getLongField, getObjectField, getObjectId, getPersistenceManager, getShortField, getStringField, getTransactionalObjectId, getVersion, isDeleted, isDirty, isLoaded, isNew, isPersistent, isTransactional, makeDirty, preSerialize, providedBooleanField, providedByteField, providedCharField, providedDoubleField, providedFloatField, providedIntField, providedLongField, providedObjectField, providedShortField, providedStringField, replacingBooleanField, replacingByteField, replacingCharField, replacingDetachedState, replacingDoubleField, replacingFlags, replacingFloatField, replacingIntField, replacingLongField, replacingObjectField, replacingShortField, replacingStateManager, replacingStringField, setBooleanField, setByteField, setCharField, setDoubleField, setFloatField, setIntField, setLongField, setObjectField, setShortField, setStringField
 

Field Detail

FLUSHED_PARTIAL

static final int FLUSHED_PARTIAL
Return values for flush operations

See Also:
Constant Field Values

FLUSHED_NONE

static final int FLUSHED_NONE
See Also:
Constant Field Values

FLUSHED_COMPLETE

static final int FLUSHED_COMPLETE
See Also:
Constant Field Values
Method Detail

getObject

javax.jdo.spi.PersistenceCapable getObject()
Provides the object managed by this state manager.

Returns:
The object managed by this state manager.

getInternalObjectId

java.lang.Object getInternalObjectId()
Returns internal representation of the object id associated with this statemanager.

Returns:
internal representation of the object id associated with this statemanager.

getExternalObjectId

java.lang.Object getExternalObjectId()
Returns external representation of the object id associated with this statemanager.

Returns:
external representation of the object id associated with this statemanager.

setObjectId

void setObjectId(java.lang.Object objectId)
Allows a client to change this state manager's object Id. For example, with datastore identity, allows one object id to be used before the object has been stored (i.e. a "provisional" id), and another once the object has been put into the datbase.


flush

boolean flush(StoreManager srm)
Causes the state manager to send itself to the store manager for insert, update, and so on as per its own state. It should flush itself only if it has no dependencies on other state manager.

Parameters:
srm - The StoreManager to which the instance should send itself.
Returns:
true if the state manager could flush itself, false if it has dependencies on other state managers and could not flush itself.

provideField

void provideField(int fieldNumber,
                  FieldManager fieldManager,
                  boolean identifying)
Causes the values of the field indicated by the specified field number be given to the FieldManager.

Parameters:
fieldNumber - Indicates which field should be provided to the fieldManager.
fieldManager - FieldManager to which the field should be given.
identifying - If true, provides values from the before or flushed image, as determined by this StateManager's state; if false provides values from the current image.

provideFields

void provideFields(int[] fields,
                   FieldManager fieldManager,
                   boolean identifying)
Causes the values of the fields indicated by the specified fields to be given to the FieldManager.

Parameters:
fields - Indicates which fields should be provided to the fieldManager.
fieldManager - FieldManager to which the field should be given.
identifying - If true, provides values from the before or flushed image, as determined by this StateManager's state; if false provides values from the current image.

replaceFields

void replaceFields(int[] fields,
                   FieldManager fieldManager)
For replacing field values in a PC with the ones that is provided by the FieldManager.

Parameters:
fields - Indicates which fields should be replaced in the PC.
fieldManager - FieldManager from which the field values should be obtained.

reload

void reload()
Fetch or refresh object from the data store.


retrieve

void retrieve()
Retrieve an instance from the store.


replace

void replace(int[] fields,
             FieldManager fieldManager)
Transition 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:
fields - Indicates which fields should be replaced in the PC.
fieldManager - FieldManager from which the field values should be obtained.

afterCompletion

void afterCompletion(boolean abort,
                     boolean retainValues,
                     boolean restoreValues)
Transitions lifecycle state in afterCompletion callback

Parameters:
abort - true if transaction has been rolled back
retainValues - true if values need to be preserved on commit.
restoreValues - true if values need to be restored on rollback.

makePersistent

void makePersistent()
Transitions lifecycle state in to PERSISTENT_NEW


makeTransactional

void makeTransactional()
Transitions lifecycle state in to transactional


makeNontransactional

void makeNontransactional()
Transitions lifecycle state in to nontransactional


makeTransient

void makeTransient()
Transitions lifecycle state in to TRANSIENT


deletePersistent

void deletePersistent()
Transitions lifecycle state in to PERSISTENT_DELETED


refreshInstance

void refreshInstance()
Transitions lifecycle state to P_CLEAN or P_NON_TX


evictInstance

void evictInstance()
Transitions lifecycle state to HOLLOW


preStore

void preStore()
Calls preStore on the associated object if necessary.


replaceSCOFields

void replaceSCOFields()
Replaces field values that are regular SCO instances with tracked SCOs. Called internally during the afterCompletion processing when instance transions to P-nontransactional (if the retainValues flag is set to true). May be called by the StoreManager during the flush process to store tracked instances in the data store.


handleReachability

void handleReachability(boolean flag)
Processes relationships for reachability algorithm and define the dependencies

Parameters:
flag - is true if method is called inside the flush, false otherwise

isStored

boolean isStored()
Returns true if the instance exists in a datastore. Returns false for transient instances, PersistentNew, PersistentNewDeleted, and PersistentDeletedFlushed


isFlushed

boolean isFlushed()
Returns true if the instance has been flushed to the datastore.


setDependency

java.lang.Object setDependency(java.lang.Object dependency)
Sets dependency object containing dependency information specific to this instance of the StateManager

Parameters:
dependency - new dependency object

getDependency

java.lang.Object getDependency()
Returns dependency object that contains dependency information specific to this instance of the StateManager


getPersistenceManager

PersistenceManagerInternal getPersistenceManager()
Returns PersistenceManager associated with this StateManager instance

Returns:
the PersistenceManager

makeDirty

void makeDirty(int fieldNumber)
Mark the associated PersistenceCapable field dirty.

The StateManager will make a copy of the field so it can be restored if needed later, and then mark the field as modified in the current transaction.

Parameters:
fieldNumber - the number of the field

trackUpdates

void trackUpdates(int fieldNumber,
                  SCO sco)
Processes changes to the Tracked SCO instance owned by this StateManager.

Parameters:
fieldNumber - the number of the field
sco - Tracked SCO instance.

getFieldName

java.lang.String getFieldName(int fieldNumber)
Returns field name for the field number. Used for debugging.

Parameters:
fieldNumber - the number of the field
Returns:
field name as String

setPCClass

void setPCClass(java.lang.Class pcClass)
Allows StateManager to set the actual PC Class if it was not available at the constructor time and create a hollow instnce of that type.

Parameters:
pcClass - the Class type of the instance.

getPCClass

java.lang.Class getPCClass()
Returns PC Class known to this StateManager. Can be a candidate Class.

Returns:
the Class type of the PC instance.

isNew

boolean isNew()
Tests whether this StateManager represents a instance made persistent object.

Returns:
true if this StateManager represents an instance made persistent in the current transaction.

isBeforeImageRequired

boolean isBeforeImageRequired()
Returns true, if a before image must be created. The decision is based on the current lifecycle state plus other conditions e.g. transaction type, restore values flag, etc.

Returns:
true if a before image must be created.


Copyright © 2005-2011 Apache Software Foundation. All Rights Reserved.