updates made during my review of beans.xml:
* eliminated all usage of "the section entitled", because <xref> links already render including "the section called ". This was resulting in sentences like 'see also the section entitled the section called "@Autowired"'. This issue affected nearly all sections of the documentation, so went beyond just beans.xml * fixed table overflow in the "Using filters to customize scanning" section (approx. p.90) * fixed all code overflows in <programlisting/> elements * corrected a couple minor syntax errors with SpEL examples (missing closing braces) * added 'language="..."' element to <programlisting> elements where appropriate to enable syntax highlighting. * normalized all code indention to four-space (some code listings were using one- and two-space) * updated all code listings to use same-line opening braces. * eliminated section regarding backward compatibility with Spring DTDs and singleton=true|false. This seems like cruft to me, and we shouldn't keep historical notes around forever. * Added <note> regarding the new thread scope (SimpleThreadScope) to Section 3.5 Bean Scopes. Also updated the section on registering a custom Scope implementation to use the SimpleThreadScope as an example. * updated the new-in-3.xml section to improve the @Configuration example
This commit is contained in:
@@ -859,8 +859,8 @@ public interface IntroductionInfo {
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Specify whether to use CGLIB (see below and also the section
|
||||
entitled <xref linkend="aop-pfb-proxy-types" />).</para>
|
||||
<para>Specify whether to use CGLIB (see below and also
|
||||
<xref linkend="aop-pfb-proxy-types" />).</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
@@ -875,8 +875,7 @@ public interface IntroductionInfo {
|
||||
if the target class is to be proxied, rather than the target class'
|
||||
interfaces. If this property value is set to
|
||||
<literal>true</literal>, then CGLIB proxies will be created (but see
|
||||
also below the section entitled <xref
|
||||
linkend="aop-pfb-proxy-types" />).</para>
|
||||
also <xref linkend="aop-pfb-proxy-types" />).</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
@@ -927,8 +926,7 @@ public interface IntroductionInfo {
|
||||
<listitem>
|
||||
<para><literal>proxyInterfaces</literal>: array of String interface
|
||||
names. If this isn't supplied, a CGLIB proxy for the target class
|
||||
will be used (but see also below the section entitled <xref
|
||||
linkend="aop-pfb-proxy-types" />).</para>
|
||||
will be used (but see also <xref linkend="aop-pfb-proxy-types" />).</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
|
||||
@@ -271,8 +271,8 @@
|
||||
indication that the Spring team favors the @AspectJ annotation-style
|
||||
approach over the Spring XML configuration-style.</para>
|
||||
|
||||
<para>See the section entitled <xref linkend="aop-choosing" /> for a
|
||||
fuller discussion of the whys and wherefores of each style.</para>
|
||||
<para>See <xref linkend="aop-choosing" /> for a
|
||||
more complete discussion of the whys and wherefores of each style.</para>
|
||||
</note>
|
||||
</section>
|
||||
|
||||
@@ -294,7 +294,7 @@
|
||||
to a method as a concrete type.</para>
|
||||
|
||||
<para>It is important to grasp the fact that Spring AOP is
|
||||
<emphasis>proxy-based</emphasis>. See the section entitled <xref
|
||||
<emphasis>proxy-based</emphasis>. See <xref
|
||||
linkend="aop-understanding-aop-proxies" /> for a thorough examination of
|
||||
exactly what this implementation detail actually means.</para>
|
||||
</section>
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
<para>This chapter covers the Spring Framework implementation of the
|
||||
Inversion of Control (IoC) <footnote>
|
||||
<para>See the section entitled <xref
|
||||
linkend="background-ioc" /></para>
|
||||
<para>See <xref linkend="background-ioc" /></para>
|
||||
</footnote>principle. IoC is also known as <emphasis>dependency
|
||||
injection</emphasis> (DI). It is a process whereby objects define their
|
||||
dependencies, that is, the other objects they work with, only through
|
||||
@@ -216,8 +215,8 @@ The footnote should x-ref to first section in that chapter but I can't find the
|
||||
metadata from a variety of external resources such as the local file
|
||||
system, from the Java <literal>CLASSPATH</literal>, and so on.</para>
|
||||
|
||||
<programlisting language="java">ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"services.xml",
|
||||
"daos.xml"});</programlisting>
|
||||
<programlisting language="java">ApplicationContext context =
|
||||
new ClassPathXmlApplicationContext(new String[] {"services.xml", "daos.xml"});</programlisting>
|
||||
|
||||
<note>
|
||||
<para>After you learn about Spring's IoC container, you may want to
|
||||
@@ -233,7 +232,7 @@ The footnote should x-ref to first section in that chapter but I can't find the
|
||||
<para>The following example shows the service layer objects
|
||||
<literal>(services.xml)</literal> configuration file:</para>
|
||||
|
||||
<programlisting><?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
@@ -256,13 +255,14 @@ The footnote should x-ref to first section in that chapter but I can't find the
|
||||
<para>The following example shows the data access objects
|
||||
<literal>daos.xml</literal>) file:</para>
|
||||
|
||||
<programlisting><?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<bean id="accountDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao">
|
||||
<bean id="accountDao"
|
||||
class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao">
|
||||
<!-- additional collaborators and configuration for this bean go here -->
|
||||
</bean>
|
||||
|
||||
@@ -361,7 +361,8 @@ The footnote should x-ref to first section in that chapter but I can't find the
|
||||
to read bean definitions and access them as follows:</para>
|
||||
|
||||
<programlisting language="java">// create and configure beans
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"services.xml", "daos.xml"});
|
||||
ApplicationContext context =
|
||||
new ClassPathXmlApplicationContext(new String[] {"services.xml", "daos.xml"});
|
||||
|
||||
// retrieve configured instance
|
||||
PetStoreServiceImpl service = context.getBean("petStore", PetStoreServiceImpl.class);
|
||||
@@ -1076,7 +1077,7 @@ public class ExampleBean {
|
||||
properties themselves are not set until the bean <emphasis>is actually
|
||||
created</emphasis>. Beans that are singleton-scoped and set to be
|
||||
pre-instantiated (the default) are created when the container is
|
||||
created. Scopes are defined in the section <xref
|
||||
created. Scopes are defined in <xref
|
||||
linkend="beans-factory-scopes" /> Otherwise, the bean is created only
|
||||
when it is requested. Creation of a bean potentially causes a graph of
|
||||
beans to be created, as the bean's dependencies and its dependencies'
|
||||
@@ -1300,19 +1301,19 @@ public class ExampleBean {
|
||||
linkend="beans-p-namespace">p-namespace</link> for even more succinct
|
||||
XML configuration.</para>
|
||||
|
||||
<programlisting><beans xmlns="http://www.springframework.org/schema/beans"
|
||||
<programlisting language="xml"><beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
|
||||
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close"
|
||||
p:driverClassName="com.mysql.jdbc.Driver"
|
||||
p:url="jdbc:mysql://localhost:3306/mydb"
|
||||
p:username="root"
|
||||
p:password="masterkaoli"/>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
</programlisting>
|
||||
@@ -1329,8 +1330,9 @@ public class ExampleBean {
|
||||
<para>You can also configure a
|
||||
<classname>java.util.Properties</classname> instance as:</para>
|
||||
|
||||
<programlisting language="xml"><bean id="mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
|
||||
<programlisting language="xml"><bean id="mappings"
|
||||
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
|
||||
<lineannotation><!-- typed as a <classname>java.util.Properties</classname> --></lineannotation>
|
||||
<property name="properties">
|
||||
<value>
|
||||
@@ -1395,7 +1397,7 @@ public class ExampleBean {
|
||||
time.</para>
|
||||
|
||||
<programlisting language="xml"><property name="targetName">
|
||||
<lineannotation><!-- a bean with an id of '<literal>theTargetBean</literal>' must exist; otherwise an XML exception will be thrown --></lineannotation>
|
||||
<lineannotation><!-- a bean with id '<literal>theTargetBean</literal>' must exist; otherwise an exception will be thrown --></lineannotation>
|
||||
<idref local="theTargetBean"/>
|
||||
</property></programlisting>
|
||||
|
||||
@@ -1465,14 +1467,12 @@ public class ExampleBean {
|
||||
</bean></programlisting>
|
||||
|
||||
<programlisting language="xml"><lineannotation><!-- in the child (descendant) context --></lineannotation>
|
||||
<bean id="accountService" <lineannotation><-- notice that the name of this bean is the <emphasis
|
||||
role="bold">same</emphasis> as the name of the <literal>parent</literal> bean</lineannotation>
|
||||
<bean id="accountService" <lineannotation><-- bean name is the same as the parent bean --></lineannotation>
|
||||
class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="target">
|
||||
<ref parent="accountService"/> <lineannotation><-- notice how we refer to the <emphasis
|
||||
role="bold">parent</emphasis> bean</lineannotation>
|
||||
<ref parent="accountService"/> <lineannotation><!-- notice how we refer to the parent bean --></lineannotation>
|
||||
</property>
|
||||
<lineannotation><!-- insert other configuration and dependencies as required as here --></lineannotation>
|
||||
<lineannotation><!-- insert other configuration and dependencies as required here --></lineannotation>
|
||||
</bean></programlisting>
|
||||
</section>
|
||||
|
||||
@@ -2231,8 +2231,8 @@ support=support@example.co.uk</programlisting>
|
||||
</table>
|
||||
|
||||
<para>If you use Java 5 and thus have access to source-level
|
||||
annotations, you may find <xref
|
||||
linkend="metadata-annotations-required" /> to be of interest.</para>
|
||||
annotations, you may find <literal><xref
|
||||
linkend="metadata-annotations-required" /></literal> to be of interest.</para>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-method-injection">
|
||||
@@ -2278,12 +2278,13 @@ public class CommandManager implements ApplicationContextAware {
|
||||
return command.execute();
|
||||
}
|
||||
|
||||
<lineannotation>// the <interfacename>Command</interfacename> returned here could be an implementation that executes asynchronously, or whatever</lineannotation>
|
||||
protected Command createCommand() {
|
||||
return this.applicationContext.getBean("command", Command.class); <lineannotation>// notice the Spring API dependency</lineannotation>
|
||||
<lineannotation>// notice the Spring API dependency!</lineannotation>
|
||||
return this.applicationContext.getBean("command", Command.class);
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
public void setApplicationContext(ApplicationContext applicationContext)
|
||||
throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
}</programlisting>
|
||||
@@ -2565,6 +2566,14 @@ public class ReplacementComputeValue implements MethodReplacer {
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
<note>
|
||||
<title>Thread-scoped beans</title>
|
||||
<para>As of Spring 3.0, a <emphasis>thread scope</emphasis> is available, but is
|
||||
not registered by default. For more information, see the documentation for
|
||||
<ulink url="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/context/support/SimpleThreadScope.html">SimpleThreadScope</ulink>.
|
||||
For instructions on how to register this or any other custom scope, see
|
||||
<xref linkend="beans-factory-scopes-custom-using"/>.</para>
|
||||
</note>
|
||||
|
||||
<section id="beans-factory-scopes-singleton">
|
||||
<title>The singleton scope</title>
|
||||
@@ -2609,11 +2618,8 @@ public class ReplacementComputeValue implements MethodReplacer {
|
||||
|
||||
<programlisting language="xml"><bean id="accountService" class="com.foo.DefaultAccountService"/>
|
||||
|
||||
<lineannotation><!-- the following is equivalent, though redundant (singleton scope is the default); using <literal>spring-beans-2.0.dtd</literal> --></lineannotation>
|
||||
<bean id="accountService" class="com.foo.DefaultAccountService" scope="singleton"/>
|
||||
|
||||
<lineannotation><!-- the following is equivalent and preserved for backward compatibility in <literal>spring-beans.dtd</literal> --></lineannotation>
|
||||
<bean id="accountService" class="com.foo.DefaultAccountService" singleton="true"/></programlisting>
|
||||
<lineannotation><!-- the following is equivalent, though redundant (singleton scope is the default) --></lineannotation>
|
||||
<bean id="accountService" class="com.foo.DefaultAccountService" scope="singleton"/></programlisting>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-scopes-prototype">
|
||||
@@ -2648,10 +2654,7 @@ public class ReplacementComputeValue implements MethodReplacer {
|
||||
<para>The following example defines a bean as a prototype in XML:</para>
|
||||
|
||||
<programlisting language="xml"><lineannotation><!-- using <literal>spring-beans-2.0.dtd</literal> --></lineannotation>
|
||||
<bean id="accountService" class="com.foo.DefaultAccountService" scope="prototype"/>
|
||||
|
||||
<lineannotation><!-- the following is equivalent and preserved for backward compatibility in <literal>spring-beans.dtd</literal> --></lineannotation>
|
||||
<bean id="accountService" class="com.foo.DefaultAccountService" singleton="false"/></programlisting>
|
||||
<bean id="accountService" class="com.foo.DefaultAccountService" scope="prototype"/></programlisting>
|
||||
|
||||
<para>In contrast to the other scopes, Spring does not manage the
|
||||
complete lifecycle of a prototype bean: the container instantiates,
|
||||
@@ -2694,32 +2697,6 @@ public class ReplacementComputeValue implements MethodReplacer {
|
||||
and injecting its dependencies. If you need a new instance of a
|
||||
prototype bean at runtime more than once, see <xref
|
||||
linkend="beans-factory-method-injection" /></para>
|
||||
|
||||
<note>
|
||||
<title>Backwards compatibility and specifying the lifecycle scope in
|
||||
XML</title>
|
||||
|
||||
<para>If you reference the <filename>spring-beans.dtd</filename> DTD
|
||||
in a bean definition file, and you are explicit about the lifecycle
|
||||
scope of your beans, you must use the <literal>singleton</literal>
|
||||
attribute to express the lifecycle scope. The <link
|
||||
linkend="beans-factory-scopes-singleton">singleton lifecycle
|
||||
scope</link> is the default. If you reference the
|
||||
<filename>spring-beans-2.0.dtd</filename> DTD or the Spring 2.0 XSD
|
||||
schema, you must use the <literal>scope</literal> attribute, because
|
||||
the <literal>singleton</literal> attribute was removed from the
|
||||
definition of the new DTD and XSD files in favor of the
|
||||
<literal>scope</literal> attribute.</para>
|
||||
|
||||
<para>This means that if you use the <literal>singleton</literal>
|
||||
attribute in an XML bean definition, you <emphasis>must</emphasis>
|
||||
reference the <filename>spring-beans.dtd</filename> DTD <emphasis>in
|
||||
that file</emphasis>. If you use the <literal>scope</literal>
|
||||
attribute, you <emphasis>must</emphasis> reference either the
|
||||
<filename>spring-beans-2.0.dtd</filename> DTD or the
|
||||
<filename>spring-beans-3.0.xsd</filename> XSD <emphasis>in that
|
||||
file</emphasis>.</para>
|
||||
</note>
|
||||
</section>
|
||||
|
||||
<section id="beans-factory-scopes-other">
|
||||
@@ -2766,7 +2743,9 @@ public class ReplacementComputeValue implements MethodReplacer {
|
||||
<programlisting language="xml"><web-app>
|
||||
...
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
|
||||
<listener-class>
|
||||
org.springframework.web.context.request.RequestContextListener
|
||||
</listener-class>
|
||||
</listener>
|
||||
...
|
||||
</web-app></programlisting>
|
||||
@@ -3131,18 +3110,21 @@ public class ReplacementComputeValue implements MethodReplacer {
|
||||
|
||||
<para>Suppose that you write your custom
|
||||
<interfacename>Scope</interfacename> implementation, and then register
|
||||
it as follows:</para>
|
||||
it as below.</para>
|
||||
<note>
|
||||
<para>The example below uses <literal>SimpleThreadScope</literal>
|
||||
which is included with Spring, but not registered by default. The instructions
|
||||
would be the same for your own custom <literal>Scope</literal> implementations.</para>
|
||||
</note>
|
||||
|
||||
<programlisting language="java"><lineannotation>// note: the <classname>ThreadScope</classname> class does <emphasis
|
||||
role="bold">not</emphasis> ship with the Spring Framework</lineannotation>
|
||||
Scope customScope = new ThreadScope();
|
||||
beanFactory.registerScope("<emphasis role="bold">thread</emphasis>", customScope);</programlisting>
|
||||
<programlisting language="java">
|
||||
Scope threadScope = new SimpleThreadScope();
|
||||
beanFactory.registerScope("<emphasis role="bold">thread</emphasis>", threadScope);</programlisting>
|
||||
|
||||
<para>You then create bean definitions that adhere to the scoping
|
||||
rules of your custom <interfacename>Scope</interfacename>:</para>
|
||||
|
||||
<programlisting language="xml"><bean id="..." class="..." <emphasis
|
||||
role="bold">scope="thread"</emphasis>/></programlisting>
|
||||
<programlisting language="xml"><bean id="..." class="..." scope="thread"></programlisting>
|
||||
|
||||
<para>With a custom <interfacename>Scope</interfacename>
|
||||
implementation, you are not limited to programmatic registration of
|
||||
@@ -3163,13 +3145,13 @@ beanFactory.registerScope("<emphasis role="bold">thread</emphasis>", customScope
|
||||
<property name="scopes">
|
||||
<map><emphasis role="bold">
|
||||
<entry key="thread">
|
||||
<bean class="com.foo.ThreadScope"/>
|
||||
<bean class="org.springframework.context.support.SimpleThreadScope"/>
|
||||
</entry></emphasis>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="bar" class="x.y.Bar" <emphasis role="bold">scope="thread"</emphasis>>
|
||||
<bean id="bar" class="x.y.Bar" scope="thread">
|
||||
<property name="name" value="Rick"/>
|
||||
<aop:scoped-proxy/>
|
||||
</bean>
|
||||
@@ -3546,7 +3528,7 @@ public final class Boot {
|
||||
<interfacename>BeanFactory</interfacename> type if the field,
|
||||
constructor, or method in question carries the
|
||||
<interfacename>@Autowired</interfacename> annotation. For more
|
||||
information, see the section entitled <xref
|
||||
information, see <xref
|
||||
linkend="beans-autowired-annotation" />.</para>
|
||||
|
||||
<para>When an ApplicationContext creates a class that implements the
|
||||
@@ -3792,11 +3774,13 @@ import org.springframework.beans.BeansException;
|
||||
public class InstantiationTracingBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
<lineannotation>// simply return the instantiated bean as-is</lineannotation>
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
return bean; <lineannotation>// we could potentially return <emphasis>any</emphasis> object reference here...</lineannotation>
|
||||
}
|
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName)
|
||||
throws BeansException {
|
||||
System.out.println("Bean '" + beanName + "' created : " + bean.toString());
|
||||
return bean;
|
||||
}
|
||||
@@ -3862,8 +3846,7 @@ org.springframework.scripting.groovy.GroovyMessenger@272961</programlisting>
|
||||
<para>Using callback interfaces or annotations in conjunction with a
|
||||
custom <interfacename>BeanPostProcessor</interfacename> implementation
|
||||
is a common means of extending the Spring IoC container. An example is
|
||||
shown in the section entitled <xref
|
||||
linkend="metadata-annotations-required" /> which demonstrates the
|
||||
shown in <xref linkend="metadata-annotations-required" /> which demonstrates the
|
||||
usage of a custom <interfacename>BeanPostProcessor</interfacename>
|
||||
implementation that ships with the Spring distribution which ensures
|
||||
that JavaBean properties on beans that are marked with an (arbitrary)
|
||||
@@ -3907,8 +3890,7 @@ org.springframework.scripting.groovy.GroovyMessenger@272961</programlisting>
|
||||
<emphasis>instances</emphasis> (the objects that are created from the
|
||||
configuration metadata), then you instead need to use a
|
||||
<interfacename>BeanPostProcessor</interfacename> (described above in
|
||||
the section entitled <xref
|
||||
linkend="beans-factory-extension-bpp" />.</para>
|
||||
<xref linkend="beans-factory-extension-bpp" />.</para>
|
||||
|
||||
<para>Also, <literal>BeanFactoryPostProcessors</literal> are scoped
|
||||
<emphasis>per-container</emphasis>. This is only relevant if you are
|
||||
@@ -4292,11 +4274,12 @@ dataSource.url=jdbc:mysql:mydb</programlisting>
|
||||
<programlisting language="java">public class MovieRecommender {
|
||||
|
||||
private MovieCatalog movieCatalog;
|
||||
|
||||
|
||||
private CustomerPreferenceDao customerPreferenceDao;
|
||||
|
||||
@Autowired
|
||||
public void prepare(MovieCatalog movieCatalog, CustomerPreferenceDao customerPreferenceDao) {
|
||||
public void prepare(MovieCatalog movieCatalog,
|
||||
CustomerPreferenceDao customerPreferenceDao) {
|
||||
this.movieCatalog = movieCatalog;
|
||||
this.customerPreferenceDao = customerPreferenceDao;
|
||||
}
|
||||
@@ -4460,7 +4443,8 @@ dataSource.url=jdbc:mysql:mydb</programlisting>
|
||||
private CustomerPreferenceDao customerPreferenceDao;
|
||||
|
||||
@Autowired
|
||||
public void prepare(<emphasis role="bold">@Qualifier("main")</emphasis> MovieCatalog movieCatalog, CustomerPreferenceDao customerPreferenceDao) {
|
||||
public void prepare(<emphasis role="bold">@Qualifier("main")</emphasis> MovieCatalog movieCatalog,
|
||||
CustomerPreferenceDao customerPreferenceDao) {
|
||||
this.movieCatalog = movieCatalog;
|
||||
this.customerPreferenceDao = customerPreferenceDao;
|
||||
}
|
||||
@@ -4668,14 +4652,14 @@ public @interface Offline {
|
||||
public @interface MovieQualifier {
|
||||
|
||||
String genre();
|
||||
|
||||
|
||||
Format format();
|
||||
}</programlisting>
|
||||
|
||||
<para>In this case <literal>Format</literal> is an enum:</para>
|
||||
|
||||
<programlisting language="java">public enum Format {
|
||||
|
||||
|
||||
VHS, DVD, BLURAY
|
||||
}</programlisting>
|
||||
|
||||
@@ -4766,7 +4750,8 @@ public @interface MovieQualifier {
|
||||
if they are not annotated with Spring's
|
||||
<interfacename>@Qualifier</interfacename> annotation.</para>
|
||||
|
||||
<programlisting language="xml"><bean id="customAutowireConfigurer" class="org.springframework.beans.factory.annotation.CustomAutowireConfigurer">
|
||||
<programlisting language="xml"><bean id="customAutowireConfigurer"
|
||||
class="org.springframework.beans.factory.annotation.CustomAutowireConfigurer">
|
||||
<property name="customQualifierTypes">
|
||||
<set>
|
||||
<value>example.CustomQualifier</value>
|
||||
@@ -4887,7 +4872,7 @@ public @interface MovieQualifier {
|
||||
only recognizes the <interfacename>@Resource</interfacename> annotation
|
||||
but also the JSR-250 <emphasis>lifecycle</emphasis> annotations.
|
||||
Introduced in Spring 2.5, the support for these annotations offers yet
|
||||
another alternative to those described in the sections on <link
|
||||
another alternative to those described in <link
|
||||
linkend="beans-factory-lifecycle-initializingbean">initialization
|
||||
callbacks</link> and <link
|
||||
linkend="beans-factory-lifecycle-disposablebean">destruction
|
||||
@@ -5140,10 +5125,11 @@ public class JpaMovieFinder implements MovieFinder {
|
||||
<row>
|
||||
<entry>custom</entry>
|
||||
|
||||
<entry><literal>org.example.MyCustomTypeFilter</literal></entry>
|
||||
<entry><literal>org.example.MyTypeFilter</literal></entry>
|
||||
|
||||
<entry>A custom implementation of the
|
||||
<interfacename>org.springframework.core.type.TypeFilter</interfacename>
|
||||
<interfacename>org.springframework.core.type
|
||||
.TypeFilter</interfacename>
|
||||
interface.</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
@@ -5154,11 +5140,12 @@ public class JpaMovieFinder implements MovieFinder {
|
||||
<interfacename>@Repository</interfacename> annotations and using "stub"
|
||||
repositories instead.</para>
|
||||
|
||||
<programlisting language="xml"><beans ...>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<context:component-scan base-package="org.example">
|
||||
<context:include-filter type="regex" expression=".*Stub.*Repository"/>
|
||||
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
|
||||
<context:exclude-filter type="annotation"
|
||||
expression="org.springframework.stereotype.Repository"/>
|
||||
</context:component-scan>
|
||||
|
||||
</beans></programlisting>
|
||||
@@ -5184,22 +5171,21 @@ public class JpaMovieFinder implements MovieFinder {
|
||||
<literal>@Configuration</literal> annotated classes. Here is a simple
|
||||
example:</para>
|
||||
|
||||
<programlisting>@Component
|
||||
<programlisting language="java">@Component
|
||||
public class FactoryMethodComponent {
|
||||
|
||||
@Bean @Qualifier("public")
|
||||
public TestBean publicInstance() {
|
||||
return new TestBean("publicInstance");
|
||||
}
|
||||
@Bean @Qualifier("public")
|
||||
public TestBean publicInstance() {
|
||||
return new TestBean("publicInstance");
|
||||
}
|
||||
|
||||
public void DoWork()
|
||||
{
|
||||
// Component method implementation omitted
|
||||
}
|
||||
public void doWork() {
|
||||
// Component method implementation omitted
|
||||
}
|
||||
}</programlisting>
|
||||
|
||||
<para>This class is a Spring component that has application-specific
|
||||
code contained in its <methodname>DoWork</methodname> method. However,
|
||||
code contained in its <methodname>doWork</methodname> method. However,
|
||||
it also contributes a bean definition that has a factory method
|
||||
referring to the method <methodname>publicInstance</methodname>. The
|
||||
<literal>@Bean</literal> annotation identifies the factory method and
|
||||
@@ -5208,37 +5194,39 @@ public class FactoryMethodComponent {
|
||||
annotations that can be specified are <literal>@Scope</literal>,
|
||||
<literal>@Lazy</literal>, and custom qualifier annotations. Autowired
|
||||
fields and methods are supported as previously discussed, with
|
||||
additional support for autowiring of @Bean methods:</para>
|
||||
additional support for autowiring of <literal>@Bean</literal> methods:</para>
|
||||
|
||||
<programlisting language="java">@Component
|
||||
public class FactoryMethodComponent {
|
||||
|
||||
private static int i;
|
||||
private static int i;
|
||||
|
||||
@Bean @Qualifier("public")
|
||||
public TestBean publicInstance() {
|
||||
return new TestBean("publicInstance");
|
||||
}
|
||||
@Bean @Qualifier("public")
|
||||
public TestBean publicInstance() {
|
||||
return new TestBean("publicInstance");
|
||||
}
|
||||
|
||||
// use of a custom qualifier and autowiring of method parameters
|
||||
// use of a custom qualifier and autowiring of method parameters
|
||||
|
||||
@Bean @BeanAge(1)
|
||||
protected TestBean protectedInstance(@Qualifier("public") TestBean spouse, @Value("#{privateInstance.age}") String country) {
|
||||
TestBean tb = new TestBean("protectedInstance", 1);
|
||||
tb.setSpouse(tb);
|
||||
tb.setCountry(country);
|
||||
return tb;
|
||||
}
|
||||
@Bean @BeanAge(1)
|
||||
protected TestBean protectedInstance(@Qualifier("public") TestBean spouse,
|
||||
@Value("#{privateInstance.age}") String country) {
|
||||
TestBean tb = new TestBean("protectedInstance", 1);
|
||||
tb.setSpouse(tb);
|
||||
tb.setCountry(country);
|
||||
return tb;
|
||||
}
|
||||
|
||||
@Bean @Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||
private TestBean privateInstance() {
|
||||
return new TestBean("privateInstance", i++);
|
||||
}
|
||||
@Bean @Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||
private TestBean privateInstance() {
|
||||
return new TestBean("privateInstance", i++);
|
||||
}
|
||||
|
||||
@Bean @Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public TestBean requestScopedInstance() {
|
||||
return new TestBean("requestScopedInstance", 3);
|
||||
}
|
||||
@Bean @Scope(value = WebApplicationContext.SCOPE_SESSION,
|
||||
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public TestBean requestScopedInstance() {
|
||||
return new TestBean("requestScopedInstance", 3);
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
|
||||
@@ -5304,7 +5292,7 @@ public class MovieFinderImpl implements MovieFinder {
|
||||
scanner:</para>
|
||||
</note>
|
||||
|
||||
<programlisting language="xml"><beans ...>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<context:component-scan base-package="org.example"
|
||||
name-generator="org.example.MyNameGenerator" />
|
||||
@@ -5341,7 +5329,7 @@ public class MovieFinderImpl implements MovieFinder {
|
||||
scanner:</para>
|
||||
</note>
|
||||
|
||||
<programlisting language="xml"><beans ...>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<context:component-scan base-package="org.example"
|
||||
scope-resolver="org.example.MyScopeResolver" />
|
||||
@@ -5356,7 +5344,7 @@ public class MovieFinderImpl implements MovieFinder {
|
||||
interfaces, and targetClass. For example, the following configuration
|
||||
will result in standard JDK dynamic proxies:</para>
|
||||
|
||||
<programlisting language="xml"><beans ...>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<context:component-scan base-package="org.example"
|
||||
scoped-proxy="interfaces" />
|
||||
@@ -5528,8 +5516,7 @@ public class AppConfig {
|
||||
<interfacename>@Configuration</interfacename>-annotated class supports
|
||||
the regular lifecycle callbacks. Any classes defined with the @Bean
|
||||
annotation can use the @PostConstruct and @PreDestroy annotations from
|
||||
JSR-250, see the section on <link
|
||||
linkend="beans-factory-lifecycle-combined-effects">JSR-250
|
||||
JSR-250, see <link linkend="beans-factory-lifecycle-combined-effects">JSR-250
|
||||
annotations</link> for further details.</para>
|
||||
|
||||
<para>The regular Spring <link
|
||||
@@ -5540,13 +5527,13 @@ public class AppConfig {
|
||||
|
||||
<para>The standard set of <code>*Aware</code> interfaces such as
|
||||
<code><link
|
||||
linkend="beans-factory-aware-beanfactoryaware">BeanFactoryAware</link></code>,
|
||||
linkend="beans-beanfactory">BeanFactoryAware</link></code>,
|
||||
<code><link
|
||||
linkend="beans-factory-aware-beannameaware">BeanNameAware</link></code>,
|
||||
linkend="beans-factory-aware">BeanNameAware</link></code>,
|
||||
<code><link
|
||||
linkend="context-functionality-messagesource">MessageSourceAware</link></code>,
|
||||
<code><link
|
||||
linkend="context-functionality-events">ApplicationContextAware</link></code>,
|
||||
linkend="beans-factory-aware">ApplicationContextAware</link></code>,
|
||||
and so on are also fully supported.</para>
|
||||
|
||||
<para>The <interfacename>@Bean</interfacename> annotation supports
|
||||
@@ -5716,7 +5703,7 @@ public CommandManager commandManager() {
|
||||
the <code>name</code> attribute. <programlisting language="java">@Configuration
|
||||
public class AppConfig {
|
||||
|
||||
@Bean(name = "bar")
|
||||
@Bean(name = "myFoo")
|
||||
public Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
@@ -5732,7 +5719,7 @@ public class AppConfig {
|
||||
<para>The <literal>context</literal> namespace introduced in Spring 2.5
|
||||
provides a <literal>load-time-weaver</literal> element.<!--Need to explain purpose of LoadTimeWeaver? Is this section ok here? --></para>
|
||||
|
||||
<programlisting language="xml"><beans ...>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<context:load-time-weaver/>
|
||||
|
||||
|
||||
@@ -448,8 +448,7 @@
|
||||
<para>This property simply holds an implementation of the
|
||||
<interfacename>RecordCreator</interfacename> interface, used for that
|
||||
purpose. The <interfacename>RecordCreator</interfacename> interface has
|
||||
already been discussed in the section entitled <xref
|
||||
linkend="cci-record-creator" />. The
|
||||
already been discussed in <xref linkend="cci-record-creator" />. The
|
||||
<literal>outputRecordCreator</literal> property must be directly
|
||||
specified on the <classname>CciTemplate</classname>. This could be done
|
||||
in the application code like so:</para>
|
||||
@@ -880,8 +879,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
||||
output records as with <classname>CciTemplate</classname> is available.
|
||||
Every operation object provides a corresponding
|
||||
<literal>setOutputRecordCreator(..)</literal> method. For further
|
||||
information, see the section entitled <xref
|
||||
linkend="automatic-output-generation" />.</para>
|
||||
information, see <xref linkend="automatic-output-generation" />.</para>
|
||||
</section>
|
||||
|
||||
<section id="cci-object-summary">
|
||||
|
||||
@@ -825,7 +825,7 @@ public interface IntroductionInfo {
|
||||
<para>Specify the target you want to proxy.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Specify whether to use CGLIB (see below and also the section entitled
|
||||
<para>Specify whether to use CGLIB (see below and also
|
||||
<xref linkend="aop-pfb-proxy-types"/>).</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
@@ -840,8 +840,7 @@ public interface IntroductionInfo {
|
||||
<literal>proxyTargetClass</literal>: <literal>true</literal> if the
|
||||
target class is to be proxied, rather than the target class' interfaces.
|
||||
If this property value is set to <literal>true</literal>, then CGLIB proxies
|
||||
will be created (but see also below the section entitled
|
||||
<xref linkend="aop-pfb-proxy-types"/>).
|
||||
will be created (but see also below <xref linkend="aop-pfb-proxy-types"/>).
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
@@ -890,8 +889,7 @@ public interface IntroductionInfo {
|
||||
<para>
|
||||
<literal>proxyInterfaces</literal>: array of String interface
|
||||
names. If this isn't supplied, a CGLIB proxy for the target class
|
||||
will be used (but see also below the section entitled
|
||||
<xref linkend="aop-pfb-proxy-types"/>).
|
||||
will be used (but see also below <xref linkend="aop-pfb-proxy-types"/>).
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</itemizedlist>
|
||||
<para>
|
||||
Fully working examples of where this dynamic language support can be immediately useful
|
||||
are described in the section entitled <xref linkend="dynamic-language-scenarios"/>.
|
||||
are described in <xref linkend="dynamic-language-scenarios"/>.
|
||||
</para>
|
||||
<para>
|
||||
<emphasis>Note:</emphasis> Only the specific versions as listed above are supported
|
||||
@@ -167,8 +167,8 @@ http://www.springframework.org/schema/lang http://www.springframework.org/schema
|
||||
idioms of the supported dynamic languages. For example, if you want to
|
||||
use Groovy to write certain of the classes in your application, then the
|
||||
assumption is that you already know Groovy. If you need further details
|
||||
about the dynamic languages themselves, please consult the section
|
||||
entitled <xref linkend="dynamic-language-resources" /> at the end of this chapter.
|
||||
about the dynamic languages themselves, please consult
|
||||
<xref linkend="dynamic-language-resources" /> at the end of this chapter.
|
||||
</para>
|
||||
|
||||
<section id="dynamic-language-beans-concepts">
|
||||
@@ -388,7 +388,7 @@ class GroovyMessenger implements Messenger {
|
||||
The refreshable bean behavior described above does
|
||||
<emphasis>not</emphasis> apply to dynamic language source files
|
||||
defined using the <literal><lang:inline-script/></literal> element
|
||||
notation (see the section entitled <xref linkend="dynamic-language-beans-inline" />).
|
||||
notation (see <xref linkend="dynamic-language-beans-inline" />).
|
||||
Additionally, it <emphasis>only</emphasis> applies to beans where
|
||||
changes to the underlying source file can actually be detected;
|
||||
for example, by code that checks the last modified date of a
|
||||
@@ -426,8 +426,8 @@ class GroovyMessenger implements Messenger {
|
||||
some scenarios. For instance, we might want to quickly add a Spring
|
||||
<interfacename>Validator</interfacename> implementation to a Spring MVC
|
||||
<interfacename>Controller</interfacename>. This is but a moment's work
|
||||
using inline source. (See the section entitled
|
||||
<xref linkend="dynamic-language-scenarios-validators" /> for such an example.)
|
||||
using inline source. (See <xref linkend="dynamic-language-scenarios-validators" />
|
||||
for such an example.)
|
||||
</para>
|
||||
<para>
|
||||
Find below an example of defining the source for a JRuby-based bean
|
||||
@@ -629,7 +629,7 @@ RubyMessenger.new]]></programlisting>
|
||||
source file as a whole must return an object (for Spring to configure).
|
||||
</para>
|
||||
<para>
|
||||
See the section entitled <xref linkend="dynamic-language-scenarios" /> for some
|
||||
See <xref linkend="dynamic-language-scenarios" /> for some
|
||||
scenarios where you might want to use JRuby-based beans.
|
||||
</para>
|
||||
</section>
|
||||
@@ -711,8 +711,8 @@ public class Main {
|
||||
(unsurprisingly) <computeroutput>10</computeroutput>.
|
||||
(Exciting example, huh? Remember that the intent is to illustrate the
|
||||
concept. Please consult the dynamic language showcase project for a
|
||||
more complex example, or indeed the section entitled
|
||||
<xref linkend="dynamic-language-scenarios" /> later in this chapter).
|
||||
more complex example, or indeed <xref linkend="dynamic-language-scenarios" />
|
||||
later in this chapter).
|
||||
</para>
|
||||
<para>
|
||||
It is important that you <emphasis>do not</emphasis> define more than one
|
||||
@@ -865,7 +865,7 @@ void setMessage(String aMessage) {
|
||||
|
||||
<lang:property name="message" value="Hello World!" />
|
||||
</lang:bsh>]]></programlisting>
|
||||
<para>See the section entitled <xref linkend="dynamic-language-scenarios" /> for some
|
||||
<para>See <xref linkend="dynamic-language-scenarios" /> for some
|
||||
scenarios where you might want to use BeanShell-based beans.</para>
|
||||
</section>
|
||||
</section>
|
||||
@@ -907,7 +907,7 @@ void setMessage(String aMessage) {
|
||||
<para>
|
||||
In order to effect this automatic 'pickup' of any changes
|
||||
to dynamic-language-backed beans, you will have had to enable the
|
||||
'refreshable beans' functionality. See the section entitle
|
||||
'refreshable beans' functionality. See
|
||||
<xref linkend="dynamic-language-refreshable-beans"/> for a full treatment
|
||||
of this feature.
|
||||
</para>
|
||||
@@ -966,7 +966,7 @@ class FortuneController implements Controller {
|
||||
<para>
|
||||
Please note that in order to effect the automatic 'pickup' of any changes
|
||||
to dynamic-language-backed beans, you will have had to enable the
|
||||
'refreshable beans' feature. See the section entitled
|
||||
'refreshable beans' feature. See
|
||||
<xref linkend="dynamic-language-refreshable-beans"/> for a full and
|
||||
detailed treatment of this feature.
|
||||
</para>
|
||||
@@ -974,9 +974,8 @@ class FortuneController implements Controller {
|
||||
<para>
|
||||
Find below an example of a Spring
|
||||
<interfacename>org.springframework.validation.Validator</interfacename>
|
||||
implemented using the Groovy dynamic language. (See the section entitled
|
||||
<xref linkend="validator"/> for a discussion of the
|
||||
<interfacename>Validator</interfacename> interface.)
|
||||
implemented using the Groovy dynamic language. (See <xref linkend="validator"/>
|
||||
for a discussion of the <interfacename>Validator</interfacename> interface.)
|
||||
</para>
|
||||
<programlisting source="java"><![CDATA[import org.springframework.validation.Validator
|
||||
import org.springframework.validation.Errors
|
||||
@@ -1057,7 +1056,7 @@ http://www.springframework.org/schema/lang http://www.springframework.org/schema
|
||||
|
||||
</beans>]]></programlisting>
|
||||
<para>
|
||||
See the section entitled <xref linkend="beans-factory-scopes"/> in <xref linkend="beans"/>
|
||||
See <xref linkend="beans-factory-scopes"/> in <xref linkend="beans"/>
|
||||
for a fuller discussion of the scoping support in the Spring Framework.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
@@ -407,7 +407,7 @@ Boolean b = simple.booleanList.get(0);
|
||||
|
||||
@Autowired
|
||||
public void configure(MovieFinder movieFinder,
|
||||
@Value("#{ systemProperties['user.region']"} String defaultLocale) {
|
||||
@Value("#{ systemProperties['user.region'] }"} String defaultLocale) {
|
||||
this.movieFinder = movieFinder;
|
||||
this.defaultLocale = defaultLocale;
|
||||
}
|
||||
@@ -418,12 +418,12 @@ Boolean b = simple.booleanList.get(0);
|
||||
<para><programlisting language="java">public class MovieRecommender {
|
||||
|
||||
private String defaultLocale;
|
||||
|
||||
|
||||
private CustomerPreferenceDao customerPreferenceDao;
|
||||
|
||||
@Autowired
|
||||
public MovieRecommender(CustomerPreferenceDao customerPreferenceDao,
|
||||
@Value("#{ systemProperties['user.country']"} String defaultLocale) {
|
||||
@Value("#{systemProperties['user.country']}"} String defaultLocale) {
|
||||
this.customerPreferenceDao = customerPreferenceDao;
|
||||
this.defaultLocale = defaultLocale;
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ public int countOfActors(Actor exampleActor) {
|
||||
<interfacename>JdbcOperations</interfacename>
|
||||
interface</emphasis>.</para>
|
||||
|
||||
<para>See also the section entitled <xref
|
||||
<para>See also <xref
|
||||
linkend="jdbc-JdbcTemplate-idioms" /> for some advice on how to best use
|
||||
the <classname>NamedParameterJdbcTemplate</classname> class in the
|
||||
context of an application.</para>
|
||||
@@ -696,10 +696,9 @@ public Actor findActor(String specialty, int age) {
|
||||
return this.simpleJdbcTemplate.queryForObject(sql, mapper, specialty, age);
|
||||
}</programlisting>
|
||||
|
||||
<para>See also the section entitled <xref
|
||||
linkend="jdbc-JdbcTemplate-idioms" /> for some advice on how to best use
|
||||
the <classname>SimpleJdbcTemplate</classname> class in the context of an
|
||||
application.</para>
|
||||
<para>See also <xref linkend="jdbc-JdbcTemplate-idioms" />
|
||||
for some advice on how to best use the <classname>SimpleJdbcTemplate</classname>
|
||||
class in the context of an application.</para>
|
||||
|
||||
<note>
|
||||
<para>The <classname>SimpleJdbcTemplate</classname> class only offers
|
||||
@@ -2755,4 +2754,4 @@ public class DataAccessUnitTestTemplate {
|
||||
]]></programlisting>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
@@ -260,9 +260,8 @@
|
||||
<para>One of the most common uses of JMS messages in the EJB world is to
|
||||
drive message-driven beans (MDBs). Spring offers a solution to create
|
||||
message-driven POJOs (MDPs) in a way that does not tie a user to an EJB
|
||||
container. (See the section entitled <xref
|
||||
linkend="jms-asynchronousMessageReception" /> for detailed coverage of
|
||||
Spring's MDP support.)</para>
|
||||
container. (See <xref linkend="jms-asynchronousMessageReception" />
|
||||
for detailed coverage of Spring's MDP support.)</para>
|
||||
|
||||
<para>A message listener container is used to receive messages from a
|
||||
JMS message queue and drive the MessageListener that is injected into
|
||||
@@ -955,10 +954,9 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
||||
<para>The example above is equivalent to creating two distinct listener
|
||||
container bean definitions and two distinct
|
||||
<classname>MessageListenerAdapter</classname> bean definitions as
|
||||
demonstrated in the section entitled <xref
|
||||
linkend="jms-receiving-async-message-listener-adapter" />. In addition to
|
||||
the attributes shown above, the <literal>listener</literal> element may
|
||||
contain several optional ones. The following table describes all available
|
||||
demonstrated in <xref linkend="jms-receiving-async-message-listener-adapter" />.
|
||||
In addition to the attributes shown above, the <literal>listener</literal> element
|
||||
may contain several optional ones. The following table describes all available
|
||||
attributes:</para>
|
||||
|
||||
<table id="jms-namespace-listener-tbl">
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
<para>This chapter is not an introduction to JMX... it doesn't try to
|
||||
explain the motivations of why one might want to use JMX (or indeed what
|
||||
the letters JMX actually stand for). If you are new to JMX, check out
|
||||
the section entitled <xref linkend="jmx-resources" /> at the end of this
|
||||
chapter.</para>
|
||||
<xref linkend="jmx-resources" /> at the end of this chapter.</para>
|
||||
</sidebar>
|
||||
|
||||
<para>Specifically, Spring's JMX support provides four core
|
||||
@@ -128,7 +127,7 @@ public class JmxTestBean implements IJmxTestBean {
|
||||
<literal>beans</literal> <interfacename>Map</interfacename> is used as the
|
||||
<classname>ObjectName</classname> for the bean referenced by the
|
||||
corresponding entry value. This behavior can be changed as described in
|
||||
the section entitled <xref linkend="jmx-naming"/>.</para>
|
||||
<xref linkend="jmx-naming"/>.</para>
|
||||
|
||||
<para>With this configuration the <literal>testBean</literal> bean is
|
||||
exposed as an MBean under the <classname>ObjectName</classname>
|
||||
@@ -270,8 +269,7 @@ public class JmxTestBean implements IJmxTestBean {
|
||||
already a valid JMX MBean and will be automatically registered by
|
||||
Spring. By default, beans that are autodetected for JMX registration
|
||||
have their bean name used as the <classname>ObjectName</classname>. This
|
||||
behavior can be overridden as detailed in the section entitled
|
||||
<xref linkend="jmx-naming" />.</para>
|
||||
behavior can be overridden as detailed in <xref linkend="jmx-naming" />.</para>
|
||||
</section>
|
||||
|
||||
<section id="jmx-exporting-registration-behavior">
|
||||
@@ -954,8 +952,8 @@ public class AnnotationTestBean implements IJmxTestBean {
|
||||
to include it. The only problem with this approach is that the name of
|
||||
the <classname>JmxTestBean</classname> now has business meaning. You can
|
||||
address this issue by changing the default behavior for
|
||||
<classname>ObjectName</classname> creation as defined in the section
|
||||
entitled <xref linkend="jmx-naming" />.</para>
|
||||
<classname>ObjectName</classname> creation as defined in
|
||||
<xref linkend="jmx-naming" />.</para>
|
||||
</section>
|
||||
|
||||
<section id="jmx-interface-java">
|
||||
@@ -1760,4 +1758,4 @@ public class JmxTestBean implements IJmxTestBean, NotificationPublisherAware {
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
existing configuration needs to change, and no existing configuration
|
||||
will break.</para>
|
||||
|
||||
<para>Both the new and the original scopes are detailed in the section
|
||||
entitled <xref linkend="beans-factory-scopes"/>.</para>
|
||||
<para>Both the new and the original scopes are detailed in
|
||||
<xref linkend="beans-factory-scopes"/>.</para>
|
||||
</section>
|
||||
|
||||
<section id="new-in-2-ioc-configuration">
|
||||
@@ -77,8 +77,7 @@
|
||||
of the new XML configuration syntax based on XML Schema. If you want to
|
||||
take advantage of the new tags that Spring provides (and the Spring team
|
||||
certainly suggest that you do because they make configuration less
|
||||
verbose and easier to read), then do read the section entitled <xref
|
||||
linkend="xsd-config"/>.</para>
|
||||
verbose and easier to read), then do read <xref linkend="xsd-config"/>.</para>
|
||||
|
||||
<para>On a related note, there is a new, updated DTD for Spring 2.0 that
|
||||
you may wish to reference if you cannot take advantage of the XML
|
||||
@@ -169,8 +168,7 @@
|
||||
backed by regular Java objects. This support takes advantage of the
|
||||
AspectJ pointcut language and offers fully typed advice (i.e. no more
|
||||
casting and <literal>Object[]</literal> argument manipulation). Details
|
||||
of this support can be found in the section entitled <xref
|
||||
linkend="aop-schema"/>.</para>
|
||||
of this support can be found in <xref linkend="aop-schema"/>.</para>
|
||||
</section>
|
||||
|
||||
<section id="new-in-2-aop-aspectj">
|
||||
@@ -258,9 +256,8 @@
|
||||
usage patterns.</para>
|
||||
|
||||
<para>If you are interested in using a JPA-implementation as the
|
||||
backbone of your persistence layer, the section entitled <xref
|
||||
linkend="orm-jpa"/> is dedicated to detailing Spring's support and
|
||||
value-add in this area.</para>
|
||||
backbone of your persistence layer, <xref linkend="orm-jpa"/> is
|
||||
dedicated to detailing Spring's support and value-add in this area.</para>
|
||||
|
||||
<para>Spring 2.5 upgrades its OpenJPA support to OpenJPA 1.0,
|
||||
with support for advanced features such as savepoints.</para>
|
||||
@@ -277,7 +274,7 @@
|
||||
receiving of messages.</para>
|
||||
|
||||
<para>Spring 2.0 now ships with full support for the reception of
|
||||
messages in an asynchronous fashion, as detailed in the section entitled
|
||||
messages in an asynchronous fashion, as detailed in
|
||||
<xref linkend="jms-asynchronousMessageReception"/>.</para>
|
||||
|
||||
<para>As of Spring 2.5, the JCA style of setting up asynchronous
|
||||
@@ -339,7 +336,7 @@
|
||||
of (always good-to-have) consistency across a codebase.</para>
|
||||
|
||||
<para>Spring MVC's convention-over-configuration support is detailed in
|
||||
the section entitled <xref linkend="mvc-coc"/></para>
|
||||
<xref linkend="mvc-coc"/></para>
|
||||
</section>
|
||||
|
||||
<section id="new-in-2-web-portlet">
|
||||
@@ -347,8 +344,7 @@
|
||||
|
||||
<para>Spring 2.0 ships with a Portlet framework that is conceptually
|
||||
similar to the Spring MVC framework. Detailed coverage of the Spring
|
||||
Portlet framework can be found in the section entitled <xref
|
||||
linkend="portlet"/>.</para>
|
||||
Portlet framework can be found in <xref linkend="portlet"/>.</para>
|
||||
</section>
|
||||
|
||||
<section id="new-in-2-web-annotations">
|
||||
@@ -376,7 +372,7 @@
|
||||
the job of authoring JSP pages much easier when using Spring MVC; the
|
||||
Spring team is confident it will satisfy all of those developers who
|
||||
voted for the issue on JIRA. The new tag library is itself covered in
|
||||
the section entitled <xref linkend="view-jsp-formtaglib"/>, and a quick
|
||||
<xref linkend="view-jsp-formtaglib"/>, and a quick
|
||||
reference to all of the new tags can be found in the appendix entitled
|
||||
<xref linkend="spring-form.tld"/>.</para>
|
||||
</section>
|
||||
@@ -419,7 +415,7 @@
|
||||
<para>Spring 2.0 introduced support for beans written in languages other
|
||||
than Java, with the currently supported dynamic languages being JRuby,
|
||||
Groovy and BeanShell. This dynamic language support is comprehensively
|
||||
detailed in the section entitled <xref linkend="dynamic-language"/>.</para>
|
||||
detailed in <xref linkend="dynamic-language"/>.</para>
|
||||
|
||||
<para>Spring 2.5 refines the dynamic languages support with autowiring
|
||||
and support for the recently released JRuby 1.0.</para>
|
||||
@@ -486,9 +482,8 @@
|
||||
<title>Task scheduling</title>
|
||||
|
||||
<para>Spring 2.0 offers an abstraction around the scheduling of tasks.
|
||||
For the interested developer, the section entitled <xref
|
||||
linkend="scheduling-task-executor"/> contains all of the
|
||||
details.</para>
|
||||
For the interested developer, <xref linkend="scheduling-task-executor"/>
|
||||
contains all of the details.</para>
|
||||
|
||||
<para>The <interfacename>TaskExecutor</interfacename> abstraction is used
|
||||
throughout the framework itself as well, e.g. for the asynchronous JMS support.
|
||||
|
||||
@@ -306,6 +306,10 @@ public class RewardsTestDatabase {
|
||||
<para>@Bean</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>@DependsOn</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>@Primary</para>
|
||||
</listitem>
|
||||
@@ -324,8 +328,10 @@ public class RewardsTestDatabase {
|
||||
</itemizedlist></para>
|
||||
|
||||
<para>Here is an example of a Java class providing basic configuration
|
||||
using the new JavaConfig features: <programlisting language="java">@Configuration
|
||||
public class AppConfig{
|
||||
using the new JavaConfig features: <programlisting language="java">package org.example.config;
|
||||
|
||||
@Configuration
|
||||
public class AppConfig {
|
||||
private @Value("#{jdbcProperties.url}") String jdbcUrl;
|
||||
private @Value("#{jdbcProperties.username}") String username;
|
||||
private @Value("#{jdbcProperties.password}") String password;
|
||||
@@ -357,8 +363,9 @@ public class AppConfig{
|
||||
}
|
||||
</programlisting> To get this to work you need to add the following component
|
||||
scanning entry in your minimal application context XML file.
|
||||
<programlisting language="java"><context:component-scan
|
||||
base-package="com.myco.config"/></programlisting></para>
|
||||
<programlisting language="xml"><context:component-scan base-package="org.example.config"/>
|
||||
<util:properties id="jdbcProperties" location="classpath:org/example/config/jdbc.properties"/>
|
||||
</programlisting></para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
normal and global). This is not a specific feature of Spring Portlet MVC
|
||||
itself, but rather of the <interfacename>WebApplicationContext</interfacename>
|
||||
container(s) that Spring Portlet MVC uses. These bean scopes are described
|
||||
in detail in the section entitled <xref linkend="beans-factory-scopes-other"/></para>
|
||||
in detail in <xref linkend="beans-factory-scopes-other"/></para>
|
||||
</section>
|
||||
|
||||
<note>
|
||||
@@ -921,8 +921,8 @@ public class SampleController extends AbstractController {
|
||||
the view technologies from Spring Web MVC. This includes not only the
|
||||
various <interfacename>View</interfacename> implementations themselves,
|
||||
but also the <interfacename>ViewResolver</interfacename> implementations.
|
||||
For more information, refer to the sections entitled
|
||||
<xref linkend="view"/> and <xref linkend="mvc-viewresolver"/> respectively.</para>
|
||||
For more information, refer to <xref linkend="view"/> and
|
||||
<xref linkend="mvc-viewresolver"/> respectively.</para>
|
||||
|
||||
<para>A few items on using the existing <interfacename>View</interfacename> and
|
||||
<interfacename>ViewResolver</interfacename> implementations are worth mentioning:</para>
|
||||
@@ -1798,4 +1798,4 @@ public class MyFormController {
|
||||
of your portlets.</para>
|
||||
</section>
|
||||
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
@@ -329,8 +329,8 @@
|
||||
|
||||
<entry><para> Loaded as a <classname>URL</classname>, from the
|
||||
filesystem. <footnote>
|
||||
<para>But see also the section entitled <xref
|
||||
linkend="resources-filesystemresource-caveats" />.</para>
|
||||
<para>But see also
|
||||
<xref linkend="resources-filesystemresource-caveats" />.</para>
|
||||
</footnote> </para></entry>
|
||||
</row>
|
||||
|
||||
@@ -394,9 +394,9 @@
|
||||
<interfacename>ResourceLoader</interfacename> as an alternative to
|
||||
implementing the <interfacename>ResourceLoaderAware</interfacename> interface.
|
||||
The "traditional" <literal>constructor</literal> and <literal>byType</literal>
|
||||
autowiring modes (as described in the section entitled
|
||||
<xref linkend="beans-factory-autowire"/>) are now capable of providing a
|
||||
dependency of type <interfacename>ResourceLoader</interfacename> for either a
|
||||
autowiring modes (as described in <xref linkend="beans-factory-autowire"/>)
|
||||
are now capable of providing a dependency of type
|
||||
<interfacename>ResourceLoader</interfacename> for either a
|
||||
constructor argument or setter method parameter respectively. For more flexibility
|
||||
(including the ability to autowire fields and multiple parameter methods), consider
|
||||
using the new annotation-based autowiring features. In that case, the
|
||||
@@ -405,7 +405,7 @@
|
||||
<interfacename>ResourceLoader</interfacename> type as long as the field,
|
||||
constructor, or method in question carries the
|
||||
<interfacename>@Autowired</interfacename> annotation. For more information,
|
||||
see the section entitled <xref linkend="beans-autowired-annotation"/>.</para>
|
||||
see <xref linkend="beans-autowired-annotation"/>.</para>
|
||||
</section>
|
||||
|
||||
<section id="resources-as-dependencies">
|
||||
@@ -739,4 +739,4 @@ ApplicationContext ctx =
|
||||
new FileSystemXmlApplicationContext("file:/conf/context.xml");]]></programlisting>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
@@ -1669,8 +1669,7 @@ New York</programlisting>
|
||||
<para>This example is a trivial Spring application that creates a list
|
||||
of words in the <interfacename>Controller</interfacename> and adds them
|
||||
to the model map. The map is returned along with the view name of our
|
||||
XSLT view. See the section entitled <xref linkend="mvc-controller" />
|
||||
for details of Spring Web MVC's
|
||||
XSLT view. See <xref linkend="mvc-controller" /> for details of Spring Web MVC's
|
||||
<interfacename>Controller</interfacename> interface. The XSLT view will
|
||||
turn the list of words into a simple XML document ready for
|
||||
transformation.</para>
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
to use Struts for the presentation layer of your web application, the
|
||||
assumption is that you are already familiar with Struts. If you need
|
||||
further details about any of the supported web frameworks themselves,
|
||||
please do consult the section entitled <xref
|
||||
linkend="web-integration-resources" /> at the end of this chapter.
|
||||
please do consult <xref linkend="web-integration-resources" /> at the end
|
||||
of this chapter.
|
||||
</emphasis></para>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ public class Client {
|
||||
<interfacename>List</interfacename> implementation will be chosen by the container.</para>
|
||||
<para>Finally, you can also control the merging behavior using the
|
||||
<literal>'merge'</literal> attribute of the <literal><util:list/></literal>
|
||||
element; collection merging is described in more detail in the section entitled
|
||||
element; collection merging is described in more detail in
|
||||
<xref linkend="beans-collection-elements-merging"/>.</para>
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-util-map">
|
||||
@@ -409,7 +409,7 @@ public class Client {
|
||||
<interfacename>Map</interfacename> implementation will be chosen by the container.</para>
|
||||
<para>Finally, you can also control the merging behavior using the
|
||||
<literal>'merge'</literal> attribute of the <literal><util:map/></literal>
|
||||
element; collection merging is described in more detail in the section entitled
|
||||
element; collection merging is described in more detail in
|
||||
<xref linkend="beans-collection-elements-merging"/>.</para>
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-util-set">
|
||||
@@ -454,7 +454,7 @@ public class Client {
|
||||
<interfacename>Set</interfacename> implementation will be chosen by the container.</para>
|
||||
<para>Finally, you can also control the merging behavior using the
|
||||
<literal>'merge'</literal> attribute of the <literal><util:set/></literal>
|
||||
element; collection merging is described in more detail in the section entitled
|
||||
element; collection merging is described in more detail in
|
||||
<xref linkend="beans-collection-elements-merging"/>.</para>
|
||||
</section>
|
||||
</section>
|
||||
@@ -776,19 +776,19 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-context-component-scan">
|
||||
<title><literal><component-scan/></literal></title>
|
||||
<para>This element is detailed in the section entitled <xref linkend="beans-annotation-config"/>.</para>
|
||||
<para>This element is detailed in <xref linkend="beans-annotation-config"/>.</para>
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-context-ltw">
|
||||
<title><literal><load-time-weaver/></literal></title>
|
||||
<para>This element is detailed in the section entitled <xref linkend="aop-aj-ltw"/>.</para>
|
||||
<para>This element is detailed in <xref linkend="aop-aj-ltw"/>.</para>
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-context-sc">
|
||||
<title><literal><spring-configured/></literal></title>
|
||||
<para>This element is detailed in the section entitled <xref linkend="aop-atconfigurable"/>.</para>
|
||||
<para>This element is detailed in <xref linkend="aop-atconfigurable"/>.</para>
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-context-mbe">
|
||||
<title><literal><mbean-export/></literal></title>
|
||||
<para>This element is detailed in the section entitled <xref linkend="jmx-context-mbeanexport"/>.</para>
|
||||
<para>This element is detailed in <xref linkend="jmx-context-mbeanexport"/>.</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -811,7 +811,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
||||
<para>Last but not least we have the tags in the <literal>beans</literal> schema.
|
||||
These are the same tags that have been in Spring since the very dawn of the framework.
|
||||
Examples of the various tags in the <literal>beans</literal> schema are not shown here
|
||||
because they are quite comprehensively covered in the section entitled <xref linkend="beans-factory-properties-detailed"/>
|
||||
because they are quite comprehensively covered in <xref linkend="beans-factory-properties-detailed"/>
|
||||
(and indeed in that entire <link linkend="beans">chapter</link>).</para>
|
||||
<para>One thing that is new to the beans tags themselves in Spring 2.0 is the idea
|
||||
of arbitrary bean metadata. In Spring 2.0 it is now possible to add zero or more
|
||||
|
||||
Reference in New Issue
Block a user