Exercise 7.3: Cascade Deletes in CMP 2.0

This very short exercise demonstrates the use of the automatic cascade-delete feature of CMP 2.0 containers. It does this with an example Customer bean and some other beans related to it.

Build and Deploy the Example Programs

Perform the following steps:

  1. Open a command prompt or shell terminal and change to the ex07_3 directory created by the extraction process.

  2. Set the JAVA_HOME and JBOSS_HOME environment variables to point to where your JDK and JBoss 4.0 are installed. Examples:

    Windows:C:workbookex07_3> set JAVA_HOME=C:jdk1.4.2 C:workbookex07_3> set JBOSS_HOME=C:jboss-4.0
    Unix:$ export JAVA_HOME=/usr/local/jdk1.4.2 $ export JBOSS_HOME=/usr/local/jboss-4.0
  3. Add ant to your execution path.

    Windows:C:workbookex07_3> set PATH=..antin;%PATH%
    Unix:$ export PATH=../ant/bin:$PATH
  4. Perform the build by typing ant.

As in the last exercise, you will see titan.jar rebuilt, copied to the JBoss deploy directory, and redeployed by the application server.

Examine the JBoss-Specific Files

There are no new JBoss configuration files or components in this exercise.

Examine and Run the Client Applications

Client_73 is a simple example to demonstrate cascade-delete. The example code is pretty straightforward and needs no explanation.

In order to run Client_73, invoke the Ant task run.client_73. Remember to set your JBOSS_HOME and PATH environment variables. The output should look something like this:

C:workbookex07_3>ant run.client_73
Buildfile: build.xml

prepare:

compile:

run.client_73:
     [java] Creating Customer 10078, Addresses, Credit Card, Phones
     [java] Creating CreditCard
     [java] customer.getCreditCard( ).getName( )=Ringo Star
     [java] Creating Address
     [java] Address Info: 780 Main Street Beverly Hills, CA 90210
     [java] Creating Phones
     [java] Adding a new type 1 phone number..
     [java] Adding a new type 2 phone number.
     [java] New contents of phone list:
     [java] Type=1  Number=612-555-1212
     [java] Type=2  Number=888-555-1212
     [java] Removing Customer EJB only
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.93.169