当前页面: 开发资料首页 → Netbeans 专题 → Refactoring in a BPEL Module Project Using NetBeans Enterprise Pack
Refactoring in a BPEL Module Project Using NetBeans Enterprise Pack
摘要: This tutorial explores refactoring in NetBeans Enterprise Pack. The NetBeans IDE with NetBeans Enterprise Pack supports XML schema, Business Process Execution Language (BPEL), and Web Service Description Language (WSDL) source file refactoring. You can use refactoring to rename and safely delete local and global components.
Prerequisite
This tutorial assumes that you have some basic knowledge of, or programming experience with, the NetBeans IDE.
System Requirements
This tutorial assumes that your system meets the requirements specified in the System Requirements topic of the NetBeans Enterprise Pack 5.5 Release Notes.
Software Needed for the Tutorial
Before you begin, you must install the following software on your computer:
- NetBeans IDE 5.5 with NetBeans Enterprise Pack 5.5 (download)
Contents
top
Creating the SynchronousSample Project
For this tutorial, you will use the Synchronous BPEL Process sample project.
- From the IDE's main menu, choose File > New Project.
- In the Categories list, expand the Samples node and select the Service Oriented Architecture node.
- In the Projects list, select Synchronous BPEL Process.
- Click Next.
- Accept the defaults for the Project Name, SynchronousSample and Project Location or change the values to suit your preferences.
- Click Finish.
The Projects window now contains two project nodes: a BPEL Module project node labeled SynchronousSample, and a Composite Application project node labeled SynchronousSampleApplication.
top
Renaming XML Schema Components
- In the Projects window, expand the SynchronousSample project node and the Process Files node.
- Double-click the SynchronousSample.xsd node.
The IDE opens the Schema view for the XML schema file.
- In the Schema view, the first column, select the Elements node.
The IDE shows the typeA element in the second column of the view.
- In the second column, select the typeA node, right-click and choose Refactor > Rename.
The Rename dialog box opens.
- In the New Name field, type typeB.
- Make sure the Preview All Changes checkbox is selected and click Next.
The Preview All Changes checkbox specifies that you want to review the refactoring changes before applying those changes.
The XML Refactoring window opens in the bottom part of the IDE.
Note: Before you proceed to the next step, review the information in Exploring the XML Refactoring Window below.
- In the XML Refactoring window, click Do Refactoring to execute the rename action.
When the refactoring is complete, typeA has been renamed to typeB and all references to that schema component have been changed to reflect the new name.
Exploring the XML Refactoring Window
Let's explore the XML Refactoring window as it appears after you initiated the Rename action from the Refactor menu.

Click to enlarge
Notice the following:
- The status bar informs you that 2 usages were found for the typeA element.
- The tree pane of the window shows all usages of the typeA element.
If you select a node in the tree pane, the IDE highlights the corresponding node in the graph pane.
- The graph pane shows a graphical representation of the information in the tree pane.
If you select a node in the graph pane, the IDE highlights the corresponding node in the tree pane.
You can expand and collapse file nodes in the graph pane by selecting
the node, right-clicking and choosing Collapse or Expand from the
pop-up menu.
- The list of files where the IDE found usages of typeA includes the SynchronousSample.wsdl file because it contains references to the typeA element.
Navigating to XML Schema Editor Views From the XML Refactoring Window
You can use the right-click pop-up menu from the graph pane to navigate to other views in the XML schema editor.
- In the graph pane of the XML Refactoring window, select one of the References "typeA" nodes, right-click and choose Go To Source.
The IDE opens the SynchronousSample.xsd file in the Source view of the editor and highlights the first line of the block for the typeA element.
- In the graph pane of the XML Refactoring window, select the typeA node, right-click and choose Go To > Schema.
The editor tab for the SynchronousSample.xsd file becomes the active tab with the typeA node highlighted in the second column of the Schema view.
Productivity Tips
Use the information below to zoom, pan, and drag the graph pane of the XML Refactoring window.
- To zoom out: right-click in the graphic and drag up.
- To zoom in: right-click in the graphic and drag down.
- To pan: click and drag in any direction.
- To drag a node: click and drag the node.
If you drag a node out of the display area, you can bring it back using one of the following methods:
- Pan in the direction of the node until it is visible in the display area again.
- Zoom out until the node is visible in the display area.
- Click the Refresh button in the XML Refactoring window toolbar.
top
Renaming WSDL Components
- In the Projects window, expand the SynchronousSample project node and the Process Files node.
- Double-click the SynchronousSample.wsdl node.
If the file was already open in the IDE, the tab for SynchronousSample.wsdl becomes the active tab in the editor.
If the file was not open in the IDE, the IDE opens the WSDL view of the WSDL editor for the WSDL file.
- If the WSDL view is not the active view, click the WSDL button in the editor toolbar.
- In the WSDL view, under the Messages > responseMessage node, select the resultType node.
- Right-click the selection and choose Refactor > Rename.
The Rename dialog box opens.
- In the New Name field, type outputType.
- Leave the Preview All Changes checkbox selected and click Next.
The Preview All Changes checkbox specifies that you want to review the refactoring changes before applying those changes.
The XML Refactoring window opens in the bottom part of the IDE.

