Promoting methods to an interface

You can promote methods to the remote interface from an enterprise bean class without editing the remote interface directly.

About this task

When you create an enterprise bean, a set of required methods for the bean is automatically created. You can modify these required methods and add new remote (business) methods of your own.

After you create these remote methods, you can promote the methods to the remote interface from the enterprise bean class without editing the remote interface directly. When exposing an API from the bean class to the remote interface, performance needs to be considered. Several calls to methods on a remote object could slow performance. In some cases, combining several operations into a single batch method can improve performance.

Other method-level extensions can be added on the Beans page of the deployment descriptor editor.

Procedure

  1. Open the Java™ editor in one of the following ways:
    • In the Enterprise Explorer view of the Java EE perspective, select the Java file for the bean class that contains the method to be promoted. Select Open with > Java Editor.
    • In the Enterprise Explorer view of the Java EE perspective, expand the ejbModule folder and the package for your bean class, then double-click the .java file for your bean class.
    • On the Bean page of the deployment descriptor editor, in the Class and Interface Files section, select the desired class and click Open.
  2. In the Outline view of the Java EE perspective, right-click the business method that you want to promote. On the pop-up menu, select one of the following options, depending on which interfaces are available and the type of bean that you are working with:
    • Enterprise Bean (1.x-2.x) > Promote to Local Interface
    • Enterprise Bean (1.x-2.x) > Promote to Local Home Interface
    • Enterprise Bean (1.x-2.x) > Promote to Remote Interface
    • Enterprise Bean (1.x-2.x) > Promote to Home Interface
    • Enterprise Bean (1.x-2.x) > Promote to Service Endpoint Interface
    If you promote to the remote interface, the generated promoted method throws the javax.ejb.RemoteException exception. If the remote interface is already opened in a Java editor, it appears dirty, and the Java editor does not show up with an "R" next to the method in the outline view until the editor holding the remote interface is saved.
  3. Save your changes and close the editor.

Feedback