org.apache.jdo.impl.fostore
Class FOStoreStoreManager

java.lang.Object
  extended byorg.apache.jdo.store.StoreManagerImpl
      extended byorg.apache.jdo.impl.fostore.FOStoreStoreManager
All Implemented Interfaces:
org.apache.jdo.store.StoreManager

class FOStoreStoreManager
extends org.apache.jdo.store.StoreManagerImpl

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.

Author:
Dave Bristor

Field Summary
private  FOStoreConnector connector
           
private static org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory javaModelFactory
          RuntimeJavaModelFactory.
private static javax.jdo.spi.JDOImplHelper jdoImplHelper
          JDOImplHelper instance.
(package private) static org.apache.commons.logging.Log logger
          Logger
private static org.apache.jdo.util.I18NHelper msg
          I18N support.
private  FOStorePMF pmf
           
private  RequestFactory rf
           
 
Fields inherited from class org.apache.jdo.store.StoreManagerImpl
optimistic
 
Constructor Summary
(package private) FOStoreStoreManager(FOStorePMF pmf)
           
 
Method Summary
private  void activateClass(java.lang.Class cls, Message message)
          Writes a request to activate the given state manager's class
private  void activateClasses(java.lang.Class cls, Message message)
          Activates this class and all supeclasses.
 void copyKeyFieldsFromObjectId(org.apache.jdo.state.StateManagerInternal sm, java.lang.Class pcClass)
           
 OID createInternalObjectId(org.apache.jdo.state.StateManagerInternal sm, javax.jdo.spi.PersistenceCapable pc, java.lang.Object oid, java.lang.Class cls, org.apache.jdo.pm.PersistenceManagerInternal pm)
          Creates a new object id for the given class.
 java.lang.Object createObjectId(org.apache.jdo.state.StateManagerInternal sm, org.apache.jdo.pm.PersistenceManagerInternal pm)
          Creates a new object id for the given sm.
 int delete(java.util.BitSet loadedFields, java.util.BitSet dirtyFields, org.apache.jdo.state.StateManagerInternal sm)
           
 java.lang.String dump(DumpOption option, java.lang.String name)
          Dumps information about the store.
 void fetch(org.apache.jdo.state.StateManagerInternal sm, int[] fieldNums)
           
 org.apache.jdo.store.Connector getConnector()
           
 org.apache.jdo.store.Connector getConnector(java.lang.String userid, java.lang.String password)
           
 javax.jdo.Extent getExtent(java.lang.Class pcClass, boolean subclasses, org.apache.jdo.pm.PersistenceManagerInternal pm)
           
 java.lang.Object getExternalObjectId(java.lang.Object objectId, javax.jdo.spi.PersistenceCapable pc)
          Provides a datastore object id.
(package private)  java.util.ArrayList getInstances(java.util.ArrayList oids, int start, int numInstances, org.apache.jdo.pm.PersistenceManagerInternal pm, java.lang.Class cls)
          Get instances for oids
 java.lang.Object getInternalObjectId(java.lang.Object objectId, org.apache.jdo.pm.PersistenceManagerInternal pm)
           
 java.lang.Class getPCClassForOid(java.lang.Object objectId, org.apache.jdo.pm.PersistenceManagerInternal pm)
           
 boolean hasActualPCClass(java.lang.Object objectId)
           
 int insert(java.util.BitSet loadedFields, java.util.BitSet dirtyFields, org.apache.jdo.state.StateManagerInternal sm)
           
 boolean isMediationRequiredToCopyOid()
           
 java.lang.Object newObjectIdInstance(java.lang.Class pcClass, java.lang.Object key)
          This method returns an object id instance corresponding to the pcClass and key arguments.
 org.apache.jdo.query.QueryResult newQueryResult(org.apache.jdo.query.QueryResultHelper qrh)
          Returns a QueryResult instance which is then returned as the result of Query.execute(...).
protected  void preFlush()
          Write a CommitRequest and flush the connector, to cause all CreateOid and ActivateClass requests to be committed in the database *before* any inserts, updates, or deletes.
 int update(java.util.BitSet loadedFields, java.util.BitSet dirtyFields, org.apache.jdo.state.StateManagerInternal sm)
           
private  boolean verify(org.apache.jdo.state.StateManagerInternal sm, boolean verifyFields, java.util.BitSet fieldsToVerify)
          Verifies existence or values of a state manager's object in the database.
 int verifyFields(java.util.BitSet ignoredFields, java.util.BitSet fieldsToVerify, org.apache.jdo.state.StateManagerInternal sm)
           
 
Methods inherited from class org.apache.jdo.store.StoreManagerImpl
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pmf

private final FOStorePMF pmf

connector

private final FOStoreConnector connector

rf

private final RequestFactory rf

msg

private static final org.apache.jdo.util.I18NHelper msg
I18N support.


logger

static final org.apache.commons.logging.Log logger
Logger


jdoImplHelper

private static final javax.jdo.spi.JDOImplHelper jdoImplHelper
JDOImplHelper instance.


javaModelFactory

private static final org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory javaModelFactory
RuntimeJavaModelFactory.

Constructor Detail

FOStoreStoreManager

FOStoreStoreManager(FOStorePMF pmf)
Method Detail

getConnector

public org.apache.jdo.store.Connector getConnector()
See Also:
StoreManager.getConnector()

getConnector

public org.apache.jdo.store.Connector getConnector(java.lang.String userid,
                                                   java.lang.String password)
See Also:
StoreManager.getConnector(String userid, String password)

insert

public int insert(java.util.BitSet loadedFields,
                  java.util.BitSet dirtyFields,
                  org.apache.jdo.state.StateManagerInternal sm)
See Also:
StoreManager.insert(BitSet, BitSet, StateManagerInternal)

update

public int update(java.util.BitSet loadedFields,
                  java.util.BitSet dirtyFields,
                  org.apache.jdo.state.StateManagerInternal sm)
See Also:
StoreManager.update(BitSet, BitSet, StateManagerInternal)

verifyFields

public int verifyFields(java.util.BitSet ignoredFields,
                        java.util.BitSet fieldsToVerify,
                        org.apache.jdo.state.StateManagerInternal sm)
See Also:
StoreManager.verifyFields(BitSet, BitSet, StateManagerInternal)

delete

public int delete(java.util.BitSet loadedFields,
                  java.util.BitSet dirtyFields,
                  org.apache.jdo.state.StateManagerInternal sm)
See Also:
StoreManager.delete(BitSet, BitSet, StateManagerInternal)

fetch

public void fetch(org.apache.jdo.state.StateManagerInternal sm,
                  int[] fieldNums)
See Also:
StoreManager.fetch(org.apache.jdo.state.StateManagerInternal, int[])

getExtent

public javax.jdo.Extent getExtent(java.lang.Class pcClass,
                                  boolean subclasses,
                                  org.apache.jdo.pm.PersistenceManagerInternal pm)
See Also:
StoreManager.getExtent(java.lang.Class, boolean, org.apache.jdo.pm.PersistenceManagerInternal)

createObjectId

public java.lang.Object createObjectId(org.apache.jdo.state.StateManagerInternal sm,
                                       org.apache.jdo.pm.PersistenceManagerInternal pm)
Creates a new object id for the given sm. Delegates implementation to #createInternalObjectId(StateManagerInternal sm,Class cls, PersistenceManagerInternal pm)

See Also:
StoreManager.createObjectId(org.apache.jdo.state.StateManagerInternal, org.apache.jdo.pm.PersistenceManagerInternal)

createInternalObjectId

public OID createInternalObjectId(org.apache.jdo.state.StateManagerInternal sm,
                                  javax.jdo.spi.PersistenceCapable pc,
                                  java.lang.Object oid,
                                  java.lang.Class cls,
                                  org.apache.jdo.pm.PersistenceManagerInternal pm)
Creates a new object id for the given class. Binds metadata for the sm (i.e., ensures that there is a CLID for instances of the sm's object's class). Creates a request in the message that will provide a datastore oid for the provisional oid which is returned, but does not interact with the store.

See Also:
StoreManager.createObjectId(org.apache.jdo.state.StateManagerInternal, org.apache.jdo.pm.PersistenceManagerInternal)

getExternalObjectId

