Class MetaDataManagerImpl
- All Implemented Interfaces:
Serializable
,MetaDataManager
Metadata can be loaded into the MetaDataManager in two ways
- Load when required. When the persistence process needs a class it will ask for metadata, and we can go and find its metadata from XML/annotations.
- Load explicitly via API calls. This happens when handling persistence for a persistence-unit for example since we know what classes/mapping is involved. It is also the case with the enhancer where we know what classes to enhance so we load the metadata first
Acts as a registry of metadata so that metadata files don't need to be parsed multiple times. MetaData is stored as a FileMetaData, which contains PackageMetaData, which contains ClassMetaData, and so on. This maps exactly to the users model of their metadata. The users access point is getMetaDataForClass() which will check the known classes without metadata, then check the existing registered metdata, then check the valid locations for metdata files. This way, the metadata is managed from this single point.
Maintains a list of all classes that have been checked for MetaData and don't have any available. This avoids the needs to look up MetaData multiple times finding the same result. Currently this list is for all ClassMetaData objects keyed by the class name.
Users can register interest in knowing when metadata for classes are loaded by registering a listener using the addListener method. This will then notify the listener when metadata for any class is initialised. This provides the opportunity to reject the metadata where particular features are not supported. For example a StoreManager could register a listener where it doesn't support datastore identity and throw an InvalidMetaDataException. This would then filter back out to the user for the operation they invoked
MetaDataManager is intended to be thread-safe. All maps are ConcurrentHashMap to provide basic multithread usage. In addition all mutating methods make use of an update "lock" so that only one thread can update the metadata definition at any time.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private static class
Simple comparator that orders the implementations of an interface so that the initial implementations are first, and the subclasses later. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Whether we allow annotations metadata.protected boolean
Flag defining if we allow metadata load currently.protected boolean
Whether we allow ORM XML metadata.protected boolean
Whether we allow XML metadata.protected final AnnotationManager
Manager for annotations.protected Collection
<String> Cache of class names that are known to not have MetaData/annotations.protected Map
<String, Collection<AbstractClassMetaData>> Map of class metadata, keyed by the application-id object-id class name (not SingleField).protected Map
<String, AbstractClassMetaData> Map of ClassMetaData, keyed by the class name.protected Map
<String, AbstractClassMetaData> Map of ClassMetaData, keyed by the class discriminator name.protected Map
<String, AbstractClassMetaData> Map of ClassMetaData, keyed by the JPA "entity name".Cache of names of concrete subclass for a class name.protected boolean
Flag defining the default nullability for fields.Cache subclass information as that is expensive to compute, keyed by class nameprotected Map
<String, MetaDataManagerImpl.DiscriminatorLookup> protected Map
<String, FetchPlanMetaData> Map of FetchPlanMetaData, keyed by the fetch plan name.protected Map
<String, FileMetaData> Map of FileMetaData for the parsed files, keyed by the URL string.protected Set
<MetaDataListener> Listeners for metadata load.private List
<AbstractClassMetaData> Temporary list of class metadata loaded during the current call, for use with listeners.protected final NucleusContext
The NucleusContext that this metadata manager is operating in.protected Map
<String, QueryMetaData> Map of QueryMetaData, keyed by the (class name + query name).protected Map
<String, QueryResultMetaData> Map of QueryResultMetaData keyed by the name.protected Map
<String, SequenceMetaData> Map of SequenceMetaData, keyed by the package name and sequence name.private static final long
protected Map
<String, StoredProcQueryMetaData> Map of StoredProcQueryMetaData, keyed by the (class name + query name).protected boolean
Flag whether we should be (XML) namespace aware when parsing.protected Map
<String, TableGeneratorMetaData> Map of TableGeneratorMetaData, keyed by the package name and generator name.protected Lock
protected Map
<String, AbstractClassMetaData> protected int
Number of user metadata items.protected ArrayList
<FileMetaData> Temporary list of the FileMetaData objects utilised in this call for metadata.protected boolean
Flag whether we should validate the (XML) metadata files when parsing. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor, specifying the context used. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Method called (by AbstractClassMetaData.initialise()) when a class/interface has its metadata initialised.void
Load up and add any annotations mapping info for the specified class to the stored ClassMetaData.void
Load up and add any O/R mapping info for the specified class to the stored ClassMetaData (if supported).void
close()
void
deregisterListener
(MetaDataListener listener) Method to deregister a listener from being notified when metadata for a class/interface is initialised.String[]
getClassesImplementingInterface
(String interfaceName, ClassLoaderResolver clr) Accessor for the list of names of classes that are declared to implement the specified interface (using <implements> in the MetaData).Accessor for the names of the classes with MetaData currently registered with this manager.protected ClassMetaData
getClassMetaDataForImplementationOfPersistentInterface
(String interfaceName) Accessor for the metadata for the implementation of the specified "persistent-interface".getClassMetaDataWithApplicationId
(String objectIdClassName) Accessor for the metadata for the class(es) with the specified object-id class name as PK.getClassNameForDiscriminatorValueWithRoot
(AbstractClassMetaData rootCmd, String discrimValue) Method to return the class name that uses the provided discriminator value using the specified root class to search from.getClassNameFromDiscriminatorValue
(String discrimValue, DiscriminatorMetaData dismd) Method to return the class name that uses the specified discriminator value for the specified discriminator.String[]
getConcreteSubclassesForClass
(String className) Accessor for the names of all concrete subclasses of the provided class.Method to return the discriminator value used by the specified class.Method to return the prefix applied to all enhancer method namesAccessor for all FileMetaData currently managed here.getImplementationNameForPersistentInterface
(String interfaceName) Accessor for the implementation name for the specified "persistent-interface".Primary accessor for the MetaData for a class.getMetaDataForClass
(String className, ClassLoaderResolver clr) Accessor for the MetaData for a class given the name and a loader.Internal convenience method for accessing the MetaData for a class.getMetaDataForDiscriminator
(String discriminator) Accessor for the MetaData for a class given the "discriminator".getMetaDataForEntityName
(String entityName) Accessor for the MetaData for a class given the "entity-name".Accessor for the MetaData for a named fetch plan.getMetaDataForImplementationOfReference
(Class referenceClass, Object implValue, ClassLoaderResolver clr) Accessor for the MetaData for an implementation of a reference type.Accessor for the MetaData for an interface.getMetaDataForQuery
(Class cls, ClassLoaderResolver clr, String queryName) Accessor for the MetaData for a named query for a class.Accessor for the MetaData for a QueryResult.getMetaDataForSequence
(ClassLoaderResolver clr, String seqName) Accessor for the MetaData for a Sequence in a package.getMetaDataForStoredProcQuery
(Class cls, ClassLoaderResolver clr, String queryName) Accessor for the MetaData for a named stored procedure query for a class.getMetaDataForTableGenerator
(ClassLoaderResolver clr, String genName) Accessor for the MetaData for a TableGenerator in a package.Convenience method to access the names of named queries that are registered with this manager.getReferencedClasses
(String[] classNames, ClassLoaderResolver clr) Convenience method to get the MetaData for all referenced classes with the passed set of classes as root.protected List
<AbstractClassMetaData> Utility to return all ClassMetaData that is referenced from the supplier class.protected MetaDataScanner
Accessor for any scanner for metadata classes (optional).String[]
getSubclassesForClass
(String className, boolean includeDescendents) Accessor for the subclasses of a particular classboolean
hasMetaDataForClass
(String className) Convenience method to check if we have metadata present for the specified class.protected void
Convenience method to initialise the MetaData for the specified class/interface.protected void
initialiseClassMetaData
(ClassMetaData cmd, Class cls, ClassLoaderResolver clr) Utility to initialise the MetaData for a class, using the specified class.protected void
initialiseFileMetaData
(FileMetaData filemd, ClassLoaderResolver clr, ClassLoader primary) Initialise all classes/interfaces in a Meta-Data file.protected void
initialiseFileMetaDataForUse
(Collection<FileMetaData> fileMetaData, ClassLoaderResolver clr) Method to initialise the provided FileMetaData, ready for use.protected void
initialiseInterfaceMetaData
(InterfaceMetaData imd, ClassLoaderResolver clr, ClassLoader primary) Utility to initialise the MetaData for a interface, using the specified class.boolean
isClassPersistable
(String className) Convenience method to return if the specified class is a known persistable class.protected boolean
isClassWithoutPersistenceInfo
(String className) Accessor for whether a class doesn't have MetaData or annotations.boolean
Acessor for the default nullability of fields.boolean
isEnhancerField
(String fieldName) Method to return whether the specified member is an enhancer-provided member.boolean
Accessor for whether we are managing the enhancement process.boolean
isFieldTypePersistable
(Class type) Utility to return if this field is of a persistable type.boolean
isPersistentInterface
(String name) Convenience method to return if the passed class name is a "persistent-interface".boolean
isPersistentInterfaceImplementation
(String interfaceName, String implName) Convenience method to return if the passed class name is an implementation of the passed "persistent-interface".protected FileMetaData
loadAnnotationsForClass
(Class cls, ClassLoaderResolver clr, boolean register, boolean populate) Method to load the annotations for the specified class and return the FileMetaData containing the class.loadClasses
(String[] classNames, ClassLoader loader) Initialisation method to load up all metadata for the specified classes.loadFiles
(String[] metadataFiles, ClassLoaderResolver clr) Method to load the metadata from the specified files.loadJar
(String jarFileName, ClassLoader loader) Initialisation method to load the metadata provided by the specified jar.loadMetaDataFiles
(String[] metadataFiles, ClassLoader loader) Initialisation method to load up all metadata defined by the specified metadata files.protected abstract AbstractClassMetaData
Load the metadata for the specified class (if available).loadPersistenceUnit
(PersistenceUnitMetaData pumd, ClassLoader loader) Initialisation method to to load all class metadata defined by the "persistence-unit".void
loadUserMetaData
(FileMetaData fileMetaData, ClassLoader loader) Method to load user-provided (dynamic) metadata (from the JDO MetaData API).protected abstract FileMetaData
parseXmlFile
(URL fileURL) Utility to parse an XML metadata file.protected boolean
populateAbstractClassMetaData
(AbstractClassMetaData cmd, ClassLoaderResolver clr, ClassLoader loader) Convenience method to populate the MetaData for the specified class/interface.protected void
populateFileMetaData
(FileMetaData filemd, ClassLoaderResolver clr, ClassLoader primary) Convenience method to populate all classes/interfaces in a Meta-Data file.protected void
Method that will perform any necessary post-processing on metadata.protected void
private void
provideSubclassesForClass
(String className, boolean includeDescendents, Collection<String> consumer) Provide the subclasses of a particular class to a givenconsumer
readMetaDataForClass
(String className) Method to access the (already known) metadata for the specified class.readMetaDataForMember
(String className, String memberName) Method to access the (already known) metadata for the field/property of the specified class.void
registerDiscriminatorValueForClass
(AbstractClassMetaData cmd, String discrimValue) Convenience method to register the discriminator value used by the specified class for easy lookup.protected void
Convenience method to register all FetchPlans found in the passed file.abstract void
registerFile
(String fileURLString, FileMetaData filemd, ClassLoaderResolver clr) Method to take the FileMetaData and register the relevant parts of it with the assorted caches provided.void
registerImplementationOfAbstractClass
(ClassMetaData cmd, Class implClass, ClassLoaderResolver clr) Method to register the metadata for an implementation of a persistent abstract class.void
registerListener
(MetaDataListener listener) Method to register a listener to be notified when metadata for a class/interface is initialised.protected void
registerMetaDataForClass
(String fullClassName, AbstractClassMetaData cmd) Internal method called when we want to register the metadata for a class/interface.void
Convenience method to register a query under a name.void
registerPersistentInterface
(InterfaceMetaData imd, Class implClass, ClassLoaderResolver clr) Method to register a persistent interface and its implementation with the MetaData system.protected void
registerQueriesForFile
(FileMetaData filemd) Convenience method to register all queries found in the passed file.protected void
Convenience method to register the query result metadata for the provided file.void
registerSequencesForFile
(FileMetaData filemd) Convenience method to register all sequences found in the passed file.protected void
Convenience method to register all stored proc queries found in the passed file.void
Convenience method to register all table generators found in the passed file.void
setAllowAnnotations
(boolean allow) void
setAllowMetaDataLoad
(boolean allow) void
setAllowXML
(boolean allow) void
setDefaultNullable
(boolean defaultNullable) void
setValidate
(boolean validate) Mutator for whether to validate the MetaData files for XML compliance.void
setXmlNamespaceAware
(boolean aware) Mutator for whether to support XML namespaces.boolean
Accessor for whether the MetaData manager supports ORM concepts and metadata.void
unloadMetaDataForClass
(String className) Convenience method to allow the unloading of metadata, for example where the user wants to reload a class definition and that class maybe has different metadata with the new definition.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
nucleusContext
The NucleusContext that this metadata manager is operating in. -
annotationManager
Manager for annotations. -
validateXML
protected boolean validateXMLFlag whether we should validate the (XML) metadata files when parsing. -
supportXMLNamespaces
protected boolean supportXMLNamespacesFlag whether we should be (XML) namespace aware when parsing. -
allowMetaDataLoad
protected boolean allowMetaDataLoadFlag defining if we allow metadata load currently. If false then we only allow access to currently loaded metadata. -
allowXML
protected boolean allowXMLWhether we allow XML metadata. -
allowAnnotations
protected boolean allowAnnotationsWhether we allow annotations metadata. -
allowORM
protected boolean allowORMWhether we allow ORM XML metadata. -
defaultNullable
protected boolean defaultNullableFlag defining the default nullability for fields. -
updateLock
-
classesWithoutPersistenceInfo
Cache of class names that are known to not have MetaData/annotations. -
classMetaDataByClass
Map of ClassMetaData, keyed by the class name. -
usableClassMetaDataByClass
-
fileMetaDataByURLString
Map of FileMetaData for the parsed files, keyed by the URL string. -
classMetaDataByEntityName
Map of ClassMetaData, keyed by the JPA "entity name". -
classMetaDataByDiscriminatorName
Map of ClassMetaData, keyed by the class discriminator name. -
directSubclassesByClass
Cache subclass information as that is expensive to compute, keyed by class name -
concreteSubclassNamesByClassName
Cache of names of concrete subclass for a class name. Used for fast lookups from ids. -
queryMetaDataByName
Map of QueryMetaData, keyed by the (class name + query name). -
storedProcQueryMetaDataByName
Map of StoredProcQueryMetaData, keyed by the (class name + query name). -
fetchPlanMetaDataByName
Map of FetchPlanMetaData, keyed by the fetch plan name. -
sequenceMetaDataByPackageSequence
Map of SequenceMetaData, keyed by the package name and sequence name. -
tableGeneratorMetaDataByPackageSequence
Map of TableGeneratorMetaData, keyed by the package name and generator name. -
queryResultMetaDataByName
Map of QueryResultMetaData keyed by the name. -
classMetaDataByAppIdClassName
Map of class metadata, keyed by the application-id object-id class name (not SingleField). -
listeners
Listeners for metadata load. -
listenersLoadedMetaData
Temporary list of class metadata loaded during the current call, for use with listeners. -
userMetaDataNumber
protected int userMetaDataNumberNumber of user metadata items. -
discriminatorLookupByRootClassName
-
utilisedFileMetaData
Temporary list of the FileMetaData objects utilised in this call for metadata.
-
-
Constructor Details
-
MetaDataManagerImpl
Constructor, specifying the context used.- Parameters:
ctx
- context that this metadata manager operates in
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceMetaDataManager
-
registerListener
Description copied from interface:MetaDataManager
Method to register a listener to be notified when metadata for a class/interface is initialised.- Specified by:
registerListener
in interfaceMetaDataManager
- Parameters:
listener
- The listener
-
deregisterListener
Description copied from interface:MetaDataManager
Method to deregister a listener from being notified when metadata for a class/interface is initialised.- Specified by:
deregisterListener
in interfaceMetaDataManager
- Parameters:
listener
- The listener
-
getEnhancedMethodNamePrefix
Description copied from interface:MetaDataManager
Method to return the prefix applied to all enhancer method names- Specified by:
getEnhancedMethodNamePrefix
in interfaceMetaDataManager
- Returns:
- The enhancer method name prefix (e.g "dn")
-
isEnhancerField
Description copied from interface:MetaDataManager
Method to return whether the specified member is an enhancer-provided member.- Specified by:
isEnhancerField
in interfaceMetaDataManager
- Parameters:
fieldName
- Name of the member- Returns:
- Whether it was added by the enhancer (e.g prefix "dn")
-
setAllowMetaDataLoad
public void setAllowMetaDataLoad(boolean allow) - Specified by:
setAllowMetaDataLoad
in interfaceMetaDataManager
-
setAllowXML
public void setAllowXML(boolean allow) - Specified by:
setAllowXML
in interfaceMetaDataManager
-
setDefaultNullable
public void setDefaultNullable(boolean defaultNullable) - Specified by:
setDefaultNullable
in interfaceMetaDataManager
-
setAllowAnnotations
public void setAllowAnnotations(boolean allow) - Specified by:
setAllowAnnotations
in interfaceMetaDataManager
-
supportsORM
public boolean supportsORM()Description copied from interface:MetaDataManager
Accessor for whether the MetaData manager supports ORM concepts and metadata. With object datastores this will return false.- Specified by:
supportsORM
in interfaceMetaDataManager
- Returns:
- Whether we support ORM
-
isDefaultNullable
public boolean isDefaultNullable()Description copied from interface:MetaDataManager
Acessor for the default nullability of fields.- Specified by:
isDefaultNullable
in interfaceMetaDataManager
- Returns:
- true if fields should be null by default and false whether it should be not-null.
-
isEnhancing
public boolean isEnhancing()Description copied from interface:MetaDataManager
Accessor for whether we are managing the enhancement process.- Specified by:
isEnhancing
in interfaceMetaDataManager
- Returns:
- Whether we are enhancing
-
setValidate
public void setValidate(boolean validate) Description copied from interface:MetaDataManager
Mutator for whether to validate the MetaData files for XML compliance.- Specified by:
setValidate
in interfaceMetaDataManager
- Parameters:
validate
- Whether to validate
-
setXmlNamespaceAware
public void setXmlNamespaceAware(boolean aware) Description copied from interface:MetaDataManager
Mutator for whether to support XML namespaces.- Specified by:
setXmlNamespaceAware
in interfaceMetaDataManager
- Parameters:
aware
- Whether to be XML namespace aware
-
getNucleusContext
- Specified by:
getNucleusContext
in interfaceMetaDataManager
-
getApiAdapter
- Specified by:
getApiAdapter
in interfaceMetaDataManager
-
getAnnotationManager
- Specified by:
getAnnotationManager
in interfaceMetaDataManager
-
loadMetaDataFiles
Description copied from interface:MetaDataManager
Initialisation method to load up all metadata defined by the specified metadata files. Metadata files can be absolute/relative filenames, or can be resources in the CLASSPATH.- Specified by:
loadMetaDataFiles
in interfaceMetaDataManager
- Parameters:
metadataFiles
- The metadata filesloader
- ClassLoader to use in loading the metadata (if any)- Returns:
- Array of the FileMetaData that is managed
-
loadClasses
Description copied from interface:MetaDataManager
Initialisation method to load up all metadata for the specified classes.- Specified by:
loadClasses
in interfaceMetaDataManager
- Parameters:
classNames
- The class namesloader
- ClassLoader to use in loading the classes (if any)- Returns:
- Array of the FileMetaData that is managed
-
loadJar
Description copied from interface:MetaDataManager
Initialisation method to load the metadata provided by the specified jar.- Specified by:
loadJar
in interfaceMetaDataManager
- Parameters:
jarFileName
- Name of the jar fileloader
- ClassLoader to use in loading of the jar (if any)- Returns:
- Array of the FileMetaData that is managed
-
loadPersistenceUnit
Description copied from interface:MetaDataManager
Initialisation method to to load all class metadata defined by the "persistence-unit".- Specified by:
loadPersistenceUnit
in interfaceMetaDataManager
- Parameters:
pumd
- The MetaData for this "persistence-unit"loader
- ClassLoader to use in loading of the persistence unit (if any)- Returns:
- Array of the FileMetaData that is managed
-
loadUserMetaData
Description copied from interface:MetaDataManager
Method to load user-provided (dynamic) metadata (from the JDO MetaData API).- Specified by:
loadUserMetaData
in interfaceMetaDataManager
- Parameters:
fileMetaData
- FileMetaData to register/populate/initialiseloader
- ClassLoader to use in loading the metadata (if any)
-
loadMetaDataForClass
Load the metadata for the specified class (if available).- Parameters:
c
- The classclr
- ClassLoader resolver- Returns:
- The metadata for this class (if found)
-
unloadMetaDataForClass
Description copied from interface:MetaDataManager
Convenience method to allow the unloading of metadata, for example where the user wants to reload a class definition and that class maybe has different metadata with the new definition.- Specified by:
unloadMetaDataForClass
in interfaceMetaDataManager
- Parameters:
className
- Name of the class
-
getScanner
Accessor for any scanner for metadata classes (optional). Looks for the persistence property "datanucleus.metadata.scanner" (if defined)- Parameters:
clr
- The classloader resolver- Returns:
- scanner instance or null if it doesn't exist or cannot be instantiated
-
initialiseFileMetaDataForUse
protected void initialiseFileMetaDataForUse(Collection<FileMetaData> fileMetaData, ClassLoaderResolver clr) Method to initialise the provided FileMetaData, ready for use.- Parameters:
fileMetaData
- Collection of FileMetaDataclr
- ClassLoader resolver- Throws:
NucleusUserException
- thrown if an error occurs during the populate/initialise of the supplied metadata.
-
loadFiles
Description copied from interface:MetaDataManager
Method to load the metadata from the specified files. Supports absolute/relative file names, or CLASSPATH resources.- Specified by:
loadFiles
in interfaceMetaDataManager
- Parameters:
metadataFiles
- array of MetaData filesclr
- ClassLoader resolver- Returns:
- List of FileMetaData
-
isClassPersistable
Description copied from interface:MetaDataManager
Convenience method to return if the specified class is a known persistable class.- Specified by:
isClassPersistable
in interfaceMetaDataManager
- Parameters:
className
- Name of the class- Returns:
- Whether it is persistable
-
getFileMetaData
Description copied from interface:MetaDataManager
Accessor for all FileMetaData currently managed here.- Specified by:
getFileMetaData
in interfaceMetaDataManager
- Returns:
- FileMetaData managed here currently
-
getClassesWithMetaData
Description copied from interface:MetaDataManager
Accessor for the names of the classes with MetaData currently registered with this manager.- Specified by:
getClassesWithMetaData
in interfaceMetaDataManager
- Returns:
- Names of classes with MetaData
-
hasMetaDataForClass
Description copied from interface:MetaDataManager
Convenience method to check if we have metadata present for the specified class.- Specified by:
hasMetaDataForClass
in interfaceMetaDataManager
- Parameters:
className
- The name of the class to check- Returns:
- Whether the metadata is already registered for this class
-
isClassWithoutPersistenceInfo
Accessor for whether a class doesn't have MetaData or annotations.- Parameters:
className
- Name of the class- Returns:
- Whether it has no metadata and annotations
-
getClassMetaDataWithApplicationId
public Collection<AbstractClassMetaData> getClassMetaDataWithApplicationId(String objectIdClassName) Description copied from interface:MetaDataManager
Accessor for the metadata for the class(es) with the specified object-id class name as PK. This only works for user-provided object-id classes (not SingleFieldIdentity).- Specified by:
getClassMetaDataWithApplicationId
in interfaceMetaDataManager
- Parameters:
objectIdClassName
- The object-id class name- Returns:
- Collection of AbstractClassMetaData for the classes using this PK
-
getMetaDataForClass
Description copied from interface:MetaDataManager
Accessor for the MetaData for a class given the name and a loader. All MetaData returned from this method will be initialised and ready for full use. If the class can't be loaded, null will be returned.- Specified by:
getMetaDataForClass
in interfaceMetaDataManager
- Parameters:
className
- Name of the class to find MetaData forclr
- ClassLoaderResolver resolver for use in loading the class.- Returns:
- The ClassMetaData for this class (or null if not found)
-
getMetaDataForClass
Description copied from interface:MetaDataManager
Primary accessor for the MetaData for a class. All MetaData returned from this method will be initialised and ready for full use.- Specified by:
getMetaDataForClass
in interfaceMetaDataManager
- Parameters:
c
- The class to find MetaData forclr
- the ClassLoaderResolver- Returns:
- The ClassMetaData for this class (or null if not found)
-
processListenerLoadingCall
protected void processListenerLoadingCall() -
getMetaDataForEntityName
Description copied from interface:MetaDataManager
Accessor for the MetaData for a class given the "entity-name".- Specified by:
getMetaDataForEntityName
in interfaceMetaDataManager
- Parameters:
entityName
- The entity name to find MetaData for- Returns:
- The ClassMetaData for this entity name (or null if not found)
-
getMetaDataForDiscriminator
Description copied from interface:MetaDataManager
Accessor for the MetaData for a class given the "discriminator".- Specified by:
getMetaDataForDiscriminator
in interfaceMetaDataManager
- Parameters:
discriminator
- The discriminator name to find MetaData for- Returns:
- The ClassMetaData for this discriminator (or null if not found)
-
readMetaDataForClass
Description copied from interface:MetaDataManager
Method to access the (already known) metadata for the specified class. If the class is not yet known about it returns null. Only used by org.datanucleus.metadata classes.- Specified by:
readMetaDataForClass
in interfaceMetaDataManager
- Parameters:
className
- Name of the class- Returns:
- MetaData for the class
-
readMetaDataForMember
Description copied from interface:MetaDataManager
Method to access the (already known) metadata for the field/property of the specified class. If the class (or this field/property) is not yet known about it returns null. Only used by org.datanucleus.metadata classes.- Specified by:
readMetaDataForMember
in interfaceMetaDataManager
- Parameters:
className
- Name of the classmemberName
- Name of the field/property- Returns:
- MetaData for the field/property
-
getMetaDataForClassInternal
Description copied from interface:MetaDataManager
Internal convenience method for accessing the MetaData for a class. MetaData returned by this method may be uninitialised so should only really be used in initialisation processes. To be implemented by the implementing class.- Specified by:
getMetaDataForClassInternal
in interfaceMetaDataManager
- Parameters:
c
- The class to find MetaData forclr
- ClassLoader resolver- Returns:
- The ClassMetaData for this class (or null if not found)
-
registerMetaDataForClass
Internal method called when we want to register the metadata for a class/interface.- Parameters:
fullClassName
- Name of the classcmd
- The metadata
-
getClassesImplementingInterface
Description copied from interface:MetaDataManager
Accessor for the list of names of classes that are declared to implement the specified interface (using <implements> in the MetaData). This will include subclasses of declared classes. Ignore abstract classes. The array of implementation class names will have the initial implementations first followed by the subclass implementations etc. So for example if we look for all implementations of I and A implements I and B extends A, then it will return [A, B] in that order.- Specified by:
getClassesImplementingInterface
in interfaceMetaDataManager
- Parameters:
interfaceName
- Name of the interfaceclr
- The ClassLoaderResolver- Returns:
- The names of the classes declared as implementing that interface. return null if no classes
-
addORMDataToClass
Description copied from interface:MetaDataManager
Load up and add any O/R mapping info for the specified class to the stored ClassMetaData (if supported). Only to be invoked by ClassMetaData, InterfaceMetaData.- Specified by:
addORMDataToClass
in interfaceMetaDataManager
- Parameters:
c
- The classclr
- ClassLoader resolver
-
addAnnotationsDataToClass
Description copied from interface:MetaDataManager
Load up and add any annotations mapping info for the specified class to the stored ClassMetaData. Only to be invoked by ClassMetaData, InterfaceMetaData.- Specified by:
addAnnotationsDataToClass
in interfaceMetaDataManager
- Parameters:
c
- The classcmd
- the metadata to add annotation toclr
- ClassLoader resolver
-
getMetaDataForImplementationOfReference
public ClassMetaData getMetaDataForImplementationOfReference(Class referenceClass, Object implValue, ClassLoaderResolver clr) Description copied from interface:MetaDataManager
Accessor for the MetaData for an implementation of a reference type. Finds the metadata for the implementation of this reference.- Specified by:
getMetaDataForImplementationOfReference
in interfaceMetaDataManager
- Parameters:
referenceClass
- The reference class to find MetaData forimplValue
- Object of an implementation class, to return if possible (null=ignore)clr
- ClassLoader resolver- Returns:
- The ClassMetaData for an implementation of a reference type
-
getMetaDataForQuery
Description copied from interface:MetaDataManager
Accessor for the MetaData for a named query for a class. If the class is not specified, searches for the query with this name for any class. Will only return metadata for queries already registered in this implementation.- Specified by:
getMetaDataForQuery
in interfaceMetaDataManager
- Parameters:
cls
- The class which has the query defined for itclr
- the ClassLoaderResolverqueryName
- Name of the query- Returns:
- The QueryMetaData for the query for this class
-
getNamedQueryNames
Description copied from interface:MetaDataManager
Convenience method to access the names of named queries that are registered with this manager.- Specified by:
getNamedQueryNames
in interfaceMetaDataManager
- Returns:
- Names of the named queries
-
getMetaDataForStoredProcQuery
public StoredProcQueryMetaData getMetaDataForStoredProcQuery(Class cls, ClassLoaderResolver clr, String queryName) Description copied from interface:MetaDataManager
Accessor for the MetaData for a named stored procedure query for a class. If the class is not specified, searches for the query with this name for any class. Will only return metadata for queries already registered in this implementation.- Specified by:
getMetaDataForStoredProcQuery
in interfaceMetaDataManager
- Parameters:
cls
- The class which has the query defined for itclr
- the ClassLoaderResolverqueryName
- Name of the (stored proc) query- Returns:
- The StoredProcQueryMetaData for the query for this class
-
getMetaDataForFetchPlan
Description copied from interface:MetaDataManager
Accessor for the MetaData for a named fetch plan.- Specified by:
getMetaDataForFetchPlan
in interfaceMetaDataManager
- Parameters:
name
- Name of the fetch plan- Returns:
- The FetchPlanMetaData for this name (if any)
-
getMetaDataForSequence
Description copied from interface:MetaDataManager
Accessor for the MetaData for a Sequence in a package. This implementation simply checks what is already loaded and returns if found- Specified by:
getMetaDataForSequence
in interfaceMetaDataManager
- Parameters:
clr
- the ClassLoaderResolverseqName
- Name of the package (fully qualified if necessary)- Returns:
- The SequenceMetaData for this named sequence
-
getMetaDataForTableGenerator
Description copied from interface:MetaDataManager
Accessor for the MetaData for a TableGenerator in a package. This implementation simply checks what is already loaded and returns if found- Specified by:
getMetaDataForTableGenerator
in interfaceMetaDataManager
- Parameters:
clr
- the ClassLoaderResolvergenName
- Name of the package (fully qualified if necessary)- Returns:
- The TableGenerator for this named generator
-
getMetaDataForQueryResult
Description copied from interface:MetaDataManager
Accessor for the MetaData for a QueryResult.- Specified by:
getMetaDataForQueryResult
in interfaceMetaDataManager
- Parameters:
name
- Name of the query result- Returns:
- The QueryResultMetaData under this name
-
getMetaDataForInterface
Description copied from interface:MetaDataManager
Accessor for the MetaData for an interface. Part of the support for "persistent-interface". This defaults to returning null since interfaces are only supported by JDO.- Specified by:
getMetaDataForInterface
in interfaceMetaDataManager
- Parameters:
c
- The interface to find MetaData forclr
- the ClassLoaderResolver- Returns:
- The InterfaceMetaData for this interface (or null if not found)
-
isPersistentInterface
Description copied from interface:MetaDataManager
Convenience method to return if the passed class name is a "persistent-interface".- Specified by:
isPersistentInterface
in interfaceMetaDataManager
- Parameters:
name
- Name if the interface- Returns:
- Whether it is a "persistent-interface"
-
isPersistentInterfaceImplementation
Description copied from interface:MetaDataManager
Convenience method to return if the passed class name is an implementation of the passed "persistent-interface".- Specified by:
isPersistentInterfaceImplementation
in interfaceMetaDataManager
- Parameters:
interfaceName
- Name of the persistent interfaceimplName
- The implementation name- Returns:
- Whether it is a (DataNucleus-generated) impl of the persistent interface
-
getImplementationNameForPersistentInterface
Description copied from interface:MetaDataManager
Accessor for the implementation name for the specified "persistent-interface".- Specified by:
getImplementationNameForPersistentInterface
in interfaceMetaDataManager
- Parameters:
interfaceName
- The name of the persistent interface- Returns:
- The name of the implementation class
-
getClassMetaDataForImplementationOfPersistentInterface
protected ClassMetaData getClassMetaDataForImplementationOfPersistentInterface(String interfaceName) Accessor for the metadata for the implementation of the specified "persistent-interface".- Parameters:
interfaceName
- The name of the persistent interface- Returns:
- The ClassMetaData of the implementation class
-
registerPersistentInterface
public void registerPersistentInterface(InterfaceMetaData imd, Class implClass, ClassLoaderResolver clr) Description copied from interface:MetaDataManager
Method to register a persistent interface and its implementation with the MetaData system. This is called by the JDO ImplementationCreator.- Specified by:
registerPersistentInterface
in interfaceMetaDataManager
- Parameters:
imd
- MetaData for the interfaceimplClass
- The implementation classclr
- ClassLoader Resolver to use
-
registerImplementationOfAbstractClass
public void registerImplementationOfAbstractClass(ClassMetaData cmd, Class implClass, ClassLoaderResolver clr) Description copied from interface:MetaDataManager
Method to register the metadata for an implementation of a persistent abstract class. This is called by the JDO ImplementationCreator.- Specified by:
registerImplementationOfAbstractClass
in interfaceMetaDataManager
- Parameters:
cmd
- MetaData for the abstract classimplClass
- The implementation classclr
- ClassLoader resolver
-
parseXmlFile
Utility to parse an XML metadata file.- Parameters:
fileURL
- URL of the file- Returns:
- The FileMetaData for this file
-
registerFile
public abstract void registerFile(String fileURLString, FileMetaData filemd, ClassLoaderResolver clr) Description copied from interface:MetaDataManager
Method to take the FileMetaData and register the relevant parts of it with the assorted caches provided. Note : this is only public to allow enhancer tests to load up metadata manually.- Specified by:
registerFile
in interfaceMetaDataManager
- Parameters:
fileURLString
- URL of the metadata filefilemd
- The File MetaDataclr
- ClassLoader resolver
-
registerDiscriminatorValueForClass
Description copied from interface:MetaDataManager
Convenience method to register the discriminator value used by the specified class for easy lookup.- Specified by:
registerDiscriminatorValueForClass
in interfaceMetaDataManager
- Parameters:
cmd
- Metadata for the classdiscrimValue
- The discriminator value
-
getClassNameForDiscriminatorValueWithRoot
public String getClassNameForDiscriminatorValueWithRoot(AbstractClassMetaData rootCmd, String discrimValue) Description copied from interface:MetaDataManager
Method to return the class name that uses the provided discriminator value using the specified root class to search from.- Specified by:
getClassNameForDiscriminatorValueWithRoot
in interfaceMetaDataManager
- Parameters:
rootCmd
- The root classdiscrimValue
- The discriminator value- Returns:
- The class using this value
-
getDiscriminatorValueForClass
Description copied from interface:MetaDataManager
Method to return the discriminator value used by the specified class.- Specified by:
getDiscriminatorValueForClass
in interfaceMetaDataManager
- Parameters:
cmd
- Class to search for- Returns:
- The discriminator value used by this class
-
getClassNameFromDiscriminatorValue
Description copied from interface:MetaDataManager
Method to return the class name that uses the specified discriminator value for the specified discriminator.- Specified by:
getClassNameFromDiscriminatorValue
in interfaceMetaDataManager
- Parameters:
discrimValue
- Discriminator valuedismd
- The discriminator metadata- Returns:
- The class name (or null if not found)
-
registerSequencesForFile
Description copied from interface:MetaDataManager
Convenience method to register all sequences found in the passed file.- Specified by:
registerSequencesForFile
in interfaceMetaDataManager
- Parameters:
filemd
- MetaData for the file
-
registerTableGeneratorsForFile
Description copied from interface:MetaDataManager
Convenience method to register all table generators found in the passed file.- Specified by:
registerTableGeneratorsForFile
in interfaceMetaDataManager
- Parameters:
filemd
- MetaData for the file
-
registerQueryResultMetaDataForFile
Convenience method to register the query result metadata for the provided file.- Parameters:
filemd
- MetaData for the file
-
registerNamedQuery
Convenience method to register a query under a name.- Specified by:
registerNamedQuery
in interfaceMetaDataManager
- Parameters:
qmd
- Query metadata
-
registerQueriesForFile
Convenience method to register all queries found in the passed file.- Parameters:
filemd
- MetaData for the file
-
registerStoredProcQueriesForFile
Convenience method to register all stored proc queries found in the passed file.- Parameters:
filemd
- MetaData for the file
-
registerFetchPlansForFile
Convenience method to register all FetchPlans found in the passed file.- Parameters:
filemd
- MetaData for the file
-
populateFileMetaData
protected void populateFileMetaData(FileMetaData filemd, ClassLoaderResolver clr, ClassLoader primary) Convenience method to populate all classes/interfaces in a Meta-Data file.- Parameters:
filemd
- The MetaData fileclr
- Class Loader to use in populationprimary
- the primary ClassLoader to use (or null)
-
initialiseFileMetaData
protected void initialiseFileMetaData(FileMetaData filemd, ClassLoaderResolver clr, ClassLoader primary) Initialise all classes/interfaces in a Meta-Data file.- Parameters:
filemd
- the FileMetaDataclr
- ClassLoader resolver to useprimary
- the primary ClassLoader to use (or null)
-
initialiseClassMetaData
Utility to initialise the MetaData for a class, using the specified class. This assigns defaults to tags that haven't been assigned. If the class that is being used to populate the MetaData is not enhanced, this will throw a NucleusUserException informing them of this.- Parameters:
cmd
- The classes metadatacls
- The class to use as a basis for initialisationclr
- ClassLoader resolver to use- Throws:
NucleusUserException
- if the class is not enhanced
-
initialiseInterfaceMetaData
protected void initialiseInterfaceMetaData(InterfaceMetaData imd, ClassLoaderResolver clr, ClassLoader primary) Utility to initialise the MetaData for a interface, using the specified class. This assigns defaults to tags that haven't been assigned. If the class that is being used to populate the MetaData is not enhanced, this will throw a NucleusUserException informing them of this.- Parameters:
imd
- The interface metadataclr
- The loader of the interfaceprimary
- the primary ClassLoader to use (or null)
-
loadAnnotationsForClass
protected FileMetaData loadAnnotationsForClass(Class cls, ClassLoaderResolver clr, boolean register, boolean populate) Method to load the annotations for the specified class and return the FileMetaData containing the class. The FileMetaData, PackageMetaData will be dummy records.- Parameters:
cls
- The classclr
- ClassLoader resolverregister
- Whether to register the datapopulate
- Whether to populate the data- Returns:
- The FileMetaData
-
postProcessClassMetaData
Method that will perform any necessary post-processing on metadata.- Parameters:
cmd
- Metadata for the classclr
- ClassLoader resolver
-
populateAbstractClassMetaData
protected boolean populateAbstractClassMetaData(AbstractClassMetaData cmd, ClassLoaderResolver clr, ClassLoader loader) Convenience method to populate the MetaData for the specified class/interface.- Parameters:
cmd
- MetaDataclr
- ClassLoader resolverloader
- The primary class loader- Returns:
- Whether it was successful
-
initialiseAbstractClassMetaData
Convenience method to initialise the MetaData for the specified class/interface.- Parameters:
cmd
- MetaDataclr
- ClassLoaderResolver
-
abstractClassMetaDataInitialised
Description copied from interface:MetaDataManager
Method called (by AbstractClassMetaData.initialise()) when a class/interface has its metadata initialised. Only to be invoked by ClassMetaData, InterfaceMetaData.- Specified by:
abstractClassMetaDataInitialised
in interfaceMetaDataManager
- Parameters:
cmd
- Metadata that has been initialised
-
getConcreteSubclassesForClass
Description copied from interface:MetaDataManager
Accessor for the names of all concrete subclasses of the provided class.- Specified by:
getConcreteSubclassesForClass
in interfaceMetaDataManager
- Parameters:
className
- Name of the class that we want the known concrete subclasses for.- Returns:
- Names of the subclasses. Returns null if there are no subclasses
-
getSubclassesForClass
Description copied from interface:MetaDataManager
Accessor for the subclasses of a particular class- Specified by:
getSubclassesForClass
in interfaceMetaDataManager
- Parameters:
className
- Name of the class that we want the known subclasses for.includeDescendents
- Whether to include subclasses of subclasses etc- Returns:
- Names of the subclasses. return null if there are no subclasses
-
provideSubclassesForClass
private void provideSubclassesForClass(String className, boolean includeDescendents, Collection<String> consumer) Provide the subclasses of a particular class to a givenconsumer
- Parameters:
className
- Name of the class that we want the known subclasses for.includeDescendents
- Whether to include subclasses of subclasses etcconsumer
- the Collection (Set) where discovered subclasses are added
-
getReferencedClasses
public List<AbstractClassMetaData> getReferencedClasses(String[] classNames, ClassLoaderResolver clr) Description copied from interface:MetaDataManager
Convenience method to get the MetaData for all referenced classes with the passed set of classes as root.- Specified by:
getReferencedClasses
in interfaceMetaDataManager
- Parameters:
classNames
- Names of the root classesclr
- ClassLoader resolver- Returns:
- List of AbstractClassMetaData objects for the referenced classes
-
getReferencedClassMetaData
protected List<AbstractClassMetaData> getReferencedClassMetaData(AbstractClassMetaData cmd, ClassLoaderResolver clr) Utility to return all ClassMetaData that is referenced from the supplier class.- Parameters:
cmd
- The origin class's MetaData.clr
- ClassLoaderResolver resolver for loading any classes.- Returns:
- List of ClassMetaData referenced by the origin
-
isFieldTypePersistable
Description copied from interface:MetaDataManager
Utility to return if this field is of a persistable type.- Specified by:
isFieldTypePersistable
in interfaceMetaDataManager
- Parameters:
type
- Type of the field (for when "type" is not yet set)- Returns:
- Whether the field type is persistable.
-