Skip to content

Commit abc3776

Browse files
blacks1nesnicoll
authored andcommitted
Reference manual polishing
1 parent f48bdaf commit abc3776

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

src/asciidoc/index.adoc

+39-33
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ The following example shows the data access objects `daos.xml` file:
12411241
<!-- additional collaborators and configuration for this bean go here -->
12421242
</bean>
12431243

1244-
<bean id="itemDao" class="org.springframework.samples.jpetstore.dao.jpa.JapItemDao">
1244+
<bean id="itemDao" class="org.springframework.samples.jpetstore.dao.jpa.JpaItemDao">
12451245
<!-- additional collaborators and configuration for this bean go here -->
12461246
</bean>
12471247

@@ -1282,7 +1282,7 @@ to load bean definitions from another file or files. For example:
12821282
</beans>
12831283
----
12841284

1285-
In the preceding example, external bean definitions are loaded from three files,
1285+
In the preceding example, external bean definitions are loaded from three files:
12861286
`services.xml`, `messageSource.xml`, and `themeSource.xml`. All location paths are
12871287
relative to the definition file doing the importing, so `services.xml` must be in the
12881288
same directory or classpath location as the file doing the importing, while
@@ -1511,7 +1511,7 @@ You use the `Class` property in one of two ways:
15111511
equivalent to Java code using the `new` operator.
15121512
* To specify the actual class containing the `static` factory method that will be
15131513
invoked to create the object, in the less common case where the container invokes a
1514-
`static`, __factory__ method on a class to create the bean. The object type returned
1514+
`static` __factory__ method on a class to create the bean. The object type returned
15151515
from the invocation of the `static` factory method may be the same class or another
15161516
class entirely.
15171517

@@ -2046,12 +2046,12 @@ part of a Spring XML configuration file specifies some bean definitions:
20462046
[subs="verbatim,quotes"]
20472047
----
20482048
<bean id="exampleBean" class="examples.ExampleBean">
2049-
<!-- setter injection using the nested <ref/> element -->
2049+
<!-- setter injection using the nested ref element -->
20502050
<property name="beanOne">
20512051
<ref bean="anotherExampleBean"/>
20522052
</property>
20532053

2054-
<!-- setter injection using the neater 'ref' attribute -->
2054+
<!-- setter injection using the neater ref attribute -->
20552055
<property name="beanTwo" ref="yetAnotherBean"/>
20562056
<property name="integerProperty" value="1"/>
20572057
</bean>
@@ -2091,12 +2091,12 @@ in the XML file. The following example uses constructor-based DI:
20912091
[subs="verbatim,quotes"]
20922092
----
20932093
<bean id="exampleBean" class="examples.ExampleBean">
2094-
<!-- constructor injection using the nested <ref/> element -->
2094+
<!-- constructor injection using the nested ref element -->
20952095
<constructor-arg>
20962096
<ref bean="anotherExampleBean"/>
20972097
</constructor-arg>
20982098

2099-
<!-- constructor injection using the neater 'ref' attribute -->
2099+
<!-- constructor injection using the neater ref attribute -->
21002100
<constructor-arg ref="yetAnotherBean"/>
21012101

