bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

Programming BPM Client Apps

Monitoring Run-Time Variables

This section explains how to monitor run-time variables, including the following topics:

- Getting Workflow Instance Variables

- Setting Workflow Instance Variables

For information about monitoring run-time variables using the WebLogic Integration Studio, see Monitoring Workflows in Using the WebLogic Integration Studio.

Getting Workflow Instance Variables

To get a list of the variables associated with a workflow instance, use the following com.bea.wlpi.server.admin.Admin method:

>     public java.util.List getInstanceVariables(
>       java.lang.String instanceId
>     ) throws java.rmi.RemoteException,
>       com.bea.wlpi.common.WorkflowException

The following table describes the getInstanceVariables() method parameter for which you must specify a value.

Table 23-1 getInstanceVariables() Method Parameter

Parameter | Description | Valid Values
--- | --- | ---
instanceId | ID of the workflow instance for which you want to get variables. | Valid workflow instance ID. To obtain the workflow instance ID, you need to obtain the InstanceInfo object corresponding to the instance for which you want to get tasks, as described in Getting Workflow Instances. To get the instance ID, use the following com.bea.wlpi.common.InstanceInfo method: public final java.lang.String getId() Note: For more information about the methods available to the InstanceInfo object, see InstanceInfo Object.

The method returns a list of com.bea.wlpi.common.VariableInfo objects. To access information about each variable, use the VariableInfo object methods described in VariableInfo Object.

Note: For variables of type XML, the value returned is of type byte[]. In order to print or display the returned value, you must convert it to a String value. For example, the following code converts the variable value of type byte[] to a String value:
String value=new String((byte[])variable.getValue())

For example, the following code gets the variables for the workflow instance corresponding to the specified instance ID. In this example, admin represents the EJBObject reference to the Admin EJB.

>     List list = admin.getInstanceVariables(instance.getId());

The instance ID is obtained using the getInstanceId() method associated with the com.bea.wlpi.common.InstanceInfo object, instance. The instance object can be obtained using the methods described in Getting Workflow Instances.

For more information about the getInstanceVariables() method, see the com.bea.wlpi.server.admin.Admin Javadoc.

Setting Workflow Instance Variables

To set variables associated with a workflow instance, use one of the following com.bea.wlpi.server.admin.Admin methods:

>     public void setInstanceVariable(
>       java.lang.String templateDefinitionId,
>       java.lang.String instanceId,
>       java.lang.String variable,
>       java.lang.Object value
>     ) throws java.rmi.RemoteException,
>       com.bea.wlpi.common.WorkflowException

>     public void setInstanceVariables(
>       java.lang.String templateDefinitionId,
>       java.lang.String instanceId,
>       java.lang.String variables
>     ) throws java.rmi.RemoteException,
>       com.bea.wlpi.common.WorkflowException

The following table describes the setInstanceVariable() method parameters for which you must specify values.

Table 23-2 setInstanceVariable() Method Parameters

Parameter | Description | Description
--- | --- | ---
templateDefinitionId | ID of the template definition for which you set workflow instance variables. | Valid template definition ID. To obtain the template definition instance ID, you need to obtain the InstanceInfo object corresponding to the instance for which you want to set instance variables, as described in Getting Workflow Instances. To get the instance ID, use the following com.bea.wlpi.common.InstanceInfo method: public final java.lang.String getTemplateDefinitionId() Note: For more information about the methods available to the InstanceInfo object, see InstanceInfo Object.
instanceId | ID of the workflow instance corresponding to the task. | Valid workflow instance ID. To obtain the template definition instance ID, you need to obtain the InstanceInfo object corresponding to the instance for which you want to set instance variables, as described in Getting Workflow Instances. To get the instance ID, use the following com.bea.wlpi.common.InstanceInfo method: public final java.lang.String getInstanceId() Note: For more information about the methods available to the InstanceInfo object, see InstanceInfo Object.
variable | Name of the variable that you want to set. | Valid variable name. To get the variable name, use the following com.bea.wlpi.common.VariableInfo method: public final String getName() For information about getting the VariableInfo object, see Getting Workflow Instance Variables. For more information about the methods available to the VariableInfo object, see VariableInfo Object.
variables | Variable names and values. | Map object with key-value pairs, specifying variables to be set as a key, and the desired value as the value.
value | Desired value for the variable. | Value that is valid for the specified variable. For a list of supported conversions for the value parameter, see the com.bea.wlpi.server.admin.Admin Javadoc.

For example, the following code updates the specified variable, setting it to the specified value. In this example, admin represents the EJBObject reference to the Admin EJB.

>     admin.setInstanceVariable(
>        instance.getTemplateDefinitionId(),
>        instance.getInstanceId(),
>        variable.getName(),
>        value
>     );

The variable name is obtained using the getName() method associated with the com.bea.wlpi.common.VariableInfo object, variable. The variable object can be obtained using the method described in Getting Workflow Instance Variables. The template definition and workflow instance IDs are obtained using the methods associated with the com.bea.wlpi.common.InstanceInfo object, instance. The instance object can be obtained using the methods described in Getting Workflow Instances.

For more information about the com.bea.wlpi.common.VariableInfo and com.bea.wlpi.common.TaskInfo methods, see Value Object Summary.

For more information about the setInstanceVariable() and setInstanceVariables() methods, see the com.bea.wlpi.server.admin.Admin Javadoc.