public java.lang.Object getExternalObjectId(java.lang.Object objectId,
                                            javax.jdo.spi.PersistenceCapable pc)
Provides a datastore object id. If objectId is not provisional, return it. Otherwise, see if we have a corresponding datastore objectId and return that if so. If neither of those works out, flush the current message which (we hope) will have a corresponding CreateObjectIdRequest in it. Then look as before for a corresponding datastore objectId in our mapping and return that. If we still don't have a correspondance, throw an exception.

See Also:
StoreManager.getExternalObjectId(Object oid, PersistenceCapable pc)

copyKeyFieldsFromObjectId

public void copyKeyFieldsFromObjectId(org.apache.jdo.state.StateManagerInternal sm,
                                      java.lang.Class pcClass)
See Also:
StoreManager.copyKeyFieldsFromObjectId(org.apache.jdo.state.StateManagerInternal, java.lang.Class)

hasActualPCClass

public boolean hasActualPCClass(java.lang.Object objectId)
See Also:
StoreManager.hasActualPCClass(java.lang.Object)

getInternalObjectId

public java.lang.Object getInternalObjectId(java.lang.Object objectId,
                                            org.apache.jdo.pm.PersistenceManagerInternal pm)
See Also:
StoreManager.getInternalObjectId(java.lang.Object, org.apache.jdo.pm.PersistenceManagerInternal)

isMediationRequiredToCopyOid

public boolean isMediationRequiredToCopyOid()
See Also:
StoreManager.isMediationRequiredToCopyOid()

getPCClassForOid

public java.lang.Class getPCClassForOid(java.lang.Object objectId,
                                        org.apache.jdo.pm.PersistenceManagerInternal pm)
See Also:
StoreManager.getPCClassForOid(java.lang.Object, org.apache.jdo.pm.PersistenceManagerInternal)

newObjectIdInstance

public java.lang.Object newObjectIdInstance(java.lang.Class pcClass,
                                            java.lang.Object key)
This method returns an object id instance corresponding to the pcClass and key arguments.

Parameters:
pcClass - the Class of the persistence-capable instance
key - the value of the key field for single-field identity.
Returns:
an instance of the object identity class

newQueryResult

public org.apache.jdo.query.QueryResult newQueryResult(org.apache.jdo.query.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. For now fostore uses the non optimized BasicQueryResult as QueryResult implemenatation.

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

activateClasses

private void activateClasses(java.lang.Class cls,
                             Message message)
Activates this class and all supeclasses.


activateClass

private void activateClass(java.lang.Class cls,
                           Message message)
Writes a request to activate the given state manager's class


dump

public java.lang.String dump(DumpOption option,
                             java.lang.String name)
Dumps information about the store. The provided information depends on the option parameter. Currently, there are the following options supported:

Parameters:
option - Dump option, specifies the kind of information.
name - Optional fully qualified classname.
See Also:
DumpOption

getInstances

java.util.ArrayList getInstances(java.util.ArrayList oids,
                                 int start,
                                 int numInstances,
                                 org.apache.jdo.pm.PersistenceManagerInternal pm,
                                 java.lang.Class cls)
Get instances for oids

Parameters:
oids - List of oids
start - Starting index within oids of oids whose instances are to be returned.
numInstances - Number of instances to return.
pm - PersistenceManagerInternal on whose behalf the instances are being obtained.
cls - Candidate Class for which instances are being obtained.
Returns:
ArrayList of instances corresponding to numInstances of oids in the oids parameter, starting at start.

verify

private boolean verify(org.apache.jdo.state.StateManagerInternal sm,
                       boolean verifyFields,
                       java.util.BitSet fieldsToVerify)
Verifies existence or values of a state manager's object in the database.

Parameters:
sm - The state manager whose object is to be verified.
verifyFields - If true, verify values of object, otherwise verify only existence (and ignore remaining parameters).
fieldsToVerify - Set of fields to be verified against those in the database.
Returns:
true if verify was successful (either by existence of value matching as per verifyFields).

preFlush

protected void preFlush()
Write a CommitRequest and flush the connector, to cause all CreateOid and ActivateClass requests to be committed in the database *before* any inserts, updates, or deletes.