Refactoring EJB 3.0 Java elements

Using workbench refactoring operations, you can quickly and safely rename code artifacts globally across your application. The workbench recognizes EJB 3.0 applications and manages changes to relevant annotations and deployment descriptors.

To rename a field or method in an EJB 3.0 application:

  1. In the

    Enterprise Explorer view, the

    Outline view, or the Java™ editor, right-click the field or method you want to rename and select

    Refactor. From the submenu that follows, select

    Rename. The

    Rename Field or

    Rename Methodpanel opens.

  2. Enter the new name for the field or method and click Next.

  3. Review each change to be performed. If you do not want to make a particular change, deselect the box next to the change. Click Finish.

The operation makes changes to the Java artifacts that reference the field or method that you rename. If the field or method is annotated with a dependency injection annotation (@EJB, @Inject, or @Resource), the refactoring operation also updates the XML artifacts that make reference to the field or method.

Additionally, by selecting

Java EE Tools | Promote Method from the context menu of a method, you can move the method to the business interface for the EJB. If a bean class specifies its business interfaces using annotations or the EJB deployment descriptor, you can still specify the business interface as the target of the operation. A

Refactor | Move operation moves a field or method from one package to another.

 

Related concepts

Editing EJB 3.0 applications

As-you-type validation tool

Content assist and EJB 3.0