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 -
Field Summary
FieldsModifier and TypeFieldDescription(package private) org.datanucleus.metadata.annotations.AnnotationObjectFields inherited from class org.datanucleus.metadata.annotations.AbstractAnnotationReader
mmgr, supportedDuplicateAnnotations, supportedPackages -
Constructor Summary
ConstructorsConstructorDescriptionJDOAnnotationReader(org.datanucleus.metadata.MetaDataManager mgr) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleandoesClassHaveNamedQueries(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.AbstractMemberMetaDatagetFieldMetaDataForPersistent(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.AnnotationObjectisClassPersistable(org.datanucleus.metadata.annotations.AnnotationObject[] annotations) Check if a class is persistable, by looking at its annotations.protected booleanisClassPersistenceAware(org.datanucleus.metadata.annotations.AnnotationObject[] annotations) Check if class is persistence aware, by looking at annotations.private booleanisMemberOfClassAField(Class cls, 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.AnnotationObjectmergeAnnotation(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.AbstractClassMetaDataprocessClassAnnotations(org.datanucleus.metadata.PackageMetaData pmd, 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.AbstractMemberMetaDataprocessMemberAnnotations(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 voidprocessMethodAnnotations(org.datanucleus.metadata.AbstractClassMetaData cmd, Method method) Method to take the passed in outline ClassMetaData and process the annotations for method adding any necessary MetaData to the ClassMetaData.protected voidprocessNamedQueries(org.datanucleus.metadata.AbstractClassMetaData cmd, Class cls, org.datanucleus.metadata.annotations.AnnotationObject[] annotations) Convenience method to process @Queries, @Query.private voidprocessPersistenceCapableAnnotation(Class cls, org.datanucleus.metadata.AbstractClassMetaData cmd, Map<String, Object> annotationValues) (package private) booleanvalueEqual(Object defaultValue, Object dupValue) Methods inherited from class org.datanucleus.metadata.annotations.AbstractAnnotationReader
addSupportedDuplicateAnnotations, getAnnotationObjectsForAnnotations, getClassAnnotationsForClass, getFieldAnnotationsForClass, getJavaBeanAccessorAnnotationsForClass, getMetaDataForClass, getSupportedAnnotationPackages, isPersistenceContext, isSupportedAnnotation, setSupportedAnnotationPackages
-
Field Details
-
persistenceCapableDefaults
org.datanucleus.metadata.annotations.AnnotationObject persistenceCapableDefaults
-
-
Constructor Details
-
JDOAnnotationReader
public JDOAnnotationReader(org.datanucleus.metadata.MetaDataManager mgr) Constructor.- Parameters:
mgr- MetaData manager
-
-
Method Details
-
processClassAnnotations
protected org.datanucleus.metadata.AbstractClassMetaData processClassAnnotations(org.datanucleus.metadata.PackageMetaData pmd, 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:
processClassAnnotationsin 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
-
processNamedQueries
protected void processNamedQueries(org.datanucleus.metadata.AbstractClassMetaData cmd, 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:
processMemberAnnotationsin 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, 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:
processMethodAnnotationsin 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
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
-
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
-