in src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java [189:224]
private void addDescriptorsFromGetters(MappingDescriptor mappingDescriptor, ClassDescriptor classDescriptor, Class clazz) {
BeanInfo beanInfo;
String fieldName = "";
try {
beanInfo = Introspector.getBeanInfo(clazz);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
fieldName = propertyDescriptor.getName();
// Check if there is an Field annotation
Field fieldAnnotation = propertyDescriptor.getReadMethod().getAnnotation(Field.class);
if (fieldAnnotation != null) {
addFieldDescriptor(classDescriptor, propertyDescriptor.getName(), fieldAnnotation);
}
// Check if there is an Bean annotation
Bean beanAnnotation = propertyDescriptor.getReadMethod().getAnnotation(Bean.class);
if (beanAnnotation != null) {
addBeanDescriptor(classDescriptor, propertyDescriptor.getName(), beanAnnotation);
}
// Check if there is an Collection annotation
Collection collectionAnnotation = propertyDescriptor.getReadMethod().getAnnotation(Collection.class);
if (collectionAnnotation != null) {
addCollectionDescriptor(mappingDescriptor, classDescriptor,
propertyDescriptor.getPropertyType().getDeclaredField(propertyDescriptor.getName()),
collectionAnnotation);
}
}
} catch (Exception e) {
throw new InitMapperException("Impossible to read the mapping descriptor from the getter for class : " +
clazz.toString() +
(fieldName == null ? "" : " for field : " + fieldName), e);
}
}