@Autowired and @Value may be used as meta-annotations for custom injection annotations

This commit is contained in:
Juergen Hoeller 2012-10-31 09:37:27 +01:00 committed by unknown
parent 7fdb637df0
commit 2081521695
3 changed files with 4 additions and 3 deletions

View File

@ -64,7 +64,7 @@ import java.lang.annotation.Target;
* @see Qualifier
* @see Value
*/
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD})
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Autowired {

View File

@ -55,6 +55,7 @@ import org.springframework.core.GenericTypeResolver;
import org.springframework.core.MethodParameter;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
@ -372,7 +373,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
private Annotation findAutowiredAnnotation(AccessibleObject ao) {
for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
Annotation annotation = ao.getAnnotation(type);
Annotation annotation = AnnotationUtils.getAnnotation(ao, type);
if (annotation != null) {
return annotation;
}

View File

@ -49,7 +49,7 @@ import java.lang.annotation.Target;
* @see org.springframework.beans.factory.config.BeanExpressionResolver
* @see org.springframework.beans.factory.support.AutowireCandidateResolver#getSuggestedValue
*/
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Value {