Java Reference
In-Depth Information
inject the EJB home object. Although it is possible to inject as many session beans as you
want in this business delegate, the best practice is to have one EJB per business delegate.
Listing 4-2. UnderwritingBusinessDelegate.java
public class UnderWritingBusinessDelegate {
private UnderwritingHome underWritingHome;
public void createPolicy(PolicyFormBean policyBean) {
try {
Underwriting bean = this.underWritingHome.create();
bean.underwriteNewPolicy(policyBean.getProductCode(),
policyBean.getFirstName(), policyBean.getAge());
} catch (RemoteException e) {
throw new RuntimeException(e);
} catch (CreateException e) {
throw new RuntimeException(e);
}
}
public UnderwritingHome getUnderWritingHome() {
return underWritingHome;
}
public void setUnderWritingHome(UnderwritingHome underWritingHome) {
this.underWritingHome = underWritingHome;
}
}
The service locator can be turned on by configuration, as shown in Listing 4-3. Appli-
cations should use a single instance of a JndiObjectFactoryBean per JNDI object.
Listing 4-3. 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 ">
Search WWH ::




Custom Search