Exercise 5.2: The EJBObject, Handle, and Primary Key

The example programs in Exercise 5.2 explore the APIs available through the EJBObject and EJBMetaData interfaces. They also reveal how to use Handle and HomeHandle as persistent references to EJB objects and homes.

Start Up JBoss

If you already have JBoss running, there is no reason to restart it. Otherwise, start it up as instructed in the JBoss Installation and Configuration chapter at the beginning of this workbook.

Initialize the Database

The database should contain the 100 rows created by a successful execution of the test programs from Exercise 4.1; otherwise, this example will not work properly.

Build and Deploy the Example Programs

In the ex05_2 directory, build and deploy the examples as you did for Exercise 5.1.

Examine the JBoss-Specific Files

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

Examine and Run the Client Applications

Three example programs illustrate the concepts explained in the EJB book:

Client_52a.java

Shows the use of EJBObject to retrieve an EJB’s home interface.

Client _52b.java

Shows how to use isIdentical( ) to determine whether two EJB references are to the same object.

Client _52c.java

Shows how to use EJB handles as persistent bean references.

The example code is pulled directly from the EJB book and embellished somewhat to expand on introduced concepts. The EJB book does a pretty good job of explaining the concepts illustrated in the example programs, so further explanation of the code is not needed in this workbook.

Run Client_52a, Client_52b, and Client_52c by invoking the appropriate Ant task as you did in previous examples: run.client_52a, run.client_52b, and run.client_52c. Remember to set your JBOSS_HOME and PATH environment variables.

..................Content has been hidden....................

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