Skip to content

Commit b9eeee8

Browse files
committed
Polishing
1 parent df1f481 commit b9eeee8

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

framework-docs/modules/ROOT/pages/core/beans/annotation-config/autowired-qualifiers.adoc

+8-7
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,16 @@ Letting qualifier values select against target bean names, within the type-match
153153
candidates, does not require a `@Qualifier` annotation at the injection point.
154154
If there is no other resolution indicator (such as a qualifier or a primary marker),
155155
for a non-unique dependency situation, Spring matches the injection point name
156-
(that is, the field name or parameter name) against the target bean names and chooses the
157-
same-named candidate, if any.
156+
(that is, the field name or parameter name) against the target bean names and chooses
157+
the same-named candidate, if any (either by bean name or by associated alias).
158+
159+
This requires the `-parameters` Java compiler flag to be present. As a fallback,
160+
version 6.0 still supports parameter names from debug symbols via `-debug` as well.
158161
====
159162

160-
That said, if you intend to express annotation-driven injection by name, do not
161-
primarily use `@Autowired`, even if it is capable of selecting by bean name among
162-
type-matching candidates. Instead, use the JSR-250 `@Resource` annotation, which is
163-
semantically defined to identify a specific target component by its unique name, with
164-
the declared type being irrelevant for the matching process. `@Autowired` has rather
163+
As an alternative for injection by name, consider the JSR-250 `@Resource` annotation
164+
which is semantically defined to identify a specific target component by its unique name,
165+
with the declared type being irrelevant for the matching process. `@Autowired` has rather
165166
different semantics: After selecting candidate beans by type, the specified `String`
166167
qualifier value is considered within those type-selected candidates only (for example,
167168
matching an `account` qualifier against beans marked with the same qualifier label).

framework-docs/modules/ROOT/pages/core/beans/definition.adoc

+2-4
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ Kotlin::
416416
======
417417

418418
This approach shows that the factory bean itself can be managed and configured through
419-
dependency injection (DI). See xref:core/beans/dependencies/factory-properties-detailed.adoc[Dependencies and Configuration in Detail]
420-
.
419+
dependency injection (DI).
420+
See xref:core/beans/dependencies/factory-properties-detailed.adoc[Dependencies and Configuration in Detail].
421421

422422
NOTE: In Spring documentation, "factory bean" refers to a bean that is configured in the
423423
Spring container and that creates objects through an
@@ -444,5 +444,3 @@ cases into account and returns the type of object that a `BeanFactory.getBean` c
444444
going to return for the same bean name.
445445

446446

447-
448-

spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ private void startBeans(boolean autoStartupOnly) {
149149

150150
lifecycleBeans.forEach((beanName, bean) -> {
151151
if (!autoStartupOnly || (bean instanceof SmartLifecycle smartLifecycle && smartLifecycle.isAutoStartup())) {
152-
int phase = getPhase(bean);
153-
phases.computeIfAbsent(
154-
phase,
155-
p -> new LifecycleGroup(phase, this.timeoutPerShutdownPhase, lifecycleBeans, autoStartupOnly)
152+
int startupPhase = getPhase(bean);
153+
phases.computeIfAbsent(startupPhase,
154+
phase -> new LifecycleGroup(phase, this.timeoutPerShutdownPhase, lifecycleBeans, autoStartupOnly)
156155
).add(beanName, bean);
157156
}
158157
});
158+
159159
if (!phases.isEmpty()) {
160160
phases.values().forEach(LifecycleGroup::start);
161161
}
@@ -195,6 +195,7 @@ private void doStart(Map<String, ? extends Lifecycle> lifecycleBeans, String bea
195195
private void stopBeans() {
196196
Map<String, Lifecycle> lifecycleBeans = getLifecycleBeans();
197197
Map<Integer, LifecycleGroup> phases = new HashMap<>();
198+
198199
lifecycleBeans.forEach((beanName, bean) -> {
199200
int shutdownPhase = getPhase(bean);
200201
LifecycleGroup group = phases.get(shutdownPhase);
@@ -204,6 +205,7 @@ private void stopBeans() {
204205
}
205206
group.add(beanName, bean);
206207
});
208+
207209
if (!phases.isEmpty()) {
208210
List<Integer> keys = new ArrayList<>(phases.keySet());
209211
keys.sort(Collections.reverseOrder());

0 commit comments

Comments
 (0)