DATACMNS-825 - Allow usage of composed annotations using @AliasFor.

We now resolve composed annotation values using @AliasFor within AnnotationBasedPersistentProperty and BasicPersistentEntity. Nevertheless it is up to the individual store implementation to make use of this.

Original pull request: #156.
This commit is contained in:
Christoph Strobl
2016-03-09 10:43:40 +01:00
committed by Oliver Gierke
parent ae96301ab0
commit a40e247c25
6 changed files with 91 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.data.util;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.ReflectionUtils.FieldCallback;
@@ -27,6 +28,7 @@ import org.springframework.util.ReflectionUtils.FieldCallback;
* afterwards.
*
* @author Oliver Gierke
* @author Christoph Strobl
*/
public class AnnotationDetectionFieldCallback implements FieldCallback {
@@ -54,7 +56,7 @@ public class AnnotationDetectionFieldCallback implements FieldCallback {
return;
}
Annotation annotation = field.getAnnotation(annotationType);
Annotation annotation = AnnotatedElementUtils.findMergedAnnotation(field, annotationType);
if (annotation != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package org.springframework.data.util;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils.MethodCallback;
@@ -26,6 +26,7 @@ import org.springframework.util.ReflectionUtils.MethodCallback;
* {@link MethodCallback} to find annotations of a given type.
*
* @author Oliver Gierke
* @author Christoph Strobl
*/
public class AnnotationDetectionMethodCallback<A extends Annotation> implements MethodCallback {
@@ -94,7 +95,7 @@ public class AnnotationDetectionMethodCallback<A extends Annotation> implements
return;
}
A foundAnnotation = AnnotationUtils.findAnnotation(method, annotationType);
A foundAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, annotationType);
if (foundAnnotation != null) {