Creating EJB access beans

You can use the Add an Access Bean wizard to generate an access bean for an EJB enterprise bean.

The wizard helps you to avoid the complexities that exist between the different types of access beans. For more information about EJB access beans and how they are used, see Access beans.

There are four types of access beans:

If you have an existing application that employs access beans that were created in VisualAge for Java, you can use the wizards to create Java bean wrappers or copy helpers. However, if you are developing a new application, it is recommended that you create only data class access beans, which employ the newer technology.

Note: EJB factories are automatically created by the Add an Access Bean wizard regardless of whether you choose to create a data class, Java bean wrapper, or copy helper. For this reason, EJB factories do not appear on the selection page of the Access Bean Creation wizard, where you specify the type of access bean that you want to create. An EJB factory will not be created if the enterprise bean only has a local client view.

Note: By design, data access beans and copy helper beans cannot be created for session beans. Only Java wrapper access beans can be created for session beans. All access bean types can be created for entity beans.

Using the wizard, you simply select the enterprise bean for which you want to create an access bean, then you customize and create the access bean. For example, the wizard lets you customize your access bean by choosing the home interface method to map to the no-arg access bean constructor. The arguments are set by special setter methods and are stored as instance variables in the access bean.

If you want to create either Java bean wrapper or copy helper access beans for two enterprise beans that participate in a 1:1 association relationship, create the enterprise beans and the access beans in the following order:

  1. Create enterprise bean A and enterprise bean B.

  2. Create an access bean for enterprise bean A.

  3. Create an association between enterprise beans A and B.

  4. Create an access bean for enterprise bean B.

  5. Re-create the access bean for enterprise bean A.

If step 2 is not carried out, you will not be able to create both access beans because each bean needs to reference the other (due to the remote interface of each enterprise bean referencing the other's remote interface).

To open the Add an Access Bean wizard:

In the J2EE perspective, click File > New > Access Bean.

The Add an Access Bean wizard opens.

Using the Add an Access Bean wizard, you can create three types of access beans:

Access beans
EJB access beans can greatly simplify client access to enterprise beans and alleviate the performance problems associated with remote calls for multiple enterprise bean attributes.

Creating data class access beans
Use the Add an Access Bean wizard to create a data class access bean.

Creating copy helper access beans
Use the Add an Access Bean wizard to create a copy helper access bean.

Creating JavaBean wrapper access beans
Use the Add an Access Bean wizard to create a JavaBean wrapper access bean.

Editing EJB access beans
Use the Edit an Access Bean wizard to change existing access beans.

Regenerating EJB access beans
You can use a wizard to regenerate EJB access beans if you change the enterprise beans.

Example: Using access beans
This example shows an EJB 1.1 access bean for three existing CMP entity beans.

 

Parent topic

Creating enterprise beans

 

Related concepts

Access beans
Programming model for JSP files and servlets (access beans)
EJB access beans and client applications

Related reference
Example: Using access beans