This sample application implements the Hotel Reservation System
using Enterprise JavaBean(EJB) components. The application implements 2 session
EJB components (HotelInformation & ReservationAgent), which is used by the
client applications, to perform hotel reservation and enquiry on all the hotels
in the System. HotelInformation & ReservationAgent beans use 2 Entity Beans(Hotel
& HotelBooking - BMP) for creating hotels, modifying bookings etc.
The HotelInformation & ReservationAgent components also use SQLJ to perform
database access.
This sample implements reservations in batch mode. The user clicks the "Reserve
Room" and makes the bookings. This way a number of bookings can be done on the
same hotel. After completing individual reservations, the user has to click
on "Batch Reserve" so that the reservations are committed to the database.
The sample application has a servlet based thin Web Client.
This sample application illustrates EJB features such as :
- Usage of EJB (both session & entity) in an application scenario.
- Usage of BMP entity beans.
- Usage of SQLJ from EJB's [both session and entity beans]
- EJB component location and instantiation.
- Invoking Entity beans from Session beans [Session facade pattern]
- Invoking methods on an EJB component from a client application.
- Accessing EJB's from a Servlet client
Software Requirements
List the softwares required for configuring and running this
sample application.
Deploying and Running
the application using Oracle9i JDeveloper
This section describes the steps required for deploying and
running this application using Oracle9i JDeveloper.
Step 1:. Open the <SAMPLE_HOME>/BMPSample/BMPSample.jws
in Oracle9i JDeveloper. The workspace contains BMPSample.jpr (project
file), Servlet files and other files.
Step 2: Create Database Server Connection
Select Database Server under the Connections Node.
Right click on Database Servers and select "New Connection".
In Step 1 of the wizard, enter the Connection Name as
'Travel'.
In Step 2 of the wizard, Provide 'travel' as user name
and password for the travel schema. (by default travel).
In Step 3 of the wizard, provide the appropriate database
connection information where travel schema is loaded.
In Step 4 of the wizard, test the connection and Select
'Finish' button
Step 3: Right click BMPSample.jpr and select
"Make BMPSample.jpr". This compiles all the java classes in the project.
Step 4: Right click BMPSample.jpr and select "Run BMPSample.jpr".
This opens up the browser and runs the HotelServlet.
Deploying and Running
the application using ANT
This section describes the steps required in deploying this
application to the Standalone OC4J using ANT Tool.
Step 1: SET Environment Variables
Open the Command Prompt and Go to the <SAMPLE_HOME>/BMPSample
directory
Ensure that JAVA_HOME environment variable is
pointing to your JDK installation directory
Ensure that <JAVA_HOME>/bin is in the PATH
Ensure that <ANT_HOME>/bin is in the PATH
Ensure that <JDEV_HOME>/bin is in the PATH
which contains sqlj.exe (for Windows) and sqlj (for Linux)
Ensure that <OC4J_HOME>/jdbc/lib/classes12dms.jar,
<OC4J_HOME>/sqlj/lib/translator.jar,
<OC4J_HOME>/sqlj/lib/runtime12ee.jar in CLASSPATH
Step 2: From the <SAMPLE_HOME>/BMPSample/src/oracle/otnsamples/BMPSample/ejb/utils
directory, run the following command to compile the sqlj and java files.
The above command creates all the class files in the same directory.
Step 3: Modify the host name, database listening
port and database sid attributes of <SAMPLE_HOME>/BMPSample/config/data-sources.xml
according to your own database settings.
Step 4: Build the EAR file
From <SAMPLE_HOME>/BMPSample, execute ant
<SAMPLE_HOME>/BMPSample
> ant
This will create the BMPSample.ear
file.
Step 5: Ensure that OC4J is up and running. To start the OC4J server,
navigate to <J2EE_HOME> and execute the following command.
java
-jar oc4j.jar
Step 6: Having created a BMPSample.ear file, to deploy
this application to Standalone OC4J use the following command, from <SAMPLE_HOME>/BMPSample
directory.
Now, the application is deployed to the Standalone OC4J.
Step 8: Open your favorite browser and access
the sample, using the following url.
http://<host_name>:<port>/BMPSample/BMPSample
where, <host_name> is the machine on which OC4J is
running and <port> is Port to which the OC4J server listens to HTTP requests.
By default OC4J listens for HTTP requests in port # 8888.
For example,
http://localhost:8888/BMPSample/BMPSample
Sample Application Files
The sample is provided
as a jar file BMPSample.jar that contains the following
files required for the sample. They get extracted in BMPSample
directory.
Directory
File
Description
BMPSample
build.xml
Ant build script
BMPSample.jws
Oracle9i JDeveloper works space file
BMPSample.jpr
Oracle9i JDeveloper project file
BMPSample/docs
Readme.html
This file
BMPSample/config
application.xml
This file is used to define the J2EE EAR file,
which contains the location of EJB JAR file, Web application WAR file
and is included in the EAR file
orion-application.xml
This file used ot define orion specific configuration
settings. This file contains reference to application specific data-sources.xml.
This is included in the EAR file
datasources.xml
This file contains database configuration
parameters for running this sample
BMPSample/src/META-INF
ejb-jar.xml
This file is used to define the EJB deployment
descriptors and is included in the EJB JAR file
This java file is the remote interface for
the HotelBooking EJB
HotelBookingBean.java
This java file contains the implementation
of the methods declared by HotelBooking
HotelBookingHome.java
This java file defines the Home interface
of the HotelBooking EJB
HotelBookingPK.java
This java file defines the primary key of
the HotelBooking EJB
BMPSample/src/oracle/otnsamples/BMPSample/web
EJBHotelServlet.java
This java file is the servlet client for
the HRS application and contains methods which contains calls to the HotelInformation
EJB & ReservationAgent EJB
EJBHotelServletHTML.java
This java file has all the method's for generating the
HTML text for display on the browser
BMPSample/src/web/WEB-INF
web.xml
This file is used to define the Web deployment descriptors
and is included in the WAR file
BMPSample/src/web/images
logo.gif
HRS logo image
Please enter your comments about this sample application
here.