@@ -3980,7 +3980,6 @@ Consult the `PropertyPlaceholderConfigurer` javadocs for more information.
3980
3980
3981
3981
[TIP]
3982
3982
====
3983
-
3984
3983
You can use the `PropertyPlaceholderConfigurer` to substitute class names, which is
3985
3984
sometimes useful when you have to pick a particular implementation class at runtime. For
3986
3985
example:
@@ -4366,7 +4365,6 @@ the `@Order` or standard `@Priority` annotation if you want items in the array o
4366
4365
to be sorted into a specific order.
4367
4366
====
4368
4367
4369
-
4370
4368
Even typed Maps can be autowired as long as the expected key type is `String`. The Map
4371
4369
values will contain all beans of the expected type, and the keys will contain the
4372
4370
corresponding bean names:
@@ -4633,7 +4631,6 @@ be injected into a `Set<MovieCatalog>` annotated with `@Qualifier("action")`.
4633
4631
4634
4632
[TIP]
4635
4633
====
4636
-
4637
4634
If you intend to express annotation-driven injection by name, do not primarily use
4638
4635
`@Autowired`, even if is technically capable of referring to a bean name through
4639
4636
`@Qualifier` values. Instead, use the JSR-250 `@Resource` annotation, which is
@@ -5320,7 +5317,6 @@ The following is an alternative using XML
5320
5317
5321
5318
[TIP]
5322
5319
====
5323
-
5324
5320
The use of `<context:component-scan>` implicitly enables the functionality of
5325
5321
`<context:annotation-config>`. There is usually no need to include the
5326
5322
`<context:annotation-config>` element when using `<context:component-scan>`.
@@ -5486,7 +5482,6 @@ support for autowiring of `@Bean` methods:
5486
5482
}
5487
5483
5488
5484
// use of a custom qualifier and autowiring of method parameters
5489
-
5490
5485
@Bean
5491
5486
protected TestBean protectedInstance(
5492
5487
@Qualifier("public") TestBean spouse,
@@ -5517,7 +5512,30 @@ defines the value of the property through the notation `#{ <expression> }`. For
5517
5512
annotations, an expression resolver is preconfigured to look for bean names when
5518
5513
resolving expression text.
5519
5514
5520
- The `@Bean` methods in a Spring component are processed differently than their
5515
+ As of Spring Framework 4.3, you may also declare a factory method parameter of type
5516
+ `InjectionPoint` (or its more specific subclass `DependencyDescriptor`) in order to
5517
+ access the requesting injection point that triggers the creation of the current bean.
5518
+ Note that this will only apply to the actual creation of bean instances, not to the
5519
+ injection of existing instances. As a consequence, this feature makes most sense for
5520
+ beans of prototype scope. For other scopes, the factory method will only ever see the
5521
+ injection point which triggered the creation of a new bean instance in the given scope:
5522
+ for example, the dependency that triggered the creation of a lazy singleton bean.
5523
+ Use the provided injection point metadata with semantic care in such scenarios.
5524
+
5525
+ [source,java,indent=0]
5526
+ [subs="verbatim,quotes"]
5527
+ ----
5528
+ @Component
5529
+ public class FactoryMethodComponent {
5530
+
5531
+ @Bean @Scope("prototype")
5532
+ public TestBean prototypeInstance(InjectionPoint injectionPoint) {
5533
+ return new TestBean("prototypeInstance for " + injectionPoint.getMember());
5534
+ }
5535
+ }
5536
+ ----
5537
+
5538
+ The `@Bean` methods in a regular Spring component are processed differently than their
5521
5539
counterparts inside a Spring `@Configuration` class. The difference is that `@Component`
5522
5540
classes are not enhanced with CGLIB to intercept the invocation of methods and fields.
5523
5541
CGLIB proxying is the means by which invoking methods or fields within `@Bean` methods
@@ -6149,7 +6167,6 @@ To enable component scanning, just annotate your `@Configuration` class as follo
6149
6167
6150
6168
[TIP]
6151
6169
====
6152
-
6153
6170
Experienced Spring users will be familiar with the XML declaration equivalent from
6154
6171
Spring's `context:` namespace
6155
6172
@@ -6440,7 +6457,6 @@ method directly during construction:
6440
6457
6441
6458
[TIP]
6442
6459
====
6443
-
6444
6460
When you work directly in Java, you can do anything you like with your objects and do
6445
6461
not always need to rely on the container lifecycle!
6446
6462
====
0 commit comments