|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpox.store.StoreManager
An abstract representation of a Store Manager. Manages the persistence of objects to the store. Will be implemented for the type of datastore (RDBMS, ODBMS, OLAP) in question. The store manager's responsibilities include:
A store manager's knowledge of its contents is typically not complete. It knows about the classes that it has encountered in its lifetime. The PersistenceManager can make the StoreManager aware of a class, and can check if the StoreManager knows about a particular class. The Auto-Start mechanism provides a way of inheriting knowledge from the last time the store was used.
Field Summary | |
protected boolean |
autoCreateColumns
Whether to auto create any columns that are missing. |
protected boolean |
autoCreateConstraints
Whether to auto create any constraints |
protected boolean |
autoCreateTables
Whether to auto create any tables. |
protected boolean |
autoCreateWarnOnError
Whether to warn only when any errors occur on auto-create. |
protected boolean |
checkExistTablesOrViews
Whether to check if table/view exists |
protected DatastoreAdapter |
dba
Adapter for the datastore being used. |
protected java.lang.String |
defaultPoidGeneratorClass
The default id generator class name for the store manager. |
protected Dictionary |
dictionary
Dictionary to use for identifiers etc. |
protected javax.sql.DataSource[] |
ds
Datasource |
protected javax.sql.DataSource[] |
dsNonTx
Non transactional Datasource |
protected boolean |
fixedSchema
Whether this datastore schema is fixed (no mods to table definitions allowed). |
protected IdentifierFactory |
identifierFactory
Factory for identifiers for this datastore. |
protected static Localiser |
LOCALISER
|
protected java.lang.String |
password
Password for the datastore being used. |
protected PMFContext |
pmfContext
PMF context. |
protected PoidManager |
poidManager
Manager for identity generation. |
protected boolean |
readOnlySchema
Whether this datastore schema is read only. |
protected AutoStartMechanism |
starter
Auto-Start mechanism to use. |
protected boolean |
starterInitialised
Whether the AutoStart mechanism is initialised |
protected MultiMap |
storeDataByAppIdClass
Map of all managed store data using Application Identity, keyed by the app id PK class |
protected java.util.Map |
storeDataByClass
Map of all managed store data, keyed by the class/field name. |
protected java.lang.String |
userName
Username for the datastore being used. |
protected boolean |
validateColumns
Whether to validate any columns |
protected boolean |
validateConstraints
Whether to validate any constraints |
protected boolean |
validateTables
Whether to validate any tables |
Constructor Summary | |
protected |
StoreManager(ClassLoaderResolver clr,
AbstractPersistenceManagerFactory pmf,
java.lang.String userName,
java.lang.String password)
Constructor for a new StoreManager. |
Method Summary | |
abstract void |
addClass(java.lang.String className,
ClassLoaderResolver clr)
Method to add a class to the managed list for this datastore manager. |
abstract void |
addClasses(java.lang.String[] classes,
ClassLoaderResolver clr)
Add classes to the persistence model for the datastore. |
protected void |
clearAutoStarter()
Method to clear the Auto-Starter status. |
void |
close()
Release of resources |
void |
delete(StateManager sm)
Deletes a persistent object from the database. |
void |
deleteDependent(StateManager sm,
int[] fieldNumbers)
Delete dependent objects of a persistent object. |
protected void |
deregisterAllStoreData()
Method to deregister all existing store data so that we are managing nothing. |
void |
fetch(StateManager sm,
int[] fieldNumbers)
Fetches a persistent object from the database. |
abstract ArrayStore |
getBackingStoreForArray(AbstractPropertyMetaData fmd,
DatastoreObject datastoreTable,
ClassLoaderResolver clr)
Method to return a backing store for an array, consistent with this store and the instantiated type. |
abstract CollectionStore |
getBackingStoreForCollection(java.lang.Class instantiatedType,
AbstractPropertyMetaData fmd,
DatastoreObject datastoreTable,
ClassLoaderResolver clr)
Method to return a backing store for a Collection, consistent with this store and the instantiated type. |
abstract MapStore |
getBackingStoreForMap(AbstractPropertyMetaData fmd,
DatastoreObject datastoreTable,
ClassLoaderResolver clr)
Method to return a backing store for a Map, consistent with this store and the instantiated type. |
AbstractClassMetaData[] |
getClassesManagingTableForClass(AbstractClassMetaData cmd,
ClassLoaderResolver clr)
Method to return the class(es) that has a table managing the persistence of the fields of the supplied class. |
abstract java.lang.String |
getClassNameForObjectID(java.lang.Object id,
ClassLoaderResolver clr,
PersistenceManager pm)
Returns the class corresponding to the given object JDO ID. |
AbstractClassMetaData |
getClassWithPrimaryKeyForClass(AbstractClassMetaData cmd,
ClassLoaderResolver clr)
Utility to navigate the inheritance hierarchy to find the base class that defines the primary keys for this tree. |
DatastoreAdapter |
getDatastoreAdapter()
Gets the DatastoreAdapter to use for this store. |
DatastoreClass |
getDatastoreClass(DatastoreIdentifier name)
Returns the JDO table having the given SQL identifier. |
DatastoreClass |
getDatastoreClass(java.lang.String className,
ClassLoaderResolver clr)
Returns the primary datastore container serving as backing for the given class. |
DatastoreContainerObject |
getDatastoreContainerObject(AbstractPropertyMetaData fmd)
Returns the datastore container (table) for the specified field. |
abstract javax.jdo.Extent |
getExtent(PersistenceManager pm,
java.lang.Class c,
boolean subclasses)
Interface to getting an Extent for a class. |
abstract FetchStatement |
getFetchStatement(DatastoreContainerObject table)
Method to create a new fetch statement for the passed table. |
IdentifierFactory |
getIdentifierFactory()
Accessor for the identifier factory. |
MappingManager |
getMappingManager()
Gets the MappingManager to use for this store. |
MetaDataManager |
getMetaDataManager()
Gets the MetaDataManager to use for this store. |
PMFContext |
getPMFContext()
Accessor for the context in which this RDBMSManager is running |
StoreData[] |
getStoreDataForTable(DatastoreIdentifier tableIdentifier)
Utility to return all StoreData for a table identifier. |
abstract java.lang.Object |
getStrategyValue(PersistenceManager pm,
DatastoreClass table,
AbstractClassMetaData cmd,
int absoluteFieldNumber,
IdentityStrategy strategy,
java.lang.String sequence,
ExtensionMetaData[] extensions)
Method to retrieve the value for a strategy for a particular field. |
java.util.HashSet |
getSubClassesForClass(java.lang.String className,
boolean includeDescendents,
ClassLoaderResolver clr)
Utility to return the names of the classes that are known subclasses of the provided class. |
protected void |
initialiseAutoStart(ClassLoaderResolver clr)
Method to initialise the auto-start mechanism, loading up the classes from its store into memory so that we start from where we got to last time. |
void |
insert(StateManager sm)
Inserts a persistent object into the database. |
boolean |
isStrategyDatastoreAttributed(IdentityStrategy identityStrategy)
Check if the strategy is attributed by the database when the PersistenceCapable object is inserted into the database |
void |
locate(StateManager sm)
Locates this object in the datastore. |
java.lang.String |
manageClassForIdentity(OID id,
ClassLoaderResolver clr)
Convenience method to ensure that the class defined by the passed OID is managed by this store. |
java.lang.String |
manageClassForIdentity(javax.jdo.identity.SingleFieldIdentity id,
ClassLoaderResolver clr)
Convenience method to ensure that the class defined by the passed SingleFieldIdentity is managed by this store. |
boolean |
managesClass(java.lang.String className)
Accessor for whether the specified class is managed currently |
abstract DatastoreContainerObject |
newJoinDatastoreContainerObject(AbstractPropertyMetaData fmd,
ClassLoaderResolver clr)
Called by Mapping objects to request the creation of a DatastoreObject (table). |
abstract java.lang.Object |
newObjectID(PersistenceManager pm,
java.lang.String className,
javax.jdo.spi.PersistenceCapable pc)
Returns a new, unique ID for an object of the given class. |
abstract javax.jdo.Query |
newQuery(java.lang.String language,
PersistenceManager pm,
java.lang.Object query)
Method to generate a new query using the passed query. |
protected void |
registerStoreData(StoreData data)
Method to register some data with the store. |
abstract void |
removeAllClasses(ClassLoaderResolver clr)
Drops all tables in the schema. |
abstract void |
resolveIdentifierMacro(MacroString.IdentifierMacro im,
ClassLoaderResolver clr)
Resolves an identifier macro. |
abstract boolean |
supportsQueryLanguage(java.lang.String language)
Accessor for the query languages supported by this store |
void |
update(StateManager sm,
int[] fieldNumbers)
Updates a persistent object in the database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final Localiser LOCALISER
protected final javax.sql.DataSource[] ds
protected final javax.sql.DataSource[] dsNonTx
protected DatastoreAdapter dba
protected final java.lang.String userName
protected final java.lang.String password
protected final boolean readOnlySchema
protected final boolean fixedSchema
protected AutoStartMechanism starter
protected boolean starterInitialised
protected final Dictionary dictionary
protected final PMFContext pmfContext
protected final boolean autoCreateTables
protected final boolean autoCreateColumns
protected final boolean autoCreateConstraints
protected final boolean autoCreateWarnOnError
protected final boolean validateTables
protected final boolean validateColumns
protected final boolean validateConstraints
protected final boolean checkExistTablesOrViews
protected final java.lang.String defaultPoidGeneratorClass
PoidGenerator
protected final PoidManager poidManager
protected IdentifierFactory identifierFactory
protected java.util.Map storeDataByClass
protected MultiMap storeDataByAppIdClass
Constructor Detail |
protected StoreManager(ClassLoaderResolver clr, AbstractPersistenceManagerFactory pmf, java.lang.String userName, java.lang.String password)
clr
- the ClassLoaderResolverpmf
- The corresponding PersistenceManagerFactory. This factory's
non-transactional data source will be used to get database
connections as needed to perform management functions.userName
- The database user name.password
- The database user's password.StoreManagerFactory
Method Detail |
public void close()
protected void registerStoreData(StoreData data)
data
- The StoreData to addprotected void deregisterAllStoreData()
public StoreData[] getStoreDataForTable(DatastoreIdentifier tableIdentifier)
tableIdentifier
- Identifier for the table
protected void initialiseAutoStart(ClassLoaderResolver clr) throws DatastoreInitialisationException
clr
- The ClassLoaderResolver
DatastoreInitialisationException
protected void clearAutoStarter()
public boolean managesClass(java.lang.String className)
className
- The name of the class
public abstract void addClass(java.lang.String className, ClassLoaderResolver clr)
className
- Name of the classclr
- The ClassLoaderResolverpublic abstract void addClasses(java.lang.String[] classes, ClassLoaderResolver clr)
This method is primarily useful for applications that wish to perform all of their datastore initialization up front, rather than wait for the JPOX runtime to do it on-demand.
classes
- The class(es) to be added.clr
- The ClassLoaderResolver
SchemaValidationException
- If there is some mismatch between the current schema contents and
those necessary to enable persistence of the given classes.public abstract void removeAllClasses(ClassLoaderResolver clr)
clr
- The ClassLoaderResolverpublic AbstractClassMetaData[] getClassesManagingTableForClass(AbstractClassMetaData cmd, ClassLoaderResolver clr)
cmd
- The supplied class.clr
- ClassLoader resolver
public java.lang.String manageClassForIdentity(OID id, ClassLoaderResolver clr)
id
- OIDclr
- ClassLoader resolver
public java.lang.String manageClassForIdentity(javax.jdo.identity.SingleFieldIdentity id, ClassLoaderResolver clr)
id
- Single Field Identityclr
- ClassLoader resolver
public abstract javax.jdo.Extent getExtent(PersistenceManager pm, java.lang.Class c, boolean subclasses)
pm
- The Persistence Managerc
- The class requiring the Extentsubclasses
- Whether to include subclasses of 'c'
public abstract boolean supportsQueryLanguage(java.lang.String language)
language
- The language name
public abstract javax.jdo.Query newQuery(java.lang.String language, PersistenceManager pm, java.lang.Object query)
language
- The query languagepm
- The PMquery
- Either the query filter (String) or an existing Query
public abstract java.lang.String getClassNameForObjectID(java.lang.Object id, ClassLoaderResolver clr, PersistenceManager pm)
id
- The JDO identity of some object.clr
- ClassLoader resolverpm
- Persistence Manager
java.lang.ClassCastException
- If the type of ID is not recognized
(OID
or SCOID
).public boolean isStrategyDatastoreAttributed(IdentityStrategy identityStrategy)
identityStrategy
- the identityStrategy
public abstract java.lang.Object getStrategyValue(PersistenceManager pm, DatastoreClass table, AbstractClassMetaData cmd, int absoluteFieldNumber, IdentityStrategy strategy, java.lang.String sequence, ExtensionMetaData[] extensions)
pm
- The Persistence Managertable
- The datastore tablecmd
- AbstractClassMetaData for the classabsoluteFieldNumber
- The field numberstrategy
- The strategysequence
- The sequence name if strategy is sequence-basedextensions
- Any extensions to control the value generation process
public abstract java.lang.Object newObjectID(PersistenceManager pm, java.lang.String className, javax.jdo.spi.PersistenceCapable pc)
pm
- The PersistenceManagerclassName
- Name of the class of the object.pc
- The persistenceCapable object. Useful for AppID
public void insert(StateManager sm)
sm
- The state manager of the object to be inserted.public void fetch(StateManager sm, int[] fieldNumbers)
sm
- The state manager of the object to be fetched.fieldNumbers
- The numbers of the fields to be fetched.public void update(StateManager sm, int[] fieldNumbers)
sm
- The state manager of the object to be updated.fieldNumbers
- The numbers of the fields to be updated.public void delete(StateManager sm)
sm
- The state manager of the object to be deleted.public void locate(StateManager sm)
sm
- The StateManager for the object to be found
javax.jdo.JDOObjectNotFoundException
- If the instance does not exist in
the datastorepublic void deleteDependent(StateManager sm, int[] fieldNumbers)
sm
- StateManager for the object being deleted.fieldNumbers
- the fields to delete.public abstract DatastoreContainerObject newJoinDatastoreContainerObject(AbstractPropertyMetaData fmd, ClassLoaderResolver clr)
fmd
- The field metadata describing the field.clr
- The ClassLoaderResolver
public java.util.HashSet getSubClassesForClass(java.lang.String className, boolean includeDescendents, ClassLoaderResolver clr)
className
- Class for which we search for subclasses.includeDescendents
- Whether to include subclasses of subclasses etcclr
- The ClassLoaderResolver
public IdentifierFactory getIdentifierFactory()
public PMFContext getPMFContext()
public MetaDataManager getMetaDataManager()
public MappingManager getMappingManager()
public DatastoreAdapter getDatastoreAdapter()
public DatastoreClass getDatastoreClass(java.lang.String className, ClassLoaderResolver clr)
addClass(java.lang.String, org.jpox.ClassLoaderResolver)
is called
to add it. Classes which have inheritance strategy of "new-table" and
"superclass-table" will return a table here, whereas "subclass-table" will
return null since it doesn't have a table as such.
className
- Name of the class whose table is be returned.clr
- The ClassLoaderResolver
NoTableManagedException
- If the given class has no table managed in the database.public DatastoreContainerObject getDatastoreContainerObject(AbstractPropertyMetaData fmd)
fmd
- The metadata for the field.
public DatastoreClass getDatastoreClass(DatastoreIdentifier name)
name
- The identifier name of the table.
public AbstractClassMetaData getClassWithPrimaryKeyForClass(AbstractClassMetaData cmd, ClassLoaderResolver clr)
cmd
- AbstractClassMetaData for this classclr
- The ClassLoaderResolver
public abstract void resolveIdentifierMacro(MacroString.IdentifierMacro im, ClassLoaderResolver clr)
im
- The macro to resolve.clr
- The ClassLoaderResolverpublic abstract FetchStatement getFetchStatement(DatastoreContainerObject table)
table
- The table to fetch from
public abstract CollectionStore getBackingStoreForCollection(java.lang.Class instantiatedType, AbstractPropertyMetaData fmd, DatastoreObject datastoreTable, ClassLoaderResolver clr)
instantiatedType
- Type of the instantiated collectionfmd
- MetaData for the field that has this collectiondatastoreTable
- The datastore objectclr
- ClassLoader resolver
public abstract MapStore getBackingStoreForMap(AbstractPropertyMetaData fmd, DatastoreObject datastoreTable, ClassLoaderResolver clr)
fmd
- MetaData for the field that has this mapdatastoreTable
- The datastore objectclr
- ClassLoader resolver
public abstract ArrayStore getBackingStoreForArray(AbstractPropertyMetaData fmd, DatastoreObject datastoreTable, ClassLoaderResolver clr)
fmd
- MetaData for the field that has this arraydatastoreTable
- The datastore objectclr
- ClassLoader resolver
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |