Java Reference
In-Depth Information
EJB 2.0 introduced local EJBs with the aim of limiting network trips and thus enhanc-
ing performance. A remote stateless session bean implementing business workflow can
be combined with local entity beans to complete a particular use case in just one
network trip.
Writing a stateless session bean is a tedious activity even with modern integrated
development environments. Each EJB 2. x or 1. x SLSB requires at least three Java files to
be created. You need two Java files for the home and remote interfaces, while the third
one is for the bean implementation class. Apart from this, you have two XML deployment
descriptors: the standard ejb-jar.xml and the other vendor-specific XML that supplies
runtime metadata. In the next few sections, I will try to simplify the development of the
session facade with Spring EJB support classes.
The first step to building a session bean is to create the home interface, as shown in
Listing 4-15.
Listing 4-15.
public interface UnderwritingRemoteHome extends EJBHome {
UnderwritingRemote create() throws CreateException, RemoteException;
The home interface is responsible for managing the life cycle of the remote EJB
object. In this case, the create method of the home interface acts as a factory responsible
for creating the remote objects. The remote object implements the remote interface as
shown in Listing 4-16.
Listing 4-16.
public interface UnderwritingRemote extends EJBObject {
public void underwriteNewPolicy(String productCd,String name,int age)
throws RemoteException;
The remote interface defines all the business methods that will be exposed by the
SLSB to its clients. The bean implementation class is responsible for providing imple-
mentation for the business methods defined in the remote interface. Spring provides
convenience base classes to simplify the development of the bean implementation class.
So, it is important to understand these classes before I get down into the implementation
Search WWH ::

Custom Search