Notice that the XML Refactoring window shows the usages of resultType, in this case, one.
The list of files containing usages include SynchronousSample.bpel, which contains references to the resultType message.
Note: Exploring the XML Refactoring Window provides additional information about the XML Refactoring window.
- In the XML Refactoring window, click Do Refactoring to execute the rename action.
When the refactoring is complete, resultType has been renamed to outputType and all references to that component have been changed to reflect the new name.
top
Safely Deleting Components
When you use the refactoring delete function to delete a component
with usages in multiple project files, the IDE will find all usages of
that component in the project and show you a preview of the refactoring
action, even if you chose not to preview the changes. When you use the
refactoring delete function to delete a component with usages in a
single project file, you cannot delete the component without previewing
the refactoring action.
Deleting Components With References
In this procedure, you will use the refactoring delete function to
see that the IDE forces you to review refactoring changes for
components that are referenced in other files in your project.
- If the SynchronousSample.xsd file is not open in the IDE, open it now.
- In the first column of the Schema view, select the Elements node and then in the second column, right-click the typeB node and choose Refactor > Safely Delete.
The Safe Delete dialog box opens.
- Clear the Preview All Changes checkbox and click Next.
Even though you cleared the Preview All Changes checkbox, the Safe Delete dialog box is now updated to show a warning.
- Click Find Usages.
The XML Usages window shows all usages of typeB, in this case, 2 usages, as shown in the status bar.
The 2 usages are in the SynchronousSample.wsdl file.
- Click Rerun Delete typeB.
The Safe Delete dialog box opens again.
- In the Safe Delete dialog box, click Cancel.
Note: At this point, you are canceling the delete action because
you will use this element to review undo and redo functionality in
refactoring.
Deleting Components Without References
In this procedure, you will create a new schema component that has
no references and then use refactoring to delete that schema component.
- In the first column of the Schema view of SynchronousSample.xsd, select the Elements node, right-click and choose Add Element from the pop-up menu.
The Element dialog box opens.
- Accept the defaults in the Element dialog box and click OK.
The second column of the Schema view now has an element node labeled newElement.
- In the second column of the Schema view, right-click the newElement node and choose Refactor > Safely Delete.
The Safe Delete dialog box opens.
- Clear the Preview All Changes checkbox and click Next.
The IDE executes the refactoring and deletes newElement.
top
Undoing and Redoing Refactoring Actions
After you perform a refactoring action, you can undo that action. If
you then decide you want to "undo" the undo, you can redo the action.
Note: To undo refactoring actions, you must invoke the action
from the Refactoring menu that appears in the pop-up menu, not from the
IDE's Edit menu.
- To undo the safe delete of the newElement schema component, in the second column of the Schema view of SynchronousSample.xsd, right-click the typeB node and choose Refactor > Undo [Safe Delete].
The IDE reverses the earlier safe delete that you invoked from the Refactoring menu and restores newElement.
- In the second column of the Schema view of SynchronousSample.xsd, right-click the typeB node and choose Refactor > Rename.
The Rename dialog box opens.
- In the New Name field, type typeA.
- Clear the Preview All Changes checkbox and click Next.
The IDE renames the typeB element to typeA.
- To undo the refactoring rename action, in the second column, select the typeA node, right-click and choose Refactor > Undo [Rename].
The IDE reverses the rename that you invoked from the Refactoring menu and restores the typeB name of the element.
- To verify that the last undo action worked correctly, in the second column of the Schema view, right-click the typeB node and choose Find Usages.
The XML Usages window opens. Notice that the references all correctly refer to typeB.
In the tree pane of the XML Usages window, double-click the inputType and outputType nodes to see the references in the Source view.
top
Summary
In this tutorial, you explored refactoring in NetBeans Enterprise
Pack. You created a new BPEL Module project and used refactoring
functionality to rename and delete components with and without
references. You also learned how to undo and redo refactoring actions.
top