Java Reference
In-Depth Information
Listing 4-17.
UnderwritingRemoteBean.java
public class UnderwritingRemoteBean extends AbstractStatelessSessionBean {
public void underwriteNewPolicy(String productCd, String name, int age)
throws RemoteException {
//implement business rule
//invoke Entity beans
}
protected void onEjbCreate() throws CreateException {
//use for post initialisation tasks
}
}
To register as a session bean and subscribe to the container services, the Java classes
must be supplemented with metadata information. The metadata information is pro-
vided in the form of XML deployment descriptors. The first deployment descriptor is
ejb-jar.xml
, which describes the bean and system services it requires. In this case, the
bean requires transactional services for all its methods, as shown in Listing 4-18.
Listing 4-18.
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="2.1" xmlns="
http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
<enterprise-beans>
<session>
<display-name>UnderwritingRemoteSB</display-name>
<ejb-name>UnderwritingRemoteBean</ejb-name>
<home>com.apress.einsure.business.
å
ejbfacade.UnderwritingRemoteHome</home>
<remote>com.apress.einsure.business.
å
ejbfacade.UnderwritingRemote</remote>
<ejb-class>com.apress.einsure.business.
å
ejbfacade.UnderwritingRemoteBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
