Migrate reference guide to well-formed docbook XML
Convert all docbook XML files to well-formed docbook 5 syntax: - Include xsi:schemaLocation element for tools support - Convert all id elements to xml:id - Convert all ulink elements to link - Simplify <lineannotation> mark-up - Fix misplaced </section> tags - Fix <interface> tags to <interfacename> - Cleanup trailing whitespace and tabs Issue: SPR-10032
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section xmlns="http://docbook.org/ns/docbook" version="5.0"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
<section xml:id="beans-dependencies"
|
||||
xmlns="http://docbook.org/ns/docbook" version="5.0"
|
||||
xmlns:xl="http://www.w3.org/1999/xlink"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xml:id="beans-dependencies">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd
|
||||
http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd">
|
||||
<title>Dependencies</title>
|
||||
|
||||
<para>A typical enterprise application does not consist of a single object (or
|
||||
@@ -12,7 +16,7 @@
|
||||
bean definitions that stand alone to a fully realized application where
|
||||
objects collaborate to achieve a goal.</para>
|
||||
|
||||
<section id="beans-factory-collaborators">
|
||||
<section xml:id="beans-factory-collaborators">
|
||||
<title>Dependency injection</title>
|
||||
|
||||
<!-- MLP: Beverly review the following two paragraphs -->
|
||||
@@ -41,7 +45,7 @@
|
||||
injection</link> and <link linkend="beans-setter-injection">Setter-based
|
||||
dependency injection</link>.</para>
|
||||
|
||||
<section id="beans-constructor-injection">
|
||||
<section xml:id="beans-constructor-injection">
|
||||
<title>Constructor-based dependency injection</title>
|
||||
|
||||
<para><emphasis>Constructor-based</emphasis> DI is accomplished by the
|
||||
@@ -58,18 +62,18 @@
|
||||
|
||||
<programlisting language="java">public class SimpleMovieLister {
|
||||
|
||||
<lineannotation>// the <classname>SimpleMovieLister</classname> has a dependency on a <interfacename>MovieFinder</interfacename></lineannotation>
|
||||
<lineannotation>// the SimpleMovieLister has a dependency on a MovieFinder</lineannotation>
|
||||
private MovieFinder movieFinder;
|
||||
|
||||
<lineannotation>// a constructor so that the Spring container can 'inject' a <interfacename>MovieFinder</interfacename></lineannotation>
|
||||
<lineannotation>// a constructor so that the Spring container can 'inject' a MovieFinder</lineannotation>
|
||||
public SimpleMovieLister(MovieFinder movieFinder) {
|
||||
this.movieFinder = movieFinder;
|
||||
}
|
||||
|
||||
<lineannotation>// business logic that actually 'uses' the injected <interfacename>MovieFinder</interfacename> is omitted...</lineannotation>
|
||||
<lineannotation>// business logic that actually 'uses' the injected MovieFinder is omitted...</lineannotation>
|
||||
}</programlisting>
|
||||
|
||||
<section id="beans-factory-ctor-arguments-resolution">
|
||||
<section xml:id="beans-factory-ctor-arguments-resolution">
|
||||
<title>Constructor argument resolution</title>
|
||||
|
||||
<para>Constructor argument resolution matching occurs using the
|
||||
@@ -129,7 +133,7 @@ public class ExampleBean {
|
||||
}
|
||||
}</programlisting>
|
||||
|
||||
<section id="beans-factory-ctor-arguments-type">
|
||||
<section xml:id="beans-factory-ctor-arguments-type">
|
||||
<title>Constructor argument type matching</title>
|
||||
|
||||
<para>In the preceding scenario, the container
|
||||
@@ -143,7 +147,7 @@ public class ExampleBean {
|
||||
</bean></programlisting>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-ctor-arguments-index">
|
||||
<section xml:id="beans-factory-ctor-arguments-index">
|
||||
<title>Constructor argument index</title>
|
||||
|
||||
<para>Use the <literal>index</literal> attribute to specify explicitly
|
||||
@@ -160,7 +164,7 @@ public class ExampleBean {
|
||||
0 based</emphasis>.</para>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-ctor-arguments-name">
|
||||
<section xml:id="beans-factory-ctor-arguments-name">
|
||||
<title>Constructor argument name</title>
|
||||
|
||||
<para>As of Spring 3.0 you can also use the constructor parameter
|
||||
@@ -175,8 +179,8 @@ public class ExampleBean {
|
||||
must be compiled with the debug flag enabled so that Spring can
|
||||
look up the parameter name from the constructor. If you can't compile
|
||||
your code with debug flag (or don't want to) you can use
|
||||
<interfacename><ulink
|
||||
url="http://download.oracle.com/javase/6/docs/api/java/beans/ConstructorProperties.html">@ConstructorProperties</ulink></interfacename>
|
||||
<interfacename><link
|
||||
xl:href="http://download.oracle.com/javase/6/docs/api/java/beans/ConstructorProperties.html">@ConstructorProperties</link></interfacename>
|
||||
JDK annotation to explicitly name your constructor arguments. The
|
||||
sample class would then have to look as follows:</para>
|
||||
|
||||
@@ -196,7 +200,7 @@ public class ExampleBean {
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="beans-setter-injection">
|
||||
<section xml:id="beans-setter-injection">
|
||||
<title>Setter-based dependency injection</title>
|
||||
|
||||
<para><emphasis>Setter-based</emphasis> DI is accomplished by the
|
||||
@@ -211,15 +215,15 @@ public class ExampleBean {
|
||||
|
||||
<programlisting language="java">public class SimpleMovieLister {
|
||||
|
||||
<lineannotation>// the <classname>SimpleMovieLister</classname> has a dependency on the <interfacename>MovieFinder</interfacename></lineannotation>
|
||||
<lineannotation>// the SimpleMovieLister has a dependency on the MovieFinder</lineannotation>
|
||||
private MovieFinder movieFinder;
|
||||
|
||||
<lineannotation>// a setter method so that the Spring container can 'inject' a <interfacename>MovieFinder</interfacename></lineannotation>
|
||||
<lineannotation>// a setter method so that the Spring container can 'inject' a MovieFinder</lineannotation>
|
||||
public void setMovieFinder(MovieFinder movieFinder) {
|
||||
this.movieFinder = movieFinder;
|
||||
}
|
||||
|
||||
<lineannotation>// business logic that actually 'uses' the injected <interfacename>MovieFinder</interfacename> is omitted...</lineannotation>
|
||||
<lineannotation>// business logic that actually 'uses' the injected MovieFinder is omitted...</lineannotation>
|
||||
}</programlisting>
|
||||
|
||||
<para>The <interfacename>ApplicationContext</interfacename> supports
|
||||
@@ -265,7 +269,7 @@ public class ExampleBean {
|
||||
</sidebar>
|
||||
</section>
|
||||
|
||||
<section id="beans-dependency-resolution">
|
||||
<section xml:id="beans-dependency-resolution">
|
||||
<title>Dependency resolution process</title>
|
||||
|
||||
<para>The container performs bean dependency resolution as follows:</para>
|
||||
@@ -371,7 +375,7 @@ public class ExampleBean {
|
||||
callback method</link>) are invoked.</para>
|
||||
</section>
|
||||
|
||||
<section id="beans-some-examples">
|
||||
<section xml:id="beans-some-examples">
|
||||
<title>Examples of dependency injection</title>
|
||||
|
||||
<para>The following example uses XML-based configuration metadata for
|
||||
@@ -380,7 +384,7 @@ public class ExampleBean {
|
||||
|
||||
<programlisting language="xml"><bean id="exampleBean" class="examples.ExampleBean">
|
||||
|
||||
<lineannotation><!-- setter injection using the nested <literal><ref/></literal> element --></lineannotation>
|
||||
<lineannotation><!-- setter injection using the nested <ref/> element --></lineannotation>
|
||||
<property name="beanOne"><ref bean="anotherExampleBean"/></property>
|
||||
|
||||
<lineannotation><!-- setter injection using the neater 'ref' attribute --></lineannotation>
|
||||
@@ -416,7 +420,7 @@ public class ExampleBean {
|
||||
|
||||
<programlisting language="xml"><bean id="exampleBean" class="examples.ExampleBean">
|
||||
|
||||
<lineannotation><!-- constructor injection using the nested <literal><ref/></literal> element --></lineannotation>
|
||||
<lineannotation><!-- constructor injection using the nested <ref/> element --></lineannotation>
|
||||
<constructor-arg>
|
||||
<ref bean="anotherExampleBean"/>
|
||||
</constructor-arg>
|
||||
@@ -494,7 +498,7 @@ public class ExampleBean {
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-properties-detailed">
|
||||
<section xml:id="beans-factory-properties-detailed">
|
||||
<title>Dependencies and configuration in detail</title>
|
||||
|
||||
<para>As mentioned in the previous section, you can define bean properties
|
||||
@@ -505,7 +509,7 @@ public class ExampleBean {
|
||||
<literal><constructor-arg/></literal> elements for this
|
||||
purpose.</para>
|
||||
|
||||
<section id="beans-value-element">
|
||||
<section xml:id="beans-value-element">
|
||||
<title>Straight values (primitives, <literal>Strings</literal>, and so
|
||||
on)</title>
|
||||
|
||||
@@ -519,7 +523,7 @@ public class ExampleBean {
|
||||
|
||||
<programlisting language="xml"><bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||
|
||||
<lineannotation><!-- results in a <methodname>setDriverClassName(String)</methodname> call --></lineannotation>
|
||||
<lineannotation><!-- results in a setDriverClassName(String) call --></lineannotation>
|
||||
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
|
||||
<property name="url" value="jdbc:mysql://localhost:3306/mydb"/>
|
||||
<property name="username" value="root"/>
|
||||
@@ -547,10 +551,10 @@ public class ExampleBean {
|
||||
</programlisting>
|
||||
|
||||
<para>The preceding XML is more succinct; however, typos are discovered at
|
||||
runtime rather than design time, unless you use an IDE such as <ulink
|
||||
url="http://www.jetbrains.com/idea/">IntelliJ IDEA</ulink> or the <ulink
|
||||
url="http://www.springsource.com/products/sts">SpringSource Tool
|
||||
Suite</ulink> (STS) that support automatic property completion when you
|
||||
runtime rather than design time, unless you use an IDE such as <link
|
||||
xl:href="http://www.jetbrains.com/idea/">IntelliJ IDEA</link> or the <link
|
||||
xl:href="http://www.springsource.com/products/sts">SpringSource Tool
|
||||
Suite</link> (STS) that support automatic property completion when you
|
||||
create bean definitions. Such IDE assistance is highly
|
||||
recommended.</para>
|
||||
|
||||
@@ -560,7 +564,7 @@ public class ExampleBean {
|
||||
<programlisting language="xml"><bean id="mappings"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
|
||||
<lineannotation><!-- typed as a <classname>java.util.Properties</classname> --></lineannotation>
|
||||
<lineannotation><!-- typed as a java.util.Properties --></lineannotation>
|
||||
<property name="properties">
|
||||
<value>
|
||||
jdbc.driver.className=com.mysql.jdbc.Driver
|
||||
@@ -577,7 +581,7 @@ public class ExampleBean {
|
||||
favor the use of the nested <literal><value/></literal> element
|
||||
over the <literal>value</literal> attribute style.</para>
|
||||
|
||||
<section id="beans-idref-element">
|
||||
<section xml:id="beans-idref-element">
|
||||
<title>The <literal>idref</literal> element</title>
|
||||
|
||||
<para>The <literal>idref</literal> element is simply an error-proof way
|
||||
@@ -622,7 +626,7 @@ public class ExampleBean {
|
||||
to validate the bean id earlier, at XML document parse time.</para>
|
||||
|
||||
<programlisting language="xml"><property name="targetName">
|
||||
<lineannotation><!-- a bean with id '<literal>theTargetBean</literal>' must exist; otherwise an exception will be thrown --></lineannotation>
|
||||
<lineannotation><!-- a bean with id 'theTargetBean' must exist; otherwise an exception will be thrown --></lineannotation>
|
||||
<idref local="theTargetBean"/>
|
||||
</property></programlisting>
|
||||
|
||||
@@ -635,7 +639,7 @@ public class ExampleBean {
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="beans-ref-element">
|
||||
<section xml:id="beans-ref-element">
|
||||
<title>References to other beans (collaborators)</title>
|
||||
|
||||
<para>The <literal>ref</literal> element is the final element inside a
|
||||
@@ -649,7 +653,7 @@ public class ExampleBean {
|
||||
container.) All references are ultimately a reference to another object.
|
||||
Scoping and validation depend on whether you specify the id/name of the
|
||||
other object through the
|
||||
<literal>bean,<literal>local,</literal></literal> or
|
||||
<literal>bean</literal>,<literal>local,</literal> or
|
||||
<literal>parent</literal> attributes.</para>
|
||||
|
||||
<para>Specifying the target bean through the <literal>bean</literal>
|
||||
@@ -701,7 +705,7 @@ public class ExampleBean {
|
||||
</bean></programlisting>
|
||||
</section>
|
||||
|
||||
<section id="beans-inner-beans">
|
||||
<section xml:id="beans-inner-beans">
|
||||
<title>Inner beans</title>
|
||||
|
||||
<para>A <literal><bean/></literal> element inside the
|
||||
@@ -729,7 +733,7 @@ public class ExampleBean {
|
||||
collaborating beans other than into the enclosing bean.</para>
|
||||
</section>
|
||||
|
||||
<section id="beans-collection-elements">
|
||||
<section xml:id="beans-collection-elements">
|
||||
<title>Collections</title>
|
||||
|
||||
<para>In the <literal><list/></literal>,
|
||||
@@ -741,7 +745,7 @@ public class ExampleBean {
|
||||
<interfacename>Properties</interfacename>, respectively.</para>
|
||||
|
||||
<programlisting language="xml"><bean id="moreComplexObject" class="example.ComplexObject">
|
||||
<lineannotation><!-- results in a setAdminEmails(<classname>java.util.Properties</classname>) call --></lineannotation>
|
||||
<lineannotation><!-- results in a setAdminEmails(java.util.Properties) call --></lineannotation>
|
||||
<property name="adminEmails">
|
||||
<props>
|
||||
<prop key="administrator">administrator@example.org</prop>
|
||||
@@ -749,14 +753,14 @@ public class ExampleBean {
|
||||
<prop key="development">development@example.org</prop>
|
||||
</props>
|
||||
</property>
|
||||
<lineannotation><!-- results in a setSomeList(<interfacename>java.util.List</interfacename>) call --></lineannotation>
|
||||
<lineannotation><!-- results in a setSomeList(java.util.List) call --></lineannotation>
|
||||
<property name="someList">
|
||||
<list>
|
||||
<value>a list element followed by a reference</value>
|
||||
<ref bean="myDataSource" />
|
||||
</list>
|
||||
</property>
|
||||
<lineannotation><!-- results in a setSomeMap(<interfacename>java.util.Map</interfacename>) call --></lineannotation>
|
||||
<lineannotation><!-- results in a setSomeMap(java.util.Map) call --></lineannotation>
|
||||
<property name="someMap">
|
||||
<map>
|
||||
<entry key="an entry" value="just some string"/>
|
||||
@@ -777,7 +781,7 @@ public class ExampleBean {
|
||||
|
||||
<programlisting language="xml">bean | ref | idref | list | set | map | props | value | null</programlisting>
|
||||
|
||||
<section id="beans-collection-elements-merging">
|
||||
<section xml:id="beans-collection-elements-merging">
|
||||
<title>Collection merging</title>
|
||||
|
||||
<para>As of Spring 2.0, the container supports the
|
||||
@@ -859,7 +863,7 @@ support=support@example.co.uk</programlisting>
|
||||
the container uses internally.</para>
|
||||
</section>
|
||||
|
||||
<section id="beans-collection-merge-limitations">
|
||||
<section xml:id="beans-collection-merge-limitations">
|
||||
<title>Limitations of collection merging</title>
|
||||
|
||||
<para>You cannot merge different collection types (such as a
|
||||
@@ -873,7 +877,7 @@ support=support@example.co.uk</programlisting>
|
||||
in Spring 2.0 and later.</para>
|
||||
</section>
|
||||
|
||||
<section id="beans-collection-elements-strongly-typed">
|
||||
<section xml:id="beans-collection-elements-strongly-typed">
|
||||
<title>Strongly-typed collection (Java 5+ only)</title>
|
||||
|
||||
<para>In Java 5 and later, you can use strongly typed collections (using
|
||||
@@ -920,7 +924,7 @@ support=support@example.co.uk</programlisting>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="beans-null-element">
|
||||
<section xml:id="beans-null-element">
|
||||
<title>Null and empty string values</title>
|
||||
|
||||
<para><!--Clarify difference between null value and empty string value?-->Spring
|
||||
@@ -946,7 +950,7 @@ support=support@example.co.uk</programlisting>
|
||||
<methodname>exampleBean.setEmail(null)</methodname>.</para>
|
||||
</section>
|
||||
|
||||
<section id="beans-p-namespace">
|
||||
<section xml:id="beans-p-namespace">
|
||||
<title>XML shortcut with the p-namespace</title>
|
||||
|
||||
<para>The p-namespace enables you to use the <literal>bean</literal>
|
||||
@@ -1030,26 +1034,26 @@ support=support@example.co.uk</programlisting>
|
||||
time.<!--Clarify ref to all three approaches.I see two, XML and namespace.--></para>
|
||||
</note>
|
||||
</section>
|
||||
|
||||
<section id="beans-c-namespace">
|
||||
|
||||
<section xml:id="beans-c-namespace">
|
||||
<title>XML shortcut with the c-namespace</title>
|
||||
|
||||
<para>Similar to the <xref linkend="beans-p-namespace"/>, the <emphasis>c-namespace</emphasis>, newly introduced in Spring 3.1,
|
||||
|
||||
<para>Similar to the <xref linkend="beans-p-namespace"/>, the <emphasis>c-namespace</emphasis>, newly introduced in Spring 3.1,
|
||||
allows usage of inlined attributes for configuring the constructor arguments rather then nested <literal>constructor-arg</literal>
|
||||
elements.</para>
|
||||
|
||||
|
||||
<para>Let's review the examples from <xref linkend="beans-constructor-injection"/> with the <literal>c</literal> namespace:</para>
|
||||
|
||||
|
||||
<programlisting language="java"><beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:c="http://www.springframework.org/schema/c"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
|
||||
<bean id="bar" class="x.y.Bar"/>
|
||||
<bean id="baz" class="x.y.Baz"/>
|
||||
|
||||
<-- 'traditional' declaration -->
|
||||
<-- 'traditional' declaration -->
|
||||
<bean id="foo" class="x.y.Foo">
|
||||
<constructor-arg ref="bar"/>
|
||||
<constructor-arg ref="baz"/>
|
||||
@@ -1061,24 +1065,24 @@ support=support@example.co.uk</programlisting>
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<para>The <literal>c:</literal> namespace uses the same conventions as the <literal>p:</literal> one (trailing <literal>-ref</literal> for bean references)
|
||||
for setting the constructor arguments by their names. And just as well, it needs to be declared even though it is not defined in an XSD schema
|
||||
(but it exists inside the Spring core).</para>
|
||||
|
||||
<para>For the rare cases where the constructor argument names are not available (usually if the bytecode was compiled without debugging information), one can
|
||||
use fallback to the argument indexes:</para>
|
||||
<para>The <literal>c:</literal> namespace uses the same conventions as the <literal>p:</literal> one (trailing <literal>-ref</literal> for bean references)
|
||||
for setting the constructor arguments by their names. And just as well, it needs to be declared even though it is not defined in an XSD schema
|
||||
(but it exists inside the Spring core).</para>
|
||||
|
||||
<para>For the rare cases where the constructor argument names are not available (usually if the bytecode was compiled without debugging information), one can
|
||||
use fallback to the argument indexes:</para>
|
||||
|
||||
<programlisting language="java"><-- 'c-namespace' index declaration -->
|
||||
<bean id="foo" class="x.y.Foo" c:_0-ref="bar" c:_1-ref="baz"></programlisting>
|
||||
|
||||
<note>Due to the XML grammar, the index notation requires the presence of the leading <emphasis>_</emphasis> as XML attribute names cannot start
|
||||
with a number (even though some IDE allow it).</note>
|
||||
|
||||
<para>In practice, the constructor resolution <link linkend="beans-factory-ctor-arguments-resolution">mechanism</link> is quite efficient in matching arguments so
|
||||
unless one really needs to, we recommend using the name notation through-out your configuration.</para>
|
||||
<note><para>Due to the XML grammar, the index notation requires the presence of the leading <emphasis>_</emphasis> as XML attribute names cannot start
|
||||
with a number (even though some IDE allow it).</para></note>
|
||||
|
||||
<para>In practice, the constructor resolution <link linkend="beans-factory-ctor-arguments-resolution">mechanism</link> is quite efficient in matching arguments so
|
||||
unless one really needs to, we recommend using the name notation through-out your configuration.</para>
|
||||
</section>
|
||||
|
||||
<section id="beans-compound-property-names">
|
||||
<section xml:id="beans-compound-property-names">
|
||||
<title>Compound property names</title>
|
||||
|
||||
<para>You can use compound or nested property names when you set bean
|
||||
@@ -1102,7 +1106,7 @@ support=support@example.co.uk</programlisting>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-dependson">
|
||||
<section xml:id="beans-factory-dependson">
|
||||
<title>Using <literal>depends-on</literal></title>
|
||||
|
||||
<para>If a bean is a dependency of another that usually means that one bean
|
||||
@@ -1144,7 +1148,7 @@ support=support@example.co.uk</programlisting>
|
||||
</note>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-lazy-init">
|
||||
<section xml:id="beans-factory-lazy-init">
|
||||
<title>Lazy-initialized
|
||||
beans<!--Changed to lazy-initialized from lazily instantiated because attribute is lazy-init, and there was a lot of inconsistency. --></title>
|
||||
|
||||
@@ -1190,7 +1194,7 @@ support=support@example.co.uk</programlisting>
|
||||
</beans></programlisting>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-autowire">
|
||||
<section xml:id="beans-factory-autowire">
|
||||
<title>Autowiring collaborators</title>
|
||||
|
||||
<!--I've moved around info and done a lot of editing/reformatting in this section, but nothing is missing.-->
|
||||
@@ -1225,7 +1229,7 @@ support=support@example.co.uk</programlisting>
|
||||
five modes. You specify autowiring <emphasis>per</emphasis> bean and thus
|
||||
can choose which ones to autowire.</para>
|
||||
|
||||
<table id="beans-factory-autowiring-modes-tbl">
|
||||
<table xml:id="beans-factory-autowiring-modes-tbl">
|
||||
<title>Autowiring modes</title>
|
||||
|
||||
<tgroup cols="2">
|
||||
@@ -1301,7 +1305,7 @@ support=support@example.co.uk</programlisting>
|
||||
<para>You can combine autowire behavior with dependency checking, which is
|
||||
performed after autowiring completes.</para>
|
||||
|
||||
<section id="beans-autowired-exceptions">
|
||||
<section xml:id="beans-autowired-exceptions">
|
||||
<title>Limitations and disadvantages of autowiring</title>
|
||||
|
||||
<para>Autowiring works best when it is used consistently across a project.
|
||||
@@ -1377,7 +1381,7 @@ support=support@example.co.uk</programlisting>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-autowire-candidate">
|
||||
<section xml:id="beans-factory-autowire-candidate">
|
||||
<title>Excluding a bean from autowiring</title>
|
||||
|
||||
<para>On a per-bean basis, you can exclude a bean from autowiring. In
|
||||
@@ -1410,7 +1414,7 @@ support=support@example.co.uk</programlisting>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-method-injection">
|
||||
<section xml:id="beans-factory-method-injection">
|
||||
<title>Method injection</title>
|
||||
|
||||
<para>In most application scenarios, most beans in the container are <link
|
||||
@@ -1446,9 +1450,9 @@ public class CommandManager implements ApplicationContextAware {
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
public Object process(Map commandState) {
|
||||
<lineannotation>// grab a new instance of the appropriate <interfacename>Command</interfacename></lineannotation>
|
||||
<lineannotation>// grab a new instance of the appropriate Command</lineannotation>
|
||||
Command command = createCommand();
|
||||
<lineannotation>// set the state on the (hopefully brand new) <interfacename>Command</interfacename> instance</lineannotation>
|
||||
<lineannotation>// set the state on the (hopefully brand new) Command instance</lineannotation>
|
||||
command.setState(commandState);
|
||||
return command.execute();
|
||||
}
|
||||
@@ -1472,11 +1476,11 @@ public class CommandManager implements ApplicationContextAware {
|
||||
|
||||
<sidebar>
|
||||
<para>You can read more about the motivation for Method Injection in
|
||||
<ulink url="http://blog.springsource.com/2004/08/06/method-injection/"
|
||||
>this blog entry</ulink>.</para>
|
||||
<link xl:href="http://blog.springsource.com/2004/08/06/method-injection/"
|
||||
>this blog entry</link>.</para>
|
||||
</sidebar>
|
||||
|
||||
<section id="beans-factory-lookup-method-injection">
|
||||
<section xml:id="beans-factory-lookup-method-injection">
|
||||
<title>Lookup method injection</title>
|
||||
|
||||
<!--Deleted a box here that doesn't seem to have much info; I moved the blog entry link above. -->
|
||||
@@ -1519,9 +1523,9 @@ public class CommandManager implements ApplicationContextAware {
|
||||
public abstract class CommandManager {
|
||||
|
||||
public Object process(Object commandState) {
|
||||
<lineannotation>// grab a new instance of the appropriate <interfacename>Command</interfacename> interface</lineannotation>
|
||||
<lineannotation>// grab a new instance of the appropriate Command interface</lineannotation>
|
||||
Command command = createCommand();
|
||||
<lineannotation>// set the state on the (hopefully brand new) <interfacename>Command</interfacename> instance</lineannotation>
|
||||
<lineannotation>// set the state on the (hopefully brand new) Command instance</lineannotation>
|
||||
command.setState(commandState);
|
||||
return command.execute();
|
||||
}
|
||||
@@ -1546,7 +1550,7 @@ public abstract class CommandManager {
|
||||
<lineannotation><!-- inject dependencies here as required --></lineannotation>
|
||||
</bean>
|
||||
|
||||
<lineannotation><!-- <literal>commandProcessor</literal> uses <literal>statefulCommandHelper</literal> --></lineannotation>
|
||||
<lineannotation><!-- commandProcessor uses statefulCommandHelper --></lineannotation>
|
||||
<bean id="commandManager" class="fiona.apple.CommandManager">
|
||||
<lookup-method name="createCommand" bean="command"/>
|
||||
</bean></programlisting>
|
||||
@@ -1569,14 +1573,14 @@ public abstract class CommandManager {
|
||||
<classname>ObjectFactoryCreatingFactoryBean</classname>, but it allows
|
||||
you to specify your own lookup interface as opposed to a
|
||||
Spring-specific lookup interface. Consult the JavaDocs for these
|
||||
classes as well as this <ulink
|
||||
url="http://blog.arendsen.net/index.php/2006/10/05/on-the-servicelocatorfactorybean-dlas-and-the-sustainability-of-code-and-design/"
|
||||
>blog entry</ulink> for additional information
|
||||
classes as well as this <link
|
||||
xl:href="http://blog.arendsen.net/index.php/2006/10/05/on-the-servicelocatorfactorybean-dlas-and-the-sustainability-of-code-and-design/"
|
||||
>blog entry</link> for additional information
|
||||
ServiceLocatorFactoryBean.</para>
|
||||
</tip>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-arbitrary-method-replacement">
|
||||
<section xml:id="beans-factory-arbitrary-method-replacement">
|
||||
<title>Arbitrary method replacement</title>
|
||||
|
||||
<para>A less useful form of method injection than lookup method Injection
|
||||
@@ -1604,8 +1608,8 @@ public String computeValue(String input) {
|
||||
<interfacename>org.springframework.beans.factory.support.MethodReplacer</interfacename>
|
||||
interface provides the new method definition.</para>
|
||||
|
||||
<programlisting language="java"><lineannotation>/** meant to be used to override the existing <methodname>computeValue(String)</methodname>
|
||||
implementation in <classname>MyValueCalculator</classname>
|
||||
<programlisting language="java"><lineannotation>/** meant to be used to override the existing computeValue(String)
|
||||
implementation in MyValueCalculator
|
||||
*/</lineannotation>
|
||||
public class ReplacementComputeValue implements MethodReplacer {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user