Refactoring an Enterprise Bean
See Also
Refactoring is especially useful in EJB modules, since changing the name of
one method often means you have to update the name in all of the related interfaces,
deployment descriptors, and dependent classes and servlets.
To refactor an EJB module, do any of the following:
- Right-click a piece of code in the Source Editor and choose from the Refactor
submenu in the contextual menu.
- Right-click a node in the Projects window, such as a Local Methods node
or a CMP Fields node, and choose from the Refactoring menu.
- Rename parts of an enterprise bean in the ejb-jar.xml deployment
descriptor. For example, in the Enterprise Bean Implementation and Interfaces
section, you can use the Rename Class and Move Class buttons to refactor an
enterprise bean's bean class and interfaces. To open ejb-jar.xml,
expand the project's Configuration Files node in the Projects window and double-click
ejb-jar.xml.
Notes:
- You cannot move an enterprise bean or any of its classes and interfaces
to a different project. The Move Class command only lets you move bean classes
and interfaces to different packages in the same EJB module.
- You cannot rename mandatory EJB infrastructure methods such as ejbCreate.
- In CMP entity beans, when you rename a finder method or select method, the
IDE updates the query element and statement in the deployment descriptor.
For finder methods, the IDE also updates the method name in the home interfaces.
- When you rename a CMP field in a CMP entity bean, the IDE updates the cmp-field
element and the names of the get and set methods in the bean class. When you
rename a CMR field, the IDE also updates the cmr-field entity.
- In CMP entity beans, you cannot run the Encapsulate Field command on a field
that is registered as the bean's primary key.
- When you rename a Web service endpoint interface, the IDE updates the corresponding
WSDL file.
- When you rename a CMP field, the EJB QL statements for the field still refer
to the old names. You have to change the EJB QL statements manually.
- See Also
- About
Refactoring
- Defining a Finder Method
- Defining a Select Method
- Defining a CMP Field
- Configuring EJB Deployment Descriptors
Legal Notices