Booking a trip reservation
93
Booking a trip reservation
To book a trip reservation, you must validate a credit card and create an order for the trip.
The reservation EJB is a workflow session bean that coordinates the trip booking
transaction. The reservation EJB calls the credit card EJB and the order EJB:
•
The credit card EJB is a session bean that has a
validate
method.
•
The order EJB is an entity bean. Entity beans provide methods to add (
ejbCreate
),
delete (
ejbRemove
), update (
ejbStore
), and retrieve (
ejbLoad
) a row in a database.
The reservation EJB is a stateless session bean that coordinates the process of booking a
trip reservation. First it invokes the credit card EJB to validate the user’s credit card. Then
the reservation EJB invokes the order EJB to create a new order.
Examine the Java source code for the following predeployed EJBs.
Examining the code for the reservation EJB
You can review the Java source code for the reservation EJB located in the tutorial_root/
compass-ear/reservation/compass directory. Open and look at the code in the following
files:
•
ReservationRemote.java
The remote interface lists the business methods available
in the EJB. This EJB has only one business method called
reserve
that allows you to
book a trip.
•
ReservationHomeRemote.java
This EJB is instantiated using a
create
method
that takes no arguments.
•
ReservationBean.java
The EJB implementation class does the following:
−
Provides an implementation for the methods defined in the
SessionBean
interface;
ejbRemove
,
ejbPassivate
,
ejbActivate
−
Provides an
ejbCreate
method corresponding to each
create
method defined in
the home interface
−
Provides an implementation for each business method defined in the remote
interface
•
ejb-jar.xml
Look at the deployment descriptor, an XML file containing the
runtime attributes of the reservation EJB, located in jrun_root/servers/tutorial/
compass-ear/reservation/META-INF. It defines the reservation EJB as a stateless
session bean.
The
reserve
method coordinates the process of reserving a trip. First it obtains an
instance of the credit card EJB and then invokes the credit card EJB
validate
method.
Then it obtains an instance of the order EJB and invokes the order EJB
create
method
to insert a new order into the database.
This procedure shows how to write an EJB that invokes other EJBs and also
demonstrates how a session bean is used to coordinate a transaction.
Содержание 38000382 - Macromedia JRun - Mac
Страница 1: ...Getting Started with JRun...
Страница 16: ......
Страница 68: ...54 Chapter 5 Introduction to EJB...
Страница 82: ......
Страница 110: ...96 Lesson 3 EJB Tutorial...
Страница 128: ...114 Lesson 4 Web Services Tutorial...
Страница 132: ...118 Index...