diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java index c3265082537..7bfcce75081 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2011 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. @@ -46,13 +46,20 @@ import java.lang.annotation.Target; * declared value type. In case of a Map, the keys must be declared as * type String and will be resolved to the corresponding bean names. * - *
Please do consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor} + *
Note that actual injection is performed through a + * {@link org.springframework.beans.factory.config.BeanPostProcessor + * BeanPostProcessor} which in turn means that you cannot + * use {@code @Autowired} to inject references into + * {@link org.springframework.beans.factory.config.BeanPostProcessor + * BeanPostProcessor} or {@link BeanFactoryPostProcessor} types. Please + * consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor} * class (which, by default, checks for the presence of this annotation). * * @author Juergen Hoeller * @author Mark Fisher * @since 2.5 * @see AutowiredAnnotationBeanPostProcessor + * @see Value */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD}) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index 81690732fa8..72232c249d3 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -62,7 +62,7 @@ import org.springframework.util.ReflectionUtils; * {@link org.springframework.beans.factory.config.BeanPostProcessor} implementation * that autowires annotated fields, setter methods and arbitrary config methods. * Such members to be injected are detected through a Java 5 annotation: - * by default, Spring's {@link Autowired} annotation. + * by default, Spring's @{@link Autowired} and @{@link Value} annotations. * *
Only one constructor (at max) of any given bean class may carry this
* annotation with the 'required' parameter set to true,
@@ -83,21 +83,23 @@ import org.springframework.util.ReflectionUtils;
* a special case of such a general config method. Such config methods
* do not have to be public.
*
- *
Also supports JSR-330's {@link javax.inject.Inject} annotation, if available. + *
Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation, if + * available. * *
Note: A default AutowiredAnnotationBeanPostProcessor will be registered * by the "context:annotation-config" and "context:component-scan" XML tags. * Remove or turn off the default annotation configuration there if you intend * to specify a custom AutowiredAnnotationBeanPostProcessor bean definition. - *
NOTE: Annotation injection will be performed before XML injection; thus - * the latter configuration will override the former for properties wired through - * both approaches. - * + *
NOTE: Annotation injection will be performed before XML injection; + * thus the latter configuration will override the former for properties wired through + * both approaches. + * * @author Juergen Hoeller * @author Mark Fisher * @since 2.5 * @see #setAutowiredAnnotationType * @see Autowired + * @see Value */ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware { diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/Value.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/Value.java index 40df0991d71..69bed418a3d 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/Value.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/Value.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2011 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. @@ -31,8 +31,19 @@ import java.lang.annotation.Target; *
A common use case is to assign default field values using * "#{systemProperties.myProp}" style expressions. * + *
Note that actual processing of the {@code @Value} annotation is performed
+ * by a {@link org.springframework.beans.factory.config.BeanPostProcessor
+ * BeanPostProcessor} which in turn means that you cannot use
+ * {@code @Value} within
+ * {@link org.springframework.beans.factory.config.BeanPostProcessor
+ * BeanPostProcessor} or {@link BeanFactoryPostProcessor} types. Please
+ * consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor}
+ * class (which, by default, checks for the presence of this annotation).
+ *
* @author Juergen Hoeller
* @since 3.0
+ * @see AutowiredAnnotationBeanPostProcessor
+ * @see Value
* @see org.springframework.beans.factory.config.BeanExpressionResolver
* @see org.springframework.beans.factory.support.AutowireCandidateResolver#getSuggestedValue
*/
diff --git a/spring-framework-reference/src/beans-annotation-config.xml b/spring-framework-reference/src/beans-annotation-config.xml
index 4a19f60078d..6f4ececae7d 100644
--- a/spring-framework-reference/src/beans-annotation-config.xml
+++ b/spring-framework-reference/src/beans-annotation-config.xml
@@ -277,6 +277,7 @@
interfaces that are well-known resolvable dependencies: