

Example Overview
================

This example shows how to use new features of container managed persistence
in EJB 2.0, like Entity Relationships and EJB-QL.

The code of the EJBs used in this example comes from the book:
  "Enterprise JavaBeans(TM)" Third Edition
  by Richard Monson-Haefel
    [O'REILLY edition ISBN 0-596-00226-2]

We have packaged this example as an ear since the client is implemented
as three servlets.


Directories structure
=====================

The "src" directory contains:

- eight Entity beans:
	CustomerEJB, 
	AddressEJB, 
	PhoneEJB, 
	CreditCardEJB, 
	CruiseEJB, 
	ShipEJB,
	ReservationEJB,
	CabinEJB,
	Sequence.
  The seven first beans shows the seven relationship types,
  the last is used for an automatic generation of primary keys.

- three Session beans:
	TravelAgentEJB,
	RTravelAgentEJB,
	SequenceSession.

- three servlets:
	ServletTest
		shows one to one relationship unidirectional or bidirectional,
	ServletTest2
		shows one to many, many to one, many to many 
		uni and bidirectional relationships
	ServletTest3
		shows example of finder methods using many EJB-QL examples

The "etc" directory contains:

- the "xml" directory which contains all the deployment descriptors
  used for this example :
	application.xml (ear file),
	ejb-jar.xml and jonas-ejb-jar.xml (jar file),
	web.xml and jonas-web.xml (war file).

- the "resources" directory which contains all the resources for this
  application
	"web" directory contains all resources used by the servlets


Compiling this example creates an .ear file that represents the application
including :
- all the beans used by the web application,
- a web application that will be used by Tomcat to run the servlets.


Prerequisites
=============
First, you must have installed a web container (ie : Catalina) 
as the web container service

You have to set the environment variables:
    CATALINA_HOME and
    CATALINA_BASE
as indicated in the Tomcat 4.0.x documentation.

As for the other JOnAS examples, you have to configure a datasource.
It's JNDI name must be 'jdbc_1'.
The 'datasource.mappername' property value must be up-to-date.


Building this example
=====================
Under $JONAS_ROOT/examples/cmp2, do
    $ ant install


Running this example
====================
Commands are given for an Unix system, similar commands can be done on
Windows.

1) Run a JOnAS server:
    $ cd $JONAS_ROOT/examples/cmp2
    $ jonas start

2) Lookup at http://<hostname>:<port>/cmp2 to start this example
    - <hostname> is the name of your machine (localhost by default), and
    - <port> the port number (8080 by default).

3) Stop the jonas server
    $jonas stop


