Promoting methods to an interface

You can promote methods to the remote interface from an enterprise bean class without editing the remote interface directly.
In order to use this functionality, you must turn on the Advanced J2EE capability in the workbench preferences (Window > Preferences > Workbench > Capabilities).

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.

To promote an existing method to an interface:

  1. Open the Java™ editor in one of the following ways:
    • In the Project Explorer view of the J2EE perspective, select the Java file for the bean class that contains the method to be promoted. Select Open with > Java Editor.
    • In the Project Explorer view of the J2EE 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. The class opens in the Java editor.
  2. In the Outline view of the J2EE 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 > Promote to Local Interface
    • Enterprise Bean > Promote to Local Home Interface
    • Enterprise Bean > Promote to Remote Interface
    • Enterprise Bean > Promote to Home Interface
    • Enterprise Bean > Promote to Service Endpoint Interface
    If you promote to the remote interface, the generated promoted method will throw the javax.ejb.RemoteException exception. If the remote interface is already opened in a Java editor, it will appear dirty, and the Java editor will 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.
Related tasks
Working with a bean's client interface methods
Adding methods to the home interface
Demoting methods from an interface

Feedback