| java.lang.Object org.jpox.store.StoreManager
All known Subclasses: org.jpox.store.MappedStoreManager,
StoreManager | abstract public class StoreManager (Code) | | 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:
- Creating and/or validating datastore tables according to the persistent classes being
accessed by the application.
- Serving as the primary intermediary between StateManagers and the database.
- Serving as the base Extent and Query factory.
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.
version: $Revision: 1.180 $ |
Method Summary | |
public void | addClass(String className, ClassLoaderResolver clr) Method to add a class to the managed list for this datastore manager. | abstract public void | addClasses(String[] classes, ClassLoaderResolver clr, Writer writer, boolean completeDdl) Add classes to the persistence model for the datastore.
In the case of an RDBMS, this will map these classes to RDBMS tables.
In the case of XML, this will map these classes to XML datafiles. | public void | addClasses(String[] classNames, ClassLoaderResolver clr) Add classes to the persistence model for the datastore. | protected void | clearAutoStarter() Method to clear the Auto-Starter status. | public void | close() | abstract public void | deleteObject(StateManager sm) Deletes a persistent object from the datastore. | protected void | deregisterAllStoreData() Method to deregister all existing store data so that we are managing nothing. | abstract public void | fetchObject(StateManager sm, int fieldNumbers) Fetches a persistent object from the database. | abstract public Object | findObject(ObjectManager om, Object id) Method to find a persistable object with the specified id from the datastore, if the StoreManager supports
this operation (optional). | public ApiAdapter | getApiAdapter() Accessor for the API adapter. | public AutoStartMechanism | getAutoStartMechanism() | public String | getClassNameForObjectID(Object id, ClassLoaderResolver clr, ObjectManager om) Returns the class corresponding to the given object identity. | public 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. | public 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. | public DatastoreAdapter | getDatastoreAdapter() Gets the DatastoreAdapter to use for this store. | public DatastoreClass | getDatastoreClass(String className, ClassLoaderResolver clr) Returns the primary datastore container serving as backing for the given class. | public synchronized DatastoreClass | getDatastoreClass(DatastoreIdentifier name) Returns the JDO table having the given SQL identifier.
Returns 'null' if no such table is (yet) known to the store manager.
Parameters: name - The identifier name of the table. | abstract public Date | getDatastoreDate() Get the date/time of the datastore. | abstract public Extent | getExtent(ObjectManager om, Class c, boolean subclasses) Interface to getting an Extent for a class. | public IdentifierFactory | getIdentifierFactory() Accessor for the identifier factory. | abstract public JPOXConnection | getJPOXConnection(ObjectManager om) Method to return a JPOX connection for the ObjectManager. | abstract public JPOXSequence | getJPOXSequence(ObjectManager om, SequenceMetaData seqmd) Method to return a datastore sequence for this datastore matching the passed sequence MetaData. | public MetaDataManager | getMetaDataManager() Gets the MetaDataManager to use for this store. | public OMFContext | getOMFContext() | public PoidManager | getPoidManager() Accessor for the POIDManager for obtaining sequences. | abstract public Store | getStore(ClassLoaderResolver clr, AbstractMemberMetaData fmd, Class type) | public String | getStoreManagerKey() Accessor for the key for this store manager. | abstract public Object | getStrategyValue(ObjectManager om, DatastoreClass table, AbstractClassMetaData cmd, int absoluteFieldNumber) Method to retrieve the value for a strategy for a particular field. | public HashSet | getSubClassesForClass(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(String mechanism, 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. | abstract public void | insertObject(StateManager sm) Inserts a persistent object into the database. | public boolean | isStrategyDatastoreAttributed(IdentityStrategy identityStrategy, boolean datastoreIdentityField) | abstract public void | locateObject(StateManager sm) Locates this object in the datastore. | public String | manageClassForIdentity(Object id, ClassLoaderResolver clr) Convenience method to ensure that the class defined by the passed OID/SingleFIeldIdentity is
managed by the store. | public boolean | managesClass(String className) | public Object | newObjectID(ObjectManager om, String className, Object pc) Returns a new, unique ID for an object of the given class.
Parameters: om - The Object Manager Parameters: className - Name of the class of the object. Parameters: pc - The persistable object. | public void | notifyObjectIsOutdated(StateManager sm) Notifies this store manager that the main memory (RAM, heap) copy of the PC object of the supplied
StateManager may not be regarded as valid anymore.
(The most common case is that the state of the PC becomes HOLLOW).
This is especially important for object databases employing implicit storing
from the main memory to the database (like DB4O).
These databases may stop tracking the main memory copy and linking it with its on-disk copy,
thus releasing memory.
More importantly, these databases then know that the object should be reloaded when it
is (maybe even implicitly) accessed again.
To be clear: There may be multiple copies of the data of one PC object (from the user perspective),
namely a copy in main memory (on the Java heap) and a copy in the database (usually on disk).
As there may be multiple copies, some of these copies may be outdated or invalid. | abstract public void | outputDatastoreInformation(PrintStream ps) Method to output the datastore information to the specified PrintStream. | abstract public void | outputSchemaInformation(PrintStream ps) Method to output the schema information to the specified PrintStream. | public void | performVersionCheck(StateManager sm, Object versionDatastore, VersionMetaData versionMetaData) Perform an optimistic version check on the passed object, against the passed version in the datastore. | protected void | registerStoreData(StoreData data) Method to register some data with the store. | abstract public void | removeAllClasses(ClassLoaderResolver clr) Drops all tables in the datastore. | abstract public void | resolveIdentifierMacro(MacroString.IdentifierMacro im, ClassLoaderResolver clr) Resolves an identifier macro. | abstract public boolean | supportsQueryLanguage(String language) Accessor for whether this query language is supported. | abstract public void | updateObject(StateManager sm, int fieldNumbers) Updates a persistent object in the datastore. | public boolean | usesDatastoreClass() Method returning whether the datastore has a "datastore class" equivalent that the StoreManager
uses to represent it. |
LOCALISER | final protected static Localiser LOCALISER(Code) | | Localiser for messages.
|
autoStartMechanism | protected String autoStartMechanism(Code) | | Name of the AutoStart mechanism.
|
fixedDatastore | final protected boolean fixedDatastore(Code) | | Whether this datastore is fixed (no mods to datastore classes allowed).
|
identifierFactory | protected IdentifierFactory identifierFactory(Code) | | Factory for identifiers for this datastore. Really should be on MappedStoreManager.
|
omfContext | final protected OMFContext omfContext(Code) | | ObjectManagerFactory context.
|
poidManager | final protected PoidManager poidManager(Code) | | Manager for identity generation.
|
readOnlyDatastore | final protected boolean readOnlyDatastore(Code) | | Whether this datastore is read only.
|
readOnlyDatastoreAction | final protected String readOnlyDatastoreAction(Code) | | What should happen if read-only and an update is invoked.
|
starterInitialised | protected boolean starterInitialised(Code) | | Whether the AutoStart mechanism is initialised
|
storeManagerKey | final protected String storeManagerKey(Code) | | Key for this StoreManager e.g "rdbms", "db4o"
|
storeManagerRuntime | protected StoreManagerRuntime storeManagerRuntime(Code) | | StoreManager Runtime. Used when providing management of services.
|
StoreManager | protected StoreManager(String key, ClassLoaderResolver clr, ObjectManagerFactoryImpl omf)(Code) | | Constructor for a new StoreManager. Stores the basic information required for the datastore management.
Parameters: key - Key for this StoreManager Parameters: clr - the ClassLoaderResolver Parameters: omf - The corresponding ObjectManagerFactory. See Also: StoreManagerFactory |
addClass | public void addClass(String className, ClassLoaderResolver clr)(Code) | | Method to add a class to the managed list for this datastore manager.
Parameters: className - Name of the class Parameters: clr - The ClassLoaderResolver |
addClasses | abstract public void addClasses(String[] classes, ClassLoaderResolver clr, Writer writer, boolean completeDdl)(Code) | | Add classes to the persistence model for the datastore.
In the case of an RDBMS, this will map these classes to RDBMS tables.
In the case of XML, this will map these classes to XML datafiles.
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.
Parameters: classes - The class(es) to be added. Parameters: clr - The ClassLoaderResolver Parameters: writer - Optional writer when you just want the DDL for persisting the specified classes Parameters: completeDdl - whether complete DDL will be created when writing DDL to a file, or only for missing elements exception: org.jpox.store.exceptions.DatastoreValidationException - If there is some mismatch between the current datastore contents andthose necessary to enable persistence of the given classes. |
addClasses | public void addClasses(String[] classNames, ClassLoaderResolver clr)(Code) | | Add classes to the persistence model for the datastore.
In the case of an RDBMS, this will map these classes to RDBMS tables.
In the case of XML, this will map these classes to XML datafiles.
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.
Parameters: classNames - The class(es) to be added. Parameters: clr - The ClassLoaderResolver exception: org.jpox.store.exceptions.DatastoreValidationException - If there is some mismatch between the current datastore contents andthose necessary to enable persistence of the given classes. |
clearAutoStarter | protected void clearAutoStarter()(Code) | | Method to clear the Auto-Starter status.
|
close | public void close()(Code) | | Release of resources
|
deleteObject | abstract public void deleteObject(StateManager sm)(Code) | | Deletes a persistent object from the datastore.
Parameters: sm - The state manager of the object to be deleted. throws: JPOXDataStoreException - when an error occurs in the datastore communication |
deregisterAllStoreData | protected void deregisterAllStoreData()(Code) | | Method to deregister all existing store data so that we are managing nothing.
|
fetchObject | abstract public void fetchObject(StateManager sm, int fieldNumbers)(Code) | | Fetches a persistent object from the database.
Parameters: sm - The state manager of the object to be fetched. Parameters: fieldNumbers - The numbers of the fields to be fetched. throws: JPOXObjectNotFoundException - if the object doesnt exist throws: JPOXDataStoreException - when an error occurs in the datastore communication |
findObject | abstract public Object findObject(ObjectManager om, Object id)(Code) | | Method to find a persistable object with the specified id from the datastore, if the StoreManager supports
this operation (optional). This allows for datastores that perform the instantiation of objects directly
(such as ODBMS). With other types of datastores (e.g RDBMS) this method returns null. If the StoreManager
supports this operation yet the object is not found an exception should be thrown.
Parameters: om - the ObjectManager which will manage the object Parameters: id - the id of the object in question. a persistable object with a valid object state (for example: hollow) or null, indicating that the implementation leaves the instantiation work to JPOX. |
getApiAdapter | public ApiAdapter getApiAdapter()(Code) | | Accessor for the API adapter.
API adapter |
getClassNameForObjectID | public String getClassNameForObjectID(Object id, ClassLoaderResolver clr, ObjectManager om)(Code) | | Returns the class corresponding to the given object identity.
If the object is an OID (datastore-identity), return the PC class specified in the identity.
If the object is SingleFieldIdentity, return the PC class specified in the identity
If the object is an AppID PK, return the PC class that uses it.
If the object is a SCOID, return the SCO class.
If the object is a PersistenceCapable class, return the class.
Parameters: id - The identity of some object. Parameters: clr - ClassLoader resolver Parameters: om - Object Manager For datastore identity, return the class of the correspondingobject. For application identity, return the class of the correspondingobject or null if object does not exist. exception: ClassCastException - If the type of ID is not recognized (OIDor SCOID). |
getClassWithPrimaryKeyForClass | public AbstractClassMetaData getClassWithPrimaryKeyForClass(AbstractClassMetaData cmd, ClassLoaderResolver clr)(Code) | | Utility to navigate the inheritance hierarchy to find the base class that defines the primary keys
for this tree. This will either go up to the next class in the hierarchy that has a table
OR go up to the base class, whichever is first.
Parameters: cmd - AbstractClassMetaData for this class Parameters: clr - The ClassLoaderResolver The AbstractClassMetaData for the class defining the primary keys |
getClassesManagingTableForClass | public AbstractClassMetaData[] getClassesManagingTableForClass(AbstractClassMetaData cmd, ClassLoaderResolver clr)(Code) | | Method to return the class(es) that has a table managing the persistence of
the fields of the supplied class. For the 3 inheritance strategies, the following
occurs :-
- new-table : will return the same ClassMetaData
- subclass-table : will return all subclasses that have a table managing its fields
- superclass-table : will return the next superclass that has a table
Parameters: cmd - The supplied class. Parameters: clr - ClassLoader resolver The ClassMetaData's managing the fields of the supplied class |
getDatastoreAdapter | public DatastoreAdapter getDatastoreAdapter()(Code) | | Gets the DatastoreAdapter to use for this store.
Returns the DatastoreAdapter |
getDatastoreClass | public DatastoreClass getDatastoreClass(String className, ClassLoaderResolver clr)(Code) | | Returns the primary datastore container serving as backing for the given class.
If the class is not yet known to the store manager,
StoreManager.addClass 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.
Parameters: className - Name of the class whose table is be returned. Parameters: clr - The ClassLoaderResolver The corresponding class table. exception: NoTableManagedException - If the given class has no table managed in the database. |
getDatastoreClass | public synchronized DatastoreClass getDatastoreClass(DatastoreIdentifier name)(Code) | | Returns the JDO table having the given SQL identifier.
Returns 'null' if no such table is (yet) known to the store manager.
Parameters: name - The identifier name of the table. The corresponding JDO table, or 'null' |
getDatastoreDate | abstract public Date getDatastoreDate()(Code) | | Get the date/time of the datastore.
Date/time of the datastore |
getExtent | abstract public Extent getExtent(ObjectManager om, Class c, boolean subclasses)(Code) | | Interface to getting an Extent for a class.
Parameters: om - The Object Manager Parameters: c - The class requiring the Extent Parameters: subclasses - Whether to include subclasses of 'c' The Extent. |
getIdentifierFactory | public IdentifierFactory getIdentifierFactory()(Code) | | Accessor for the identifier factory.
Returns the identifier factory. |
getJPOXConnection | abstract public JPOXConnection getJPOXConnection(ObjectManager om)(Code) | | Method to return a JPOX connection for the ObjectManager.
Parameters: om - ObjectManager The JPOX Connection |
getJPOXSequence | abstract public JPOXSequence getJPOXSequence(ObjectManager om, SequenceMetaData seqmd)(Code) | | Method to return a datastore sequence for this datastore matching the passed sequence MetaData.
Parameters: om - The Object Manager Parameters: seqmd - SequenceMetaData The Sequence |
getMetaDataManager | public MetaDataManager getMetaDataManager()(Code) | | Gets the MetaDataManager to use for this store.
Returns the MetaDataManager. |
getOMFContext | public OMFContext getOMFContext()(Code) | | Accessor for the context in which this RDBMSManager is running
Returns the context. |
getPoidManager | public PoidManager getPoidManager()(Code) | | Accessor for the POIDManager for obtaining sequences.
The POID manager for this datastore |
getStoreManagerKey | public String getStoreManagerKey()(Code) | | Accessor for the key for this store manager.
StoreManager key |
getStrategyValue | abstract public Object getStrategyValue(ObjectManager om, DatastoreClass table, AbstractClassMetaData cmd, int absoluteFieldNumber)(Code) | | Method to retrieve the value for a strategy for a particular field.
Parameters: om - The Object Manager Parameters: table - The datastore table Parameters: cmd - AbstractClassMetaData for the class Parameters: absoluteFieldNumber - The field number The value |
getSubClassesForClass | public HashSet getSubClassesForClass(String className, boolean includeDescendents, ClassLoaderResolver clr)(Code) | | Utility to return the names of the classes that are known subclasses of the provided
class. Actually uses the MetaDataManager for determining what is a subclass
since the MetaData is often registered before being needed by the Store.
Parameters: className - Class for which we search for subclasses. Parameters: includeDescendents - Whether to include subclasses of subclasses etc Parameters: clr - The ClassLoaderResolver Set of classes that are subclasses of the input class. |
insertObject | abstract public void insertObject(StateManager sm)(Code) | | Inserts a persistent object into the database.
Parameters: sm - The state manager of the object to be inserted. throws: JPOXDataStoreException - when an error occurs in the datastore communication |
isStrategyDatastoreAttributed | public boolean isStrategyDatastoreAttributed(IdentityStrategy identityStrategy, boolean datastoreIdentityField)(Code) | | Check if the strategy is attributed by the database when the
PersistenceCapable object is inserted into the database
Parameters: identityStrategy - the identityStrategy Parameters: datastoreIdentityField - Whether this is for the surrogate datastore identity field if the object for the strategy is attributed by the database |
manageClassForIdentity | public String manageClassForIdentity(Object id, ClassLoaderResolver clr)(Code) | | Convenience method to ensure that the class defined by the passed OID/SingleFIeldIdentity is
managed by the store.
Parameters: id - OID Parameters: clr - ClassLoader resolver The class name of the class associated to this identity throws: JPOXUserException - if the identity is assigned to the wrong class |
managesClass | public boolean managesClass(String className)(Code) | | Accessor for whether the specified class is managed currently
Parameters: className - The name of the class Whether it is managed |
newObjectID | public Object newObjectID(ObjectManager om, String className, Object pc)(Code) | | Returns a new, unique ID for an object of the given class.
Parameters: om - The Object Manager Parameters: className - Name of the class of the object. Parameters: pc - The persistable object. Used for application-identity A new object ID. throws: JPOXUserException - if the class has no available table in the datastore |
notifyObjectIsOutdated | public void notifyObjectIsOutdated(StateManager sm)(Code) | | Notifies this store manager that the main memory (RAM, heap) copy of the PC object of the supplied
StateManager may not be regarded as valid anymore.
(The most common case is that the state of the PC becomes HOLLOW).
This is especially important for object databases employing implicit storing
from the main memory to the database (like DB4O).
These databases may stop tracking the main memory copy and linking it with its on-disk copy,
thus releasing memory.
More importantly, these databases then know that the object should be reloaded when it
is (maybe even implicitly) accessed again.
To be clear: There may be multiple copies of the data of one PC object (from the user perspective),
namely a copy in main memory (on the Java heap) and a copy in the database (usually on disk).
As there may be multiple copies, some of these copies may be outdated or invalid. In case such
a copy is to be accessed, its contents should not be used. Rather than that, the outdated copy should
be overwritten by an authorative copy.
This method marks the main memory copy of the object (on the Java heap) to be outdated in that sense.
|
outputDatastoreInformation | abstract public void outputDatastoreInformation(PrintStream ps) throws Exception(Code) | | Method to output the datastore information to the specified PrintStream.
Parameters: ps - PrintStream throws: Exception - If an error occurs obtaining the datastore info |
outputSchemaInformation | abstract public void outputSchemaInformation(PrintStream ps) throws Exception(Code) | | Method to output the schema information to the specified PrintStream.
Parameters: ps - PrintStream throws: Exception - If an error occurs obtaining the schema info |
performVersionCheck | public void performVersionCheck(StateManager sm, Object versionDatastore, VersionMetaData versionMetaData)(Code) | | Perform an optimistic version check on the passed object, against the passed version in the datastore.
Parameters: sm - StateManager of the object to check Parameters: versionDatastore - Version of the object in the datastore Parameters: versionMetaData - VersionMetaData to use for checking throws: JPOXUserException - thrown when an invalid strategy is specified throws: JPOXOptimisticException - thrown when the version check fails |
registerStoreData | protected void registerStoreData(StoreData data)(Code) | | Method to register some data with the store.
This will also register the data with the starter process.
Parameters: data - The StoreData to add |
removeAllClasses | abstract public void removeAllClasses(ClassLoaderResolver clr)(Code) | | Drops all tables in the datastore.
This empties the datastore of all datastore objects managed by JPOX.
All objects not managed by JPOX are left untouched.
Parameters: clr - The ClassLoaderResolver |
resolveIdentifierMacro | abstract public void resolveIdentifierMacro(MacroString.IdentifierMacro im, ClassLoaderResolver clr)(Code) | | Resolves an identifier macro. The public fields clazz ,
fieldName , and subfieldName of the given macro
are taken as inputs, and the public value field is set to the
SQL identifier of the corresponding database table or column.
Parameters: im - The macro to resolve. Parameters: clr - The ClassLoaderResolver |
updateObject | abstract public void updateObject(StateManager sm, int fieldNumbers)(Code) | | Updates a persistent object in the datastore.
Parameters: sm - The state manager of the object to be updated. Parameters: fieldNumbers - The numbers of the fields to be updated. throws: JPOXDataStoreException - when an error occurs in the datastore communication |
usesDatastoreClass | public boolean usesDatastoreClass()(Code) | | Method returning whether the datastore has a "datastore class" equivalent that the StoreManager
uses to represent it. For datastores like RDBMS this will return "true" since we have a "table".
For object datastores this is typically "false" since the objects are stored in some internal form
not visible via its API.
Whether datastore classes are used by the StoreManager |
|
|