@Autowired and @Value may be used as meta-annotations for custom injection annotations
This commit is contained in:
parent
7fdb637df0
commit
2081521695
|
@ -64,7 +64,7 @@ import java.lang.annotation.Target;
|
||||||
* @see Qualifier
|
* @see Qualifier
|
||||||
* @see Value
|
* @see Value
|
||||||
*/
|
*/
|
||||||
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD})
|
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface Autowired {
|
public @interface Autowired {
|
||||||
|
|
|
@ -55,6 +55,7 @@ import org.springframework.core.GenericTypeResolver;
|
||||||
import org.springframework.core.MethodParameter;
|
import org.springframework.core.MethodParameter;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.PriorityOrdered;
|
import org.springframework.core.PriorityOrdered;
|
||||||
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
@ -372,7 +373,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
|
|
||||||
private Annotation findAutowiredAnnotation(AccessibleObject ao) {
|
private Annotation findAutowiredAnnotation(AccessibleObject ao) {
|
||||||
for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
|
for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
|
||||||
Annotation annotation = ao.getAnnotation(type);
|
Annotation annotation = AnnotationUtils.getAnnotation(ao, type);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
return annotation;
|
return annotation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ import java.lang.annotation.Target;
|
||||||
* @see org.springframework.beans.factory.config.BeanExpressionResolver
|
* @see org.springframework.beans.factory.config.BeanExpressionResolver
|
||||||
* @see org.springframework.beans.factory.support.AutowireCandidateResolver#getSuggestedValue
|
* @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)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface Value {
|
public @interface Value {
|
||||||
|
|
Loading…
Reference in New Issue