added language element to programlisting for syntax highlighting
This commit is contained in:
parent
077d7f4bce
commit
38e5deefda
|
@ -94,7 +94,7 @@
|
|||
<para>In a managed mode, you access a <interfacename>ConnectionFactory</interfacename>
|
||||
from JNDI; its properties will be configured in the application server.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="eciConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="eciConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="eis/cicseci"/>
|
||||
</bean>]]></programlisting>
|
||||
|
||||
|
@ -105,7 +105,7 @@
|
|||
implementation of your connector, exposing the application-level
|
||||
CCI <interfacename>ConnectionFactory</interfacename>.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="eciManagedConnectionFactory" class="com.ibm.connector2.cics.ECIManagedConnectionFactory">
|
||||
<programlisting language="xml"><![CDATA[<bean id="eciManagedConnectionFactory" class="com.ibm.connector2.cics.ECIManagedConnectionFactory">
|
||||
<property name="serverName" value="TXSERIES"/>
|
||||
<property name="connectionURL" value="tcp://localhost/"/>
|
||||
<property name="portNumber" value="2006"/>
|
||||
|
@ -142,7 +142,7 @@
|
|||
in the application server (in managed mode) or on the corresponding local
|
||||
<classname>ManagedConnectionFactory</classname> implementation.</para>
|
||||
|
||||
<programlisting><![CDATA[public interface ConnectionFactory implements Serializable, Referenceable {
|
||||
<programlisting language="java"><![CDATA[public interface ConnectionFactory implements Serializable, Referenceable {
|
||||
...
|
||||
Connection getConnection() throws ResourceException;
|
||||
Connection getConnection(ConnectionSpec connectionSpec) throws ResourceException;
|
||||
|
@ -156,7 +156,7 @@
|
|||
uses the <literal>getConnection</literal> variant without argument,
|
||||
else the one with the <interfacename>ConnectionSpec</interfacename> argument.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="managedConnectionFactory"
|
||||
<programlisting language="xml"><![CDATA[<bean id="managedConnectionFactory"
|
||||
class="com.sun.connector.cciblackbox.CciLocalTxManagedConnectionFactory">
|
||||
<property name="connectionURL" value="jdbc:hsqldb:hsql://localhost:9001"/>
|
||||
<property name="driverName" value="org.hsqldb.jdbcDriver"/>
|
||||
|
@ -190,7 +190,7 @@
|
|||
proxies that behave accordingly, all sharing the same underlying physical
|
||||
connection.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="eciManagedConnectionFactory"
|
||||
<programlisting language="xml"><![CDATA[<bean id="eciManagedConnectionFactory"
|
||||
class="com.ibm.connector2.cics.ECIManagedConnectionFactory">
|
||||
<property name="serverName" value="TEST"/>
|
||||
<property name="connectionURL" value="tcp://localhost/"/>
|
||||
|
@ -235,7 +235,7 @@
|
|||
developer can use a dedicated implementation of the
|
||||
<interfacename>RecordCreator</interfacename> interface.</para>
|
||||
|
||||
<programlisting><![CDATA[public interface RecordCreator {
|
||||
<programlisting language="java"><![CDATA[public interface RecordCreator {
|
||||
|
||||
Record createRecord(RecordFactory recordFactory) throws ResourceException, DataAccessException;
|
||||
}]]></programlisting>
|
||||
|
@ -249,7 +249,7 @@
|
|||
shows how to use the <interfacename>RecordCreator</interfacename> interface
|
||||
and indexed/mapped records.</para>
|
||||
|
||||
<programlisting><![CDATA[public class MyRecordCreator implements RecordCreator {
|
||||
<programlisting language="java"><![CDATA[public class MyRecordCreator implements RecordCreator {
|
||||
|
||||
public Record createRecord(RecordFactory recordFactory) throws ResourceException {
|
||||
IndexedRecord input = recordFactory.createIndexedRecord("input");
|
||||
|
@ -264,14 +264,14 @@
|
|||
Spring's <classname>CciTemplate</classname> for extracting data from the output
|
||||
<interfacename>Record</interfacename>.</para>
|
||||
|
||||
<programlisting><![CDATA[public interface RecordExtractor {
|
||||
<programlisting language="java"><![CDATA[public interface RecordExtractor {
|
||||
|
||||
Object extractData(Record record) throws ResourceException, SQLException, DataAccessException;
|
||||
}]]></programlisting>
|
||||
|
||||
<para>The following sample shows how to use the <interfacename>RecordExtractor</interfacename> interface.</para>
|
||||
|
||||
<programlisting><![CDATA[public class MyRecordExtractor implements RecordExtractor {
|
||||
<programlisting language="java"><![CDATA[public class MyRecordExtractor implements RecordExtractor {
|
||||
|
||||
public Object extractData(Record record) throws ResourceException {
|
||||
CommAreaRecord commAreaRecord = (CommAreaRecord) record;
|
||||
|
@ -299,7 +299,7 @@
|
|||
operations on an EIS. The CCI <interfacename>Interaction</interfacename>
|
||||
interface provides two execute method signatures:</para>
|
||||
|
||||
<programlisting><![CDATA[public interface javax.resource.cci.Interaction {
|
||||
<programlisting language="java"><![CDATA[public interface javax.resource.cci.Interaction {
|
||||
...
|
||||
boolean execute(InteractionSpec spec, Record input, Record output) throws ResourceException;
|
||||
|
||||
|
@ -333,7 +333,7 @@
|
|||
will be used. These methods directly correspond to those on the
|
||||
<interfacename>Interaction</interfacename> interface.</para>
|
||||
|
||||
<programlisting><![CDATA[public class CciTemplate implements CciOperations {
|
||||
<programlisting language="java"><![CDATA[public class CciTemplate implements CciOperations {
|
||||
|
||||
public Record execute(InteractionSpec spec, Record inputRecord)
|
||||
throws DataAccessException { ... }
|
||||
|
@ -349,7 +349,7 @@
|
|||
The corresponding <classname>CciTemplate</classname> methods are the
|
||||
following:</para>
|
||||
|
||||
<programlisting><![CDATA[public class CciTemplate implements CciOperations {
|
||||
<programlisting language="java"><![CDATA[public class CciTemplate implements CciOperations {
|
||||
|
||||
public Record execute(InteractionSpec spec, RecordCreator inputCreator)
|
||||
throws DataAccessException { ... }
|
||||
|
@ -379,7 +379,7 @@
|
|||
instances to pass into corresponding
|
||||
<literal>CciTemplate.execute(..)</literal> methods.</para>
|
||||
|
||||
<programlisting><![CDATA[public class CciTemplate implements CciOperations {
|
||||
<programlisting language="java"><![CDATA[public class CciTemplate implements CciOperations {
|
||||
|
||||
public IndexedRecord createIndexedRecord(String name) throws DataAccessException { ... }
|
||||
|
||||
|
@ -401,7 +401,7 @@
|
|||
for a passed-in <interfacename>ConnectionFactory</interfacename>, exposing
|
||||
it to concrete data access implementations in subclasses.</para>
|
||||
|
||||
<programlisting><![CDATA[public abstract class CciDaoSupport {
|
||||
<programlisting language="java"><![CDATA[public abstract class CciDaoSupport {
|
||||
|
||||
public void setConnectionFactory(ConnectionFactory connectionFactory) { ... }
|
||||
public ConnectionFactory getConnectionFactory() { ... }
|
||||
|
@ -432,12 +432,12 @@
|
|||
property must be directly specified on the <classname>CciTemplate</classname>.
|
||||
This could be done in the application code like so:</para>
|
||||
|
||||
<programlisting><![CDATA[cciTemplate.setOutputRecordCreator(new EciOutputRecordCreator());]]></programlisting>
|
||||
<programlisting langauge="java"><![CDATA[cciTemplate.setOutputRecordCreator(new EciOutputRecordCreator());]]></programlisting>
|
||||
|
||||
<para>Or (recommended) in the Spring configuration, if the <classname>CciTemplate</classname>
|
||||
is configured as a dedicated bean instance:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="eciOutputRecordCreator" class="eci.EciOutputRecordCreator"/>
|
||||
<programlisting language="xml"><![CDATA[<bean id="eciOutputRecordCreator" class="eci.EciOutputRecordCreator"/>
|
||||
|
||||
<bean id="cciTemplate" class="org.springframework.jca.cci.core.CciTemplate">
|
||||
<property name="connectionFactory" ref="eciConnectionFactory"/>
|
||||
|
@ -593,7 +593,7 @@
|
|||
can be useful for example to get an associated <interfacename>RecordFactory</interfacename>
|
||||
instance and create indexed/mapped records, for example.</para>
|
||||
|
||||
<programlisting><![CDATA[public interface ConnectionCallback {
|
||||
<programlisting language="java"><![CDATA[public interface ConnectionCallback {
|
||||
|
||||
Object doInConnection(Connection connection, ConnectionFactory connectionFactory)
|
||||
throws ResourceException, SQLException, DataAccessException;
|
||||
|
@ -604,7 +604,7 @@
|
|||
operations on it, plus the corresponding CCI <interfacename>ConnectionFactory</interfacename>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[public interface InteractionCallback {
|
||||
<programlisting language="java"><![CDATA[public interface InteractionCallback {
|
||||
|
||||
Object doInInteraction(Interaction interaction, ConnectionFactory connectionFactory)
|
||||
throws ResourceException, SQLException, DataAccessException;
|
||||
|
@ -628,14 +628,14 @@
|
|||
<interfacename>InteractionSpec</interfacename> must be done to specify which CICS
|
||||
program to access and how to interact with it.</para>
|
||||
|
||||
<programlisting><![CDATA[ECIInteractionSpec interactionSpec = new ECIInteractionSpec();
|
||||
<programlisting langauge="java"><![CDATA[ECIInteractionSpec interactionSpec = new ECIInteractionSpec();
|
||||
interactionSpec.setFunctionName("MYPROG");
|
||||
interactionSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);]]></programlisting>
|
||||
|
||||
<para>Then the program can use CCI via Spring's template and specify
|
||||
mappings between custom objects and CCI <literal>Records</literal>.</para>
|
||||
|
||||
<programlisting><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
<programlisting language="java"><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
|
||||
public OutputObject getData(InputObject input) {
|
||||
ECIInteractionSpec interactionSpec = ...;
|
||||
|
@ -663,7 +663,7 @@ interactionSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);]]></pr
|
|||
<para>As discussed previously, callbacks can be used to work
|
||||
directly on CCI connections or interactions.</para>
|
||||
|
||||
<programlisting><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
<programlisting language="java"><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
|
||||
public OutputObject getData(InputObject input) {
|
||||
ObjectOutput output = (ObjectOutput) getCciTemplate().execute(
|
||||
|
@ -691,7 +691,7 @@ interactionSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);]]></pr
|
|||
<interfacename>Interaction</interfacename> will be managed and closed by the
|
||||
<classname>CciTemplate</classname> in this case.</para>
|
||||
|
||||
<programlisting><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
<programlisting language="java"><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
|
||||
public String getData(String input) {
|
||||
ECIInteractionSpec interactionSpec = ...;
|
||||
|
@ -714,7 +714,7 @@ interactionSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);]]></pr
|
|||
<para>For the examples above, the corresponding configuration of the
|
||||
involved Spring beans could look like this in non-managed mode:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="managedConnectionFactory" class="com.ibm.connector2.cics.ECIManagedConnectionFactory">
|
||||
<programlisting language="xml"><![CDATA[<bean id="managedConnectionFactory" class="com.ibm.connector2.cics.ECIManagedConnectionFactory">
|
||||
<property name="serverName" value="TXSERIES"/>
|
||||
<property name="connectionURL" value="local:"/>
|
||||
<property name="userName" value="CICSUSER"/>
|
||||
|
@ -732,7 +732,7 @@ interactionSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);]]></pr
|
|||
<para>In managed mode (that is, in a J2EE environment), the configuration
|
||||
could look as follows:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="eis/cicseci"/>
|
||||
</bean>
|
||||
|
||||
|
@ -781,7 +781,7 @@ interactionSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);]]></pr
|
|||
|
||||
<para>Here are the signatures of these methods:</para>
|
||||
|
||||
<programlisting><![CDATA[public abstract class MappingRecordOperation extends EisOperation {
|
||||
<programlisting language="java"><![CDATA[public abstract class MappingRecordOperation extends EisOperation {
|
||||
...
|
||||
protected abstract Record createInputRecord(RecordFactory recordFactory, Object inputObject)
|
||||
throws ResourceException, DataAccessException { ... }
|
||||
|
@ -795,7 +795,7 @@ interactionSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);]]></pr
|
|||
a single execute method, passing in an application-level input object
|
||||
and receiving an application-level output object as result:</para>
|
||||
|
||||
<programlisting><![CDATA[public abstract class MappingRecordOperation extends EisOperation {
|
||||
<programlisting language="java"><![CDATA[public abstract class MappingRecordOperation extends EisOperation {
|
||||
...
|
||||
public Object execute(Object inputObject) throws DataAccessException {
|
||||
...
|
||||
|
@ -808,7 +808,7 @@ interactionSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);]]></pr
|
|||
The following constructor must be used to instantiate an operation
|
||||
object with a specific <interfacename>InteractionSpec</interfacename>:</para>
|
||||
|
||||
<programlisting><![CDATA[InteractionSpec spec = ...;
|
||||
<programlisting langauge="java"><![CDATA[InteractionSpec spec = ...;
|
||||
MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnectionFactory(), spec);
|
||||
...]]></programlisting>
|
||||
</section>
|
||||
|
@ -827,7 +827,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
convert an input object into an input COMMAREA and the output COMMAREA
|
||||
into an output object.</para>
|
||||
|
||||
<programlisting><![CDATA[public abstract class MappingCommAreaOperation extends MappingRecordOperation {
|
||||
<programlisting language="java"><![CDATA[public abstract class MappingCommAreaOperation extends MappingRecordOperation {
|
||||
...
|
||||
protected abstract byte[] objectToBytes(Object inObject)
|
||||
throws IOException, DataAccessException;
|
||||
|
@ -914,7 +914,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
convert the CCI result record to an instance of the
|
||||
<classname>Person</classname> class.</para>
|
||||
|
||||
<programlisting><![CDATA[public class PersonMappingOperation extends MappingRecordOperation {
|
||||
<programlisting language="java"><![CDATA[public class PersonMappingOperation extends MappingRecordOperation {
|
||||
|
||||
public PersonMappingOperation(ConnectionFactory connectionFactory) {
|
||||
setConnectionFactory(connectionFactory);
|
||||
|
@ -949,7 +949,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
person identifier as argument. Note that operation object could be
|
||||
set up as shared instance, as it is thread-safe.</para>
|
||||
|
||||
<programlisting><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
<programlisting language="java"><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
|
||||
public Person getPerson(int id) {
|
||||
PersonMappingOperation query = new PersonMappingOperation(getConnectionFactory());
|
||||
|
@ -961,7 +961,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
<para>The corresponding configuration of Spring beans could look
|
||||
as follows in non-managed mode:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="managedConnectionFactory"
|
||||
<programlisting language="xml"><![CDATA[<bean id="managedConnectionFactory"
|
||||
class="com.sun.connector.cciblackbox.CciLocalTxManagedConnectionFactory">
|
||||
<property name="connectionURL" value="jdbc:hsqldb:hsql://localhost:9001"/>
|
||||
<property name="driverName" value="org.hsqldb.jdbcDriver"/>
|
||||
|
@ -990,7 +990,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
<para>In managed mode (that is, in a J2EE environment), the configuration
|
||||
could look as follows:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="targetConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="targetConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="eis/blackbox"/>
|
||||
</bean>
|
||||
|
||||
|
@ -1021,7 +1021,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
initialized to specify which CICS program to access and how to interact
|
||||
with it.</para>
|
||||
|
||||
<programlisting><![CDATA[public abstract class EciMappingOperation extends MappingCommAreaOperation {
|
||||
<programlisting language="java"><![CDATA[public abstract class EciMappingOperation extends MappingCommAreaOperation {
|
||||
|
||||
public EciMappingOperation(ConnectionFactory connectionFactory, String programName) {
|
||||
setConnectionFactory(connectionFactory);
|
||||
|
@ -1044,7 +1044,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
then be subclassed to specify mappings between custom objects and
|
||||
<literal>Records</literal>.</para>
|
||||
|
||||
<programlisting><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
<programlisting language="java"><![CDATA[public class MyDaoImpl extends CciDaoSupport implements MyDao {
|
||||
|
||||
public OutputObject getData(Integer id) {
|
||||
EciMappingOperation query = new EciMappingOperation(getConnectionFactory(), "MYPROG") {
|
||||
|
@ -1068,7 +1068,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
<para>The corresponding configuration of Spring beans could look
|
||||
as follows in non-managed mode:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="managedConnectionFactory" class="com.ibm.connector2.cics.ECIManagedConnectionFactory">
|
||||
<programlisting language="xml"><![CDATA[<bean id="managedConnectionFactory" class="com.ibm.connector2.cics.ECIManagedConnectionFactory">
|
||||
<property name="serverName" value="TXSERIES"/>
|
||||
<property name="connectionURL" value="local:"/>
|
||||
<property name="userName" value="CICSUSER"/>
|
||||
|
@ -1086,7 +1086,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
<para>In managed mode (that is, in a J2EE environment), the configuration
|
||||
could look as follows:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="eis/cicseci"/>
|
||||
</bean>
|
||||
|
||||
|
@ -1106,7 +1106,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
example with a CICS ECI connector), global transactions (for example with an
|
||||
IMS connector).</para>
|
||||
|
||||
<programlisting><![CDATA[<connector>
|
||||
<programlisting language="xml"><![CDATA[<connector>
|
||||
|
||||
<resourceadapter>
|
||||
|
||||
|
@ -1131,7 +1131,7 @@ MyMappingRecordOperation eisOperation = new MyMappingRecordOperation(getConnecti
|
|||
executes such local CCI transactions, fully compliant with Spring's generic
|
||||
<interfacename>PlatformTransactionManager</interfacename> abstraction.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="eciConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="eciConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="eis/cicseci"/>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<appendix id="springbeansdtd">
|
||||
<title><literal>spring-beans-2.0.dtd</literal></title>
|
||||
|
||||
<para><programlisting><!--
|
||||
<para><programlisting language="xml"><!--
|
||||
Spring XML Beans DTD, version 2.0
|
||||
Authors: Rod Johnson, Juergen Hoeller, Alef Arendsen, Colin Sampaleanu, Rob Harrop
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ class GroovyMessenger implements Messenger {
|
|||
</para>
|
||||
<para>For more information on schema-based configuration, see <xref linkend="xsd-config"/>.</para>
|
||||
</note>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xsi:schemaLocation="
|
||||
|
@ -288,7 +288,7 @@ http://www.springframework.org/schema/lang http://www.springframework.org/schema
|
|||
in this chapter, here's what we would change in the Spring XML configuration
|
||||
to effect refreshable beans:
|
||||
</para>
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
]]><lineannotation><!-- this bean is now 'refreshable' due to the presence of the 'refresh-check-delay' attribute --></lineannotation><![CDATA[
|
||||
<lang:groovy id="messenger"
|
||||
|
@ -403,7 +403,7 @@ class GroovyMessenger implements Messenger {
|
|||
inside a Spring configuration file. An example will perhaps make the
|
||||
inline script feature crystal clear:
|
||||
</para>
|
||||
<programlisting><![CDATA[<lang:groovy id="messenger">
|
||||
<programlisting language="xml"><![CDATA[<lang:groovy id="messenger">
|
||||
<lang:inline-script>
|
||||
package org.springframework.scripting.groovy;
|
||||
|
||||
|
@ -433,7 +433,7 @@ class GroovyMessenger implements Messenger {
|
|||
characters to denote a <literal>'<'</literal> character. In such a case
|
||||
surrounding the inline source in a <literal><![CDATA[]]></literal> region might be better.)
|
||||
</para>
|
||||
<programlisting><![CDATA[<lang:jruby id="messenger" script-interfaces="org.springframework.scripting.Messenger">
|
||||
<programlisting language="xml"><![CDATA[<lang:jruby id="messenger" script-interfaces="org.springframework.scripting.Messenger">
|
||||
<lang:inline-script>
|
||||
require 'java'
|
||||
|
||||
|
@ -484,7 +484,7 @@ class GroovyMessenger implements Messenger {
|
|||
|
||||
String anotherMessage
|
||||
}]]></programlisting>
|
||||
<programlisting><![CDATA[<lang:groovy id="badMessenger"
|
||||
<programlisting language="xml"><![CDATA[<lang:groovy id="badMessenger"
|
||||
script-source="classpath:Messenger.groovy">
|
||||
]]>
|
||||
<lineannotation><!-- this next constructor argument will *not* be injected into the <classname>GroovyMessenger</classname> --></lineannotation>
|
||||
|
@ -579,7 +579,7 @@ RubyMessenger.new]]></programlisting>
|
|||
And here is the Spring XML that defines an instance of the
|
||||
<classname>RubyMessenger</classname> JRuby bean.
|
||||
</para>
|
||||
<programlisting><![CDATA[<lang:jruby id="messageService"
|
||||
<programlisting language="xml"><![CDATA[<lang:jruby id="messageService"
|
||||
script-interfaces="org.springframework.scripting.Messenger"
|
||||
script-source="classpath:RubyMessenger.rb">
|
||||
|
||||
|
@ -683,7 +683,7 @@ class GroovyCalculator implements Calculator {
|
|||
x + y
|
||||
}
|
||||
}]]></programlisting>
|
||||
<programlisting><lineannotation><-- from the file 'beans.xml' --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><-- from the file 'beans.xml' --></lineannotation><![CDATA[
|
||||
<beans>
|
||||
<lang:groovy id="calculator" script-source="classpath:calculator.groovy"/>
|
||||
</beans>]]></programlisting>
|
||||
|
@ -765,7 +765,7 @@ public class Main {
|
|||
Actually making use of a <interfacename>GroovyObjectCustomizer</interfacename>
|
||||
is easy if you are using the Spring 2.0 namespace support.
|
||||
</para>
|
||||
<programlisting><lineannotation><!-- define the <interfacename>GroovyObjectCustomizer</interfacename> just like any other bean --></lineannotation>
|
||||
<programlisting language="xml"><lineannotation><!-- define the <interfacename>GroovyObjectCustomizer</interfacename> just like any other bean --></lineannotation>
|
||||
<![CDATA[<bean id="tracingCustomizer" class="example.SimpleMethodTracingCustomizer" />
|
||||
|
||||
]]><lineannotation><!-- ... and plug it into the desired Groovy bean via the '<literal>customizer-ref</literal>' attribute --></lineannotation><![CDATA[
|
||||
|
@ -776,7 +776,7 @@ public class Main {
|
|||
If you are not using the Spring 2.0 namespace support, you can still
|
||||
use the <interfacename>GroovyObjectCustomizer</interfacename> functionality.
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="calculator" class="org.springframework.scripting.groovy.GroovyScriptFactory">
|
||||
<programlisting language="xml"><![CDATA[<bean id="calculator" class="org.springframework.scripting.groovy.GroovyScriptFactory">
|
||||
<constructor-arg value="classpath:org/springframework/scripting/groovy/Calculator.groovy"/>
|
||||
]]><lineannotation><!-- define the <interfacename>GroovyObjectCustomizer</interfacename> (as an inner bean) --></lineannotation><![CDATA[
|
||||
<constructor-arg>
|
||||
|
@ -857,7 +857,7 @@ void setMessage(String aMessage) {
|
|||
And here is the Spring XML that defines an 'instance' of the above 'class'
|
||||
(again, the term is used very loosely here).
|
||||
</para>
|
||||
<programlisting><![CDATA[<lang:bsh id="messageService" script-source="classpath:BshMessenger.bsh"
|
||||
<programlisting language="xml"><![CDATA[<lang:bsh id="messageService" script-source="classpath:BshMessenger.bsh"
|
||||
script-interfaces="org.springframework.scripting.Messenger">
|
||||
|
||||
<lang:property name="message" value="Hello World!" />
|
||||
|
@ -935,7 +935,7 @@ class FortuneController implements Controller {
|
|||
return new ModelAndView("tell", "fortune", this.fortuneService.tellFortune())
|
||||
}
|
||||
}]]></programlisting>
|
||||
<programlisting><![CDATA[<lang:groovy id="fortune"
|
||||
<programlisting language="xml"><![CDATA[<lang:groovy id="fortune"
|
||||
refresh-check-delay="3000"
|
||||
script-source="/WEB-INF/groovy/FortuneController.groovy">
|
||||
<lang:property name="fortuneService" ref="fortuneService"/>
|
||||
|
@ -1037,7 +1037,7 @@ class TestBeanValidator implements Validator {
|
|||
to define a Groovy bean scoped as a
|
||||
<link linkend="beans-factory-scopes-prototype">prototype</link>.
|
||||
</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xsi:schemaLocation="
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
EJB-specific business methods interface. Let’s call this business
|
||||
methods interface <classname>MyComponent</classname>.
|
||||
</para>
|
||||
<programlisting><![CDATA[public interface MyComponent {
|
||||
<programlisting langauge="java"><![CDATA[public interface MyComponent {
|
||||
...
|
||||
}]]></programlisting>
|
||||
<para>
|
||||
|
@ -105,7 +105,7 @@
|
|||
on the controller. This will save the reference as an instance variable in the
|
||||
controller:
|
||||
</para>
|
||||
<programlisting><![CDATA[private MyComponent myComponent;
|
||||
<programlisting langauge="java"><![CDATA[private MyComponent myComponent;
|
||||
|
||||
public void setMyComponent(MyComponent myComponent) {
|
||||
this.myComponent = myComponent;
|
||||
|
@ -119,7 +119,7 @@ public void setMyComponent(MyComponent myComponent) {
|
|||
the <literal>myComponent</literal> property of the controller is done
|
||||
with a configuration entry such as:
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="myComponent"
|
||||
<programlisting language="xml"><![CDATA[<bean id="myComponent"
|
||||
class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
|
||||
<property name="jndiName" value="ejb/myBean"/>
|
||||
<property name="businessInterface" value="com.mycom.MyComponent"/>
|
||||
|
@ -148,7 +148,7 @@ public void setMyComponent(MyComponent myComponent) {
|
|||
consider using the <literal><jee:local-slsb></literal>
|
||||
configuration element in Spring's "jee" namespace:
|
||||
</para>
|
||||
<programlisting><![CDATA[<jee:local-slsb id="myComponent" jndi-name="ejb/myBean"
|
||||
<programlisting language="xml"><![CDATA[<jee:local-slsb id="myComponent" jndi-name="ejb/myBean"
|
||||
business-interface="com.mycom.MyComponent"/>
|
||||
|
||||
<bean id="myController" class="com.mycom.myController">
|
||||
|
@ -278,19 +278,19 @@ public void setMyComponent(MyComponent myComponent) {
|
|||
Consider an example Stateless Session bean which actually delegates
|
||||
the implementation to a plain java service object. We have the business interface:
|
||||
</para>
|
||||
<programlisting><![CDATA[public interface MyComponent {
|
||||
<programlisting language="java"><![CDATA[public interface MyComponent {
|
||||
public void myMethod(...);
|
||||
...
|
||||
}]]></programlisting>
|
||||
<para>We also have the plain Java implementation object:</para>
|
||||
<programlisting><![CDATA[public class MyComponentImpl implements MyComponent {
|
||||
<programlisting language="java"><![CDATA[public class MyComponentImpl implements MyComponent {
|
||||
public String myMethod(...) {
|
||||
...
|
||||
}
|
||||
...
|
||||
}]]></programlisting>
|
||||
<para>And finally the Stateless Session Bean itself:</para>
|
||||
<programlisting><![CDATA[public class MyFacadeEJB extends AbstractStatelessSessionBean
|
||||
<programlisting language="java"><![CDATA[public class MyFacadeEJB extends AbstractStatelessSessionBean
|
||||
implements MyFacadeLocal {
|
||||
|
||||
private MyComponent myComp;
|
||||
|
@ -351,7 +351,7 @@ public void setMyComponent(MyComponent myComponent) {
|
|||
shared container to be used by multiple EJBs or other clients. Doing this is relatively
|
||||
simple, by adding code similar to this to the EJB:
|
||||
</para>
|
||||
<programlisting><![CDATA[ /**
|
||||
<programlisting langauge="java"><![CDATA[ /**
|
||||
* Override default BeanFactoryLocator implementation
|
||||
* @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
|
||||
*/
|
||||
|
@ -367,7 +367,7 @@ public void setMyComponent(MyComponent myComponent) {
|
|||
<literal>businessApplicationContext.xml</literal> contains the bean definitions for all business
|
||||
service POJOs):
|
||||
</para>
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
<bean id="businessBeanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
|
||||
<constructor-arg value="businessApplicationContext.xml" />
|
||||
</bean>
|
||||
|
@ -376,7 +376,7 @@ public void setMyComponent(MyComponent myComponent) {
|
|||
In the above example, the <literal>ServicesConstants.PRIMARY_CONTEXT_ID</literal> constant
|
||||
would be defined as follows:
|
||||
</para>
|
||||
<programlisting><![CDATA[public static final String ServicesConstants.PRIMARY_CONTEXT_ID = "businessBeanFactory";]]></programlisting>
|
||||
<programlisting language="java"><![CDATA[public static final String ServicesConstants.PRIMARY_CONTEXT_ID = "businessBeanFactory";]]></programlisting>
|
||||
<para>
|
||||
Please see the respective Javadocs for the <classname>BeanFactoryLocator</classname> and
|
||||
<classname>ContextSingletonBeanFactoryLocator</classname> classes for more information on
|
||||
|
@ -395,7 +395,7 @@ public void setMyComponent(MyComponent myComponent) {
|
|||
in the EJB component class, or through an <literal>interceptor-binding</literal>
|
||||
XML element in the EJB deployment descriptor.
|
||||
</para>
|
||||
<programlisting><![CDATA[@Stateless
|
||||
<programlisting langauge="java"><![CDATA[@Stateless
|
||||
@Interceptors(SpringBeanAutowiringInterceptor.class)
|
||||
public class MyFacadeEJB implements MyFacadeLocal {
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@
|
|||
default destination. Here is an example that sends a message to a queue
|
||||
using the 1.0.2 implementation.</para>
|
||||
|
||||
<programlisting><![CDATA[import javax.jms.ConnectionFactory;
|
||||
<programlisting langauge="java"><![CDATA[import javax.jms.ConnectionFactory;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.Queue;
|
||||
|
@ -448,7 +448,7 @@ public class JmsQueueSender {
|
|||
example below demonstrates how to modify a message header and a property after
|
||||
a <interfacename>java.util.Map</interfacename> is converted to a message.</para>
|
||||
|
||||
<programlisting><![CDATA[public void sendWithConversion() {
|
||||
<programlisting langauge="java"><![CDATA[public void sendWithConversion() {
|
||||
Map map = new HashMap();
|
||||
map.put("Name", "Mark");
|
||||
map.put("Age", new Integer(47));
|
||||
|
@ -520,7 +520,7 @@ public class JmsQueueSender {
|
|||
receiving messages on multiple threads, it is important to ensure that your
|
||||
implementation is thread-safe.</para>
|
||||
<para>Below is a simple implementation of an MDP:</para>
|
||||
<programlisting><![CDATA[import javax.jms.JMSException;
|
||||
<programlisting langauge="java"><![CDATA[import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageListener;
|
||||
import javax.jms.TextMessage;
|
||||
|
@ -546,7 +546,7 @@ public class ExampleListener implements MessageListener {
|
|||
<para>Find below an example of how to define and configure one of the message listener
|
||||
containers that ships with Spring (in this case the
|
||||
<classname>DefaultMessageListenerContainer</classname>).</para>
|
||||
<programlisting><lineannotation><!-- this is the Message Driven POJO (MDP) --></lineannotation>
|
||||
<programlisting langauge="xml"><lineannotation><!-- this is the Message Driven POJO (MDP) --></lineannotation>
|
||||
<![CDATA[<bean id="messageListener" class="jmsexample.ExampleListener" />
|
||||
|
||||
]]><lineannotation><!-- and this is the message listener container --></lineannotation><![CDATA[
|
||||
|
@ -566,7 +566,7 @@ public class ExampleListener implements MessageListener {
|
|||
<interfacename>MessageListener</interfacename> interface, but also provides
|
||||
the message handling method with access to the JMS <interfacename>Session</interfacename>
|
||||
from which the <interfacename>Message</interfacename> was received.</para>
|
||||
<programlisting><![CDATA[package org.springframework.jms.listener;
|
||||
<programlisting langauge="java"><![CDATA[package org.springframework.jms.listener;
|
||||
|
||||
public interface SessionAwareMessageListener {
|
||||
|
||||
|
@ -609,7 +609,7 @@ public interface SessionAwareMessageListener {
|
|||
Notice also how the various message handling methods are strongly typed according to
|
||||
the <emphasis>contents</emphasis> of the various <interfacename>Message</interfacename>
|
||||
types that they can receive and handle.</para>
|
||||
<programlisting><![CDATA[public interface MessageDelegate {
|
||||
<programlisting langauge="java"><![CDATA[public interface MessageDelegate {
|
||||
|
||||
void handleMessage(String message);
|
||||
|
||||
|
@ -619,14 +619,14 @@ public interface SessionAwareMessageListener {
|
|||
|
||||
void handleMessage(Serializable message);
|
||||
}]]></programlisting>
|
||||
<programlisting><![CDATA[public class DefaultMessageDelegate implements MessageDelegate {
|
||||
<programlisting langauge="java"><![CDATA[public class DefaultMessageDelegate implements MessageDelegate {
|
||||
]]><lineannotation>// implementation elided for clarity...</lineannotation><![CDATA[
|
||||
}]]></programlisting>
|
||||
<para>In particular, note how the above implementation of the <interfacename>MessageDelegate</interfacename>
|
||||
interface (the above <classname>DefaultMessageDelegate</classname> class) has
|
||||
<emphasis>no</emphasis> JMS dependencies at all. It truly is a POJO that we will
|
||||
make into an MDP via the following configuration.</para>
|
||||
<programlisting><lineannotation><!-- this is the Message Driven POJO (MDP) --></lineannotation>
|
||||
<programlisting langauge="xml"><lineannotation><!-- this is the Message Driven POJO (MDP) --></lineannotation>
|
||||
<emphasis role="bold"><![CDATA[<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
|
||||
<constructor-arg>
|
||||
<bean class="jmsexample.DefaultMessageDelegate"/>
|
||||
|
@ -646,16 +646,16 @@ public interface SessionAwareMessageListener {
|
|||
<literal>'handleMessage'</literal>), but it is configurable (as you will see below).
|
||||
Notice also how the <literal>'receive(..)'</literal> method is strongly typed to
|
||||
receive and respond only to JMS <interfacename>TextMessage</interfacename> messages.</para>
|
||||
<programlisting><![CDATA[public interface TextMessageDelegate {
|
||||
<programlisting langauge="java"><![CDATA[public interface TextMessageDelegate {
|
||||
|
||||
void receive(TextMessage message);
|
||||
}]]></programlisting>
|
||||
<programlisting><![CDATA[public class DefaultTextMessageDelegate implements TextMessageDelegate {
|
||||
<programlisting langauge="java"><![CDATA[public class DefaultTextMessageDelegate implements TextMessageDelegate {
|
||||
]]><lineannotation>// implementation elided for clarity...</lineannotation><![CDATA[
|
||||
}]]></programlisting>
|
||||
<para>The configuration of the attendant <classname>MessageListenerAdapter</classname> would
|
||||
look like this:</para>
|
||||
<programlisting><![CDATA[<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
|
||||
<programlisting langauge="xml"><![CDATA[<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
|
||||
<constructor-arg>
|
||||
<bean class="jmsexample.DefaultTextMessageDelegate"/>
|
||||
</constructor-arg>
|
||||
|
@ -673,12 +673,12 @@ public interface SessionAwareMessageListener {
|
|||
class is the ability to automatically send back a response <interfacename>Message</interfacename>
|
||||
if a handler method returns a non-void value.
|
||||
Consider the interface and class:</para>
|
||||
<programlisting><![CDATA[public interface ResponsiveTextMessageDelegate {
|
||||
<programlisting langauge="java"><![CDATA[public interface ResponsiveTextMessageDelegate {
|
||||
|
||||
]]><lineannotation><emphasis role="bold">// notice the return type...</emphasis></lineannotation><![CDATA[
|
||||
String receive(TextMessage message);
|
||||
}]]></programlisting>
|
||||
<programlisting><![CDATA[public class DefaultResponsiveTextMessageDelegate implements ResponsiveTextMessageDelegate {
|
||||
<programlisting langauge="java"><![CDATA[public class DefaultResponsiveTextMessageDelegate implements ResponsiveTextMessageDelegate {
|
||||
]]><lineannotation>// implementation elided for clarity...</lineannotation><![CDATA[
|
||||
}]]></programlisting>
|
||||
<para>If the above <classname>DefaultResponsiveTextMessageDelegate</classname> is used in
|
||||
|
@ -714,7 +714,7 @@ public interface SessionAwareMessageListener {
|
|||
implementation, covering the case where database processing has
|
||||
committed but message processing failed to commit.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
|
||||
<programlisting langauge="xml"><![CDATA[<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
<property name="destination" ref="destination"/>
|
||||
<property name="messageListener" ref="messageListener"/>
|
||||
|
@ -736,13 +736,13 @@ public interface SessionAwareMessageListener {
|
|||
part of the same transaction (with unified commit semantics,
|
||||
at the expense of XA transaction log overhead).</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
|
||||
<programlisting langauge="xml"><![CDATA[<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
|
||||
]]></programlisting>
|
||||
|
||||
<para>Then you just need to add it to our earlier container configuration. The
|
||||
container will take care of the rest.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
|
||||
<programlisting language="xml"><![CDATA[<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
<property name="destination" ref="destination"/>
|
||||
<property name="messageListener" ref="messageListener"/>
|
||||
|
@ -763,7 +763,7 @@ public interface SessionAwareMessageListener {
|
|||
<classname>JmsActivationSpecConfig</classname> as shown in the following example.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<bean class="org.springframework.jms.listener.endpoint.JmsMessageEndpointManager">
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.jms.listener.endpoint.JmsMessageEndpointManager">
|
||||
<property name="resourceAdapter" ref="resourceAdapter"/>
|
||||
<property name="activationSpecConfig">
|
||||
<bean class="org.springframework.jms.listener.endpoint.JmsActivationSpecConfig">
|
||||
|
@ -778,7 +778,7 @@ public interface SessionAwareMessageListener {
|
|||
<interfacename>ActivationSpec</interfacename> object may also come
|
||||
from a JNDI lookup (using <literal><jee:jndi-lookup></literal>).</para>
|
||||
|
||||
<programlisting><![CDATA[<bean class="org.springframework.jms.listener.endpoint.JmsMessageEndpointManager">
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.jms.listener.endpoint.JmsMessageEndpointManager">
|
||||
<property name="resourceAdapter" ref="resourceAdapter"/>
|
||||
<property name="activationSpec">
|
||||
<bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
|
||||
|
@ -793,7 +793,7 @@ public interface SessionAwareMessageListener {
|
|||
the target <interfacename>ResourceAdapter</interfacename> may be
|
||||
configured locally as depicted in the following example.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="resourceAdapter" class="org.springframework.jca.support.ResourceAdapterFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="resourceAdapter" class="org.springframework.jca.support.ResourceAdapterFactoryBean">
|
||||
<property name="resourceAdapter">
|
||||
<bean class="org.apache.activemq.ra.ActiveMQResourceAdapter">
|
||||
<property name="serverUrl" value="tcp://localhost:61616"/>
|
||||
|
@ -846,7 +846,7 @@ public interface SessionAwareMessageListener {
|
|||
<para>Spring 2.5 introduces an XML namespace for simplifying JMS configuration. To use the
|
||||
JMS namespace elements you will need to reference the JMS schema:</para>
|
||||
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
]]><emphasis role="bold">xmlns:jms="http://www.springframework.org/schema/jms"</emphasis><![CDATA[
|
||||
|
@ -863,7 +863,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<literal><listener/></literal> child elements. Here is an example of a basic configuration
|
||||
for two listeners.</para>
|
||||
|
||||
<programlisting><![CDATA[<jms:listener-container>
|
||||
<programlisting language="xml"><![CDATA[<jms:listener-container>
|
||||
|
||||
<jms:listener destination="queue.orders" ref="orderService" method="placeOrder"/>
|
||||
|
||||
|
@ -956,7 +956,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
highly-customized listener containers while still benefiting from the convenience of the
|
||||
namespace.</para>
|
||||
|
||||
<programlisting><![CDATA[<jms:listener-container connection-factory="myConnectionFactory"
|
||||
<programlisting language="xml"><![CDATA[<jms:listener-container connection-factory="myConnectionFactory"
|
||||
task-executor="myTaskExecutor"
|
||||
destination-resolver="myDestinationResolver"
|
||||
transaction-manager="myTransactionManager"
|
||||
|
@ -1098,7 +1098,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
|
||||
<para>Configuring a JCA-based listener container with the "jms" schema support is very similar.</para>
|
||||
|
||||
<programlisting><![CDATA[<jms:jca-listener-container resource-adapter="myResourceAdapter"
|
||||
<programlisting language="xml"><![CDATA[<jms:jca-listener-container resource-adapter="myResourceAdapter"
|
||||
destination-resolver="myDestinationResolver"
|
||||
transaction-manager="myTransactionManager"
|
||||
concurrency="10">
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<interfacename>MBeanServer</interfacename>. For example, consider the following
|
||||
class:</para>
|
||||
|
||||
<programlisting><![CDATA[package org.springframework.jmx;
|
||||
<programlisting language="java"><![CDATA[package org.springframework.jmx;
|
||||
|
||||
public class JmxTestBean implements IJmxTestBean {
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
<classname>MBeanExporter</classname> class in your configuration file and
|
||||
pass in the bean as shown below:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
]]><lineannotation><!-- this bean must <emphasis role="bold">not</emphasis> be lazily initialized if the exporting is to happen --></lineannotation><![CDATA[
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter"]]> <emphasis
|
||||
|
@ -159,7 +159,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
property to the <interfacename>MBeanServer</interfacename> value returned by an
|
||||
<classname>MBeanServerFactoryBean</classname>; for example:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/>
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
cases, one should use the <interfacename>MBeanServer</interfacename>
|
||||
<literal>agentId</literal> to indicate which instance to be used:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
|
||||
]]><lineannotation><!-- indicate to first look for a server --></lineannotation><![CDATA[
|
||||
<property name="locateExistingServerIfPossible" value="true"/>
|
||||
|
@ -222,7 +222,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
has a dynamic (or unknown) <literal>agentId</literal> which is retrieved through lookup
|
||||
methods, one should use <link linkend="beans-factory-class-static-factory-method">factory-method</link>:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="server">
|
||||
]]><lineannotation><!-- Custom <literal>MBeanServerLocator</literal> --></lineannotation><![CDATA[
|
||||
|
@ -257,7 +257,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
by the <classname>MBeanExporter</classname> by setting the
|
||||
<literal>autodetect</literal> property to <literal>true</literal>:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<programlisting language="xml"><![CDATA[<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="autodetect" value="true"/>
|
||||
</bean>
|
||||
|
||||
|
@ -369,7 +369,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
default registration behavior to the
|
||||
<literal>REGISTRATION_REPLACE_EXISTING</literal> behavior:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -455,7 +455,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
class that you saw earlier marked with Commons Attributes
|
||||
metadata:</para>
|
||||
|
||||
<programlisting><![CDATA[package org.springframework.jmx;
|
||||
<programlisting language="java"><![CDATA[package org.springframework.jmx;
|
||||
|
||||
/**
|
||||
* @@org.springframework.jmx.export.metadata.ManagedResource
|
||||
|
@ -540,7 +540,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
<classname>MBeanExporter</classname> to use the
|
||||
<classname>MetadataMBeanInfoAssembler</classname>:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -592,7 +592,7 @@ public class JmxTestBean implements IJmxTestBean {
|
|||
<para>The example below shows a bean where the management interface is defined
|
||||
by the presence of JDK 5.0 annotation types:</para>
|
||||
|
||||
<programlisting><![CDATA[package org.springframework.jmx;
|
||||
<programlisting language="java"><![CDATA[package org.springframework.jmx;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedResource;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
|
@ -644,7 +644,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
<para>As you can see little has changed, other than the basic syntax of
|
||||
the metadata definitions.</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="assembler" ref="assembler"/>
|
||||
<property name="namingStrategy" ref="namingStrategy"/>
|
||||
|
@ -910,7 +910,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
<classname>ObjectName</classname> which results in a configuration like
|
||||
this:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
]]><lineannotation><!-- notice how no <literal>'beans'</literal> are explicitly configured here --></lineannotation><![CDATA[
|
||||
|
@ -975,7 +975,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
interface for the <classname>JmxTestBean</classname> class that you saw
|
||||
earlier:</para>
|
||||
|
||||
<programlisting><![CDATA[public interface IJmxTestBean {
|
||||
<programlisting language="java"><![CDATA[public interface IJmxTestBean {
|
||||
|
||||
public int add(int x, int y);
|
||||
|
||||
|
@ -995,7 +995,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
shows how to configure Spring JMX to use this interface as the
|
||||
definition for the management interface:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -1055,7 +1055,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
as attributes and operations. The code below shows a sample
|
||||
configuration for this:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<programlisting language="xml"><![CDATA[<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
<map>
|
||||
<entry key="bean:name=testBean5" value-ref="testBean"/>
|
||||
|
@ -1120,7 +1120,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
<para>The code below shows a sample configuration for the
|
||||
<classname>KeyNamingStrategy</classname>:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -1174,7 +1174,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
configuration for the
|
||||
<classname>MetadataNamingStrategy</classname>:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -1208,7 +1208,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
following bean would be: <emphasis>com.foo:type=MyClass,name=myBean</emphasis>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="myBean" class="com.foo.MyClass"/>]]></programlisting>
|
||||
<programlisting language="xml"><![CDATA[<bean id="myBean" class="com.foo.MyClass"/>]]></programlisting>
|
||||
|
||||
</section>
|
||||
|
||||
|
@ -1225,7 +1225,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
'<literal>context</literal>' namespace in Spring 2.5. Rather than defining an
|
||||
<classname>MBeanExporter</classname> bean, provide this single element:</para>
|
||||
|
||||
<programlisting><![CDATA[<context:mbean-export/>]]></programlisting>
|
||||
<programlisting language="xml"><![CDATA[<context:mbean-export/>]]></programlisting>
|
||||
|
||||
<para>You can provide a reference to a particular MBean server if
|
||||
necessary, and the <literal>defaultDomain</literal> attribute
|
||||
|
@ -1237,7 +1237,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
<link linkend="jmx-naming-metadata"><classname>MetadataNamingStrategy</classname></link>.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<context:mbean-export server="myMBeanServer" default-domain="myDomain"/>]]></programlisting>.
|
||||
<programlisting language="xml"><![CDATA[<context:mbean-export server="myMBeanServer" default-domain="myDomain"/>]]></programlisting>.
|
||||
|
||||
<note>
|
||||
<para>Do not use interface-based AOP proxies in combination with autodetection of
|
||||
|
@ -1266,7 +1266,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
<classname>JMXConnectorServer</classname> use the following
|
||||
configuration:</para>
|
||||
|
||||
<programlisting><bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean"/></programlisting>
|
||||
<programlisting language="xml"><bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean"/></programlisting>
|
||||
|
||||
<para>By default <literal>ConnectorServerFactoryBean</literal> creates a
|
||||
<classname>JMXConnectorServer</classname> bound to
|
||||
|
@ -1283,7 +1283,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
<interfacename>MBeanServer</interfacename> use the <literal>serviceUrl</literal>
|
||||
and <classname>ObjectName</classname> properties respectively:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="serverConnector"
|
||||
<programlisting language="xml"><![CDATA[<bean id="serverConnector"
|
||||
class="org.springframework.jmx.support.ConnectorServerFactoryBean">
|
||||
<property name="objectName" value="connector:name=rmi"/>
|
||||
<property name="serviceUrl"
|
||||
|
@ -1298,7 +1298,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
<classname>ConnectorServerFactoryBean</classname> when creating a
|
||||
JMXConnector:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="serverConnector"
|
||||
<programlisting language="xml"><![CDATA[<bean id="serverConnector"
|
||||
class="org.springframework.jmx.support.ConnectorServerFactoryBean">
|
||||
<property name="objectName" value="connector:name=iiop"/>
|
||||
<property name="serviceUrl"
|
||||
|
@ -1319,7 +1319,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
RMI registry. If not, you can easily start a registry using the
|
||||
following snippet of configuration:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
|
||||
<property name="port" value="1099"/>
|
||||
</bean>]]></programlisting>
|
||||
</section>
|
||||
|
@ -1332,7 +1332,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
<classname>MBeanServerConnectionFactoryBean</classname> as shown
|
||||
below:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="clientConnector" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="clientConnector" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
|
||||
<property name="serviceUrl" value="service:jmx:rmi://localhost:9875"/>
|
||||
</bean>]]></programlisting>
|
||||
</section>
|
||||
|
@ -1349,7 +1349,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
of protocols like SOAP, Hessian, Burlap over simple HTTP or SSL and
|
||||
others:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean">
|
||||
<property name="objectName" value="connector:name=burlap"/>
|
||||
<property name="serviceUrl" value="service:jmx:burlap://localhost:9874"/>
|
||||
</bean>]]></programlisting>
|
||||
|
@ -1369,7 +1369,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
proxy for an MBean running in a local
|
||||
<interfacename>MBeanServer</interfacename>:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="proxy" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="proxy" class="org.springframework.jmx.access.MBeanProxyFactoryBean">
|
||||
<property name="objectName" value="bean:name=testBean"/>
|
||||
<property name="proxyInterface" value="org.springframework.jmx.IJmxTestBean"/>
|
||||
</bean>]]></programlisting>
|
||||
|
@ -1391,7 +1391,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
pointing to a remote <interfacename>MBeanServer</interfacename> to cater for
|
||||
proxies pointing to remote MBeans:</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="clientConnector"
|
||||
<programlisting language="xml"><![CDATA[<bean id="clientConnector"
|
||||
class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
|
||||
<property name="serviceUrl" value="service:jmx:rmi://remotehost:9875"/>
|
||||
</bean>
|
||||
|
@ -1429,7 +1429,7 @@ public class AnnotationTestBean implements IJmxTestBean {
|
|||
would like to be informed (via a <classname>Notification</classname>)
|
||||
each and every time an attribute of a target MBean changes.</para>
|
||||
|
||||
<programlisting><![CDATA[package com.example;
|
||||
<programlisting language="java"><![CDATA[package com.example;
|
||||
|
||||
import javax.management.AttributeChangeNotification;
|
||||
import javax.management.Notification;
|
||||
|
@ -1449,7 +1449,7 @@ public class ConsoleLoggingNotificationListener
|
|||
}
|
||||
}]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -1486,7 +1486,7 @@ public class ConsoleLoggingNotificationListener
|
|||
<para>You can also use straight bean names as the link between exported beans
|
||||
and listeners:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -1516,7 +1516,7 @@ public class ConsoleLoggingNotificationListener
|
|||
as the key for an entry in the <literal>notificationListenerMappings</literal>
|
||||
property map; for example:</para>
|
||||
|
||||
<programlisting><![CDATA[<property name="notificationListenerMappings">
|
||||
<programlisting language="xml"><![CDATA[<property name="notificationListenerMappings">
|
||||
<map>
|
||||
<entry key="*">
|
||||
<bean class="com.example.ConsoleLoggingNotificationListener"/>
|
||||
|
@ -1545,7 +1545,7 @@ public class ConsoleLoggingNotificationListener
|
|||
<classname>NotificationListenerBean</classname> instances is not wildly
|
||||
different to what was presented previously:</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -1586,7 +1586,7 @@ public class ConsoleLoggingNotificationListener
|
|||
section of the JMX specification (1.2) entitled <literal>'The JMX
|
||||
Notification Model'</literal>.)</para>
|
||||
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
|
||||
<property name="beans">
|
||||
|
@ -1689,7 +1689,7 @@ public class ConsoleLoggingNotificationListener
|
|||
a <classname>NotificationEvent</classname> every time the
|
||||
<literal>add(int, int)</literal> operation is invoked.</para>
|
||||
|
||||
<programlisting><![CDATA[package org.springframework.jmx;
|
||||
<programlisting language="java"><![CDATA[package org.springframework.jmx;
|
||||
|
||||
import org.springframework.jmx.export.notification.NotificationPublisherAware;
|
||||
import org.springframework.jmx.export.notification.NotificationPublisher;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<section id="mail-usage">
|
||||
<title>Usage</title>
|
||||
<para>Let's assume there is a business interface called <interfacename>OrderManager</interfacename>:</para>
|
||||
<programlisting><![CDATA[public interface OrderManager {
|
||||
<programlisting language="java"><![CDATA[public interface OrderManager {
|
||||
|
||||
void placeOrder(Order order);
|
||||
}]]></programlisting>
|
||||
|
@ -59,7 +59,7 @@
|
|||
|
||||
<section id="mail-usage-simple">
|
||||
<title>Basic <interfacename>MailSender</interfacename> and <classname>SimpleMailMessage</classname> usage</title>
|
||||
<programlisting><![CDATA[import org.springframework.mail.MailException;
|
||||
<programlisting langauge="java"><![CDATA[import org.springframework.mail.MailException;
|
||||
import org.springframework.mail.MailSender;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class SimpleOrderManager implements OrderManager {
|
|||
}]]></programlisting>
|
||||
|
||||
<para>Find below the bean definitions for the above code:</para>
|
||||
<programlisting><![CDATA[<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||
<programlisting langauge="xml"><![CDATA[<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
||||
<property name="host" value="mail.mycompany.com"/>
|
||||
</bean>
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class SimpleOrderManager implements OrderManager {
|
|||
<interfacename>JavaMailSender</interfacename> so that we are able to use the JavaMail
|
||||
<classname>MimeMessage</classname> class:</para>
|
||||
|
||||
<programlisting><![CDATA[import javax.mail.Message;
|
||||
<programlisting langauge="java"><![CDATA[import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
@ -199,7 +199,7 @@ public class SimpleOrderManager implements OrderManager {
|
|||
which shields you from having to use the verbose JavaMail API. Using
|
||||
the <classname>MimeMessageHelper</classname> it is pretty easy to
|
||||
create a <classname>MimeMessage</classname>:</para>
|
||||
<programlisting><lineannotation>// of course you would use DI in any real-world cases</lineannotation><![CDATA[
|
||||
<programlisting langauge="java"><lineannotation>// of course you would use DI in any real-world cases</lineannotation><![CDATA[
|
||||
JavaMailSenderImpl sender = new JavaMailSenderImpl();
|
||||
sender.setHost("mail.host.com");
|
||||
|
||||
|
@ -220,7 +220,7 @@ sender.send(message);]]></programlisting>
|
|||
<para>The following example shows you how to use the
|
||||
<classname>MimeMessageHelper</classname> to send an email along with a
|
||||
single JPEG image attachment.</para>
|
||||
<programlisting><![CDATA[JavaMailSenderImpl sender = new JavaMailSenderImpl();
|
||||
<programlisting langauge="java"><![CDATA[JavaMailSenderImpl sender = new JavaMailSenderImpl();
|
||||
sender.setHost("mail.host.com");
|
||||
|
||||
MimeMessage message = sender.createMimeMessage();
|
||||
|
@ -242,7 +242,7 @@ sender.send(message);]]></programlisting>
|
|||
<para>The following example shows you how to use the
|
||||
<classname>MimeMessageHelper</classname> to send an email along with an
|
||||
inline image.</para>
|
||||
<programlisting><![CDATA[JavaMailSenderImpl sender = new JavaMailSenderImpl();
|
||||
<programlisting langauge="java"><![CDATA[JavaMailSenderImpl sender = new JavaMailSenderImpl();
|
||||
sender.setHost("mail.host.com");
|
||||
|
||||
MimeMessage message = sender.createMimeMessage();
|
||||
|
@ -309,7 +309,7 @@ sender.send(message);]]></programlisting>
|
|||
template that this example will be using... as you can see it is HTML-based,
|
||||
and since it is plain text it can be created using your favorite HTML editor
|
||||
without recourse to having to know Java.</para>
|
||||
<programlisting><lineannotation># in the <literal>com/foo/package</literal></lineannotation><![CDATA[
|
||||
<programlisting langauge="xml"><lineannotation># in the <literal>com/foo/package</literal></lineannotation><![CDATA[
|
||||
<html>
|
||||
<body>
|
||||
<h3>Hi ${user.userName}, welcome to the Chipping Sodbury On-the-Hill message boards!</h3>
|
||||
|
@ -323,7 +323,7 @@ sender.send(message);]]></programlisting>
|
|||
<para>Find below some simple code and Spring XML configuration that
|
||||
makes use of the above Velocity template to create email content and
|
||||
send email(s).</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting langauge="java"><![CDATA[package com.foo;
|
||||
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
|
@ -371,7 +371,7 @@ public class SimpleRegistrationService implements RegistrationService {
|
|||
this.mailSender.send(preparator);
|
||||
}
|
||||
}]]></programlisting>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?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
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<emphasis>annotations</emphasis> to program elements - usually, classes
|
||||
and/or methods.</para>
|
||||
<para>For example, we might add metadata to a class as follows:</para>
|
||||
<programlisting><![CDATA[/**
|
||||
<programlisting language="java"><![CDATA[/**
|
||||
* Normal comments here
|
||||
* @@org.springframework.transaction.interceptor.DefaultTransactionAttribute()
|
||||
*/
|
||||
|
@ -112,7 +112,7 @@ public void echoException(Exception ex) throws Exception {
|
|||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>The Spring <interfacename>Attributes</interfacename> interface looks like this:</para>
|
||||
<programlisting><![CDATA[public interface Attributes {
|
||||
<programlisting language="java"><![CDATA[public interface Attributes {
|
||||
|
||||
Collection getAttributes(Class targetClass);
|
||||
|
||||
|
@ -164,7 +164,7 @@ public void echoException(Exception ex) throws Exception {
|
|||
at runtime.</para>
|
||||
<para>The best way to illustrate the usage of this annotation is to
|
||||
show an example:</para>
|
||||
<programlisting><![CDATA[public class SimpleMovieLister {
|
||||
<programlisting language="java"><![CDATA[public class SimpleMovieLister {
|
||||
|
||||
]]><lineannotation>// the <classname>SimpleMovieLister</classname> has a dependency on the <interfacename>MovieFinder</interfacename></lineannotation><![CDATA[
|
||||
private MovieFinder movieFinder;
|
||||
|
@ -187,7 +187,7 @@ public void echoException(Exception ex) throws Exception {
|
|||
Let's look at an example of some XML configuration that will
|
||||
<emphasis role="bold">not</emphasis> pass validation.
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="movieLister" class="x.y.SimpleMovieLister">
|
||||
<programlisting language="xml"><![CDATA[<bean id="movieLister" class="x.y.SimpleMovieLister">
|
||||
]]><lineannotation><!-- whoops, no MovieFinder is set (and this property is <interfacename>@Required</interfacename>) --></lineannotation><![CDATA[
|
||||
</bean>]]></programlisting>
|
||||
<para>
|
||||
|
@ -213,7 +213,7 @@ public void echoException(Exception ex) throws Exception {
|
|||
to configure; simply drop the following bean definition into your Spring
|
||||
XML configuration.
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>]]></programlisting>
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>]]></programlisting>
|
||||
<para>
|
||||
Finally, one can configure an instance of the
|
||||
<classname>RequiredAnnotationBeanPostProcessor</classname> class to look
|
||||
|
@ -229,7 +229,7 @@ public void echoException(Exception ex) throws Exception {
|
|||
You can make a <classname>RequiredAnnotationBeanPostProcessor</classname>
|
||||
instance <interfacename>@Mandatory</interfacename>-aware like so:
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor">
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor">
|
||||
<property name="requiredAnnotationType" value="your.company.package.Mandatory"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>
|
||||
|
@ -238,7 +238,7 @@ public void echoException(Exception ex) throws Exception {
|
|||
is itself annotated with appropriate annotations for its target
|
||||
and runtime retention policy.
|
||||
</para>
|
||||
<programlisting><![CDATA[package your.company.package;
|
||||
<programlisting language="java"><![CDATA[package your.company.package;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -351,7 +351,7 @@ public @interface Mandatory {
|
|||
2. Import the Commons Attributes ant tasks into your project build
|
||||
script, as follows:
|
||||
</para>
|
||||
<programlisting><![CDATA[<taskdef resource="org/apache/commons/attributes/anttasks.properties"/>]]></programlisting>
|
||||
<programlisting language="xml"><![CDATA[<taskdef resource="org/apache/commons/attributes/anttasks.properties"/>]]></programlisting>
|
||||
<para>
|
||||
3. Next, define an attribute compilation task, which will use the
|
||||
Commons Attributes attribute-compiler task to "compile" the attributes in
|
||||
|
@ -359,7 +359,7 @@ public @interface Mandatory {
|
|||
to a location specified by the <literal>destdir</literal> attribute. Here we show the use of
|
||||
a temporary directory for storing the generated files:
|
||||
</para>
|
||||
<programlisting><![CDATA[<target name="compileAttributes">
|
||||
<programlisting language="xml"><![CDATA[<target name="compileAttributes">
|
||||
|
||||
<attribute-compiler destdir="${commons.attributes.tempdir}">
|
||||
<fileset dir="${src.dir}" includes="**/*.java"/>
|
||||
|
@ -397,7 +397,7 @@ public @interface Mandatory {
|
|||
create an index of all the attributes defined on your sources, for
|
||||
efficient lookup at runtime. The step looks like this:
|
||||
</para>
|
||||
<programlisting><![CDATA[<attribute-indexer jarFile="myCompiledSources.jar">
|
||||
<programlisting language="xml"><![CDATA[<attribute-indexer jarFile="myCompiledSources.jar">
|
||||
|
||||
<classpath refid="master-classpath"/>
|
||||
|
||||
|
@ -432,7 +432,7 @@ public @interface Mandatory {
|
|||
This builds on the Spring AOP autoproxy functionality.
|
||||
Configuration might look like this:
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
|
||||
|
||||
<bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
|
||||
<property name="transactionInterceptor" ref="txInterceptor" />
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
</itemizedlist></para>
|
||||
<para>While discussing the remoting capabilities of Spring, we'll use the following domain
|
||||
model and corresponding services:</para>
|
||||
<programlisting><![CDATA[public class Account implements Serializable{
|
||||
<programlisting language="java"><![CDATA[public class Account implements Serializable{
|
||||
|
||||
private String name;
|
||||
|
||||
|
@ -64,19 +64,19 @@
|
|||
this.name = name;
|
||||
}
|
||||
}]]></programlisting>
|
||||
<programlisting><![CDATA[public interface AccountService {
|
||||
<programlisting language="java"><![CDATA[public interface AccountService {
|
||||
|
||||
public void insertAccount(Account account);
|
||||
|
||||
public List getAccounts(String name);
|
||||
}]]></programlisting>
|
||||
<programlisting><![CDATA[public interface RemoteAccountService extends Remote {
|
||||
<programlisting language="java"><![CDATA[public interface RemoteAccountService extends Remote {
|
||||
|
||||
public void insertAccount(Account account) throws RemoteException;
|
||||
|
||||
public List getAccounts(String name) throws RemoteException;
|
||||
}]]></programlisting>
|
||||
<programlisting><lineannotation>// the implementation doing nothing at the moment</lineannotation><![CDATA[
|
||||
<programlisting language="java"><lineannotation>// the implementation doing nothing at the moment</lineannotation><![CDATA[
|
||||
public class AccountServiceImpl implements AccountService {
|
||||
|
||||
public void insertAccount(Account acc) {
|
||||
|
@ -110,11 +110,11 @@ public class AccountServiceImpl implements AccountService {
|
|||
exposing of any non-RMI services via RMI invokers.
|
||||
</para>
|
||||
<para>Of course, we first have to set up our service in the Spring container:</para>
|
||||
<programlisting><![CDATA[<bean id="accountService" class="example.AccountServiceImpl">
|
||||
<programlisting language="xml"><![CDATA[<bean id="accountService" class="example.AccountServiceImpl">
|
||||
]]><lineannotation><!-- any additional properties, maybe a DAO? --></lineannotation><![CDATA[
|
||||
</bean>]]></programlisting>
|
||||
<para>Next we'll have to expose our service using the <classname>RmiServiceExporter</classname>:</para>
|
||||
<programlisting><![CDATA[<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
|
||||
]]><lineannotation><!-- does not necessarily have to be the same name as the bean to be exported --></lineannotation><![CDATA[
|
||||
<property name="serviceName" value="AccountService"/>
|
||||
<property name="service" ref="accountService"/>
|
||||
|
@ -138,7 +138,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
<title>Linking in the service at the client</title>
|
||||
<para>Our client is a simple object using the <interfacename>AccountService</interfacename>
|
||||
to manage accounts:</para>
|
||||
<programlisting><![CDATA[public class SimpleObject {
|
||||
<programlisting language="java"><![CDATA[public class SimpleObject {
|
||||
|
||||
private AccountService accountService;
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
}]]></programlisting>
|
||||
<para>To link in the service on the client, we'll create a separate Spring container,
|
||||
containing the simple object and the service linking configuration bits:</para>
|
||||
<programlisting><![CDATA[<bean class="example.SimpleObject">
|
||||
<programlisting language="xml"><![CDATA[<bean class="example.SimpleObject">
|
||||
<property name="accountService" ref="accountService"/>
|
||||
</bean>
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
from Spring Web MVC usage, you can easily wire up such a servlet exposing
|
||||
your services. First we'll have to create a new servlet in your application
|
||||
(this an excerpt from <filename>'web.xml'</filename>):</para>
|
||||
<programlisting><![CDATA[<servlet>
|
||||
<programlisting language="xml"><![CDATA[<servlet>
|
||||
<servlet-name>remoting</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
|
@ -203,7 +203,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
<title>Exposing your beans by using the <classname>HessianServiceExporter</classname></title>
|
||||
<para>In the newly created application context called <literal>remoting-servlet.xml</literal>,
|
||||
we'll create a <classname>HessianServiceExporter</classname> exporting your services:</para>
|
||||
<programlisting><![CDATA[<bean id="accountService" class="example.AccountServiceImpl">
|
||||
<programlisting language="xml"><![CDATA[<bean id="accountService" class="example.AccountServiceImpl">
|
||||
]]><lineannotation><!-- any additional properties, maybe a DAO? --></lineannotation><![CDATA[
|
||||
</bean>
|
||||
|
||||
|
@ -219,7 +219,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
</para>
|
||||
<para>Alternatively, create a <classname>HessianServiceExporter</classname> in your
|
||||
root application context (e.g. in <filename>'WEB-INF/applicationContext.xml'</filename>):</para>
|
||||
<programlisting><![CDATA[<bean name="accountExporter" class="org.springframework.remoting.caucho.HessianServiceExporter">
|
||||
<programlisting language="xml"><![CDATA[<bean name="accountExporter" class="org.springframework.remoting.caucho.HessianServiceExporter">
|
||||
<property name="service" ref="accountService"/>
|
||||
<property name="serviceInterface" value="example.AccountService"/>
|
||||
</bean>]]></programlisting>
|
||||
|
@ -227,7 +227,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
in <filename>'web.xml'</filename>, with the same end result: The exporter
|
||||
getting mapped to the request path <literal>/remoting/AccountService</literal>.
|
||||
Note that the servlet name needs to match the bean name of the target exporter.</para>
|
||||
<programlisting><![CDATA[<servlet>
|
||||
<programlisting language="xml"><![CDATA[<servlet>
|
||||
<servlet-name>accountExporter</servlet-name>
|
||||
<servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
|
||||
</servlet>
|
||||
|
@ -245,7 +245,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
a separate bean factory or application context and mention the following beans
|
||||
where the <classname>SimpleObject</classname> is using the
|
||||
<interfacename>AccountService</interfacename> to manage accounts:</para>
|
||||
<programlisting><![CDATA[<bean class="example.SimpleObject">
|
||||
<programlisting language="xml"><![CDATA[<bean class="example.SimpleObject">
|
||||
<property name="accountService" ref="accountService"/>
|
||||
</bean>
|
||||
|
||||
|
@ -271,7 +271,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
features, for example. Usually, you don't use per-user security credentials here, but
|
||||
rather shared credentials defined at the <literal>Hessian/BurlapProxyFactoryBean</literal> level
|
||||
(similar to a JDBC <interfacename>DataSource</interfacename>).</para>
|
||||
<programlisting><![CDATA[<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
|
||||
<property name="interceptors" ref="authorizationInterceptor"/>
|
||||
</bean>
|
||||
|
||||
|
@ -315,7 +315,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
<para>To expose the <literal>AccountService</literal> (mentioned above) within a
|
||||
Spring Web MVC <classname>DispatcherServlet</classname>, the following configuration
|
||||
needs to be in place in the dispatcher's application context:</para>
|
||||
<programlisting><![CDATA[<bean name="/AccountService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
|
||||
<programlisting language="xml"><![CDATA[<bean name="/AccountService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
|
||||
<property name="service" ref="accountService"/>
|
||||
<property name="serviceInterface" value="example.AccountService"/>
|
||||
</bean>
|
||||
|
@ -325,14 +325,14 @@ public class AccountServiceImpl implements AccountService {
|
|||
as explained in the section on Hessian.</para>
|
||||
<para>Alternatively, create an <classname>HttpInvokerServiceExporter</classname> in your
|
||||
root application context (e.g. in <filename>'WEB-INF/applicationContext.xml'</filename>):</para>
|
||||
<programlisting><![CDATA[<bean name="accountExporter" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
|
||||
<programlisting language="xml"><![CDATA[<bean name="accountExporter" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
|
||||
<property name="service" ref="accountService"/>
|
||||
<property name="serviceInterface" value="example.AccountService"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>In addition, define a corresponding servlet for this exporter in
|
||||
<filename>'web.xml'</filename>, with the servlet name matching the bean
|
||||
name of the target exporter:</para>
|
||||
<programlisting><![CDATA[<servlet>
|
||||
<programlisting language="xml"><![CDATA[<servlet>
|
||||
<servlet-name>accountExporter</servlet-name>
|
||||
<servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
|
||||
</servlet>
|
||||
|
@ -349,7 +349,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
do it when using Hessian or Burlap. Using a proxy, Spring will be able to
|
||||
translate your calls to HTTP POST requests to the URL pointing to the exported
|
||||
service.</para>
|
||||
<programlisting><![CDATA[<bean id="httpInvokerProxy" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="httpInvokerProxy" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
|
||||
<property name="serviceUrl" value="http://remotehost:8080/remoting/AccountService"/>
|
||||
<property name="serviceInterface" value="example.AccountService"/>
|
||||
</bean>
|
||||
|
@ -358,7 +358,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
By default, the <classname>HttpInvokerProxy</classname> uses the J2SE HTTP functionality, but
|
||||
you can also use the Commons <classname>HttpClient</classname> by setting the
|
||||
<literal>httpInvokerRequestExecutor</literal> property:</para>
|
||||
<programlisting><![CDATA[<property name="httpInvokerRequestExecutor">
|
||||
<programlisting language="xml"><![CDATA[<property name="httpInvokerRequestExecutor">
|
||||
<bean class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor"/>
|
||||
</property>
|
||||
]]></programlisting>
|
||||
|
@ -404,7 +404,7 @@ public class AccountServiceImpl implements AccountService {
|
|||
<interfacename>AccountService</interfacename> we extend Spring's
|
||||
<classname>ServletEndpointSupport</classname> class and implement our business
|
||||
logic here, usually delegating the call to the business layer.</para>
|
||||
<programlisting><lineannotation>/**
|
||||
<programlisting langauge="java"><lineannotation>/**
|
||||
* JAX-RPC compliant RemoteAccountService implementation that simply delegates
|
||||
* to the AccountService implementation in the root web application context.
|
||||
*
|
||||
|
@ -455,7 +455,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
|||
in the previous section. You will see that Spring has great support for web services
|
||||
requiring little coding efforts - most of the setup is done in the Spring configuration
|
||||
file as usual:</para>
|
||||
<programlisting><![CDATA[<bean id="accountWebService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="accountWebService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
|
||||
<property name="serviceInterface" value="example.RemoteAccountService"/>
|
||||
<property name="wsdlDocumentUrl" value="http://localhost:8080/account/services/accountService?WSDL"/>
|
||||
<property name="namespaceUri" value="http://localhost:8080/account/services/accountService"/>
|
||||
|
@ -470,13 +470,13 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
|||
</para>
|
||||
<para>Accessing the web service is now very easy as we have a bean factory for it that will expose it
|
||||
as <literal>RemoteAccountService</literal> interface. We can wire this up in Spring:</para>
|
||||
<programlisting><![CDATA[<bean id="client" class="example.AccountClientImpl">
|
||||
<programlisting language="xml"><![CDATA[<bean id="client" class="example.AccountClientImpl">
|
||||
...
|
||||
<property name="service" ref="accountWebService"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>From the client code we can access the web service just as if it
|
||||
was a normal class, except that it throws <exceptionname>RemoteException</exceptionname>.</para>
|
||||
<programlisting><![CDATA[public class AccountClientImpl {
|
||||
<programlisting language="java"><![CDATA[public class AccountClientImpl {
|
||||
|
||||
private RemoteAccountService service;
|
||||
|
||||
|
@ -498,14 +498,14 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
|||
Spring supports automatic conversion to its corresponding unchecked
|
||||
<exceptionname>RemoteException</exceptionname>. This requires that we provide a non-RMI
|
||||
interface also. Our configuration is now:</para>
|
||||
<programlisting><![CDATA[<bean id="accountWebService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="accountWebService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
|
||||
<property name="serviceInterface" value="example.AccountService"/>
|
||||
<property name="portInterface" value="example.RemoteAccountService"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>Where <literal>serviceInterface</literal> is changed to our non RMI interface. Our RMI
|
||||
interface is now defined using the property <literal>portInterface</literal>. Our client
|
||||
code can now avoid handling <exceptionname>java.rmi.RemoteException</exceptionname>:</para>
|
||||
<programlisting><![CDATA[public class AccountClientImpl {
|
||||
<programlisting language="java"><![CDATA[public class AccountClientImpl {
|
||||
|
||||
private AccountService service;
|
||||
|
||||
|
@ -538,7 +538,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
|||
</note>
|
||||
<para>We will use Axis to register bean mappings on the client side. To do this we need to
|
||||
register the bean mappings programmatically:</para>
|
||||
<programlisting><![CDATA[public class AxisPortProxyFactoryBean extends JaxRpcPortProxyFactoryBean {
|
||||
<programlisting language="java"><![CDATA[public class AxisPortProxyFactoryBean extends JaxRpcPortProxyFactoryBean {
|
||||
|
||||
protected void postProcessJaxRpcService(Service service) {
|
||||
TypeMappingRegistry registry = service.getTypeMappingRegistry();
|
||||
|
@ -564,7 +564,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
|||
The <interfacename>Handler</interfacename> is a callback interface. There is a convenience
|
||||
base class provided in <filename class="libraryfile">jaxrpc.jar</filename>, namely
|
||||
<classname>javax.rpc.xml.handler.GenericHandler</classname> that we will extend:</para>
|
||||
<programlisting><![CDATA[public class AccountHandler extends GenericHandler {
|
||||
<programlisting language="java"><![CDATA[public class AccountHandler extends GenericHandler {
|
||||
|
||||
public QName[] getHeaders() {
|
||||
return null;
|
||||
|
@ -590,7 +590,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
|||
use the programmatic approach. However Spring has made it very easy for us to do this as we can
|
||||
override the <methodname>postProcessJaxRpcService(..)</methodname> method that is designed for
|
||||
this:</para>
|
||||
<programlisting><![CDATA[public class AccountHandlerJaxRpcPortProxyFactoryBean extends JaxRpcPortProxyFactoryBean {
|
||||
<programlisting language="java"><![CDATA[public class AccountHandlerJaxRpcPortProxyFactoryBean extends JaxRpcPortProxyFactoryBean {
|
||||
|
||||
protected void postProcessJaxRpcService(Service service) {
|
||||
QName port = new QName(this.getNamespaceUri(), this.getPortName());
|
||||
|
@ -601,7 +601,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
|||
}]]></programlisting>
|
||||
<para>The last thing we must remember to do is to change the Spring configuration to use our
|
||||
factory bean:</para>
|
||||
<programlisting><![CDATA[<bean id="accountWebService" class="example.AccountHandlerJaxRpcPortProxyFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="accountWebService" class="example.AccountHandlerJaxRpcPortProxyFactoryBean">
|
||||
...
|
||||
</bean>]]></programlisting>
|
||||
</section>
|
||||
|
@ -615,7 +615,7 @@ public class AccountServiceEndpoint extends ServletEndpointSupport implements Re
|
|||
logic here, usually delegating the call to the business layer.
|
||||
We'll simply use Spring 2.5's <literal>@Autowired</literal>
|
||||
annotation for expressing such dependencies on Spring-managed beans.</para>
|
||||
<programlisting><lineannotation>/**
|
||||
<programlisting langauge="java"><lineannotation>/**
|
||||
* JAX-WS compliant AccountService implementation that simply delegates
|
||||
* to the AccountService implementation in the root web application context.
|
||||
*
|
||||
|
@ -669,7 +669,7 @@ public class AccountServiceEndpoint extends SpringBeanAutowiringSupport {
|
|||
Of course, annotation-driven injection through <literal>@Autowired</literal>
|
||||
will work as well.
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
|
||||
<property name="baseAddress" value="http://localhost:9999/"/>
|
||||
</bean>
|
||||
|
||||
|
@ -684,7 +684,7 @@ public class AccountServiceEndpoint extends SpringBeanAutowiringSupport {
|
|||
This means that the endpoint implementation may look like as follows,
|
||||
without any superclass declared - and Spring's <literal>@Autowired</literal>
|
||||
configuration annotation still being honored:</para>
|
||||
<programlisting><![CDATA[@WebService(serviceName="AccountService")
|
||||
<programlisting langauge="java"><![CDATA[@WebService(serviceName="AccountService")
|
||||
public class AccountServiceEndpoint {
|
||||
|
||||
@Autowired
|
||||
|
@ -730,7 +730,7 @@ public class AccountServiceEndpoint {
|
|||
a proxy that implements our business service interface. In this example we use the latter
|
||||
to create a proxy for the <interfacename>AccountService</interfacename> endpoint (again):
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="accountWebService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="accountWebService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
|
||||
<property name="serviceInterface" value="example.AccountService"/>
|
||||
<property name="wsdlDocumentUrl" value="http://localhost:8080/account/services/accountService?WSDL"/>
|
||||
<property name="namespaceUri" value="http://localhost:8080/account/services/accountService"/>
|
||||
|
@ -745,13 +745,13 @@ public class AccountServiceEndpoint {
|
|||
</para>
|
||||
<para>Accessing the web service is now very easy as we have a bean factory for it that will expose it
|
||||
as <literal>AccountService</literal> interface. We can wire this up in Spring:</para>
|
||||
<programlisting><![CDATA[<bean id="client" class="example.AccountClientImpl">
|
||||
<programlisting language="xml"><![CDATA[<bean id="client" class="example.AccountClientImpl">
|
||||
...
|
||||
<property name="service" ref="accountWebService"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>From the client code we can access the web service just as if it
|
||||
was a normal class:</para>
|
||||
<programlisting><![CDATA[public class AccountClientImpl {
|
||||
<programlisting language="java"><![CDATA[public class AccountClientImpl {
|
||||
|
||||
private AccountService service;
|
||||
|
||||
|
@ -780,7 +780,7 @@ public class AccountServiceEndpoint {
|
|||
<classname>DispatcherServlet</classname> with a corresponding
|
||||
<interfacename>WebApplicationContext</interfacename> containing the services you will be
|
||||
exposing:</para>
|
||||
<programlisting><![CDATA[<servlet>
|
||||
<programlisting language="xml"><![CDATA[<servlet>
|
||||
<servlet-name>xfire</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
</servlet>]]></programlisting>
|
||||
|
@ -788,7 +788,7 @@ public class AccountServiceEndpoint {
|
|||
file to the <literal>contextConfigLocations</literal> context parameter picked up by the
|
||||
<classname>ContextLoaderListener</classname> (or <classname>ContextLoaderServlet</classname>
|
||||
for that matter).</para>
|
||||
<programlisting><![CDATA[<context-param>
|
||||
<programlisting language="xml"><![CDATA[<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>classpath:org/codehaus/xfire/spring/xfire.xml</param-value>
|
||||
</context-param>
|
||||
|
@ -801,7 +801,7 @@ public class AccountServiceEndpoint {
|
|||
declared above) you only have to add one extra bean to expose the service using XFire.
|
||||
Add for example the following configuration in your <filename>'xfire-servlet.xml'</filename>
|
||||
file:</para>
|
||||
<programlisting><![CDATA[<beans>
|
||||
<programlisting language="xml"><![CDATA[<beans>
|
||||
|
||||
<bean name="/Echo" class="org.codehaus.xfire.spring.remoting.XFireExporter">
|
||||
<property name="serviceInterface" value="org.codehaus.xfire.spring.Echo"/>
|
||||
|
@ -828,14 +828,14 @@ public class AccountServiceEndpoint {
|
|||
<emphasis>same non-transactional</emphasis> <interfacename>Session</interfacename>, and as
|
||||
such throughput will be very implementation dependent.</para>
|
||||
<para>The following interface is used on both the server and the client side.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting langauge="java"><![CDATA[package com.foo;
|
||||
|
||||
public interface CheckingAccountService {
|
||||
|
||||
public void cancelAccount(Long accountId);
|
||||
}]]></programlisting>
|
||||
<para>The following simple implementation of the above interface is used on the server-side.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting langauge="java"><![CDATA[package com.foo;
|
||||
|
||||
public class SimpleCheckingAccountService implements CheckingAccountService {
|
||||
|
||||
|
@ -845,7 +845,7 @@ public class SimpleCheckingAccountService implements CheckingAccountService {
|
|||
}]]></programlisting>
|
||||
<para>This configuration file contains the JMS-infrastructure beans that are shared on both
|
||||
the client and server.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?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
|
||||
|
@ -865,7 +865,7 @@ public class SimpleCheckingAccountService implements CheckingAccountService {
|
|||
<title>Server-side configuration</title>
|
||||
<para>On the server, you just need to expose the service object using the
|
||||
<classname>JmsInvokerServiceExporter</classname>.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?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
|
||||
|
@ -887,7 +887,7 @@ public class SimpleCheckingAccountService implements CheckingAccountService {
|
|||
</bean>
|
||||
|
||||
</beans>]]></programlisting>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting langauge="java"><![CDATA[package com.foo;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
|
@ -906,7 +906,7 @@ public class Server {
|
|||
object created off the back of the following bean definition can be injected into other
|
||||
client side objects, and the proxy will take care of forwarding the call to the
|
||||
server-side object via JMS.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?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
|
||||
|
@ -920,7 +920,7 @@ public class Server {
|
|||
</bean>
|
||||
|
||||
</beans>]]></programlisting>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting langauge="java"><![CDATA[package com.foo;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
that makes the <classname>JobDetail</classname> more of an actual JavaBean
|
||||
with sensible defaults. Let's have a look at an example:
|
||||
</para>
|
||||
<programlisting><![CDATA[
|
||||
<programlisting langauge="xml"><![CDATA[
|
||||
<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
|
||||
<property name="jobClass" value="example.ExampleJob" />
|
||||
<property name="jobDataAsMap">
|
||||
|
@ -50,7 +50,7 @@
|
|||
So in this case, if the <classname>ExampleJob</classname> contains a property
|
||||
named <literal>timeout</literal>, the <classname>JobDetailBean</classname> will
|
||||
automatically apply it:</para>
|
||||
<programlisting><![CDATA[package example;
|
||||
<programlisting language="java"><![CDATA[package example;
|
||||
|
||||
public class ExampleJob extends QuartzJobBean {
|
||||
|
||||
|
@ -78,13 +78,13 @@ public class ExampleJob extends QuartzJobBean {
|
|||
<title>Using the <classname>MethodInvokingJobDetailFactoryBean</classname></title>
|
||||
<para>Often you just need to invoke a method on a specific object. Using the
|
||||
<classname>MethodInvokingJobDetailFactoryBean</classname> you can do exactly this:</para>
|
||||
<programlisting><![CDATA[<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="targetObject" ref="exampleBusinessObject" />
|
||||
<property name="targetMethod" value="doIt" />
|
||||
</bean>]]></programlisting>
|
||||
<para>The above example will result in the <literal>doIt</literal> method being called on the
|
||||
<literal>exampleBusinessObject</literal> method (see below):</para>
|
||||
<programlisting><![CDATA[public class ExampleBusinessObject {
|
||||
<programlisting language="java"><![CDATA[public class ExampleBusinessObject {
|
||||
|
||||
]]><lineannotation>// properties and collaborators</lineannotation><![CDATA[
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
}
|
||||
}]]></programlisting>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
<programlisting langauge="xml"><![CDATA[
|
||||
<bean id="exampleBusinessObject" class="examples.ExampleBusinessObject"/>]]></programlisting>
|
||||
<para>Using the <classname>MethodInvokingJobDetailFactoryBean</classname>, you don't need to
|
||||
create one-line jobs that just invoke a method, and you only need to create the actual
|
||||
|
@ -106,7 +106,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
will not start before the first one has finished. To make jobs resulting from the
|
||||
<classname>MethodInvokingJobDetailFactoryBean</classname> non-concurrent, set the
|
||||
<literal>concurrent</literal> flag to <literal>false</literal>.</para>
|
||||
<programlisting><![CDATA[
|
||||
<programlisting language="xml"><![CDATA[
|
||||
<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="targetObject" ref="exampleBusinessObject" />
|
||||
<property name="targetMethod" value="doIt" />
|
||||
|
@ -132,7 +132,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
schedules the actual jobs with those triggers.
|
||||
</para>
|
||||
<para>Find below a couple of examples:</para>
|
||||
<programlisting><![CDATA[<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<!-- see the example of method invoking job above -->
|
||||
<property name="jobDetail" ref="jobDetail" />
|
||||
<!-- 10 seconds -->
|
||||
|
@ -149,7 +149,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
<para>Now we've set up two triggers, one running every 50 seconds with a starting delay of
|
||||
10 seconds and one every morning at 6 AM. To finalize everything, we need to set up the
|
||||
<classname>SchedulerFactoryBean</classname>:</para>
|
||||
<programlisting><![CDATA[<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||
<property name="triggers">
|
||||
<list>
|
||||
<ref bean="cronTrigger" />
|
||||
|
@ -180,7 +180,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
Using the <classname>TimerTask</classname> you can create customer
|
||||
timer tasks, similar to Quartz jobs:
|
||||
</para>
|
||||
<programlisting><![CDATA[public class CheckEmailAddresses extends TimerTask {
|
||||
<programlisting language="java"><![CDATA[public class CheckEmailAddresses extends TimerTask {
|
||||
|
||||
private List emailAddresses;
|
||||
|
||||
|
@ -195,7 +195,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
<para>
|
||||
Wiring it up is simple:
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="checkEmail" class="examples.CheckEmailAddress">
|
||||
<programlisting language="xml"><![CDATA[<bean id="checkEmail" class="examples.CheckEmailAddress">
|
||||
<property name="emailAddresses">
|
||||
<list>
|
||||
<value>test@springframework.org</value>
|
||||
|
@ -225,7 +225,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
Similar to the Quartz support, the <classname>Timer</classname> support also features
|
||||
a component that allows you to periodically invoke a method:
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="doIt" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="doIt" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
|
||||
<property name="targetObject" ref="exampleBusinessObject" />
|
||||
<property name="targetMethod" value="doIt" />
|
||||
</bean>]]></programlisting>
|
||||
|
@ -233,7 +233,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
The above example will result in the <literal>doIt</literal> method being called on the
|
||||
<literal>exampleBusinessObject</literal> (see below):
|
||||
</para>
|
||||
<programlisting><![CDATA[public class BusinessObject {
|
||||
<programlisting language="java"><![CDATA[public class BusinessObject {
|
||||
|
||||
]]><lineannotation>// properties and collaborators</lineannotation><![CDATA[
|
||||
|
||||
|
@ -252,7 +252,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
purpose: setting up the actual scheduling. The <classname>TimerFactoryBean</classname>
|
||||
sets up an actual <classname>Timer</classname> and schedules the tasks it has
|
||||
references to. You can specify whether or not daemon threads should be used.</para>
|
||||
<programlisting><![CDATA[<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
|
||||
<property name="scheduledTimerTasks">
|
||||
<list>
|
||||
]]><lineannotation><!-- see the example above --></lineannotation><![CDATA[
|
||||
|
@ -445,7 +445,7 @@ public class ExampleJob extends QuartzJobBean {
|
|||
a bean that uses the <classname>ThreadPoolTaskExecutor</classname>
|
||||
to asynchronously print out a set of messages.</para>
|
||||
|
||||
<programlisting><![CDATA[import org.springframework.core.task.TaskExecutor;
|
||||
<programlisting language="java"><![CDATA[import org.springframework.core.task.TaskExecutor;
|
||||
|
||||
public class TaskExecutorExample {
|
||||
|
||||
|
@ -484,7 +484,7 @@ public class TaskExecutorExample {
|
|||
<para>To configure the rules that the <interfacename>TaskExecutor</interfacename>
|
||||
will use, simple bean properties have been exposed.</para>
|
||||
|
||||
<programlisting><![CDATA[<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
|
||||
<programlisting language="xml"><![CDATA[<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
|
||||
<property name="corePoolSize" value="5" />
|
||||
<property name="maxPoolSize" value="10" />
|
||||
<property name="queueCapacity" value="25" />
|
||||
|
|
|
@ -1015,6 +1015,7 @@ Exception in thread "main" java.lang.UnsupportedOperationException
|
|||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="transaction-declarative-annotations">
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<classname>SimpleDateFormat</classname> (from the <literal>java.text</literal> package)
|
||||
in an easy manner. When we are done, we will be able to define bean definitions of type
|
||||
<classname>SimpleDateFormat</classname> like this:</para>
|
||||
<programlisting><![CDATA[<myns:dateformat id="dateFormat"
|
||||
<programlisting language="xml"><![CDATA[<myns:dateformat id="dateFormat"
|
||||
pattern="yyyy-MM-dd HH:mm"
|
||||
lenient="true"/>
|
||||
]]></programlisting>
|
||||
|
@ -51,7 +51,7 @@
|
|||
starts with authoring an XML Schema to describe the extension. What follows
|
||||
is the schema we'll use to configure <classname>SimpleDateFormat</classname>
|
||||
objects.</para>
|
||||
<programlisting><lineannotation><!-- myns.xsd (inside package org/springframework/samples/xml) --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- myns.xsd (inside package org/springframework/samples/xml) --></lineannotation><![CDATA[
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsd:schema xmlns="http://www.mycompany.com/schema/myns"
|
||||
|
@ -83,7 +83,7 @@
|
|||
<para>The above schema will be used to configure <classname>SimpleDateFormat</classname>
|
||||
objects, directly in an XML application context file using the
|
||||
<literal><myns:dateformat/></literal> element.</para>
|
||||
<programlisting><![CDATA[<myns:dateformat id="dateFormat"
|
||||
<programlisting language="xml"><![CDATA[<myns:dateformat id="dateFormat"
|
||||
pattern="yyyy-MM-dd HH:mm"
|
||||
lenient="true"/>
|
||||
]]></programlisting>
|
||||
|
@ -92,7 +92,7 @@
|
|||
we're just creating a bean in the container, identified by the name
|
||||
<literal>'dateFormat'</literal> of type <classname>SimpleDateFormat</classname>, with a
|
||||
couple of properties set.</para>
|
||||
<programlisting><![CDATA[<bean id="dateFormat" class="java.text.SimpleDateFormat">
|
||||
<programlisting language="xml"><![CDATA[<bean id="dateFormat" class="java.text.SimpleDateFormat">
|
||||
<constructor-arg value="yyyy-HH-dd HH:mm"/>
|
||||
<property name="lenient" value="true"/>
|
||||
</bean>]]></programlisting>
|
||||
|
@ -142,7 +142,7 @@
|
|||
results in a single <classname>SimpleDateFormat</classname> bean definition).
|
||||
Spring features a number of convenience classes that support this scenario.
|
||||
In this example, we'll make use the <classname>NamespaceHandlerSupport</classname> class:</para>
|
||||
<programlisting><![CDATA[package org.springframework.samples.xml;
|
||||
<programlisting language="java"><![CDATA[package org.springframework.samples.xml;
|
||||
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
|
||||
|
@ -172,7 +172,7 @@ public class MyNamespaceHandler extends NamespaceHandlerSupport {
|
|||
responsible for parsing <emphasis>one</emphasis> distinct top-level XML element defined in the
|
||||
schema. In the parser, we'll have access to the XML element (and thus its subelements too)
|
||||
so that we can parse our custom XML content, as can be seen in the following example:</para>
|
||||
<programlisting><![CDATA[package org.springframework.samples.xml;
|
||||
<programlisting language="java"><![CDATA[package org.springframework.samples.xml;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
|
@ -258,7 +258,7 @@ public class SimpleDateFormatBeanDefinitionParser extends AbstractSingleBeanDefi
|
|||
using one of the 'custom' extensions that Spring provides straight out of the box. Find below
|
||||
an example of using the custom <literal><dateformat/></literal> element developed in the
|
||||
previous steps in a Spring XML configuration file.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:myns="http://www.mycompany.com/schema/myns"
|
||||
|
@ -285,7 +285,7 @@ http://www.mycompany.com/schema/myns http://www.mycompany.com/schema/myns/myns.x
|
|||
<title>Nesting custom tags within custom tags</title>
|
||||
<para>This example illustrates how you might go about writing the various artifacts
|
||||
required to satisfy a target of the following configuration:</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:foo="http://www.foo.com/schema/component"
|
||||
|
@ -306,7 +306,7 @@ http://www.foo.com/schema/component http://www.foo.com/schema/component/componen
|
|||
a setter method for the <literal>'components'</literal> property; this makes it hard
|
||||
(or rather impossible) to configure a bean definition for the <classname>Component</classname>
|
||||
class using setter injection.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting language="java"><![CDATA[package com.foo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -335,7 +335,7 @@ public class Component {
|
|||
}]]></programlisting>
|
||||
<para>The typical solution to this issue is to create a custom <interfacename>FactoryBean</interfacename>
|
||||
that exposes a setter property for the <literal>'components'</literal> property.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting language="java"><![CDATA[package com.foo;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
||||
|
@ -378,7 +378,7 @@ public class ComponentFactoryBean implements FactoryBean {
|
|||
Spring plumbing. If we stick to <link linkend="extensible-xml-introduction">the steps described
|
||||
previously</link>, we'll start off by creating the XSD schema to define the structure of
|
||||
our custom tag.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<xsd:schema xmlns="http://www.foo.com/schema/component"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
|
@ -399,7 +399,7 @@ public class ComponentFactoryBean implements FactoryBean {
|
|||
</xsd:schema>
|
||||
]]></programlisting>
|
||||
<para>We'll then create a custom <interfacename>NamespaceHandler</interfacename>.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting language="java"><![CDATA[package com.foo;
|
||||
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
|
||||
|
@ -412,7 +412,7 @@ public class ComponentNamespaceHandler extends NamespaceHandlerSupport {
|
|||
<para>Next up is the custom <interfacename>BeanDefinitionParser</interfacename>. Remember
|
||||
that what we are creating is a <interfacename>BeanDefinition</interfacename> describing
|
||||
a <classname>ComponentFactoryBean</classname>.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting language="java"><![CDATA[package com.foo;
|
||||
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
|
@ -471,7 +471,7 @@ http\://www.foo.com/schema/component/component.xsd=com/foo/component.xsd]]></pro
|
|||
definition for a service object that will (unknown to it) be accessing a clustered
|
||||
<ulink url="http://jcp.org/en/jsr/detail?id=107">JCache</ulink>, and you want to ensure that
|
||||
the named JCache instance is eagerly started within the surrounding cluster:</para>
|
||||
<programlisting><![CDATA[<bean id="checkingAccountService" class="com.foo.DefaultCheckingAccountService"
|
||||
<programlisting language="xml"><![CDATA[<bean id="checkingAccountService" class="com.foo.DefaultCheckingAccountService"
|
||||
]]><lineannotation><emphasis role="bold">jcache:cache-name="checking.account"></emphasis></lineannotation><![CDATA[
|
||||
]]><lineannotation><!-- other dependencies here... --></lineannotation><![CDATA[
|
||||
</bean>]]></programlisting>
|
||||
|
@ -481,7 +481,7 @@ http\://www.foo.com/schema/component/component.xsd=com/foo/component.xsd]]></pro
|
|||
for us. We will also modify the existing <interfacename>BeanDefinition</interfacename> for the
|
||||
<literal>'checkingAccountService'</literal> so that it will have a dependency on this
|
||||
new JCache-initializing <interfacename>BeanDefinition</interfacename>.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting language="java"><![CDATA[package com.foo;
|
||||
|
||||
public class JCacheInitializer {
|
||||
|
||||
|
@ -497,7 +497,7 @@ public class JCacheInitializer {
|
|||
}]]></programlisting>
|
||||
<para>Now onto the custom extension. Firstly, the authoring of the XSD schema describing the
|
||||
custom attribute (quite easy in this case).</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<xsd:schema xmlns="http://www.foo.com/schema/jcache"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
|
@ -509,7 +509,7 @@ public class JCacheInitializer {
|
|||
</xsd:schema>
|
||||
]]></programlisting>
|
||||
<para>Next, the associated <interfacename>NamespaceHandler</interfacename>.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting language="java"><![CDATA[package com.foo;
|
||||
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
|
||||
|
@ -524,7 +524,7 @@ public class JCacheNamespaceHandler extends NamespaceHandlerSupport {
|
|||
<para>Next, the parser. Note that in this case, because we are going to be parsing an XML
|
||||
attribute, we write a <interfacename>BeanDefinitionDecorator</interfacename> rather than a
|
||||
<interfacename>BeanDefinitionParser</interfacename>.</para>
|
||||
<programlisting><![CDATA[package com.foo;
|
||||
<programlisting language="java"><![CDATA[package com.foo;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<title>Referencing the schemas</title>
|
||||
<para>To switch over from the DTD-style to the new XML Schema-style, you need
|
||||
to make the following change.</para>
|
||||
<programlisting>
|
||||
<programlisting language="xml">
|
||||
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
|
||||
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
</beans>]]></programlisting>
|
||||
<para>The equivalent file in the XML Schema-style would be...</para>
|
||||
<programlisting>
|
||||
<programlisting language="xml">
|
||||
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
|
@ -98,7 +98,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
the following preamble at the top of your Spring XML configuration file;
|
||||
the emboldened text in the snippet below references the correct schema so that
|
||||
the tags in the <literal>util</literal> namespace are available to you.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
]]><emphasis role="bold">xmlns:util="http://www.springframework.org/schema/util"</emphasis><![CDATA[
|
||||
|
@ -112,7 +112,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<section id="xsd-config-body-schemas-util-constant">
|
||||
<title><literal><util:constant/></literal></title>
|
||||
<para>Before...</para>
|
||||
<programlisting><![CDATA[<bean id="..." class="...">
|
||||
<programlisting language="xml"><![CDATA[<bean id="..." class="...">
|
||||
<property name="isolation">
|
||||
<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"
|
||||
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" />
|
||||
|
@ -129,7 +129,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
and clearly expresses the developer's intent (<emphasis>'inject this constant
|
||||
value'</emphasis>), and it just reads better.
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="..." class="...">
|
||||
<programlisting language="xml"><![CDATA[<bean id="..." class="...">
|
||||
<property name="isolation">
|
||||
<util:constant static-field="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
|
||||
</property>
|
||||
|
@ -149,13 +149,13 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
using the <ulink url="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.html#setStaticField(java.lang.String)"><literal>staticField</literal></ulink>
|
||||
property:
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="myField"
|
||||
<programlisting language="xml"><![CDATA[<bean id="myField"
|
||||
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
|
||||
<property name="staticField" value="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>There is also a convenience usage form where the <literal>static</literal>
|
||||
field is specified as the bean name:</para>
|
||||
<programlisting><![CDATA[<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"
|
||||
<programlisting language="xml"><![CDATA[<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"
|
||||
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>]]></programlisting>
|
||||
<para>
|
||||
This does mean that there is no longer any choice in what the bean id is (so
|
||||
|
@ -164,7 +164,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
inner bean since the id doesn't have to be specified for the bean
|
||||
reference:
|
||||
</para>
|
||||
<programlisting><![CDATA[<bean id="..." class="...">
|
||||
<programlisting language="xml"><![CDATA[<bean id="..." class="...">
|
||||
<property name="isolation">
|
||||
<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"
|
||||
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" />
|
||||
|
@ -183,7 +183,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
as the <classname>FieldRetrievingFactoryBean</classname>). Let's look at an example
|
||||
to see how easy injecting an enum value is; consider this JDK 5 enum:
|
||||
</para>
|
||||
<programlisting><![CDATA[package javax.persistence;
|
||||
<programlisting language="java"><![CDATA[package javax.persistence;
|
||||
|
||||
public enum PersistenceContextType {
|
||||
|
||||
|
@ -192,7 +192,7 @@ public enum PersistenceContextType {
|
|||
|
||||
}]]></programlisting>
|
||||
<para>Now consider a setter of type <classname>PersistenceContextType</classname>:</para>
|
||||
<programlisting><![CDATA[package example;
|
||||
<programlisting language="java"><![CDATA[package example;
|
||||
|
||||
public class Client {
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class Client {
|
|||
}
|
||||
}]]></programlisting>
|
||||
<para>.. and the corresponding bean definition:</para>
|
||||
<programlisting><![CDATA[<bean class="example.Client">
|
||||
<programlisting language="xml"><![CDATA[<bean class="example.Client">
|
||||
<property name="persistenceContextType" value="TRANSACTION" />
|
||||
</bean>]]></programlisting>
|
||||
<para>
|
||||
|
@ -216,7 +216,7 @@ public class Client {
|
|||
<section id="xsd-config-body-schemas-util-property-path">
|
||||
<title><literal><util:property-path/></literal></title>
|
||||
<para>Before...</para>
|
||||
<programlisting><lineannotation><!-- target bean to be referenced by name --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- target bean to be referenced by name --></lineannotation><![CDATA[
|
||||
<bean id="testBean" class="org.springframework.beans.TestBean" scope="prototype">
|
||||
<property name="age" value="10"/>
|
||||
<property name="spouse">
|
||||
|
@ -235,7 +235,7 @@ public class Client {
|
|||
property of the <literal>'testBean'</literal> bean.
|
||||
</para>
|
||||
<para>After...</para>
|
||||
<programlisting><lineannotation><!-- target bean to be referenced by name --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- target bean to be referenced by name --></lineannotation><![CDATA[
|
||||
<bean id="testBean" class="org.springframework.beans.TestBean" scope="prototype">
|
||||
<property name="age" value="10"/>
|
||||
<property name="spouse">
|
||||
|
@ -257,7 +257,7 @@ public class Client {
|
|||
name. This value may then be used in another bean definition as a property
|
||||
value or constructor argument.</para>
|
||||
<para>Here's an example where a path is used against another bean, by name:</para>
|
||||
<programlisting><![CDATA[// target bean to be referenced by name
|
||||
<programlisting language="xml"><![CDATA[// target bean to be referenced by name
|
||||
<bean id="person" class="org.springframework.beans.TestBean" scope="prototype">
|
||||
<property name="age" value="10"/>
|
||||
<property name="spouse">
|
||||
|
@ -274,7 +274,7 @@ public class Client {
|
|||
<property name="propertyPath" value="spouse.age"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>In this example, a path is evaluated against an inner bean:</para>
|
||||
<programlisting><lineannotation><!-- will result in 12, which is the value of property 'age' of the inner bean --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- will result in 12, which is the value of property 'age' of the inner bean --></lineannotation><![CDATA[
|
||||
<bean id="theAge"
|
||||
class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
|
||||
<property name="targetObject">
|
||||
|
@ -285,14 +285,14 @@ public class Client {
|
|||
<property name="propertyPath" value="age"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>There is also a shortcut form, where the bean name is the property path.</para>
|
||||
<programlisting><lineannotation><!-- will result in 10, which is the value of property 'age' of bean 'person' --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- will result in 10, which is the value of property 'age' of bean 'person' --></lineannotation><![CDATA[
|
||||
<bean id="person.age"
|
||||
class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>]]></programlisting>
|
||||
<para>This form does mean that there is no choice in the name of the bean.
|
||||
Any reference to it will also have to use the same id, which is the path.
|
||||
Of course, if used as an inner bean, there is no need to refer to it at
|
||||
all:</para>
|
||||
<programlisting><![CDATA[<bean id="..." class="...">
|
||||
<programlisting language="xml"><![CDATA[<bean id="..." class="...">
|
||||
<property name="age">
|
||||
<bean id="person.age"
|
||||
class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
|
||||
|
@ -306,7 +306,7 @@ public class Client {
|
|||
<section id="xsd-config-body-schemas-util-properties">
|
||||
<title><literal><util:properties/></literal></title>
|
||||
<para>Before...</para>
|
||||
<programlisting><lineannotation><!-- creates a <classname>java.util.Properties</classname> instance with values loaded from the supplied location --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- creates a <classname>java.util.Properties</classname> instance with values loaded from the supplied location --></lineannotation><![CDATA[
|
||||
<bean id="jdbcConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
|
||||
<property name="location" value="classpath:com/foo/jdbc-production.properties"/>
|
||||
</bean>]]></programlisting>
|
||||
|
@ -316,13 +316,13 @@ public class Client {
|
|||
the supplied <link linkend="resources"><interfacename>Resource</interfacename></link> location).
|
||||
</para>
|
||||
<para>After...</para>
|
||||
<programlisting><lineannotation><!-- creates a <classname>java.util.Properties</classname> instance with values loaded from the supplied location --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- creates a <classname>java.util.Properties</classname> instance with values loaded from the supplied location --></lineannotation><![CDATA[
|
||||
<util:properties id="jdbcConfiguration" location="classpath:com/foo/jdbc-production.properties"/>]]></programlisting>
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-util-list">
|
||||
<title><literal><util:list/></literal></title>
|
||||
<para>Before...</para>
|
||||
<programlisting><lineannotation><!-- creates a <classname>java.util.List</classname> instance with values loaded from the supplied <literal>'sourceList'</literal> --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- creates a <classname>java.util.List</classname> instance with values loaded from the supplied <literal>'sourceList'</literal> --></lineannotation><![CDATA[
|
||||
<bean id="emails" class="org.springframework.beans.factory.config.ListFactoryBean">
|
||||
<property name="sourceList">
|
||||
<list>
|
||||
|
@ -339,7 +339,7 @@ public class Client {
|
|||
with values taken from the supplied <literal>'sourceList'</literal>.
|
||||
</para>
|
||||
<para>After...</para>
|
||||
<programlisting><lineannotation><!-- creates a <classname>java.util.List</classname> instance with values loaded from the supplied <literal>'sourceList'</literal> --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- creates a <classname>java.util.List</classname> instance with values loaded from the supplied <literal>'sourceList'</literal> --></lineannotation><![CDATA[
|
||||
<util:list id="emails">
|
||||
<value>pechorin@hero.org</value>
|
||||
<value>raskolnikov@slums.org</value>
|
||||
|
@ -351,7 +351,7 @@ public class Client {
|
|||
attribute on the <literal><util:list/></literal> element. For example, if we
|
||||
really need a <classname>java.util.LinkedList</classname> to be instantiated, we could
|
||||
use the following configuration:</para>
|
||||
<programlisting><![CDATA[<util:list id="emails" list-class="java.util.LinkedList">
|
||||
<programlisting language="xml"><![CDATA[<util:list id="emails" list-class="java.util.LinkedList">
|
||||
<value>jackshaftoe@vagabond.org</value>
|
||||
<value>eliza@thinkingmanscrumpet.org</value>
|
||||
<value>vanhoek@pirate.org</value>
|
||||
|
@ -367,7 +367,7 @@ public class Client {
|
|||
<section id="xsd-config-body-schemas-util-map">
|
||||
<title><literal><util:map/></literal></title>
|
||||
<para>Before...</para>
|
||||
<programlisting><lineannotation><!-- creates a <classname>java.util.Map</classname> instance with values loaded from the supplied <literal>'sourceMap'</literal> --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- creates a <classname>java.util.Map</classname> instance with values loaded from the supplied <literal>'sourceMap'</literal> --></lineannotation><![CDATA[
|
||||
<bean id="emails" class="org.springframework.beans.factory.config.MapFactoryBean">
|
||||
<property name="sourceMap">
|
||||
<map>
|
||||
|
@ -384,7 +384,7 @@ public class Client {
|
|||
with key-value pairs taken from the supplied <literal>'sourceMap'</literal>.
|
||||
</para>
|
||||
<para>After...</para>
|
||||
<programlisting><lineannotation><!-- creates a <classname>java.util.Map</classname> instance with values loaded from the supplied <literal>'sourceMap'</literal> --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- creates a <classname>java.util.Map</classname> instance with values loaded from the supplied <literal>'sourceMap'</literal> --></lineannotation><![CDATA[
|
||||
<util:map id="emails">
|
||||
<entry key="pechorin" value="pechorin@hero.org"/>
|
||||
<entry key="raskolnikov" value="raskolnikov@slums.org"/>
|
||||
|
@ -396,7 +396,7 @@ public class Client {
|
|||
attribute on the <literal><util:map/></literal> element. For example, if we
|
||||
really need a <classname>java.util.TreeMap</classname> to be instantiated, we could
|
||||
use the following configuration:</para>
|
||||
<programlisting><![CDATA[<util:map id="emails" map-class="java.util.TreeMap">
|
||||
<programlisting language="xml"><![CDATA[<util:map id="emails" map-class="java.util.TreeMap">
|
||||
<entry key="pechorin" value="pechorin@hero.org"/>
|
||||
<entry key="raskolnikov" value="raskolnikov@slums.org"/>
|
||||
<entry key="stavrogin" value="stavrogin@gov.org"/>
|
||||
|
@ -412,7 +412,7 @@ public class Client {
|
|||
<section id="xsd-config-body-schemas-util-set">
|
||||
<title><literal><util:set/></literal></title>
|
||||
<para>Before...</para>
|
||||
<programlisting><lineannotation><!-- creates a <classname>java.util.Set</classname> instance with values loaded from the supplied <literal>'sourceSet'</literal> --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- creates a <classname>java.util.Set</classname> instance with values loaded from the supplied <literal>'sourceSet'</literal> --></lineannotation><![CDATA[
|
||||
<bean id="emails" class="org.springframework.beans.factory.config.SetFactoryBean">
|
||||
<property name="sourceSet">
|
||||
<set>
|
||||
|
@ -429,7 +429,7 @@ public class Client {
|
|||
with values taken from the supplied <literal>'sourceSet'</literal>.
|
||||
</para>
|
||||
<para>After...</para>
|
||||
<programlisting><lineannotation><!-- creates a <classname>java.util.Set</classname> instance with values loaded from the supplied <literal>'sourceSet'</literal> --></lineannotation><![CDATA[
|
||||
<programlisting language="xml"><lineannotation><!-- creates a <classname>java.util.Set</classname> instance with values loaded from the supplied <literal>'sourceSet'</literal> --></lineannotation><![CDATA[
|
||||
<util:set id="emails">
|
||||
<value>pechorin@hero.org</value>
|
||||
<value>raskolnikov@slums.org</value>
|
||||
|
@ -441,7 +441,7 @@ public class Client {
|
|||
attribute on the <literal><util:set/></literal> element. For example, if we
|
||||
really need a <classname>java.util.TreeSet</classname> to be instantiated, we could
|
||||
use the following configuration:</para>
|
||||
<programlisting><![CDATA[<util:set id="emails" set-class="java.util.TreeSet">
|
||||
<programlisting language="xml"><![CDATA[<util:set id="emails" set-class="java.util.TreeSet">
|
||||
<value>pechorin@hero.org</value>
|
||||
<value>raskolnikov@slums.org</value>
|
||||
<value>stavrogin@gov.org</value>
|
||||
|
@ -463,7 +463,7 @@ public class Client {
|
|||
the following preamble at the top of your Spring XML configuration file;
|
||||
the emboldened text in the following snippet references the correct schema so that
|
||||
the tags in the <literal>jee</literal> namespace are available to you.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
]]><emphasis role="bold">xmlns:jee="http://www.springframework.org/schema/jee"</emphasis><![CDATA[
|
||||
|
@ -477,7 +477,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<section id="xsd-config-body-schemas-jee-jndi-lookup">
|
||||
<title><literal><jee:jndi-lookup/></literal> (simple)</title>
|
||||
<para>Before...</para>
|
||||
<programlisting><![CDATA[<bean id="]]><emphasis role="bold"><![CDATA[dataSource]]></emphasis><![CDATA[" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="]]><emphasis role="bold"><![CDATA[dataSource]]></emphasis><![CDATA[" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="jdbc/MyDataSource"/>
|
||||
</bean>
|
||||
|
||||
|
@ -486,7 +486,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<property name="dataSource" ref="]]><emphasis role="bold">dataSource</emphasis>"/><![CDATA[
|
||||
</bean>]]></programlisting>
|
||||
<para>After...</para>
|
||||
<programlisting><![CDATA[<jee:jndi-lookup id="]]><emphasis role="bold"><![CDATA[dataSource]]></emphasis><![CDATA[" jndi-name="jdbc/MyDataSource"/>
|
||||
<programlisting language="xml"><![CDATA[<jee:jndi-lookup id="]]><emphasis role="bold"><![CDATA[dataSource]]></emphasis><![CDATA[" jndi-name="jdbc/MyDataSource"/>
|
||||
|
||||
<bean id="userDao" class="com.foo.JdbcUserDao">
|
||||
]]><lineannotation><!-- Spring will do the cast automatically (as usual) --></lineannotation><![CDATA[
|
||||
|
@ -496,7 +496,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<section id="xsd-config-body-schemas-jee-jndi-lookup-environment-single">
|
||||
<title><literal><jee:jndi-lookup/></literal> (with single JNDI environment setting)</title>
|
||||
<para>Before...</para>
|
||||
<programlisting><![CDATA[<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="jdbc/MyDataSource"/>
|
||||
<property name="jndiEnvironment">
|
||||
<props>
|
||||
|
@ -505,14 +505,14 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
</property>
|
||||
</bean>]]></programlisting>
|
||||
<para>After...</para>
|
||||
<programlisting><![CDATA[<jee:jndi-lookup id="simple" jndi-name="jdbc/MyDataSource">
|
||||
<programlisting language="xml"><![CDATA[<jee:jndi-lookup id="simple" jndi-name="jdbc/MyDataSource">
|
||||
<jee:environment>foo=bar</jee:environment>
|
||||
</jee:jndi-lookup>]]></programlisting>
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-jee-jndi-lookup-evironment-multiple">
|
||||
<title><literal><jee:jndi-lookup/></literal> (with multiple JNDI environment settings)</title>
|
||||
<para>Before...</para>
|
||||
<programlisting><![CDATA[<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="jdbc/MyDataSource"/>
|
||||
<property name="jndiEnvironment">
|
||||
<props>
|
||||
|
@ -522,7 +522,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
</property>
|
||||
</bean>]]></programlisting>
|
||||
<para>After...</para>
|
||||
<programlisting><![CDATA[<jee:jndi-lookup id="simple" jndi-name="jdbc/MyDataSource">
|
||||
<programlisting language="xml"><![CDATA[<jee:jndi-lookup id="simple" jndi-name="jdbc/MyDataSource">
|
||||
]]><lineannotation><!-- newline-separated, key-value pairs for the environment (standard <classname>Properties</classname> format) --></lineannotation><![CDATA[
|
||||
<jee:environment>
|
||||
foo=bar
|
||||
|
@ -533,7 +533,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<section id="xsd-config-body-schemas-jee-jndi-lookup-complex">
|
||||
<title><literal><jee:jndi-lookup/></literal> (complex)</title>
|
||||
<para>Before...</para>
|
||||
<programlisting><![CDATA[<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<programlisting language="xml"><![CDATA[<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="jdbc/MyDataSource"/>
|
||||
<property name="cache" value="true"/>
|
||||
<property name="resourceRef" value="true"/>
|
||||
|
@ -542,7 +542,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<property name="proxyInterface" value="com.myapp.Foo"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>After...</para>
|
||||
<programlisting><![CDATA[<jee:jndi-lookup id="simple"
|
||||
<programlisting language="xml"><![CDATA[<jee:jndi-lookup id="simple"
|
||||
jndi-name="jdbc/MyDataSource"
|
||||
cache="true"
|
||||
resource-ref="true"
|
||||
|
@ -555,18 +555,18 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<para>The <literal><jee:local-slsb/></literal> tag configures a
|
||||
reference to an EJB Stateless SessionBean.</para>
|
||||
<para>Before...</para>
|
||||
<programlisting><![CDATA[<bean id="simple"
|
||||
<programlisting language="xml"><![CDATA[<bean id="simple"
|
||||
class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
|
||||
<property name="jndiName" value="ejb/RentalServiceBean"/>
|
||||
<property name="businessInterface" value="com.foo.service.RentalService"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>After...</para>
|
||||
<programlisting><![CDATA[<jee:local-slsb id="simpleSlsb" jndi-name="ejb/RentalServiceBean"
|
||||
<programlisting language="xml"><![CDATA[<jee:local-slsb id="simpleSlsb" jndi-name="ejb/RentalServiceBean"
|
||||
business-interface="com.foo.service.RentalService"/>]]></programlisting>
|
||||
</section>
|
||||
<section id="xsd-config-body-schemas-jee-local-slsb-complex">
|
||||
<title><literal><jee:local-slsb/></literal> (complex)</title>
|
||||
<programlisting><![CDATA[<bean id="complexLocalEjb"
|
||||
<programlisting language="xml"><![CDATA[<bean id="complexLocalEjb"
|
||||
class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
|
||||
<property name="jndiName" value="ejb/RentalServiceBean"/>
|
||||
<property name="businessInterface" value="com.foo.service.RentalService"/>
|
||||
|
@ -575,7 +575,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<property name="resourceRef" value="true"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>After...</para>
|
||||
<programlisting><![CDATA[<jee:local-slsb id="complexLocalEjb"
|
||||
<programlisting language="xml"><![CDATA[<jee:local-slsb id="complexLocalEjb"
|
||||
jndi-name="ejb/RentalServiceBean"
|
||||
business-interface="com.foo.service.RentalService"
|
||||
cache-home="true"
|
||||
|
@ -587,7 +587,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<para>The <literal><jee:remote-slsb/></literal> tag configures a
|
||||
reference to a <literal>remote</literal> EJB Stateless SessionBean.</para>
|
||||
<para>Before...</para>
|
||||
<programlisting><![CDATA[<bean id="complexRemoteEjb"
|
||||
<programlisting language="xml"><![CDATA[<bean id="complexRemoteEjb"
|
||||
class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
|
||||
<property name="jndiName" value="ejb/MyRemoteBean"/>
|
||||
<property name="businessInterface" value="com.foo.service.RentalService"/>
|
||||
|
@ -598,7 +598,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<property name="refreshHomeOnConnectFailure" value="true"/>
|
||||
</bean>]]></programlisting>
|
||||
<para>After...</para>
|
||||
<programlisting><![CDATA[<jee:remote-slsb id="complexRemoteEjb"
|
||||
<programlisting language="xml"><![CDATA[<jee:remote-slsb id="complexRemoteEjb"
|
||||
jndi-name="ejb/MyRemoteBean"
|
||||
business-interface="com.foo.service.RentalService"
|
||||
cache-home="true"
|
||||
|
@ -622,7 +622,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
configuration file; the emboldened text in the following snippet references the
|
||||
correct schema so that the tags in the <literal>lang</literal> namespace are
|
||||
available to you.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
]]><emphasis role="bold">xmlns:lang="http://www.springframework.org/schema/lang"</emphasis><![CDATA[
|
||||
|
@ -647,7 +647,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
configuration file; the emboldened text in the following snippet references the
|
||||
correct schema so that the tags in the <literal>jms</literal> namespace are
|
||||
available to you.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
]]><emphasis role="bold">xmlns:jms="http://www.springframework.org/schema/jms"</emphasis><![CDATA[
|
||||
|
@ -679,7 +679,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
configuration file; the emboldened text in the following snippet references the
|
||||
correct schema so that the tags in the <literal>tx</literal> namespace are
|
||||
available to you.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
|
@ -710,7 +710,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/
|
|||
configuration file; the emboldened text in the following snippet references the
|
||||
correct schema so that the tags in the <literal>aop</literal> namespace are
|
||||
available to you.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
]]><emphasis role="bold">xmlns:aop="http://www.springframework.org/schema/aop"</emphasis><![CDATA[
|
||||
|
@ -730,7 +730,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
but rather beans that do a lot of grunt work in Spring, such as <interfacename>BeanfactoryPostProcessors</interfacename>.
|
||||
The following snippet references the correct schema so that the tags in the <literal>context</literal>
|
||||
namespace are available to you.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
]]><emphasis role="bold">xmlns:context="http://www.springframework.org/schema/context"</emphasis><![CDATA[
|
||||
|
@ -819,7 +819,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<para>Find below an example of the <literal><meta/></literal> tag in the context
|
||||
of a surrounding <literal><bean/></literal> (please note that without any logic
|
||||
to interpret it the metadata is effectively useless as-is).</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?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="
|
||||
|
@ -862,7 +862,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
|||
<para>Create a new XML file. You can name this file whatever you want. In the
|
||||
example below, the file is named <literal>'context.xml'</literal>.
|
||||
Copy and paste the following text into the file so that it matches the screenshot.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
|
@ -984,7 +984,7 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema
|
|||
<para>Create a new XML file (you can name this file whatever you want). In the
|
||||
example below, the file is named <literal>'context.xml'</literal>. Copy and paste
|
||||
the following text into the file so that it matches the screenshot.</para>
|
||||
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
|
|
Loading…
Reference in New Issue