Tool Mentor: Designing EJBs Using Rational XDE Developer - Java Platform Edition
This tool mentor describes how Rational XDE supports designing EJBs.
Tool: Rational XDE Developer
Relationships
Related Elements
Main Description

Purpose

This tool mentor describes how Rational XDE supports the designing of Guideline: Enterprise JavaBean (EJB). For more information on designing EJBs, see Guideline: Designing Enterprise JavaBeans (EJBs).

Overview

This tool mentor assumes that an XDE EJB code model and package structure has already been created.  For more information, see Tool Mentor: Setting Up for a Project Using Rational XDE Developer

The following steps are performed in this tool mentor:

For More Information

Links to topics in the Rational XDE™ online Help are marked with helpbook icon.

Identify the EJBs

The following steps describe how to create EJBs using XDE:

  1. Decide on your conventions for EJB names and whether to generate local or remote interfaces. Set these preferences in advance. For information on how to set these preferences, see helpbook iconSetting EJB/Servlet Preferences .
  2. Add one or more EJBs to the model. See helpbook iconCreating EJBs .
    Note: EJBs can be created from an existing class, in which case the methods and fields in the class will be copied to the EJB. See helpbook iconCreating EJBs from Existing Classes . When you create EJBs from existing classes, you can select several classes at a time in the Model Explorer. All of them will be transformed to the same type of EJB. So, you can create all your session EJBs in one step, your CMP 2.0 entity EJBs in another step, etc.

The best way to view and model your EJB's is to use the EJB Diagram, which provides a succinct and configurable view of  the EJB's. See helpbook iconEJB Diagram . For example, by default, interfaces are suppressed, since they are redundant, and CMP 2.0 fields are shown as attributes, even though they are really implemented as a pair of abstract "get/set" methods (which are also suppressed).
Note: This is why you will see an "attribute" for the CMP field in the Model Explorer and regular class diagram for a CMP 2.0 entity EJB, even though the attribute would be "illegal" in the source code. In cases like this, the attribute has a value of "false" for the "Synchronization" property, meaning that it is ignored during round-trip engineering.

Define Attributes

Once you have created your EJB's, you can add fields. For example, see helpbook iconAdding Container-Managed Fields to Entity Beans .

You can create primary key fields (or classes) for your entity EJBs. See helpbook iconAdding Primary Keys to Entity Beans .

You can also define the mapping between database tables in the Data Model and container-managed persistent (CMP) entity EJB's. For more information, see helpbook iconUsing EJBs with Databases .

Define Operations

You can add "business" methods that implement the logic of the application, including appropriate read and write access to data, as well as standard EJB support methods like "find", "select", and "create" methods. See helpbook iconModeling Methods on EJBs .

The standard EJB support methods will be exposed on the appropriate interface. Generic Java methods are treated as implementation support methods and are not automatically promoted to an interface. Implementation support methods can be "promoted" to the appropriate interface (home or instance). See helpbook iconPromoting Business Methods .

When designing BMP entity EJBs, you need to include all the "create", "postCreate", and "find" methods in order to instantiate EJBs and populate their data appropriately. Furthermore, for BMP and CMP EJBs, you will need to provide appropriate "business methods" that permit clients to access and manipulate data.

Define Behavior

While part of the EJB behavior is provided by the methods, additional behavior is provided through EJB collaborations. Using the Connector Assistant tool, you can create references between EJB's, and for CMP 2.0 entity EJBs, you can create container-managed relationships (CMR's) between them. See helpbook iconDefining Relationships for EJBs .

Design Supporting Classes

Supporting Java classes can be modeled in separate Java code models or in the same EJB code model.

More complex patterns include collaborations of support classes that encapsulate EJB creation for bean clients (the "Service Locator" pattern, see Core J2EE Patterns ([ALU01]). The built-in "Gang of Four" (GoF) patterns can also be applied (see helpbook iconApplying the Gang of Four Sample Patterns . For more information on applying patterns, see helpbook iconApply Patterns .

For More Information  

For general information on EJBs in XDE, see helpbook iconModeling EJBs .

See also helpbook iconA Tour of Modeling EJB's .