Package org.datanucleus.api.jdo.metadata
Class JDOAnnotationReader
- java.lang.Object
-
- org.datanucleus.metadata.annotations.AbstractAnnotationReader
-
- org.datanucleus.api.jdo.metadata.JDOAnnotationReader
-
- All Implemented Interfaces:
org.datanucleus.metadata.annotations.AnnotationReader
public class JDOAnnotationReader extends org.datanucleus.metadata.annotations.AbstractAnnotationReader
Implementation for Annotation Reader for java annotations using the JDO definition.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
JDOAnnotationReader.PersistenceCapableModel
-
Field Summary
Fields Modifier and Type Field Description (package private) org.datanucleus.metadata.annotations.AnnotationObject
persistenceCapableDefaults
-
Constructor Summary
Constructors Constructor Description JDOAnnotationReader(org.datanucleus.metadata.MetaDataManager mgr)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
doesClassHaveNamedQueries(org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Check if class has Query annotations (for classes that are not persistable but provide named query definitions.private org.datanucleus.metadata.AbstractMemberMetaData
getFieldMetaDataForPersistent(org.datanucleus.metadata.MetaData parent, javax.jdo.annotations.Persistent member, boolean isField)
Convenience method to create MetaData for a @Persistent annotation representing a field or property.protected org.datanucleus.metadata.annotations.AnnotationObject
isClassPersistable(org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Check if a class is persistable, by looking at its annotations.protected boolean
isClassPersistenceAware(org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Check if class is persistence aware, by looking at annotations.private boolean
isMemberOfClassAField(java.lang.Class cls, java.lang.String memberName)
Convenience method that tries to find if a specified member name (field or property) is for a field.(package private) org.datanucleus.metadata.annotations.AnnotationObject
mergeAnnotation(org.datanucleus.metadata.annotations.AnnotationObject defaults, org.datanucleus.metadata.annotations.AnnotationObject base, org.datanucleus.metadata.annotations.AnnotationObject dup)
Merge a duplicated annotation into the original annotation.protected org.datanucleus.metadata.AbstractClassMetaData
processClassAnnotations(org.datanucleus.metadata.PackageMetaData pmd, java.lang.Class cls, org.datanucleus.metadata.annotations.AnnotationObject[] annotations, org.datanucleus.ClassLoaderResolver clr)
Method to process the "class" level annotations and create the outline ClassMetaData object.protected org.datanucleus.metadata.AbstractMemberMetaData
processMemberAnnotations(org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.metadata.annotations.Member member, org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Convenience method to process the annotations for a field/property.protected void
processMethodAnnotations(org.datanucleus.metadata.AbstractClassMetaData cmd, java.lang.reflect.Method method)
Method to take the passed in outline ClassMetaData and process the annotations for method adding any necessary MetaData to the ClassMetaData.protected void
processNamedQueries(org.datanucleus.metadata.AbstractClassMetaData cmd, java.lang.Class cls, org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Convenience method to process @Queries, @Query.private void
processPersistenceCapableAnnotation(java.lang.Class cls, org.datanucleus.metadata.AbstractClassMetaData cmd, java.util.Map<java.lang.String,java.lang.Object> annotationValues)
(package private) boolean
valueEqual(java.lang.Object defaultValue, java.lang.Object dupValue)
-
Methods inherited from class org.datanucleus.metadata.annotations.AbstractAnnotationReader
addSupportedDuplicateAnnotations, getAnnotationObjectsForAnnotations, getClassAnnotationsForClass, getFieldAnnotationsForClass, getJavaBeanAccessorAnnotationsForClass, getMetaDataForClass, getSupportedAnnotationPackages, isPersistenceContext, isSupportedAnnotation, setSupportedAnnotationPackages
-
-
-
-
Method Detail
-
processClassAnnotations
protected org.datanucleus.metadata.AbstractClassMetaData processClassAnnotations(org.datanucleus.metadata.PackageMetaData pmd, java.lang.Class cls, org.datanucleus.metadata.annotations.AnnotationObject[] annotations, org.datanucleus.ClassLoaderResolver clr)
Method to process the "class" level annotations and create the outline ClassMetaData object. Supports classes annotated with @PersistenceCapable, classes annotated with @PersistenceAware, and classes which have neither of those but have @Queries or @Query.- Specified by:
processClassAnnotations
in classorg.datanucleus.metadata.annotations.AbstractAnnotationReader
- Parameters:
pmd
- Parent PackageMetaDatacls
- The classannotations
- Annotations for this classclr
- ClassLoader resolver- Returns:
- The ClassMetaData/InterfaceMetaData (or null if no annotations)
-
processPersistenceCapableAnnotation
private void processPersistenceCapableAnnotation(java.lang.Class cls, org.datanucleus.metadata.AbstractClassMetaData cmd, java.util.Map<java.lang.String,java.lang.Object> annotationValues)
-
processNamedQueries
protected void processNamedQueries(org.datanucleus.metadata.AbstractClassMetaData cmd, java.lang.Class cls, org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Convenience method to process @Queries, @Query.- Parameters:
cmd
- Metadata for the class, to which any queries will be addedcls
- Class that the named queries are registered againstannotations
- Annotations specified on the class
-
processMemberAnnotations
protected org.datanucleus.metadata.AbstractMemberMetaData processMemberAnnotations(org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.metadata.annotations.Member member, org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Convenience method to process the annotations for a field/property. The passed annotations may have been specified on the field or on the getter methods.- Specified by:
processMemberAnnotations
in classorg.datanucleus.metadata.annotations.AbstractAnnotationReader
- Parameters:
cmd
- The ClassMetaData/InterfaceMetaData to updatemember
- The field/propertyannotations
- Annotations for the field/property- Returns:
- The FieldMetaData/PropertyMetaData that was added (if any)
-
processMethodAnnotations
protected void processMethodAnnotations(org.datanucleus.metadata.AbstractClassMetaData cmd, java.lang.reflect.Method method)
Method to take the passed in outline ClassMetaData and process the annotations for method adding any necessary MetaData to the ClassMetaData.- Specified by:
processMethodAnnotations
in classorg.datanucleus.metadata.annotations.AbstractAnnotationReader
- Parameters:
cmd
- The ClassMetaData/InterfaceMetaData (to be updated)method
- The method
-
getFieldMetaDataForPersistent
private org.datanucleus.metadata.AbstractMemberMetaData getFieldMetaDataForPersistent(org.datanucleus.metadata.MetaData parent, javax.jdo.annotations.Persistent member, boolean isField)
Convenience method to create MetaData for a @Persistent annotation representing a field or property.- Parameters:
parent
- Parent MetaDatamember
- The @Persistent annotationisField
- Whether this is a field (otherwise is a property)- Returns:
- The metadata for the field/property
-
isMemberOfClassAField
private boolean isMemberOfClassAField(java.lang.Class cls, java.lang.String memberName)
Convenience method that tries to find if a specified member name (field or property) is for a field.- Parameters:
cls
- The classmemberName
- Name of the member- Returns:
- Whether it is a field (else it's a property).
-
isClassPersistable
protected org.datanucleus.metadata.annotations.AnnotationObject isClassPersistable(org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Check if a class is persistable, by looking at its annotations.- Parameters:
annotations
- Annotations for the class- Returns:
- The annotationObject for PersistenceCapable
-
mergeAnnotation
org.datanucleus.metadata.annotations.AnnotationObject mergeAnnotation(org.datanucleus.metadata.annotations.AnnotationObject defaults, org.datanucleus.metadata.annotations.AnnotationObject base, org.datanucleus.metadata.annotations.AnnotationObject dup)
Merge a duplicated annotation into the original annotation. Iterate all values in the default annotation. If the duplicate annotation has a non-default value, add it to the base value. If both annotations have a non-default value, logs a warning.
-
valueEqual
boolean valueEqual(java.lang.Object defaultValue, java.lang.Object dupValue)
-
isClassPersistenceAware
protected boolean isClassPersistenceAware(org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Check if class is persistence aware, by looking at annotations.- Parameters:
annotations
- Annotations for the class- Returns:
- true if the class has @PersistenceAware
-
doesClassHaveNamedQueries
protected boolean doesClassHaveNamedQueries(org.datanucleus.metadata.annotations.AnnotationObject[] annotations)
Check if class has Query annotations (for classes that are not persistable but provide named query definitions.- Parameters:
annotations
- Annotations for the class- Returns:
- true if the class has Named query annotations
-
-