All Examples  All EJB Examples  This Group

Package examples.ejb.subclassParent

Enterprise JavaBean subclassParent
example package and classes

about this example

This example consists of a set of packages that demonstrate an Enterprise JavaBean. Please run this example before attempting to create your own Enterprise JavaBeans, as it will show you the different steps involved. The example is a stateless session EJBean called ParentBean that is the parent class for another EJBean, ChildBean.

The example demonstrates:

The Client application performs these steps:
  1. Contacts the Parent home ("Parent") through JNDI to find the EJBean
  2. Creates a Parent
  3. Calls a method of the Parent bean that is overloaded in the Child bean
  4. Calls a method that's unique to the Parent bean
The package demonstrates how you can use inheritance to simplfy the design of beans where there is common code shared by related beans. See the Child bean example for how this is used.

how to use this example

To get the most out of this example, first read through the source code files to see what is happening. Start with DeploymentDescriptor.txt to find the general structure of the EJBean, which classes are used for the different objects and interfaces, then look at Client.java to see how the application works.

In general, you'll need to adjust certain properties to match your setup. You'll need to edit the entry for the property that begins with "weblogic.ejb.deploy" in the weblogic.properties file to deploy the EJBeans. The property is commented out in the default properties file; make sure that you uncomment out all the lines of the property.

This example is shipped "pre-built"; you can either run it as shipped, or build the example and run it to test that you are able to successfully build and run EJBeans.

These three sections cover what to do:

  1. Build the example
  2. Set your environment
  3. Run the example

Build the example

Set up your development environment as described in Setting your development environment.

We provide separate build scripts for Windows NT and UNIX:

The "build" scripts build individual examples, such as this entry for Windows:

$ build subclass parent
To build under Microsoft's JDK for Java, use
$ build subclass parent -ms
These scripts will build the example and place the files in the correct locations: Note: When you build the subclass child example, the ejb_subclass_parent.jar file will be deleted as the parent and child examples are merged into one ejb_subclass.jar file by the script.

Set your environment

Deploy the EJBean by adding the path to the .jar file to the "weblogic.ejb.deploy" property.

We provide a commented-out version in the property that begins with "weblogic.ejb.deploy" that you can use. You'll need to adjust the property depending on which EJBeans you're building and are deploying, or if the location of the files differs from the installed location.

Note: If you're running under the Microsoft SDK for Java, you'll also need to add the path to the .jar to the CLASSPATH for your WebLogic Server.

Run the example

  1. Start the WebLogic Server. You can check that the EJBean has been deployed correctly either by checking the server command line window, or by opening the Console and examining "EJB" under the "Distributed objects"; you should see parent.ParentHome deployed, and can monitor its activity.

  2. Run the client in a separate command line window. Set up your client as described in Setting your development environment, and then run the client by entering:
    $ java examples.ejb.subclass.parent.Client

    If you're not running the WebLogic Server with its default settings, you will have to run the client using:

    $ java examples.ejb.subclass.parent.Client "t3://WebLogicURL:Port"

    where:

    WebLogicURL
    Domain address of the WebLogic Server
    Port
    Port that is listening for connections (weblogic.system.ListenPort)

    Parameters are optional, but if any are supplied, they are interpreted in this order:

    Parameters:
    url - URL such as "t3://localhost:7001" of Server
    user - User name, default null
    password - User password, default null

  3. If you're running the Client example, you should get output similar to this from the client application:
    Begin parent.Client...
    
    Creating Parent...
    
    Calling Parent's "parentSaysHello()" method...
    
    Hello from the ParentBean.
    
    Calling Parent's "parentMethodOnly()" method...
    
    This method is only in the ParentBean.
    
    End parent.Client...
See the Child bean example for more information.

there's more

Read more about EJB in the Developers Guide, Using WebLogic Enterprise JavaBeans.

Copyright © 1998-1999 BEA Systems, Inc. All rights reserved.

Last updated 09/06/1999