bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

Programming BPM Plug-Ins

BPM Plug-In Sample

This section describes the BPM plug-in sample in detail. It includes the following sections:

- Plug-In Sample Contents

- Using the Plug-In Sample

Plug-In Sample Contents

The BPM plug-in sample provides a set of plug-in classes that represent common plug-in scenarios, and is provided with the software in the SAMPLES_HOME/integration/samples/bpm_api/plugin/src/com/bea/wlpi/tour/po/plugin directory. The sample includes two workflow templates, Plug-in Order Processing and Plug-in Order Fulfillment. Excerpts from the plug-in sample are referenced throughout this document.

Note: The plug-in sample is loosely based on a generic Web-based sales order scenario that is described in detail in Introduction to WebLogic Integration and the Example Workflows in Learning to Use BPM with WebLogic Integration.

The following table describes the plug-in sample, shown in the figure Plug-In Sample Workflow Templates, listing the workflow component and the associated example source files located in the SAMPLES_HOME/integration/samples/bpm_api/plugin/src/com/bea/wlpi/tour/po/plugin directory. Workflow components 1 through 3 are provided as part of the Plug-in Order Processing workflow template. Workflow components 4 and 5 are provided as part of the Plug-in Order Fulfillment workflow template.

Table 10-1 Plug-In and Related Source File Descriptions

# | Workflow Component | Description | Related Source File(s)
--- | --- | --- | ---
1 | Start Node | Triggered by the plug-in event, Start Order, to start workflow upon receipt of a plug-in message type (semicolon -delimited text string). | StartObject.java: Implements the PluginObject interface to read the plug-in data in XML format. StartNodeData.java: Implements the PluginData interface to read and save data pertaining to the Start node. StartNodePanel.java: Defines the PluginTriggerPanel class to display the plug-in GUI component in the design client. StartNode.java: Defines the plug-in run-time component class to specify the execution information. OrderField.java: Defines the plug-in field to access the plug-in data that is associated with the plug-in external event, Start Order.
2 | Action: Check Inventory | Checks available inventory for an item. | CheckInventoryActionObject.java:Implements the PluginObject interface to read the plug-in data in XML format. CheckInventoryActionData.java: Implements the PluginActionData interface to read and save plug-in action data in XML format. CheckInventoryActionPanel.java: Defines the PluginTriggerPanel interface to display the plug-in GUI component in the design client. CheckInventoryAction.java: Defines the run-time component class to specify the execution information.
3 | Event Node: Wait for Confirmation | Triggered by plug-in event, Confirm Order Event, to pause a workflow until the receipt of a plug-in message type (semicolon -delimited text string). | EventObject.java: Implements the PluginObject interface to read the plug-in data in XML format. EventNodeData.java: Implements the PluginData interface to read and save data pertaining to the Event node. EventNodePanel.java: Defines the PluginTriggerPanel class to display the plug-in GUI component in the design client. EventNode.java: Defines the plug-in run-time component class to specify the execution information. ConfirmField.java: Defines the plug-in field to access the plug-in data that is associated with the plug-in external event, Confirm Order.
4 | Function: CalculateTotalPrice | Calculates total price of an order based on an item number, quantity, and state/province of the shipping destination. | CalculateTotalPriceFunction.java: Implements the execution information to calculate the total price of an order using the item ID, quantity, and the state and/or province of the order. The state and/or province is used to look up the sales tax rate.
5 | Action: Confirm Order Fulfillment | Generates an event message to trigger a Confirm Order Event node. | SendConfirmObject.java: Implements the PluginObject interface to read the plug-in data in XML format. SendConfirmActionData.java: Implements the PluginActionData interface to read and save plug-in action data in XML format. SendConfirmActionPanel.java: Implements the PluginTriggerPanel interface to display the plug-in GUI component in the design client. SendConfirmAction.java: Implements the PluginAction interface to define the execution information.

The following table defines the additional source files that exist in the SAMPLES_HOME/integration/samples/bpm_api/plugin/src/com/bea/wlpi/tour/po/plugin directory.

Table 10-2 Additional Plug-in Sample Source Files

File | Description
--- | ---
Sample.gif | Custom icon that appears in the upper-right corner of the Start and Event nodes that contain customized plug-in properties when the WebLogic Integration Studio interface view is enabled. You can specify a custom plug-in icon when creating the remote plug-in object interface, as described in Plug-In Home Interface.
SampleBundle.java | Bundle of localized resources.
SamplePlugin.properties | Resource strings.
SamplePluginBean.java | Plug-in session EJB.
SamplePluginConstants.java | Plug-in constants file.
StartOrderDriver.java | Driver for triggering order processing.

