Home Methods Sample

A home method is a business method that is not specific to one bean instance, and that is invoked on an entity bean's (local or remote) home interface. This sample shows a CMP entity bean that uses various home methods to obtain information about the persistent data the bean represents. Specifically, an ItemsBean_H EJB models the persistent data in a prefilled database table Items, representing an inventory of products. Each items has a product name, a quantity that is in stock, and a price. Various home methods are used to obtain information about the items in stock on the basis of their price.

Concepts Demonstrated by this Sample

Location of Sample Files

The code of the CMP entity bean is located in the homeMethods folder of the EJBs project in the SamplesApp sample application. In the file system the location is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\EJBs\homeMethods\ItemsBean_H.ejb

The web service that you run as a client application to test the EJB, and the EJB control that you use to locate and reference the EJB, are located in the homeMethods folder of the EJBs_ClientApps project in the SamplesApp sample application. In the file system the location of the web service is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\EJBs_ClientApps\homeMethods\ItemsBeanControlTest.jws

To Run the Sample

  1. Start WebLogic Server in the appropriate domain.
  1. Launch the test web service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/EJBs_ClientApps/homeMethods/ItemsBeanControlTest.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run the sample.
  2. Navigate to the Test Form tab of Test View, if necessary.
  3. Invoke the startTestDrive method to create a new conversational instance.
  4. Click continue this conversation.
  5. Locate the ejbHomeGetNumberOfExpensiveItems section, enter a valid price, and click ejbHomeGetNumberOfExpensiveItems. The number of items above that price are returned.
  6. Repeat the last two steps for the other home methods.

Related Topics

How Do I: Add a Home Method to an Entity Bean?

@ejbgen:local-home-method Annotation

@ejbgen:remote-home-method Annotation

Select Methods Sample