Class AbstractStoreManager
java.lang.Object
org.datanucleus.properties.PropertyStore
org.datanucleus.store.AbstractStoreManager
- All Implemented Interfaces:
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, etc) 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 ExecutionContext can make the StoreManager aware of a class, and can check if the StoreManager knows about a particular class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConnectionManagerConnectionManagerprotected FlushProcessThe flush process appropriate for this datastore.protected NamingFactoryNaming factory.protected PersistenceNucleusContextNucleus Context.protected StorePersistenceHandlerPersistence handler.protected QueryManagerQuery Manager.protected StoreSchemaHandlerSchema handler.protected StoreDataManagerManager for the data definition in the datastore.protected final StringKey for this StoreManager e.g "rdbms", "neo4j"protected ValueGenerationManagerManager for value generation.Fields inherited from class PropertyStore
frequentProperties, propertiesFields inherited from interface StoreManager
OPTION_APPLICATION_COMPOSITE_ID, OPTION_APPLICATION_ID, OPTION_DATASTORE_ID, OPTION_DATASTORE_TIME_STORES_MILLISECS, OPTION_DATASTORE_TIME_STORES_NANOSECS, OPTION_DATASTORE_TIMEOUT, OPTION_NONDURABLE_ID, OPTION_ORM, OPTION_ORM_EMBEDDED_ARRAY, OPTION_ORM_EMBEDDED_ARRAY_NESTED, OPTION_ORM_EMBEDDED_COLLECTION, OPTION_ORM_EMBEDDED_COLLECTION_NESTED, OPTION_ORM_EMBEDDED_MAP, OPTION_ORM_EMBEDDED_MAP_NESTED, OPTION_ORM_EMBEDDED_PC, OPTION_ORM_EMBEDDED_PC_NESTED, OPTION_ORM_FOREIGN_KEYS, OPTION_ORM_INHERITANCE_COMPLETE_TABLE, OPTION_ORM_INHERITANCE_JOINED_TABLE, OPTION_ORM_INHERITANCE_SINGLE_TABLE, OPTION_ORM_SECONDARY_TABLE, OPTION_ORM_SERIALISED_ARRAY_ELEMENT, OPTION_ORM_SERIALISED_COLLECTION_ELEMENT, OPTION_ORM_SERIALISED_MAP_KEY, OPTION_ORM_SERIALISED_MAP_VALUE, OPTION_ORM_SERIALISED_PC, OPTION_QUERY_CANCEL, OPTION_QUERY_JDOQL_BITWISE_OPS, OPTION_QUERY_JDOQL_BULK_DELETE, OPTION_QUERY_JDOQL_BULK_INSERT, OPTION_QUERY_JDOQL_BULK_UPDATE, OPTION_QUERY_JPQL_BULK_DELETE, OPTION_QUERY_JPQL_BULK_INSERT, OPTION_QUERY_JPQL_BULK_UPDATE, OPTION_TRANSACTION_ACID, OPTION_TXN_ISOLATION_READ_COMMITTED, OPTION_TXN_ISOLATION_READ_UNCOMMITTED, OPTION_TXN_ISOLATION_REPEATABLE_READ, OPTION_TXN_ISOLATION_SERIALIZABLE, RELATION_IDENTITY_STORAGE_PERSISTABLE_IDENTITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractStoreManager(String key, ClassLoaderResolver clr, PersistenceNucleusContext nucleusContext, Map<String, Object> props) Constructor for a new StoreManager. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddValueGenerationPropertiesForIncrement(Properties properties, TableGeneratorMetaData tablegenmd) protected voidaddValueGenerationPropertiesForSequence(Properties properties, SequenceMetaData seqmd) voidclose()protected voidMethod to deregister all existing store data so that we are managing nothing.voidConvenience method to override the specified schema generation properties and enable schema generation.Accessor for the API adapter.Accessor for the specified property as a Boolean.booleangetBooleanProperty(String name) Accessor for the specified property as a boolean.booleangetBooleanProperty(String name, boolean resultIfNotSet) Accessor for the specified property as a boolean.getClassNameForObjectID(Object id, ClassLoaderResolver clr, ExecutionContext ec) Returns the class corresponding to the given object identity.Accessor for the connection manager for this store manager.Convenience accessor for the password to use for the connection.<T> Extent<T> getExtent(ExecutionContext ec, Class<T> c, boolean subclasses) Interface to getting an Extent for a class.intgetIntProperty(String name) Accessor for the specified property as an int.protected ObjectgetNextValueForValueGenerator(ValueGenerator generator, ExecutionContext ec) Accessor for the next value from the specified ValueGenerator.Method to return a connection to the user for the ExecutionContext.Accessor for the context in which this StoreManager is running.protected PropertiesgetPropertiesForValueGenerator(AbstractClassMetaData cmd, int absoluteFieldNumber, ClassLoaderResolver clr, SequenceMetaData seqmd, TableGeneratorMetaData tablegenmd) Method to return the properties to pass to the generator for the specified field.getProperty(String name) Method to get the value of a property from the store.getStoreDataForClass(String className) Accessor for the key for this store manager.getStringProperty(String name) Accessor for the specified property as a String.getSubClassesForClass(String className, boolean includeDescendents, ClassLoaderResolver clr) Utility to return the names of the classes that are known subclasses of the provided class.Accessor for the supported options in string form.Accessor for the supported query languages.Accessor for the ValueGenerationManager for generating field values.Method defining which value-strategy to use when the user specifies "native" on datastore-identity.Method defining which value-strategy to use when the user specifies "native" on a member.getValueGenerationStrategyValue(ExecutionContext ec, AbstractClassMetaData cmd, AbstractMemberMetaData mmd) Method to retrieve the value for a value generation strategy for a particular field or datastore-identity.protected ValueGeneratorgetValueGeneratorForMember(ClassLoaderResolver clr, AbstractClassMetaData cmd, AbstractMemberMetaData mmd) booleanhasProperty(String name) Accessor for whether a particular property is defined (but may be null).booleanisClosed()booleanReturns whether the datastore is a "JDBC datastore".booleanisValueGenerationStrategyDatastoreAttributed(AbstractClassMetaData cmd, int absFieldNumber) Convenience method to return whether the strategy used by the specified class/member is generated by the datastore (during a persist).protected voidConvenience method to log the configuration of this store manager.voidmanageClasses(ClassLoaderResolver clr, String... classNames) Manage the specified classes.Convenience method to ensure that the class defined by the passed DatastoreId/SingleFieldId is managed by the store.booleanmanagesClass(String className) Accessor for whether the specified class is managed currentlyprotected StoreDatanewStoreData(ClassMetaData cmd, ClassLoaderResolver clr) Instantiate a StoreData instance using the provided ClassMetaData and ClassLoaderResolver.voidprintInformation(String category, PrintStream ps) Method to output the information about the StoreManager.protected voidRegister the default ConnectionManager implementation.protected voidregisterStoreData(StoreData data) Method to register some data with the store.voidConvenience method to reset the schema generation properties to their initial creation values, effectively undoing a call to enableSchemaGeneration.booleansupportsQueryLanguage(String language) Accessor for whether this query language is supported.booleansupportsValueGenerationStrategy(String strategy) Accessor for whether this value strategy is supported.voidRemove all classes from the persistence model for the datastore.voidunmanageClass(ClassLoaderResolver clr, String className, boolean removeFromDatastore) Method to remove knowledge of the specified class from this StoreManager.booleanMethod to return whether the specified member should use a backed SCO wrapper.Methods inherited from class PropertyStore
getFrequentProperties, hasPropertyNotNull, setPropertyInternalMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface StoreManager
getConnectionDriverName, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionURL, getConnectionUserName, getDatastoreDate, getDefaultCatalogName, getDefaultSchemaName, getNativeQueryLanguage, getNucleusSequence, getQueryCacheKey, newQuery, newQuery, newQuery, transactionCommitted, transactionRolledBack, transactionStarted, usesBackedSCOWrappers
-
Field Details
-
storeManagerKey
Key for this StoreManager e.g "rdbms", "neo4j" -
nucleusContext
Nucleus Context. -
valueGenerationMgr
Manager for value generation. -
storeDataMgr
Manager for the data definition in the datastore. -
persistenceHandler
Persistence handler. -
flushProcess
The flush process appropriate for this datastore. -
queryMgr
Query Manager. Lazy initialised, so use getQueryManager() to access. -
schemaHandler
Schema handler. -
namingFactory
Naming factory. -
connectionMgr
ConnectionManager
-
-
Constructor Details
-
AbstractStoreManager
protected AbstractStoreManager(String key, ClassLoaderResolver clr, PersistenceNucleusContext nucleusContext, Map<String, Object> props) Constructor for a new StoreManager. Stores the basic information required for the datastore management.- Parameters:
key- Key for this StoreManagerclr- the ClassLoaderResolvernucleusContext- The corresponding nucleus context.props- Any properties controlling this datastore
-
-
Method Details
-
registerConnectionMgr
protected void registerConnectionMgr()Register the default ConnectionManager implementation. Having this in a separate method to allow overriding by store plugins if required. -
close
public void close()- Specified by:
closein interfaceStoreManager
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceStoreManager
-
getConnectionManager
Description copied from interface:StoreManagerAccessor for the connection manager for this store manager.- Specified by:
getConnectionManagerin interfaceStoreManager- Returns:
- connection manager
-
getConnectionPassword
Convenience accessor for the password to use for the connection. Will perform decryption if the persistence property "datanucleus.ConnectionPasswordDecrypter" has also been specified.- Specified by:
getConnectionPasswordin interfaceStoreManager- Returns:
- Password
-
isJdbcStore
public boolean isJdbcStore()Description copied from interface:StoreManagerReturns whether the datastore is a "JDBC datastore". If it is then the JDO spec needs to return a connection that implements java.sql.Connection. RDBMS is the only one that will return true from here (or certainly as we can foresee now).- Specified by:
isJdbcStorein interfaceStoreManager- Returns:
- Whether this is a JDBC datastore
-
getPersistenceHandler
- Specified by:
getPersistenceHandlerin interfaceStoreManager
-
getFlushProcess
- Specified by:
getFlushProcessin interfaceStoreManager
-
getQueryManager
- Specified by:
getQueryManagerin interfaceStoreManager
-
getSchemaHandler
- Specified by:
getSchemaHandlerin interfaceStoreManager
-
getNamingFactory
- Specified by:
getNamingFactoryin interfaceStoreManager
-
getNucleusConnection
Description copied from interface:StoreManagerMethod to return a connection to the user for the ExecutionContext. Typically provides a wrapper to the currently in-use ManagedConnection.- Specified by:
getNucleusConnectionin interfaceStoreManager- Parameters:
ec- execution context- Returns:
- The datastore Connection
-
getValueGenerationManager
Description copied from interface:StoreManagerAccessor for the ValueGenerationManager for generating field values.- Specified by:
getValueGenerationManagerin interfaceStoreManager- Returns:
- The ValueGenerationManager for this datastore
-
getApiAdapter
Description copied from interface:StoreManagerAccessor for the API adapter.- Specified by:
getApiAdapterin interfaceStoreManager- Returns:
- API adapter
-
getStoreManagerKey
Description copied from interface:StoreManagerAccessor for the key for this store manager.- Specified by:
getStoreManagerKeyin interfaceStoreManager- Returns:
- StoreManager key
-
getNucleusContext
Description copied from interface:StoreManagerAccessor for the context in which this StoreManager is running.- Specified by:
getNucleusContextin interfaceStoreManager- Returns:
- Returns the context.
-
getMetaDataManager
- Specified by:
getMetaDataManagerin interfaceStoreManager
-
getStoreDataForClass
- Specified by:
getStoreDataForClassin interfaceStoreManager
-
registerStoreData
Method to register some data with the store. This will also register the data with the starter process.- Parameters:
data- The StoreData to add
-
deregisterAllStoreData
protected void deregisterAllStoreData()Method to deregister all existing store data so that we are managing nothing. -
logConfiguration
protected void logConfiguration()Convenience method to log the configuration of this store manager. -
printInformation
Method to output the information about the StoreManager. Supports the category "DATASTORE".- Specified by:
printInformationin interfaceStoreManager- Parameters:
category- Category of informationps- PrintStream- Throws:
Exception- Thrown if an error occurs in the output process
-
managesClass
Description copied from interface:StoreManagerAccessor for whether the specified class is managed currently- Specified by:
managesClassin interfaceStoreManager- Parameters:
className- The name of the class- Returns:
- Whether it is managed
-
manageClasses
Description copied from interface:StoreManagerManage the specified classes. This 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.- Specified by:
manageClassesin interfaceStoreManager- Parameters:
clr- The ClassLoaderResolverclassNames- The class(es) to be managed
-
newStoreData
Instantiate a StoreData instance using the provided ClassMetaData and ClassLoaderResolver. Override this method if you want to instantiate a subclass of StoreData.- Parameters:
cmd- MetaData for the classclr- ClassLoader resolver- Returns:
- The StoreData
-
unmanageAllClasses
Description copied from interface:StoreManagerRemove all classes from the persistence model for the datastore. This empties the datastore of all datastore objects managed by us. All objects of types not managed are left untouched. In the case of RDBMS this means drop all tables for types managed by us.- Specified by:
unmanageAllClassesin interfaceStoreManager- Parameters:
clr- The ClassLoaderResolver
-
unmanageClass
Description copied from interface:StoreManagerMethod to remove knowledge of the specified class from this StoreManager. This can optionally also remove it from the datastore.- Specified by:
unmanageClassin interfaceStoreManager- Parameters:
clr- ClassLoader resolverclassName- Name of the classremoveFromDatastore- Whether to also remove it from the datastore (otherwise just from the StoreManager)
-
manageClassForIdentity
Description copied from interface:StoreManagerConvenience method to ensure that the class defined by the passed DatastoreId/SingleFieldId is managed by the store.- Specified by:
manageClassForIdentityin interfaceStoreManager- Parameters:
id- identityclr- ClassLoader resolver- Returns:
- The class name of the class associated to this identity
-
getExtent
Description copied from interface:StoreManagerInterface to getting an Extent for a class.- Specified by:
getExtentin interfaceStoreManager- Type Parameters:
T- Type of the extent- Parameters:
ec- execution contextc- The class requiring the Extentsubclasses- Whether to include subclasses of 'c'- Returns:
- The Extent.
-
getSupportedQueryLanguages
Description copied from interface:StoreManagerAccessor for the supported query languages.- Specified by:
getSupportedQueryLanguagesin interfaceStoreManager- Returns:
- The supported query languages
-
supportsQueryLanguage
Description copied from interface:StoreManagerAccessor for whether this query language is supported.- Specified by:
supportsQueryLanguagein interfaceStoreManager- Parameters:
language- The language- Returns:
- Whether it is supported.
-
getClassNameForObjectID
Description copied from interface:StoreManagerReturns the class corresponding to the given object identity. If the object is datastore-identity, return the PC class specified in the identity. If the object is single-field identity, 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 persistable class, return the class.- Specified by:
getClassNameForObjectIDin interfaceStoreManager- Parameters:
id- The identity of some object.clr- ClassLoader resolverec- execution context- Returns:
- For datastore identity, return the class of the corresponding object. For application identity, return the class of the corresponding object or null if object does not exist.
-
supportsValueGenerationStrategy
Accessor for whether this value strategy is supported.- Specified by:
supportsValueGenerationStrategyin interfaceStoreManager- Parameters:
strategy- The strategy- Returns:
- Whether it is supported.
-
isValueGenerationStrategyDatastoreAttributed
public boolean isValueGenerationStrategyDatastoreAttributed(AbstractClassMetaData cmd, int absFieldNumber) Convenience method to return whether the strategy used by the specified class/member is generated by the datastore (during a persist).- Specified by:
isValueGenerationStrategyDatastoreAttributedin interfaceStoreManager- Parameters:
cmd- Metadata for the classabsFieldNumber- Absolute field number for the field (or -1 if datastore id)- Returns:
- Whether the strategy is generated in the datastore
-
getValueGenerationStrategyValue
public Object getValueGenerationStrategyValue(ExecutionContext ec, AbstractClassMetaData cmd, AbstractMemberMetaData mmd) Description copied from interface:StoreManagerMethod to retrieve the value for a value generation strategy for a particular field or datastore-identity.- Specified by:
getValueGenerationStrategyValuein interfaceStoreManager- Parameters:
ec- execution contextcmd- AbstractClassMetaData for the classmmd- MetaData for the member when this is for a member (or null for datastore-identity)- Returns:
- The generated value
-
getValueGeneratorForMember
protected ValueGenerator getValueGeneratorForMember(ClassLoaderResolver clr, AbstractClassMetaData cmd, AbstractMemberMetaData mmd) -
getValueGenerationStrategyForNative
Method defining which value-strategy to use when the user specifies "native" on datastore-identity. This will return as follows- If your field is Numeric-based (or no jdbc-type) then chooses the first one that is supported of "identity", "sequence", "increment", otherwise exception.
- Otherwise your field is String-based then chooses "uuid-hex".
- Specified by:
getValueGenerationStrategyForNativein interfaceStoreManager- Parameters:
cmd- Class requiring the strategy- Returns:
- The strategy used when "native" is specified
-
getValueGenerationStrategyForNative
Method defining which value-strategy to use when the user specifies "native" on a member. This will return as follows- If your field is Numeric-based then chooses the first one that is supported of "identity", "sequence", "increment", otherwise exception.
- Otherwise your field is String-based then chooses "uuid-hex".
- Specified by:
getValueGenerationStrategyForNativein interfaceStoreManager- Parameters:
mmd- Member requiring the strategy- Returns:
- The strategy used when "native" is specified
-
getNextValueForValueGenerator
Accessor for the next value from the specified ValueGenerator. This implementation simply returns generator.next(). Any case where the generator requires datastore connections should override this method.- Parameters:
generator- The generatorec- execution context- Returns:
- The next value.
-
getPropertiesForValueGenerator
protected Properties getPropertiesForValueGenerator(AbstractClassMetaData cmd, int absoluteFieldNumber, ClassLoaderResolver clr, SequenceMetaData seqmd, TableGeneratorMetaData tablegenmd) Method to return the properties to pass to the generator for the specified field. Will define the following properties "class-name", "root-class-name", "field-name" (if for a field), "sequence-name", "key-initial-value", "key-cache-size", "sequence-table-name", "sequence-schema-name", "sequence-catalog-name", "sequence-name-column-name", "sequence-nextval-column-name". In addition any extension properties on the respective field or datastore-identity are also passed through as properties.- Parameters:
cmd- MetaData for the classabsoluteFieldNumber- Number of the field (-1 = datastore identity)clr- ClassLoader resolverseqmd- Any sequence metadatatablegenmd- Any table generator metadata- Returns:
- The properties to use for this field
-
addValueGenerationPropertiesForIncrement
protected void addValueGenerationPropertiesForIncrement(Properties properties, TableGeneratorMetaData tablegenmd) -
addValueGenerationPropertiesForSequence
protected void addValueGenerationPropertiesForSequence(Properties properties, SequenceMetaData seqmd) -
getSubClassesForClass
public Collection<String> getSubClassesForClass(String className, boolean includeDescendents, ClassLoaderResolver clr) Description copied from interface:StoreManagerUtility 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. The important difference is that this method will then register the subclass as required- Specified by:
getSubClassesForClassin interfaceStoreManager- Parameters:
className- Class for which we search for subclasses.includeDescendents- Whether to include subclasses of subclasses etcclr- The ClassLoaderResolver- Returns:
- Set of classes that are subclasses of the input class.
-
getSupportedOptions
Accessor for the supported options in string form. Typical values specified here are :-- ApplicationIdentity - if the datastore supports application identity
- DatastoreIdentity - if the datastore supports datastore identity
- ORM - if the datastore supports (some) ORM concepts
- TransactionIsolationLevel.read-committed - if supporting this txn isolation level
- TransactionIsolationLevel.read-uncommitted - if supporting this txn isolation level
- TransactionIsolationLevel.repeatable-read - if supporting this txn isolation level
- TransactionIsolationLevel.serializable - if supporting this txn isolation level
- TransactionIsolationLevel.snapshot - if supporting this txn isolation level
- Query.Cancel - if supporting cancelling of queries
- Query.Timeout - if supporting timeout of queries
- Specified by:
getSupportedOptionsin interfaceStoreManager- Returns:
- The supported options
-
hasProperty
Description copied from class:PropertyStoreAccessor for whether a particular property is defined (but may be null).- Specified by:
hasPropertyin interfaceStoreManager- Overrides:
hasPropertyin classPropertyStore- Parameters:
name- Property name- Returns:
- Whether the property is defined
-
getProperty
Description copied from class:PropertyStoreMethod to get the value of a property from the store.- Specified by:
getPropertyin interfaceStoreManager- Overrides:
getPropertyin classPropertyStore- Parameters:
name- Name of the property- Returns:
- Its value (or null)
-
getIntProperty
Description copied from class:PropertyStoreAccessor for the specified property as an int. If the specified property isn't found returns 0.- Specified by:
getIntPropertyin interfaceStoreManager- Overrides:
getIntPropertyin classPropertyStore- Parameters:
name- Name of the property- Returns:
- Int value for the property
-
getStringProperty
Description copied from class:PropertyStoreAccessor for the specified property as a String. If the specified property isn't found returns null.- Specified by:
getStringPropertyin interfaceStoreManager- Overrides:
getStringPropertyin classPropertyStore- Parameters:
name- Name of the property- Returns:
- String value for the property
-
getBooleanProperty
Description copied from class:PropertyStoreAccessor for the specified property as a boolean. If the specified property isn't found returns false.- Specified by:
getBooleanPropertyin interfaceStoreManager- Overrides:
getBooleanPropertyin classPropertyStore- Parameters:
name- Name of the property- Returns:
- Boolean value for the property
-
getBooleanProperty
Description copied from class:PropertyStoreAccessor for the specified property as a boolean.- Specified by:
getBooleanPropertyin interfaceStoreManager- Overrides:
getBooleanPropertyin classPropertyStore- Parameters:
name- Name of the propertyresultIfNotSet- The value to return if no value for the specified property is found.- Returns:
- Boolean value for the property
-
getBooleanObjectProperty
Description copied from class:PropertyStoreAccessor for the specified property as a Boolean. If the specified property isn't found returns false.- Specified by:
getBooleanObjectPropertyin interfaceStoreManager- Overrides:
getBooleanObjectPropertyin classPropertyStore- Parameters:
name- Name of the property- Returns:
- Boolean value for the property (or null if not present)
-
enableSchemaGeneration
public void enableSchemaGeneration()Description copied from interface:StoreManagerConvenience method to override the specified schema generation properties and enable schema generation.- Specified by:
enableSchemaGenerationin interfaceStoreManager
-
resetSchemaGeneration
public void resetSchemaGeneration()Description copied from interface:StoreManagerConvenience method to reset the schema generation properties to their initial creation values, effectively undoing a call to enableSchemaGeneration.- Specified by:
resetSchemaGenerationin interfaceStoreManager
-
useBackedSCOWrapperForMember
Description copied from interface:StoreManagerMethod to return whether the specified member should use a backed SCO wrapper.- Specified by:
useBackedSCOWrapperForMemberin interfaceStoreManager- Parameters:
mmd- Metadata for the memberec- ExecutionContext- Returns:
- Whether to use a back SCO wrapper (false means use a simple SCO wrapper).
-
getDefaultStateManagerClassName
- Specified by:
getDefaultStateManagerClassNamein interfaceStoreManager
-