

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 or Jetty to run the servlets.


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

You have to set the environment variables
   CATALINA_HOME and CATALINA_BASE as indicated in the Tomcat 4.1.x documentation.
or JETTY_HOME for Jetty 4.2.x

(See the howto on ObjectWeb : http://www.objectweb.org/jonas/doc/index.html)

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:
    $ jonas start

2) Load cmp2.ear (if you have not added it in the ear service descriptors list) using jonasAdmin
management application (http://<hostname>:<port>/jonasAdmin) or the 'jonas admin' command.

3) 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 (9000 by default).

4) Stop the jonas server
    $jonas stop


