Creating EJB access beans

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

About this task

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:

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.

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 is not created if the enterprise bean only has a local client view.

Creating an Access Bean

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, you must 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 cannot 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).

Using the Add an Access Bean wizard

To open the Add an Access Bean wizard, complete the following steps:

Procedure

  1. In the Java EE perspective, click File > New > Other.
  2. Select EJB > Access Bean and click Next.

Results

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


Feedback