|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.datanucleus.store.AbstractStoreManager
public abstract class AbstractStoreManager
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 java.lang.String |
autoStartMechanism
Name of the AutoStart mechanism. |
protected ConnectionManager |
connectionMgr
ConnectionManager |
protected boolean |
fixedDatastore
Whether this datastore is fixed (no mods to datastore classes allowed). |
protected static Localiser |
LOCALISER
Localiser for messages. |
protected java.lang.String |
nontxConnectionFactoryName
Name of non-transactional connection factory (null if not present). |
protected OMFContext |
omfContext
ObjectManagerFactory context. |
protected StorePersistenceHandler |
persistenceHandler2
Persistence handler. |
protected boolean |
readOnlyDatastore
Whether this datastore is read only. |
protected StoreSchemaHandler |
schemaHandler
Schema handler. |
protected AutoStartMechanism |
starter
Auto-Start mechanism to use. |
protected boolean |
starterInitialised
Whether the AutoStart mechanism is initialised |
protected StoreDataManager |
storeDataMgr
Manager for the data definition in the datastore. |
protected java.lang.String |
storeManagerKey
Key for this StoreManager e.g "rdbms", "db4o" |
protected StoreManagerRuntime |
storeManagerRuntime
StoreManager Runtime. |
protected java.lang.String |
txConnectionFactoryName
Name of transactional connection factory. |
protected ValueGenerationManager |
valueGenerationMgr
Manager for value generation. |
| Constructor Summary | |
|---|---|
protected |
AbstractStoreManager(java.lang.String key,
ClassLoaderResolver clr,
OMFContext omfContext)
Constructor for a new StoreManager. |
| Method Summary | |
|---|---|
void |
addClass(java.lang.String className,
ClassLoaderResolver clr)
Method to add a class to the managed list for this datastore manager. |
void |
addClasses(java.lang.String[] classNames,
ClassLoaderResolver clr)
Add classes to the persistence model for the datastore. |
void |
assertReadOnlyForUpdateOfObject(ObjectProvider op)
Convenience method to assert when this StoreManager is read-only and the specified object is attempting to be updated. |
protected void |
clearAutoStarter()
Method to clear the Auto-Starter status. |
void |
close()
Release of resources. |
protected void |
deregisterAllStoreData()
Method to deregister all existing store data so that we are managing nothing. |
ApiAdapter |
getApiAdapter()
Accessor for the API adapter. |
Store |
getBackingStoreForField(ClassLoaderResolver clr,
AbstractMemberMetaData fmd,
java.lang.Class type)
Accessor for the backing store for the specified field. |
java.lang.String |
getClassNameForObjectID(java.lang.Object id,
ClassLoaderResolver clr,
ExecutionContext ec)
Returns the class corresponding to the given object identity. |
ManagedConnection |
getConnection(ExecutionContext ec)
Accessor for a connection for the specified ObjectManager. |
ManagedConnection |
getConnection(ExecutionContext ec,
java.util.Map options)
Accessor for a connection for the specified ObjectManager. |
ManagedConnection |
getConnection(int isolation_level)
Utility to return a non-transactional Connection. |
java.lang.String |
getConnectionDriverName()
Convenience accessor for the driver name to use for the connection (if applicable for this datastore). |
java.lang.Object |
getConnectionFactory()
Convenience accessor for the factory for the connection (transactional). |
java.lang.Object |
getConnectionFactory2()
Convenience accessor for the factory for the connection (non-transactional). |
java.lang.String |
getConnectionFactory2Name()
Convenience accessor for the factory name for the connection (non-transactional). |
java.lang.String |
getConnectionFactoryName()
Convenience accessor for the factory name for the connection (transactional). |
ConnectionManager |
getConnectionManager()
Accessor for the connection manager for this store manager. |
java.lang.String |
getConnectionPassword()
Convenience accessor for the password to use for the connection. |
java.lang.String |
getConnectionURL()
Convenience accessor for the URL for the connection |
java.lang.String |
getConnectionUserName()
Convenience accessor for the username to use for the connection |
java.util.Date |
getDatastoreDate()
Get the date/time of the datastore. |
Extent |
getExtent(ExecutionContext ec,
java.lang.Class c,
boolean subclasses)
Interface to getting an Extent for a class. |
MetaDataManager |
getMetaDataManager()
|
NucleusConnection |
getNucleusConnection(ExecutionContext ec)
Method to return a connection for the ObjectManager. |
NucleusSequence |
getNucleusSequence(ExecutionContext ec,
SequenceMetaData seqmd)
Method to return a datastore sequence for this datastore matching the passed sequence MetaData. |
OMFContext |
getOMFContext()
Accessor for the context in which this StoreManager is running |
StorePersistenceHandler |
getPersistenceHandler()
Accessor for the store persistence handler. |
protected java.util.Properties |
getPropertiesForGenerator(AbstractClassMetaData cmd,
int absoluteFieldNumber,
ExecutionContext ec,
SequenceMetaData seqmd,
TableGeneratorMetaData tablegenmd)
Method to return the properties to pass to the generator for the specified field. |
java.lang.String |
getQueryCacheKey()
Accessor for the key used for representing this store manager in the query cache. |
StoreManagerRuntime |
getRuntimeManager()
Accessor for the runtime management of this component (if specified as required to the PMF/EMF). |
StoreSchemaHandler |
getSchemaHandler()
Accessor for the store schema handler (if this datastore supports the concept of a schema). |
java.lang.String |
getStoreManagerKey()
Accessor for the key for this store manager. |
protected java.lang.String |
getStrategyForNative(AbstractClassMetaData cmd,
int absFieldNumber)
Method defining which value-strategy to use when the user specifies "native". |
java.lang.Object |
getStrategyValue(ExecutionContext ec,
AbstractClassMetaData cmd,
int absoluteFieldNumber)
Method to retrieve the value for a strategy for a particular field. |
protected java.lang.Object |
getStrategyValueForGenerator(ValueGenerator generator,
ExecutionContext ec)
Accessor for the next value from the specified generator. |
java.util.HashSet<java.lang.String> |
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. |
java.util.Collection<java.lang.String> |
getSupportedOptions()
Accessor for the supported options in string form. |
ValueGenerationManager |
getValueGenerationManager()
Accessor for the ValueGenerationManager for obtaining sequences. |
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. |
boolean |
isStrategyDatastoreAttributed(IdentityStrategy identityStrategy,
boolean datastoreIdentityField)
Method to return if a particular value strategy is attributed by the datastore. |
protected void |
logConfiguration()
Convenience method to log the configuration of this store manager. |
java.lang.String |
manageClassForIdentity(java.lang.Object id,
ClassLoaderResolver clr)
Convenience method to ensure that the class defined by the passed OID/SingleFIeldIdentity is managed by the store. |
boolean |
managesClass(java.lang.String className)
Accessor for whether the specified class is managed currently |
protected StoreData |
newStoreData(ClassMetaData cmd,
ClassLoaderResolver clr)
Instantiate a StoreData instance using the provided ClassMetaData and ClassLoaderResolver. |
void |
notifyObjectIsOutdated(ObjectProvider 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. |
void |
performVersionCheck(ObjectProvider sm,
java.lang.Object versionDatastore,
VersionMetaData versionMetaData)
Perform an optimistic version check on the passed object, against the passed version in the datastore. |
void |
printInformation(java.lang.String category,
java.io.PrintStream ps)
Method to output the information about the StoreManager. |
protected void |
registerConnectionFactory()
Register the Connection Factory defined in plugins |
protected void |
registerConnectionMgr()
Register the default ConnectionManager implementation |
protected void |
registerStoreData(StoreData data)
Method to register some data with the store. |
void |
removeAllClasses(ClassLoaderResolver clr)
Remove all classes from the persistence model for the datastore. |
boolean |
supportsQueryLanguage(java.lang.String language)
Accessor for whether this query language is supported. |
boolean |
supportsValueStrategy(java.lang.String strategy)
Accessor for whether this value strategy is supported. |
void |
transactionCommitted(ExecutionContext ec)
Method to inform the StoreManager that a transaction has committed for the specified execution context. |
void |
transactionRolledBack(ExecutionContext ec)
Method to inform the StoreManager that a transaction has rolled back for the specified execution context. |
void |
transactionStarted(ExecutionContext ec)
Method to inform the StoreManager that a transaction has started for the specified execution context. |
| 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 java.lang.String storeManagerKey
protected final boolean readOnlyDatastore
protected final boolean fixedDatastore
protected AutoStartMechanism starter
protected boolean starterInitialised
protected final OMFContext omfContext
protected final ValueGenerationManager valueGenerationMgr
protected StoreManagerRuntime storeManagerRuntime
protected StoreDataManager storeDataMgr
protected java.lang.String autoStartMechanism
protected StorePersistenceHandler persistenceHandler2
protected StoreSchemaHandler schemaHandler
protected ConnectionManager connectionMgr
protected java.lang.String txConnectionFactoryName
protected java.lang.String nontxConnectionFactoryName
| Constructor Detail |
|---|
protected AbstractStoreManager(java.lang.String key,
ClassLoaderResolver clr,
OMFContext omfContext)
key - Key for this StoreManagerclr - the ClassLoaderResolveromfContext - The corresponding ObjectManagerFactory context.| Method Detail |
|---|
protected void registerConnectionMgr()
protected void registerConnectionFactory()
public void close()
StoreManager
close in interface StoreManagerpublic ConnectionManager getConnectionManager()
StoreManager
getConnectionManager in interface StoreManagerpublic ManagedConnection getConnection(ExecutionContext ec)
If there is an active transaction, a connection from the transactional connection factory will be returned. If there is no active transaction, a connection from the nontransactional connection factory will be returned.
getConnection in interface StoreManagerec - execution context
NucleusException - Thrown if an error occurs getting the connection
public ManagedConnection getConnection(ExecutionContext ec,
java.util.Map options)
If there is an active transaction, a connection from the transactional connection factory will be returned. If there is no active transaction, a connection from the nontransactional connection factory will be returned.
getConnection in interface StoreManagerec - execution contextoptions - connetion options
NucleusException - Thrown if an error occurs getting the connectionpublic ManagedConnection getConnection(int isolation_level)
isolation_level - The transaction isolation scheme to use e.g Connection.TRANSACTION_NONE
Pass in -1 if just want the default
NucleusException - if an error occurs getting the connectionpublic java.lang.String getConnectionDriverName()
getConnectionDriverName in interface StoreManagerpublic java.lang.String getConnectionURL()
getConnectionURL in interface StoreManagerpublic java.lang.String getConnectionUserName()
getConnectionUserName in interface StoreManagerpublic java.lang.String getConnectionPassword()
getConnectionPassword in interface StoreManagerpublic java.lang.Object getConnectionFactory()
getConnectionFactory in interface StoreManagerpublic java.lang.String getConnectionFactoryName()
getConnectionFactoryName in interface StoreManagerpublic java.lang.Object getConnectionFactory2()
getConnectionFactory2 in interface StoreManagerpublic java.lang.String getConnectionFactory2Name()
getConnectionFactory2Name in interface StoreManagerpublic StoreManagerRuntime getRuntimeManager()
StoreManager
getRuntimeManager in interface StoreManagerpublic StorePersistenceHandler getPersistenceHandler()
StoreManager
getPersistenceHandler in interface StoreManagerpublic StoreSchemaHandler getSchemaHandler()
StoreManager
getSchemaHandler in interface StoreManager
public NucleusSequence getNucleusSequence(ExecutionContext ec,
SequenceMetaData seqmd)
getNucleusSequence in interface StoreManagerec - execution contextseqmd - SequenceMetaData
public NucleusConnection getNucleusConnection(ExecutionContext ec)
StoreManager
getNucleusConnection in interface StoreManagerec - execution context
public ValueGenerationManager getValueGenerationManager()
StoreManager
getValueGenerationManager in interface StoreManagerpublic ApiAdapter getApiAdapter()
StoreManager
getApiAdapter in interface StoreManagerpublic java.lang.String getStoreManagerKey()
StoreManager
getStoreManagerKey in interface StoreManagerpublic java.lang.String getQueryCacheKey()
StoreManager
getQueryCacheKey in interface StoreManagerpublic OMFContext getOMFContext()
StoreManager
getOMFContext in interface StoreManagerpublic MetaDataManager getMetaDataManager()
public java.util.Date getDatastoreDate()
StoreManager
getDatastoreDate in interface StoreManagerprotected void registerStoreData(StoreData data)
data - The StoreData to addprotected void deregisterAllStoreData()
protected void logConfiguration()
public void printInformation(java.lang.String category,
java.io.PrintStream ps)
throws java.lang.Exception
printInformation in interface StoreManagercategory - Category of informationps - PrintStream
java.lang.Exception - Thrown if an error occurs in the output process
protected void initialiseAutoStart(ClassLoaderResolver clr)
throws DatastoreInitialisationException
clr - The ClassLoaderResolver
DatastoreInitialisationExceptionprotected void clearAutoStarter()
public boolean managesClass(java.lang.String className)
StoreManager
managesClass in interface StoreManagerclassName - The name of the class
public void addClass(java.lang.String className,
ClassLoaderResolver clr)
StoreManager
addClass in interface StoreManagerclassName - Name of the classclr - The ClassLoaderResolver
public void addClasses(java.lang.String[] classNames,
ClassLoaderResolver clr)
StoreManagerThis method is primarily useful for applications that wish to perform all of their datastore initialization up front, rather than wait for the runtime to do it on-demand.
addClasses in interface StoreManagerclassNames - The class(es) to be added.clr - The ClassLoaderResolver
protected StoreData newStoreData(ClassMetaData cmd,
ClassLoaderResolver clr)
cmd - MetaData for the classclr - ClassLoader resolverpublic void removeAllClasses(ClassLoaderResolver clr)
StoreManager
removeAllClasses in interface StoreManagerclr - The ClassLoaderResolver
public java.lang.String manageClassForIdentity(java.lang.Object id,
ClassLoaderResolver clr)
StoreManager
manageClassForIdentity in interface StoreManagerid - OIDclr - ClassLoader resolver
public Extent getExtent(ExecutionContext ec,
java.lang.Class c,
boolean subclasses)
StoreManager
getExtent in interface StoreManagerec - execution contextc - The class requiring the Extentsubclasses - Whether to include subclasses of 'c'
public boolean supportsQueryLanguage(java.lang.String language)
StoreManager
supportsQueryLanguage in interface StoreManagerlanguage - The language
public boolean supportsValueStrategy(java.lang.String strategy)
supportsValueStrategy in interface StoreManagerstrategy - The strategy
public java.lang.String getClassNameForObjectID(java.lang.Object id,
ClassLoaderResolver clr,
ExecutionContext ec)
StoreManager
getClassNameForObjectID in interface StoreManagerid - The identity of some object.clr - ClassLoader resolverec - execution context
public boolean isStrategyDatastoreAttributed(IdentityStrategy identityStrategy,
boolean datastoreIdentityField)
isStrategyDatastoreAttributed in interface StoreManageridentityStrategy - The strategydatastoreIdentityField - Whether this is a datastore id field
public java.lang.Object getStrategyValue(ExecutionContext ec,
AbstractClassMetaData cmd,
int absoluteFieldNumber)
StoreManager
getStrategyValue in interface StoreManagerec - execution contextcmd - AbstractClassMetaData for the classabsoluteFieldNumber - The field number
protected java.lang.String getStrategyForNative(AbstractClassMetaData cmd,
int absFieldNumber)
cmd - Class requiring the strategyabsFieldNumber - Field of the class
protected java.lang.Object getStrategyValueForGenerator(ValueGenerator generator,
ExecutionContext ec)
generator - The generatorec - execution context
protected java.util.Properties getPropertiesForGenerator(AbstractClassMetaData cmd,
int absoluteFieldNumber,
ExecutionContext ec,
SequenceMetaData seqmd,
TableGeneratorMetaData tablegenmd)
cmd - MetaData for the classabsoluteFieldNumber - Number of the field (-1 = datastore identity)ec - execution contextseqmd - Any sequence metadatatablegenmd - Any table generator metadata
public void performVersionCheck(ObjectProvider sm,
java.lang.Object versionDatastore,
VersionMetaData versionMetaData)
StoreManager
performVersionCheck in interface StoreManagersm - StateManager of the object to checkversionDatastore - Version of the object in the datastoreversionMetaData - VersionMetaData to use for checking
public java.util.HashSet<java.lang.String> getSubClassesForClass(java.lang.String className,
boolean includeDescendents,
ClassLoaderResolver clr)
StoreManager
getSubClassesForClass in interface StoreManagerclassName - Class for which we search for subclasses.includeDescendents - Whether to include subclasses of subclasses etcclr - The ClassLoaderResolver
public void notifyObjectIsOutdated(ObjectProvider sm)
StoreManager
notifyObjectIsOutdated in interface StoreManager
public Store getBackingStoreForField(ClassLoaderResolver clr,
AbstractMemberMetaData fmd,
java.lang.Class type)
StoreManager
getBackingStoreForField in interface StoreManagerclr - ClassLoader resolverfmd - MetaData for the field/propertytype - Type
public java.util.Collection<java.lang.String> getSupportedOptions()
getSupportedOptions in interface StoreManagerpublic void assertReadOnlyForUpdateOfObject(ObjectProvider op)
op - ObjectProvider for the objectpublic void transactionStarted(ExecutionContext ec)
StoreManager
transactionStarted in interface StoreManagerec - ExecutionContextpublic void transactionCommitted(ExecutionContext ec)
StoreManager
transactionCommitted in interface StoreManagerec - ExecutionContextpublic void transactionRolledBack(ExecutionContext ec)
StoreManager
transactionRolledBack in interface StoreManagerec - ExecutionContext
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||