Creating session bean facades

Use the Create Session Bean Facade wizard to create session facades and their associated static SDOs for CMP entity beans.

Before you can create a session bean facade using the wizard, you must have at least one EJB 2.x CMP entity bean in an EJB project. The wizard does not support generating session bean facades for EJB 1.x entity beans.

For a description of the workbench's implementation of session bean facades and SDOs, see Session bean facades and SDOs.

When you use the Create Session Bean Facade wizard to generate the facade, the following code is generated for you:

The wizard generates Java code that uses annotations for defining the bean and SDO implementations. The annotations are then used by the EJB tools to generate the necessary bean classes. You can modify the annotations to modify the session bean facade and the SDOs.

See Annotations for session facades and SDOs for reference information about the @ws.sdo and @ws.sbf tag sets.

See Annotation-based programming overview for general information about working with annotations.

To use the wizard to create a session bean facade for EJB 2.x CMP entity beans:

  1. In the Project Explorer view of the J2EE perspective, right-click an EJB 2.x CMP entity bean and select Create Session Bean Facade from the pop-up menu. The Create Session Bean Facade wizard opens.

  2. In the Name drop-down list, enter the name for the session bean facade that you want to create.

    Note: If you already have a session bean facade in your project, you can select the existing facade. The wizard allows you to add the SDOs for multiple CMP entity beans to the same session bean facade.

  3. In the Available CMP beans list, select the entity bean that you want to include in the session bean facade, and click Next.

  4. On the SDO creation page of the wizard, for each CMP entity bean in the table, enter a name for the SDO that you want to create.

  5. Optional: If you do not want to include the create, update, and delete methods on the session facade for the primary CMP entity bean, select the Read Only check box. The root SDO that is constructed does not contain any create methods for the non-contained SDOs.

  6. Click the Show Advanced button and specify the CMP attributes and container-managed relationship (CMR) entities that you want to include for each SDO.

    The advanced section includes two views of the CMR entities that are available in the selected CMP entity bean:

    • A table that lists each relationship

    • A tree view that shows all attributes and relationships

  7. Use the tree view to select the CMP attributes and relationships that you want to include for the facade.
    Tip: If the SDO is not read only, required attributes and relationships must be included and are selected by default. For example, the entity bean's primary and foreign keys are required if the SDO is not read only.

  8. Use the table view of the CMR entities to do the following steps:

    1. Optional: Enter a new name for each SDO that will be created for the relationships included in the facade.

    2. Optional: Specify whether a relationship is contained. Specifying whether a relationship is contained impacts how the wizard generates the SDOs. The generated root SDO includes create methods for non-contained relationships.

  9. Optional: Click Next and specify whether you want to include the session bean facade in a class diagram.

  10. Click Finish .

The wizard generates the annotations and the workbench generates the classes for the session bean facade and the SDOs.

Session bean facades and SDOs
This topic discusses the general concept of session bean facades, and it introduces the benefits of the implementation provided by the workbench. The workbench implements session bean facades that interact with WebSphere's EJB Mediator and operate on statically generated Service Data Objects (SDOs).

Example: Creating a session bean facade
This topic demonstrates how to use the Create Session Bean Facade wizard to generate a session bean facade. It also gives several examples of using annotations to change the session bean facade.

Annotations for session facades and SDOs
This section includes reference topics for the @ws.sdo and @ws.sbf annotation tag sets, which are used to define and generate session bean facades.

 

Parent topic

Creating enterprise beans

Related reference
Annotation-based programming overview