public class AnnotationMetadataProviderImpl extends MetadataProviderBase
At the moment, it will only process classes which were previously identified by the JPA implementation.
TODO: Addition of a new Annotation which will need to be scanned for in order to process non-persistent classes as data objects.
masterMetadataMap
Constructor and Description |
---|
AnnotationMetadataProviderImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
addDataObjectCollection(DataObjectMetadataImpl metadata,
Field f,
CollectionRelationship a)
Adds a collection relationship for a field to the metadata object.
|
protected void |
addDataObjectRelationship(DataObjectMetadataImpl metadata,
Field f,
Relationship a)
Adds a relationship for a field to the metadata object.
|
DataObjectService |
getDataObjectService()
Gets the
DataObjectService . |
protected String |
getPropertyNameFromGetterMethod(Method m)
Used to find the property name from a getter method.
|
protected Class<?> |
getTypeOfProperty(Class<?> clazz,
String propertyName)
Used to find the property type of a given attribute regardless of whether the attribute exists as a field or only
as a getter method.
|
protected void |
initializeMetadata(Collection<Class<?>> types)
Performs the initialization of the provider with the given set of types.
|
boolean |
isInitializationAttempted()
Gets whether initialization was attempted.
|
protected boolean |
processAnnotationForAttribute(Annotation a,
DataObjectAttributeImpl attr,
DataObjectMetadataImpl metadata)
Helper method to process the annotations which can be present on attributes.
|
protected boolean |
processAnnotationsforCommonMetadata(Annotation a,
MetadataCommonBase metadata)
Helper method to process the annotations which can be present on attributes or classes.
|
protected boolean |
processClassLevelAnnotations(Class<?> clazz,
DataObjectMetadataImpl metadata)
Handle annotations made at the class level and add their data to the given metadata object.
|
protected boolean |
processFieldLevelAnnotations(Class<?> clazz,
DataObjectMetadataImpl metadata)
Handle annotations made at the field level and add their data to the given metadata object.
|
protected boolean |
processInheritedAttributes(Class<?> clazz,
DataObjectMetadataImpl metadata)
Handle inherited properties and add their data to the given metadata object.
|
protected boolean |
processMethodLevelAnnotations(Class<?> clazz,
DataObjectMetadataImpl metadata)
Handle annotations made at the method level and add their data to the given metadata object.
|
boolean |
requiresListOfExistingTypes()
Flag which allows the service to indicate that it requires knowledge of previously discovered persistable
entities.
|
void |
setDataObjectService(DataObjectService dataObjectService)
Setter for the the
DataObjectService . |
getMetadataForType, getSupportedTypes, handles, isClassPersistable, provideMetadata, provideMetadataForTypes
public AnnotationMetadataProviderImpl()
protected void initializeMetadata(Collection<Class<?>> types)
If the list is null or empty, the provider is expected to discover the types via other means, or do nothing if the types cannot be discovered.
initializeMetadata
in class MetadataProviderBase
protected boolean processClassLevelAnnotations(Class<?> clazz, DataObjectMetadataImpl metadata)
clazz
- the class to process.metadata
- the metadata for the class.protected boolean processFieldLevelAnnotations(Class<?> clazz, DataObjectMetadataImpl metadata)
clazz
- the class to process.metadata
- the metadata for the class.protected boolean processAnnotationsforCommonMetadata(Annotation a, MetadataCommonBase metadata)
a
- the annotation to process.metadata
- the metadata for the class.protected boolean processAnnotationForAttribute(Annotation a, DataObjectAttributeImpl attr, DataObjectMetadataImpl metadata)
Used to abstract the logic so it can be applied to both field and method-level annotations.
a
- the annotation to process.attr
- the attribute for the field.metadata
- the metadata for the class.protected String getPropertyNameFromGetterMethod(Method m)
(Not using PropertyUtils since it required an instance of the class.)
m
- the method from which to get the property name.protected boolean processMethodLevelAnnotations(Class<?> clazz, DataObjectMetadataImpl metadata)
clazz
- the class to process.metadata
- the metadata for the class.protected void addDataObjectRelationship(DataObjectMetadataImpl metadata, Field f, Relationship a)
metadata
- the metadata for the class.f
- the field to process.a
- the relationship to add.protected void addDataObjectCollection(DataObjectMetadataImpl metadata, Field f, CollectionRelationship a)
metadata
- the metadata for the class.f
- the field to process.a
- the collection relationship to add.protected boolean processInheritedAttributes(Class<?> clazz, DataObjectMetadataImpl metadata)
clazz
- the class to process.metadata
- the metadata for the class.protected Class<?> getTypeOfProperty(Class<?> clazz, String propertyName)
(Not using PropertyUtils since it required an instance of the class.)
clazz
- the class that contains the property.propertyName
- the name of the property.public boolean requiresListOfExistingTypes()
That is, the service is designed only to process existing objects and not to create new ones.
By default, providers are assumed to be able to pull the list of annotated types from somewhere. Returns true in this implementation. This tells the composite metadata provider to pass in all known metadata to the initializeMetadata method.requiresListOfExistingTypes
in interface MetadataProvider
requiresListOfExistingTypes
in class MetadataProviderBase
public boolean isInitializationAttempted()
public DataObjectService getDataObjectService()
DataObjectService
.DataObjectService
.public void setDataObjectService(DataObjectService dataObjectService)
DataObjectService
.dataObjectService
- the the DataObjectService
to set.Copyright © 2005–2015 The Kuali Foundation. All rights reserved.