站内搜索: 请输入搜索关键词

当前页面: 开发资料首页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:

Contents

top


Creating the SynchronousSample Project

For this tutorial, you will use the Synchronous BPEL Process sample project.

  1. From the IDE's main menu, choose File > New Project.
  2. In the Categories list, expand the Samples node and select the Service Oriented Architecture node.
  3. In the Projects list, select Synchronous BPEL Process.
  4. Click Next.
  5. Accept the defaults for the Project Name, SynchronousSample and Project Location or change the values to suit your preferences.
  6. 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

  1. In the Projects window, expand the SynchronousSample project node and the Process Files node.
  2. Double-click the SynchronousSample.xsd node.
    The IDE opens the Schema view for the XML schema file.
  3. In the Schema view, the first column, select the Elements node.
    The IDE shows the typeA element in the second column of the view.
  4. In the second column, select the typeA node, right-click and choose Refactor > Rename.
    The Rename dialog box opens.
  5. In the New Name field, type typeB.
  6. 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.
  7. 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.

XML Refactoring window for Rename in XSD, click to enlarge
Click to enlarge

Notice the following:

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.

Productivity Tips

Use the information below to zoom, pan, and drag the graph pane of the XML Refactoring window.

If you drag a node out of the display area, you can bring it back using one of the following methods:

top


Renaming WSDL Components

  1. In the Projects window, expand the SynchronousSample project node and the Process Files node.
  2. 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.
  3. If the WSDL view is not the active view, click the WSDL button in the editor toolbar.
  4. In the WSDL view, under the Messages > responseMessage node, select the resultType node.
  5. Right-click the selection and choose Refactor > Rename.
    The Rename dialog box opens.
  6. In the New Name field, type outputType.
  7. 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.

    XML Refactoring window for Rename in WSDL, click to enlarge

  8. 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.
  9. 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.

  1. If the SynchronousSample.xsd file is not open in the IDE, open it now.
  2. 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.
  3. 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.
  4. 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.
  5. Click Rerun Delete typeB.
    The Safe Delete dialog box opens again.
  6. 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.

  1. 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.
  2. 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.
  3. In the second column of the Schema view, right-click the newElement node and choose Refactor > Safely Delete.
    The Safe Delete dialog box opens.
  4. 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.

  1. 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.
  2. 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.
  3. In the New Name field, type typeA.
  4. Clear the Preview All Changes checkbox and click Next.
    The IDE renames the typeB element to typeA.
  5. 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.
  6. 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.


Send Us Your Feedback

top


↑返回目录
前一篇: Setting Up Page Navigation
后一篇: Porting a Legacy Web Application to NetBeans