Using the Plug-In Sample

The plug-in sample is ready to use out-of-the-box. For your convenience, the plug-in sample JAR, WAR, and deployment descriptor files are deployed to the appropriate directories when you install WebLogic Integration.

The following sections describe how to import and run the sample plug-in.

Importing the Plug-In Sample

To import the plug-in sample, use the Studio import package tool. The Studio import package tool enables you to import a workflow package, in the form of a JAR file, that can contain one or more of the following objects: templates, template definitions, event keys, and business operations.

To import the plug-in sample package:

1. Start BEA WebLogic Integration using the samples domain, as described in "Configuring and Starting the Samples Domain" in Getting Started in Starting, Stopping, and Customizing BEA WebLogic Integration.

2. Invoke the Studio design client.

   For more information, see Using the WebLogic Integration Studio.

3. Choose Tools—>Import Package.

   The Import wizard Select File dialog box is displayed.

4. Click Browse and navigate to the SAMPLES_HOME/integration/samples/bpm_api/plugin directory to open the file sample_plug_in.jar.

5. Click Next.

   The Select Components to Import dialog box appears.

6. Set the target organization to CDExpress.

   All workflow objects in the import file are selected by default.

7. Select the Activate workflows after import check box in order to activate the plug-in sample workflows.

   Note: You must activate a workflow before you can run it. Alternatively, you can activate a workflow after it has been imported, as described in Using the WebLogic Integration Studio.

8. Click Import to import the entire package, consisting of templates, template definitions, business operations, and event keys.

   The Review Import Summary dialog box appears with a summary of the objects imported.

9. Click Close to close the dialog box.

   The imported templates and template definitions now appear in the folder tree.

For more information about importing and exporting workflow packages, see Importing and Exporting Workflow Packages in Using the WebLogic Integration Studio.

Running the Plug-In Sample

The plug-in sample can be run by triggering the Plug-in Order Processing workflow template using a plug-in-defined event. For your convenience, a generic driver file, StartOrderDriver.java, is provided in the SAMPLES_HOME/integration/samples/bpm_api/plugin/src/com/bea/wlpi/tour/po/plugin directory. This driver generates a plug-in defined event that supplies the Plugin Order Processing workflow with the customer order information. This information is stored in the Plugin Order Processing workflow variables and is used to process the order.

Note: The Worklist client application is being deprecated as of this release of WebLogic Integration. For information about the features that are replacing it, see the BEA WebLogic Integration Release Notes.

To run the example:

1. Start BEA WebLogic Integration, if it is not already started.

2. Start the BPM Worklist tool, and log on using the following login and password:

   - Login: admin

   - Password: security

   The admin user has been defined as a member of all of the roles used in the sample workflows. For more information, see "Logging On to the Worklist Application" in Executing and Monitoring the Example Workflows in Learning to Use BPM with WebLogic Integration.

   You will need to interact with the plug-in sample using the Worklist tool.

3. Select the CDExpress organization from the drop-down list in the Worklist tool.

4. Execute the StartOrderDriver:

   1. On Windows, run the WL_HOME\samples\integration\samples\bpm_api\plugin\StartOrder.cmd script.

   2. On UNIX, execute the following commands to set the environment and CLASSPATH variable, and execute the StartOrderDriver script:

   >     $SAMPLES_HOME/setenv.sh
   >     CLASSPATH=
   >     $WL_HOME/lib/weblogic.jar:$SAMPLES_HOME/integration/samples/lib/wlpi-ejb.jar:
   >        $SAMPLES_HOME/integration/samples/lib/sampleplugin-ejb.jar
   >     $JAVA_HOME/bin/java -classpath "$CLASSPATH"
   >        com.bea.wlpi.tour.po.plugin.StartOrderDriver
   >        t3://localhost:7001 joe password

   The Check Customer Credit task appears in the admin user task list.

5. Double-click the Check Customer Credit task to execute it.

   The Credit Check message box appears.

6. Click Yes to mark the task as done.

   The next task, Start Order Fulfillment, automatically starts the Order Fulfillment subworkflow.

7. Select the Shipping tab and double-click the Ship Order task to execute it.

   The Ship Order task is executed.

8. Select the Accounting tab and double-click the Generate Invoice task to execute it.

   The following tasks are performed:

   - Generate Invoice task is executed and marked as done.

   - Calculate Total Price business operation calculates the total price of the order and returns the value to the Order Processing workflow.

   - Confirm Order Fulfillment task is automatically executed.

   At this point, the business process is complete.