|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Feature A Simple ADK for WLI's Business Process Management
A Simple ADK for WLI's Business Process Management
By: Andy Winskill
Mar. 26, 2002 12:00 AM
WebLogic Integration (WLI) consists of many application components, including a B2B application that manages business-to-business contracts during software conversation. To support the B2B application, WLI has a business process management (BPM) application for connecting business processes together. This used to be marketed as a discrete product, WebLogic Process Integrator (WLPI). The BPM application's ADK requires the application developer to understand the architecture of the BPM application. The ADK has a number of components whose use depends on the state of the workflow and the operation that's required. Interaction with the BPM ADK's components and objects leads to an application developer coding to a low level interface. This article outlines the design of a simple facade to the BPM ADK, providing a clean object interface that is, by intent, easy to use. It simplifies interaction with the BPM engine and ensures that changes in the underlying BPM implementation won't affect the ADK adversely. Access to the BPM application is solely via the publicized WLPI interface.
Using the Simplified ADK
Programming to the BPM ADK led to code that, while meeting the application requirements, was both difficult to read and hid my intent in low-level detail. When I programmed to the BPM ADK directly, there was a tendency to parse XML documents frequently and a lot of interaction with EJB components that didn't appear, at first glance, to have any direct responsibility for the operation I required. For example, the Admin EJB is responsible for finding out what tasks are available in a workflow and the Worklist EJB is responsible for executing the task in the workflow. In the WLI ADK, interaction with the workflow is indirect, with the workflow described by an InstanceInfo object. The InstanceInfo attributes are used in interactions with the Worklist component or the Admin component to effect a change in the workflow state. This led to code that was often difficult for a reader new to the BPM interface to understand, which caused me concern over the long-term maintenance of the code base. Using the facade design pattern, I produced a simplified ADK to the BPM application. The first step was to understand the main use cases and key entities that most BPM applications have. The use cases in many BPM clients are:
ADK Key Concepts
IUser
IWorkflowController
IWorkflow
In this ADK a workflow can have three main states: defined, running, and stopped. A defined workflow is defined within the BPM studio. It has tasks and may have workflow variables defined. Defined workflows can have instances created if the permissions of the workflow allow it. A workflow instance is a running workflow. Running workflows can have tasks waiting to be executed and may have workflow variables to set. A stopped workflow is a workflow instance that's been stopped. In this stopped state Workflow variables can be read, but their values can't be set.
Variables
Tasks
Use-Case Model
Use-Case Realizations
Starting A Workflow With Variable
The IWorkflowController creates a list of IWorkflow objects depending on whether the client requires a new workflow started or an existing workflow. Creation of WLIWorkflow objects is only via the IWorkflowController interface and the class WLIWorkflowController, shown in Figure 5, realizes this interface. The workflow controller is responsible for generating lists of workflows based on the user's permissions. How the permissions affect the starting of a workflow is dependent on the underlying workflow engine. A WLI user can belong to multiple organizations with one organization specified as the user's default organization. For this iteration of the ADK I decided that the WLIWorkflowController would only access workflows in the user's default organization. An instance of WLIWorkflowController is normally created with a WLIUser object specified. The WLIUser class acts as a facade to the underlying WLIPrincipal remote interface and UserInfo class. It creates an association to the underlying UserInfo object. I decided to keep the IUser interface simple since it focuses on the use cases described above.
ADK Code Walk
In line 1 a WLIUser object is created and the J2EE connection information is supplied, along with the organization that the user will belong to for this interaction. The J2EE connection information object is a data structure for holding all properties required to open the JNDI initial context. At line 2 the WLIWorkflowController is created for the user. Line 3 illustrates the use of the workflow controller to get the workflows that are available to the user. Lines 4 through 7 are interactions with the user. In line 8 I create a WorkflowVariable that's an instance of XMLWfVar (XML Workflow Variable) and in line 9 a value for the variable is set. Line 10 introduces the concept of the VariableFormatter, discussed below. The workflow variable is associated with the workflow in line 12. Finally, the workflow is started.
WLI Implementation
WLIUser
theUserInfo = principal.getUserInfo(userId); returns a state object of class UserInfo. The WLIUser object caches this state, and maintains the reference to the WLPIPrincipal. Access to the WLPIPrincipal cache is available to other classes in the Java package.
WLIWorkflowController
The WLIWorkflowController passes a reference to the BPM's Admin EJB to the WLIWorkflow on construction of the WLIWorkflow. This EJB is used to control access to the workflow variables. To access running WLI workflows the client would use the method WLIWorkflowController.getRunningWorkflows(). The code snippet below shows the mechanism used within the ADK. Access to running workflows in the WLI ADK is not via the Worklist EJB, but rather by the Admin EJB.
instanceList = To find a running workflow, the ADK must first find workflows that the user can start. Once the list of workflows that can be started is created, the ADK queries the Admin EJB to find out which workflow templates have running instances. The simplified ADK hides the client from this complexity.
WLIWorkflow
Should the workflow be running, the WLIWorkflow object must be created with a reference to a com.bea.wlpi.common.InstanceInfo object. This contains state information about the workflow and is used by the WLIWorkflow object to access task information. Starting a workflow in WLI is achieved in one of two ways. The mechanism depends on if the workflow has had variables associated with it. I wanted to hide this from my ADK's clients. If we have a workflow in a defined (nonstarted) state, the WLIWorkflow object starts the workflow as follows:
wList.instantiateWorkflow( The instantiateWorkflow() method in com.bea.wlpi.server.worklist.Worklist is used, and has the organization and the template identifier passed to it. To me, this mechanism doesn't manipulate workflows; rather, it relies on the client to track template identifiers and organizations. I wanted to hide this level of detail from the ADK's clients; treating the Workflow as an entity in the design allowed me to use the facade pattern to abstract the client away from the underlying WLI complexity. The importance of this is further underlined when setting variables in running workflows or manipulating tasks. If the workflow has variables to be passed to it before starting, the ADK's clients need to have invoked setVariable on the WLIWorkflow object. The workflow object caches the variables in a HashMap, which is then passed to the overloaded instantiateWorkflow() method defined in com.bea.wlpi.server.worklist.Worklist.
Variables
In the Worklist EJB, passing a hashmap of the variable objects to the instantiateWorkflow() method sets the input variables. The keys to the hash map are used for the variable names; the object in the hash map is used for the variable value. In the Admin interface, the method below can be used:
admin.setInstanceVariable I wanted the clients to be abstracted from the complexity required to support multiple variable formats. The Mediator pattern was an excellent solution for this required decoupling. Now the client can set a workflow variable on a workflow and the client doesn't need to be aware of the underlying mechanism that the BPM requires, or the format of the workflow variable. The client needs only to associate the correct variable formatter with the variable.
Tasks
In the ADK, tasks can have one of the following states: started, completed, or inactive. WLI has an overdue state which isn't currently supported. An inactive task is one that's defined in the BPM, but the preconditions for its starting haven't yet been met. A started task is one where all of its preconditions are met and the automatic processing of the task's actions has started. A completed task has completed all of its actions and been marked done. Marking a task as done can trigger additional processing within the task. For this reason, we execute a task within the ADK. This signifies that there may be processing yet to be done. Once the task is executed (all actions are performed) then the task is completed. Access to a WLI workflow's tasks is via the com.bea.wlpi.server.admin.Admin EJB using the method: List lst = admin.getInstanceTasks(instanceInfo.getId()); This method returns a list of com.bea.wlpi.common.TaskInfo objects. As a workflow has tasks, I did not want to expose the Admin EJB to the ADK's clients. Using the IWorkflow::getTasks() method, the client can access tasks directly from the workflow object. This method will return a list of ITask objects. Once the client has the task object it can manipulate the task without having any dependency on the Admin EJB. Executing the task requires an interaction with the com.bea.wlpi.server.worklist.Worklist EJB. The method used within the simple ADK is shown below:
wList.taskExecute(taskInf.getTemplateDefinitionId(), Currently, the WLITask doesn't have any method for waiting for task completion. The WLI BPM application is designed to support tasks that are very long running, spanning days or months. I've stayed away from specifying this behavior in the task interface. Should ADK clients require this functionality, then I believe they should be aware of the implications!
Conclusion
BEA WEBLOGIC LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||