Guide to Building Business Processes

     Previous  Next    Open TOC in new window  Open Index in new window  View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Business Process Source Code

As you design business processes using the graphical tools in BEA Workshop for WebLogic Platform, BEA Workshop for WebLogic Platform writes source code to a business process file (Process. java file), in keeping with your work in the Design view. This Pocess.java contains annotations and the implementation code intended specifically for a business process class, this file is treated specially by BEA Workshop for WebLogic Platform compiler"

You can access the source code for business processes you are creating in the Design view, by clicking the Source tab.

This section describes the source code in a business process (Java) file, and how it is related to the work you do while creating your business process graphically in the Design view. It includes the following topics:

Overview

To organize the source code in a Java file, the code generated for you as you work in the Design view is hidden in collapsible regions in the Source view. Methods that you write for conditions in Decision, For Each, While nodes, and so on, are shown inside teach their own collapsible regions in the Java file in the Source view.

Specific regions in the Source view represent variable declarations, control declarations, XQuery annotations, and methods associated with client operations and communication with controls. In the Source view, you can expand these collapsed regions of code to add or edit the contained code. The BEA Workshop for WebLogic Platform environment supports two-way editing of your business process (Java) class—the extent to which you can add code or change the code generated by BEA Workshop for WebLogic Platform is indicated by comments in the source code and described in the following sections.

Business Process Language

To view the business process annotation that describes the business process you created in the Design view, choose WindowArrow symbolShow ViewArrow symbolAnnotations.

The Process annotation contains the business process definition, created for you as you add nodes to your business process in the Design view. The Java methods and variables defined in this Java file can be referenced by the flow logic described in annotation.

The <process> element is the top-level container for the business process logic. A business process is composed of a set of activities with defined ordering. The business process element contains a name attribute, which specifies the name of your business process. Lines of XML describe the nodes in your business process. A line of XML is written in this area of code for each node you add to your business process in the Design view.

Two-way editing is supported for the process language. In other words, changes you make to the code in this region of the Process.java file appear in the Design view. For example, you can:

WARNING: If you add any text within XML comment tags, or comment out sections of code, those lines of comments will disappear from the Source view the next time you make changes in the Design view. This only applies to comments, any other code changes remains.

Variables

Business process variables are defined within the region of code in the Source view.

Two-way editing is supported for variables. In other words, changes you make to the code in this region of the Java file appear in the Design view, specifically the Variables section on the Data Palette.

You can create, edit, or delete a business process variable in the Source view. The Variables tab on the Data Palette, is updated to reflect your changes. If the variable is not declared correctly, the error is identified in the Source view with red, wavy, underlines, and the variable does not appear on the Variables tab.

WARNING: Ensure that you update a given variable in all locations where it is used. If you do not, changes you make to the business process variable generates errors in your application.

Control Declarations

Declarations for controls are defined in the region of code in the Source view.

Two-way editing is supported for control declarations. In other words, changes you make to the code in this region of the Process.java file appear in the Design view.

You can create, edit, or delete a control declaration in the Source view. The Design view, specifically the Controls tab on the Data Palette, is updated to reflect your changes. If the control is not declared correctly, the error is identified in the Source View with red, wavy, underlines, and the control does not appear on the Controls tab.

WARNING: Changing declarations for controls already in use by your application generates errors in your application if you do not remove or update references to the control.

To learn about working with controls in the Design view, see Interacting With Resources Using Controls.

Client Operations and Control Communication Methods

Every client operation and communication method associated with a control is defined in its own collapsed region of code in the Source view. Code in these regions is generated automatically.

Can You Edit Code?

In the Source view, you can add and edit the code within the blocks of code that specify client operations and control methods.

After you add or edit the code b, the following icon is associated with the appropriate node (Client Request, Client Response, Control Send, Control Receive, Control Send with Return) in the Design view: Client Receive. Two-way editing is still supported. In other words, you can continue to design the node in either the Source view or the Design view. The icon (Client Receive) in the Design view is a visual reminder that you edited the code in the Source view.

For example your business process can include a Client Receive node that you configured using the Client Receive node builder. In the Design view, the node is displayed as shown Figure 25-1.

Figure 25-1 Client Receive

Client Receive

If you right-click the node and select View Code from the drop-down menu, your view is switched to the Source view at the appropriate method.

After you add your custom code, you can open the Design view by clicking the Design view tab. Note that the representation of the node associated with this code changed from:

Client Receive

You can make subsequent changes to the design of the node using either the Design view or the Source view. To learn about designing client and control operations in the Design view, see Interacting With Clients and Interacting With Resources Using Controls.

Perform Methods

Methods you create for Perform nodes and methods you write for conditions in Decision, For Each, or While nodes are shown outside (and below) the collapsed regions of code in the Java file in the Source view.

public void perform() throws Exception {
}

You can write code (perform methods) in the Source view to perform any logic you want. The Design view for your business process is not updated in keeping with your work on such perform methods until you create a reference to the methods in the Business Process Language.

To learn about creating Perform nodes in the Design view, see To Create a Perform Node in Your Business Process.

XQuery Statements

XQuery statements are written to the Java file in the region of code in the Source view.

The XQuery statements are preceded by the following annotation:

@com.bea.wli.common.XQuery

For example, when you select a repeating XML node using the For Each node builder, as described in Designing For Each Nodes, an XQuery expression is created in your Java file. The expression returns the set of XML elements over which the For Each node iterates. XQuery expressions are also written in your Process.java file when you create conditions on Decision nodes. XQuery expressions also define the transformations you create between disparate data types using the mapping tool.

To learn more about For Each nodes, Decision nodes, and data transformations, see the following topics:


  Back to Top       Previous  Next