Java Reference
In-Depth Information
return policyDetailDao;
}
public void setPolicyDetailDao(PolicyDetailDao policyDetailDao) {
this.policyDetailDao = policyDetailDao;
}
}
Note that the session facade invokes the application service, which in turn calls the
DAO method. As a result, the DAO method automatically comes into the same transac-
tional scope as the session bean method. So, there is no need for any programmatic
transaction handling in the DAO.
The JdbcDaoSupport object needs a data source to connect to and execute the SQL
query. The data source object is generally registered in the application server's JNDI. The
Spring service locator (explained in Chapter 4) will be used to look up the data source
from the JNDI and inject it into the JdbcDaoSupport object.
Finally, everything needs to be wired up by the configuration in the Spring applica-
tion context associated with the stateless session bean, as shown in Listing 5-6. I am
showing the application service and DAO in the same configuration so that you can
understand and visualize the coupling between the two. However, for modularity, it is
advised that you put them in separate configuration files.
Listing 5-6. Underwriting-service.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="uwrApplicationService"
class="com.apress.einsure.business.impl. å
UnderwritingApplicationServiceImpl">
<property name="policyDetailDao" ref="policyDetailDao"/>
</bean>
<bean id="policyDetailDao"
class="com.apress.einusre.persistence.dao.impl.PolicyDetailDaoImpl"
>
<property name="dataSource" ref="datasource"/>
</bean>
 
Search WWH ::




Custom Search