21022102
<constructor-arg type="int" value="1"/>
@@ -2297,18 +2297,12 @@ likely fatal results) when the `client` bean is actually instantiated. If the `c
22972297
bean is a <<beans-factory-scopes,prototype>> bean, this typo and the resulting exception
22982298
may only be discovered long after the container is deployed.
22992299

2300-
Additionally, if the referenced bean is in the same XML unit, and the bean name is the
2301-
bean __id__, you can use the `local` attribute, which allows the XML parser itself to
2302-
validate the bean id earlier, at XML document parse time.
2303-
2304-
[source,xml,indent=0]
2305-
[subs="verbatim,quotes"]
2306-
----
2307-
<property name="targetName">
2308-
<!-- a bean with id theTargetBean must exist; otherwise an exception will be thrown -->
2309-
<idref bean="theTargetBean"/>
2310-
</property>
2311-
----
2300+
[NOTE]
2301+
====
2302+
The `local` attribute on the `idref` element is no longer supported in the 4.0 beans xsd
2303+
since it does not provide value over a regular `bean` reference anymore. Simply change
2304+
your existing `idref local` references to `idref bean` when upgrading to the 4.0 schema.
2305+
====
23122306

23132307
A common place (at least in versions earlier than Spring 2.0) where the `<idref/>` element
23142308
brings value is in the configuration of <<aop-pfb-1,AOP interceptors>> in a
@@ -2360,7 +2354,7 @@ container with a proxy that will have the same name as the parent bean.
23602354
[subs="verbatim,quotes"]
23612355
----
23622356
<!-- in the child (descendant) context -->
2363-
<bean id="accountService" <-- bean name is the same as the parent bean -->
2357+
<bean id="accountService" <!-- bean name is the same as the parent bean -->
23642358
class="org.springframework.aop.framework.ProxyFactoryBean">
23652359
<property name="target">
23662360
<ref parent="accountService"/> <!-- notice how we refer to the parent bean -->
@@ -2586,7 +2580,14 @@ following XML-based configuration metadata snippet sets the email property to th
25862580
----
25872581

25882582
The preceding example is equivalent to the following Java code:
2589-
`exampleBean.setEmail("")`. The `<null/>` element handles `null` values. For example:
2583+
2584+
[source,java,indent=0]
2585+
[subs="verbatim,quotes"]
2586+
----
2587+
exampleBean.setEmail("")
2588+
----
2589+
2590+
The `<null/>` element handles `null` values. For example:
25902591

25912592
[source,xml,indent=0]
25922593
[subs="verbatim,quotes"]
@@ -2599,7 +2600,12 @@ The preceding example is equivalent to the following Java code:
25992600
----
26002601

26012602
The above configuration is equivalent to the following Java code:
2602-
`exampleBean.setEmail(null)`.
2603+
2604+
[source,java,indent=0]
2605+
[subs="verbatim,quotes"]
2606+
----
2607+
exampleBean.setEmail(null)
2608+
----
26032609

26042610

26052611
[[beans-p-namespace]]
@@ -3779,7 +3785,7 @@ of the scope. You can also do the `Scope` registration declaratively, using the
37793785

37803786
[NOTE]
37813787
====
3782-
When you place <aop:scoped-proxy/> in a `FactoryBean` implementation, it is the factory
3788+
When you place `<aop:scoped-proxy/>` in a `FactoryBean` implementation, it is the factory
37833789
bean itself that is scoped, not the object returned from `getObject()`.
37843790
====
37853791

@@ -4074,7 +4080,7 @@ lifecycle requirements (e.g. starts and stops some background process):
40744080
----
40754081

40764082
Any Spring-managed object may implement that interface. Then, when the
4077-
ApplicationContext itself starts and stops, it will cascade those calls to all Lifecycle
4083+
`ApplicationContext` itself starts and stops, it will cascade those calls to all `Lifecycle`
40784084
implementations defined within that context. It does this by delegating to a
40794085
`LifecycleProcessor`:
40804086

@@ -4126,7 +4132,7 @@ another option, namely the `getPhase()` method as defined on its super-interface
41264132

41274133
When starting, the objects with the lowest phase start first, and when stopping, the
41284134
reverse order is followed. Therefore, an object that implements `SmartLifecycle` and
4129-
whose getPhase() method returns `Integer.MIN_VALUE` would be among the first to start
4135+
whose `getPhase()` method returns `Integer.MIN_VALUE` would be among the first to start
41304136
and the last to stop. At the other end of the spectrum, a phase value of
41314137
`Integer.MAX_VALUE` would indicate that the object should be started last and stopped
41324138
first (likely because it depends on other processes to be running). When considering the
@@ -4136,7 +4142,7 @@ negative phase value would indicate that an object should start before those sta
41364142
components (and stop after them), and vice versa for any positive phase value.
41374143

41384144
As you can see the stop method defined by `SmartLifecycle` accepts a callback. Any
4139-
implementation __must__ invoke that callback's run() method after that implementation's
4145+
implementation __must__ invoke that callback's `run()` method after that implementation's
41404146
shutdown process is complete. That enables asynchronous shutdown where necessary since
41414147
the default implementation of the `LifecycleProcessor` interface,
41424148
`DefaultLifecycleProcessor`, will wait up to its timeout value for the group of objects
@@ -4156,14 +4162,14 @@ defining the following would be sufficient:
41564162

41574163
As mentioned, the `LifecycleProcessor` interface defines callback methods for the
41584164
refreshing and closing of the context as well. The latter will simply drive the shutdown
4159-
process as if stop() had been called explicitly, but it will happen when the context is
4165+
process as if `stop()` had been called explicitly, but it will happen when the context is
41604166
closing. The 'refresh' callback on the other hand enables another feature of
41614167
`SmartLifecycle` beans. When the context is refreshed (after all objects have been
41624168
instantiated and initialized), that callback will be invoked, and at that point the
41634169
default lifecycle processor will check the boolean value returned by each
41644170
`SmartLifecycle` object's `isAutoStartup()` method. If "true", then that object will be
41654171
started at that point rather than waiting for an explicit invocation of the context's or
4166-
its own start() method (unlike the context refresh, the context start does not happen
4172+
its own `start()` method (unlike the context refresh, the context start does not happen
41674173
automatically for a standard context implementation). The "phase" value as well as any
41684174
"depends-on" relationships will determine the startup order in the same way as described
41694175
above.
@@ -4216,8 +4222,8 @@ declared on the `AbstractApplicationContext` class:
42164222
[[beans-factory-aware]]
42174223
==== ApplicationContextAware and BeanNameAware
42184224

4219-
When an `ApplicationContext` creates a class that implements the
4220-
`org.springframework.context.ApplicationContextAware` interface, the class is provided
4225+
When an `ApplicationContext` creates an object instance that implements the
4226+
`org.springframework.context.ApplicationContextAware` interface, the instance is provided
42214227
with a reference to that `ApplicationContext`.
42224228

42234229
[source,java,indent=0]
@@ -4237,8 +4243,8 @@ additional functionality. One use would be the programmatic retrieval of other b
42374243
Sometimes this capability is useful; however, in general you should avoid it, because it
42384244
couples the code to Spring and does not follow the Inversion of Control style, where
42394245
collaborators are provided to beans as properties. Other methods of the
4240-
ApplicationContext provide access to file resources, publishing application events, and
4241-
accessing a MessageSource. These additional features are described in
4246+
`ApplicationContext` provide access to file resources, publishing application events, and
4247+
accessing a `MessageSource`. These additional features are described in
42424248
<<context-introduction>>
42434249

42444250
As of Spring 2.5, autowiring is another alternative to obtain reference to the
@@ -4252,7 +4258,7 @@ parameter that is expecting the `ApplicationContext` type if the field, construc
42524258
method in question carries the `@Autowired` annotation. For more information, see
42534259
<<beans-autowired-annotation>>.
42544260

4255-
When an ApplicationContext creates a class that implements the
4261+
When an `ApplicationContext` creates a class that implements the
42564262
`org.springframework.beans.factory.BeanNameAware` interface, the class is provided with
42574263
a reference to the name defined in its associated object definition.
42584264

0 commit comments

Comments
 (0)