Skip to content

Commit bf6653b

Browse files
committed
Adapted to 4.3.3 backport
Issue: SPR-14728
1 parent f532de9 commit bf6653b

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

spring-context/src/main/java/org/springframework/context/annotation/Bean.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
* <h3>Bean Names</h3>
4747
*
4848
* <p>While a {@link #name} attribute is available, the default strategy for
49-
* determining the name of a bean is to use the name of the {@code @Bean} method. This
50-
* is convenient and intuitive, but if explicit naming is desired, the {@code name}
51-
* attribute (or its alias {@code value}) may be used. Also note that {@code name}
52-
* accepts an array of Strings. This is in order to allow for specifying multiple names
53-
* (i.e., aliases) for a single bean.
49+
* determining the name of a bean is to use the name of the {@code @Bean} method.
50+
* This is convenient and intuitive, but if explicit naming is desired, the
51+
* {@code name} attribute (or its alias {@code value}) may be used. Also note
52+
* that {@code name} accepts an array of Strings, allowing for multiple names
53+
* (i.e. a primary bean name plus one or more aliases) for a single bean.
5454
*
5555
* <pre class="code">
56-
* &#064;Bean({"b1","b2"}) // bean available as 'b1' and 'b2', but not 'myBean'
56+
* &#064;Bean({"b1", "b2"}) // bean available as 'b1' and 'b2', but not 'myBean'
5757
* public MyBean myBean() {
5858
* // instantiate and configure MyBean obj
5959
* return obj;
@@ -79,9 +79,9 @@
7979
* <h3>{@code @Bean} Methods in {@code @Configuration} Classes</h3>
8080
*
8181
* <p>Typically, {@code @Bean} methods are declared within {@code @Configuration}
82-
* classes. In this case, bean methods may reference other {@code @Bean} methods
83-
* in the same class by calling them <i>directly</i>. This ensures that references between
84-
* beans are strongly typed and navigable. Such so-called <em>'inter-bean references'</em> are
82+
* classes. In this case, bean methods may reference other {@code @Bean} methods in the
83+
* same class by calling them <i>directly</i>. This ensures that references between beans
84+
* are strongly typed and navigable. Such so-called <em>'inter-bean references'</em> are
8585
* guaranteed to respect scoping and AOP semantics, just like {@code getBean()} lookups
8686
* would. These are the semantics known from the original 'Spring JavaConfig' project
8787
* which require CGLIB subclassing of each such configuration class at runtime. As a
@@ -194,15 +194,15 @@
194194
* Alias for {@link #name}.
195195
* <p>Intended to be used when no other attributes are needed, for example:
196196
* {@code @Bean("customBeanName")}.
197-
* @since 5.0
197+
* @since 4.3.3
198198
* @see #name
199199
*/
200200
@AliasFor("name")
201201
String[] value() default {};
202202

203203
/**
204-
* The name of this bean, or if plural, aliases for this bean.
205-
* <p>If left unspecified the name of the bean is the name of the annotated method.
204+
* The name of this bean, or if several names, a primary bean name plus aliases.
205+
* <p>If left unspecified, the name of the bean is the name of the annotated method.
206206
* If specified, the method name is ignored.
207207
* <p>The bean name and aliases may also be configured via the {@link #value}
208208
* attribute if no other attributes are declared.

spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222
import java.util.Set;
2323
import java.util.function.Supplier;
24-
2524
import javax.inject.Provider;
2625

2726
import org.junit.Rule;
@@ -279,6 +278,7 @@ public TestBean methodName() {
279278
}
280279
}
281280

281+
282282
@Configuration
283283
static class ConfigWithBeanWithCustomNameConfiguredViaValueAttribute {
284284

@@ -290,6 +290,7 @@ public TestBean methodName() {
290290
}
291291
}
292292

293+
293294
@Configuration
294295
static class ConfigWithBeanWithAliases {
295296

@@ -301,6 +302,7 @@ public TestBean methodName() {
301302
}
302303
}
303304

305+
304306
@Configuration
305307
static class ConfigWithBeanWithAliasesConfiguredViaValueAttribute {
306308

@@ -452,7 +454,7 @@ public int getOrder() {
452454
};
453455
}
454456

455-
//@Bean
457+
// @Bean
456458
public BeanFactoryPostProcessor beanFactoryPostProcessor() {
457459
return new BeanFactoryPostProcessor() {
458460
@Override

0 commit comments

Comments
 (0)