org.apache.jdo.store
Interface StoreManager

All Known Implementing Classes:
StoreManagerImpl

public interface StoreManager

StoreManager represents the datastore to the rest of the JDO components. It provides the means to write and read instances, to get the extent of classes, and to get the object id for a persistence capable object.


Method Summary
 void copyKeyFieldsFromObjectId(StateManagerInternal sm, java.lang.Class pcClass)
          This method copies PK field values from internal Object Id into the Hollow instance.
 java.lang.Object createObjectId(StateManagerInternal sm, PersistenceManagerInternal pm)
          Creates a new Object Id for the given StateManagerInternal.
 int delete(java.util.BitSet loadedFields, java.util.BitSet dirtyFields, StateManagerInternal sm)
          Causes the object managed by the given state manager to be deleted in the database.
 void fetch(StateManagerInternal sm, int[] fieldNums)
          Causes values for fields required by the state manager's object to be retrieved from the store and supplied to the state manager.
 void flush(java.util.Iterator it, PersistenceManagerInternal pm)
          Flushes all elements in the given iterator.
 Connector getConnector()
          Returns a Connector suitable for committing or rolling back operations on this store.
 Connector getConnector(java.lang.String userid, java.lang.String password)
          Returns a Connector suitable for committing or rolling back operations on this store for a specific userid.
 javax.jdo.Extent getExtent(java.lang.Class pcClass, boolean subclasses, PersistenceManagerInternal pm)
          Provides the means to get all instances of a particular class, or of that class and its subclasses.
 java.lang.Object getExternalObjectId(java.lang.Object objectId, javax.jdo.spi.PersistenceCapable pc)
          Returns an Object Id that can be given to user/client code and which is a copy or external representation of the given objectId.
 java.lang.Object getInternalObjectId(java.lang.Object objectId, PersistenceManagerInternal pm)
          Returns an Object Id that can be used by the runtime code and which is a an internal representation of the given objectId.
 java.lang.Class getPCClassForOid(java.lang.Object oid, PersistenceManagerInternal pm)
          Returns the Class of the PersistenceCapable instance identified by the given oid.
 boolean hasActualPCClass(java.lang.Object objectId)
          Returns true if actual Class for a PersistenceCapable instance can be resolved only in the database.
 int insert(java.util.BitSet loadedFields, java.util.BitSet dirtyFields, StateManagerInternal sm)
          Causes the object managed by the given state manager's object to be inserted into the database.
 java.lang.Object newObjectIdInstance(java.lang.Class pcClass, java.lang.String str)
          This method returns an object id instance corresponding to the Class and String arguments.
 QueryResult newQueryResult(QueryResultHelper qrh)
          Returns a QueryResult instance which is then returned as the result of Query.execute(...).
 int update(java.util.BitSet loadedFields, java.util.BitSet dirtyFields, StateManagerInternal sm)
          Causes the object managed by the given state manager to be updated in the database.
 int verifyFields(java.util.BitSet loadedFields, java.util.BitSet dirtyFields, StateManagerInternal sm)
          Causes the object managed by the given state manager to be verified in the database.
 

Method Detail

getConnector

public Connector getConnector()
Returns a Connector suitable for committing or rolling back operations on this store.


getConnector

public Connector getConnector(java.lang.String userid,
                              java.lang.String password)
Returns a Connector suitable for committing or rolling back operations on this store for a specific userid.

Parameters:
userid - the userid for the connection
password - the password for the connection

insert

public int insert(java.util.BitSet loadedFields,
                  java.util.BitSet dirtyFields,
                  StateManagerInternal sm)
Causes the object managed by the given state manager's object to be inserted into the database.

Parameters:
loadedFields - BitSet of fields to be inserted in the database (may be ignored).
dirtyFields - BitSet of all fields as all fields are marked as dirty for insert. After return, bits will remain as set for fields that were not inserted. If any bits are set, the return will be FLUSHED_PARTIAL.
sm - The state manager whose object is to be inserted.
Returns:
one of StateManagerInternal.FLUSHED_{COMPLETE, PARTIAL, NONE}, depending on the success of the operation in inserting specified fields into the database.

update

public int update(java.util.BitSet loadedFields,
                  java.util.BitSet dirtyFields,
                  StateManagerInternal sm)
Causes the object managed by the given state manager to be updated in the database.

Parameters:
loadedFields - BitSet of fields loaded from the database.
dirtyFields - BitSet of changed fields that are to be flushed to the database. It is the StoreManager policy which fields are to be verified against those in the database, if this update 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 FLUSHED_PARTIAL.
sm - The state manager whose object is to be updated.
Returns:
one of StateManagerInternal.FLUSHED_{COMPLETE, PARTIAL, NONE}, depending on the success of the operation in updating specified fields into the database.

verifyFields

public int verifyFields(java.util.BitSet loadedFields,
                        java.util.BitSet dirtyFields,
                        StateManagerInternal sm)
Causes the object managed by the given state manager to be verified in the database.

Parameters:
loadedFields - BitSet of fields to be verified against those in the database.
dirtyFields - Unused as there are no changed fields in this transaction.
sm - The state manager whose object is to be verified.
Returns:
StateManagerInternal.FLUSHED_COMPLETE.
Throws:
JDODataStoreException - if data in memory does not match that in the database.

delete

public int delete(java.util.BitSet loadedFields,
                  java.util.BitSet dirtyFields,
                  StateManagerInternal sm)
Causes the object managed by the given state manager to be deleted in the database.

Parameters:
loadedFields - BitSet of fields loaded from the database.
dirtyFields - BitSet of changed fields. It is the StoreManager policy which fields are to be verified against those in the database, if this delete is within the context of an optimistic transaction. After return, bits will remain set for the fields that were not flushed, if the update was performed to resolve dependencies. In such case the return will be StateManagerInternal.FLUSHED_PARTIAL.
sm - The state manager whose object is to be deleted.
Returns:
one of StateManagerInternal.FLUSHED_{COMPLETE, NONE}, depending on the success of the delete operation.

fetch

public void fetch(StateManagerInternal sm,
                  int[] fieldNums)
Causes values for fields required by the state manager's object to be retrieved from the store and supplied to the state manager.

Parameters:
sm - The state manager whose fields are to be read.
fieldNums - The fields which are to be read.

getExtent

public javax.jdo.Extent getExtent(java.lang.Class pcClass,
                                  boolean subclasses,
                                  PersistenceManagerInternal pm)
Provides the means to get all instances of a particular class, or of that class and its subclasses. If there are no instances of the given class (nor its subclass) in the store, returns null.

Parameters:
pcClass - Indicates the class of the instances that are in the returned Extent.
subclasses - If true, then instances subclasses of pcClass are included in the resulting Extent. If false, then only instances of pcClass are included.
pm - PersistenceManagerInternal making the request.
Returns:
An Extent from which instances of pcClass (and subclasses if appropriate) can be obtained. Does not return null if there are no instances; in that case it returns an empty Extent.

createObjectId

public java.lang.Object createObjectId(StateManagerInternal sm,
                                       PersistenceManagerInternal pm)
Creates a new Object Id for the given StateManagerInternal. The resulting Object Id should not be given to user/client code.

Parameters:
sm - StateManagerInternal for which an Object Id is needed.
pm - PersistenceManagerInternal in which the sm's object is created.
Returns:
Object Id corresponding to the given StateManagerInternal

getExternalObjectId

public java.lang.Object getExternalObjectId(java.lang.Object objectId,
                                            javax.jdo.spi.PersistenceCapable pc)
Returns an Object Id that can be given to user/client code and which is a copy or external representation of the given objectId.

Parameters:
objectId - Object Id for which an external Object Id is needed.
pc - PersistenceCapable instance associated with this Object Id.
Returns:
An Object Id that can be given to user/client code.

getInternalObjectId

public java.lang.Object getInternalObjectId(java.lang.Object objectId,
                                            PersistenceManagerInternal pm)
Returns an Object Id that can be used by the runtime code and which is a an internal representation of the given objectId.

Parameters:
objectId - Object Id for which an internal Object Id is needed.
pm - PersistenceManagerInternal which requested the Object Id.
Returns:
An Object Id that can be given to user/client code.

getPCClassForOid

public java.lang.Class getPCClassForOid(java.lang.Object oid,
                                        PersistenceManagerInternal pm)
Returns the Class of the PersistenceCapable instance identified by the given oid.

Parameters:
oid - object id whose java.lang.Class is wanted.
pm - PersistenceManagerInternal to use in loading the oid's Class.
Returns:
java.lang.Class of the PersistenceCapable instance identified with this oid.

hasActualPCClass

public boolean hasActualPCClass(java.lang.Object objectId)
Returns true if actual Class for a PersistenceCapable instance can be resolved only in the database.

Parameters:
objectId - Object Id whose java.lang.Class needs to be resolved.
Returns:
true if the request needs to be resolved in the back end.

newObjectIdInstance

public java.lang.Object newObjectIdInstance(java.lang.Class pcClass,
                                            java.lang.String str)
This method returns an object id instance corresponding to the Class and String arguments. The String argument might have been the result of executing toString on an object id instance.

Parameters:
pcClass - the Class of the persistence-capable instance
str - the String form of the object id
Returns:
an instance of the object identity class

copyKeyFieldsFromObjectId

public void copyKeyFieldsFromObjectId(StateManagerInternal sm,
                                      java.lang.Class pcClass)
This method copies PK field values from internal Object Id into the Hollow instance.

Parameters:
sm - StateManagerInternal for which an operation is needed.
pcClass - the Class of the persistence-capable instance

flush

public void flush(java.util.Iterator it,
                  PersistenceManagerInternal pm)
Flushes all elements in the given iterator.

Parameters:
it - Iterator of StateManagerInternal instances to be flushed.
pm - PersistenceManagerInternal on whose behalf instances are being flushed.
Throws:
JDOFatalDataStoreException - if instances could not all be flushed as determined by sm.isFlushed().

newQueryResult

public QueryResult newQueryResult(QueryResultHelper qrh)
Returns a QueryResult instance which is then returned as the result of Query.execute(...). This method allows support for datastore specific query execution strategies, since each StoreManager can have its own implementation of the QueryResult interface.

Parameters:
qrh - the helper providing the query tree, the candidates and the actual parameters.
Returns:
a datastore specific query result instance