|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpox.store.StoreManager
public abstract class 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 java.util.Map |
datastoreContainerByIdentifier
Map of all managed datastore containers (tables) keyed by the datastore identifier. |
protected DatastoreAdapter |
dba
Adapter for the datastore being used. |
protected javax.sql.DataSource[] |
ds
Datasource |
protected javax.sql.DataSource[] |
dsNonTx
Non transactional Datasource |
protected boolean |
fixedDatastore
Whether this datastore is fixed (no mods to datastore classes 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 |
readOnlyDatastore
Whether this datastore is read only. |
protected java.lang.String |
readOnlyDatastoreAction
What should happen when readonly and an update occurs. |
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,
java.io.FileWriter writer)
Add classes to the persistence model for the datastore. |
void |
addDatastoreContainer(DatastoreContainerObject table)
Method to add a datastore container to the managed datastore classes |
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. |
AutoStartMechanism |
getAutoStartMechanism()
Accessor for the AutoStartMechanism |
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(AbstractPropertyMetaData fmd,
DatastoreObject datastoreTable,
ClassLoaderResolver clr,
boolean instantiated,
boolean listBased)
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. |
DatastoreClass |
getDatastoreContainerForIdentifier(DatastoreIdentifier identifier)
Accessor for the datastore container (table) for a given datastore identifier |
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. |
java.util.Collection |
getManagedClasses()
Accessor for the names of the classes currently managed by this store. |
abstract Transaction |
getManagedTransaction(ManagedConnectionImpl pm,
javax.resource.spi.security.PasswordCredential credential)
Method to obtain a managed transaction for the specified persistence manager for this store. |
MappingManager |
getMappingManager()
Gets the MappingManager to use for this store. |
MetaDataManager |
getMetaDataManager()
Gets the MetaDataManager to use for this store. |
abstract Transaction |
getNonmanagedTransaction(PersistenceManagerImpl pm,
java.lang.String userName,
java.lang.String password)
Method to obtain a nonmanaged transaction for the specified persistence manager for this store. |
PMFContext |
getPMFContext()
Accessor for the context in which this RDBMSManager is running |
abstract javax.jdo.datastore.Sequence |
getSequence(PersistenceManager pm,
SequenceMetaData seqmd)
Method to return a datastore sequence for this datastore matching the passed sequence MetaData. |
StoreData[] |
getStoreDataForDatastoreContainerObject(DatastoreIdentifier tableIdentifier)
Utility to return all StoreData for a Datastore Container 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(java.lang.String mechanism,
java.lang.String mode,
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). |
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. |
javax.jdo.Query |
newQuery(java.lang.String language,
PersistenceManager pm,
java.lang.Object query)
Method to generate a new query using the passed query as basis. |
protected void |
registerStoreData(StoreData data)
Method to register some data with the store. |
abstract void |
removeAllClasses(ClassLoaderResolver clr)
Drops all tables in the datastore. |
abstract void |
resolveIdentifierMacro(MacroString.IdentifierMacro im,
ClassLoaderResolver clr)
Resolves an identifier macro. |
abstract boolean |
supportsQueryLanguage(java.lang.String language)
Accessor for whether this query language is supported. |
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 readOnlyDatastore
protected final java.lang.String readOnlyDatastoreAction
protected final boolean fixedDatastore
protected AutoStartMechanism starter
protected boolean starterInitialised
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 PoidManager poidManager
protected IdentifierFactory identifierFactory
protected java.util.Map storeDataByClass
protected MultiMap storeDataByAppIdClass
protected java.util.Map datastoreContainerByIdentifier
| 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()
public abstract Transaction getNonmanagedTransaction(PersistenceManagerImpl pm,
java.lang.String userName,
java.lang.String password)
pm - The PersistenceManageruserName - The usernamepassword - The password
public abstract Transaction getManagedTransaction(ManagedConnectionImpl pm,
javax.resource.spi.security.PasswordCredential credential)
pm - The PersistenceManager implementation for managed environmentcredential - Password credential
public abstract javax.jdo.datastore.Sequence getSequence(PersistenceManager pm,
SequenceMetaData seqmd)
pm - The PersistenceManagerseqmd - SequenceMetaData
protected void registerStoreData(StoreData data)
data - The StoreData to addprotected void deregisterAllStoreData()
public StoreData[] getStoreDataForDatastoreContainerObject(DatastoreIdentifier tableIdentifier)
tableIdentifier - Identifier for the table
public DatastoreClass getDatastoreContainerForIdentifier(DatastoreIdentifier identifier)
identifier - The identifier
public void addDatastoreContainer(DatastoreContainerObject table)
table - The datastore container
protected void initialiseAutoStart(java.lang.String mechanism,
java.lang.String mode,
ClassLoaderResolver clr)
throws DatastoreInitialisationException
mechanism - AutoStart mechanismmode - Mode for autostart mechanismclr - The ClassLoaderResolver
DatastoreInitialisationExceptionprotected void clearAutoStarter()
public AutoStartMechanism getAutoStartMechanism()
AutoStartMechanism
public java.util.Collection getManagedClasses()
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 ClassLoaderResolver
public abstract void addClasses(java.lang.String[] classes,
ClassLoaderResolver clr,
java.io.FileWriter writer)
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 ClassLoaderResolverwriter - Optional writer when you just want the DDL for persisting the specified classes
DatastoreValidationException - If there is some mismatch between the current datastore contents and
those necessary to enable persistence of the given classes.public abstract void removeAllClasses(ClassLoaderResolver clr)
clr - The ClassLoaderResolver
public 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
supportsQueryLanguage(java.lang.String)
public javax.jdo.Query newQuery(java.lang.String language,
PersistenceManager pm,
java.lang.Object query)
language - The query languagepm - The PMquery - The query filter (String) or a previous 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 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 datastore
public 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(AbstractPropertyMetaData fmd,
DatastoreObject datastoreTable,
ClassLoaderResolver clr,
boolean instantiated,
boolean listBased)
fmd - MetaData for the field that has this collectiondatastoreTable - The datastore objectclr - ClassLoader resolverinstantiated - Whether it is already instantiatedlistBased - whether the collection is list based
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 | |||||||||