Java Reference
In-Depth Information
The ReportingMDB has a Spring application context associated with it. It uses the
beans registered in this application context to carry out long-running report generation
tasks. This Spring application context is configured as shown in Listing 5-23.
Listing 5-23. Reporting-beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
>
<bean name="reportServiceProvider"
class="net.sf.reporting.ReportServiceProviderImpl">
</bean>
</beans>
So far, I have explained the server-side Java components and configuration. Now I
will focus on the client that triggers the asynchronous report processing. Spring provides
the JmsTemplate class to simplify the process of sending JMS messages. It is also based on
the GOF Template Method design pattern. To use this class, you will need to configure it
in the Spring application context and inject the JNDI bound ConnectionFactory and
Destination objects. This is shown in Listing 5-24.
Listing 5-24. insurance-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" >
<bean id="qConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="ConnectionFactory" />
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">
 
Search WWH ::




Custom Search