Package bexee.model.xmltobpel

This package contains BPEL process element and activity factories used by the Digester.

See:
          Description

Class Summary
AbstractObjectCreationFactory This class should be used as superclass by all classes wishing to transform BPEL xml elements into corresponding objects.
AssignImplFactory This class is used by the Digester for the transformation of Assign activities from a BPEL document into AssignImpl objects.
BpelCaseImplFactory This class is used by the Digester for the transformation of Switch Case elements from a BPEL document into BpelCaseImpl objects.
BPELElementFactory This is a factory for the creation of BPEL process elements.
CorrelationsImplFactory This class is used by the Digester for the transformation of Correlations elements from a BPEL document into CorrelationImpl objects.
FromImplFactory This class is used by the Digester for the transformation of From elements from a BPEL document into FromImpl objects.
InvokeImplFactory This class is used by the Digester for the transformation of Invoke activities from a BPEL document into InvokeImpl objects.
PartnerLinkImplFactory This class is used by the Digester for the transformation of PartnerLink elements from a BPEL document into PartnerLinkImpl objects.
ProcessImplFactory This class is used by the Digester for the transformation of a process from a BPEL document into a ProcessImpl object.
ReceiveImplFactory This class is used by the Digester for the transformation of Receive activities from a BPEL document into ReceiveImpl objects.
ReplyImplFactory This class is used by the Digester for the transformation of Reply activities from a BPEL document into ReplyImpl objects.
SwitchImplFactory This class is used by the Digester for the transformation of Switch activities from a BPEL document into SwitchImpl objects.
ToImplFactory This class is used by the Digester for the transformation of To elements from a BPEL document into ToImpl objects.
VariableImplFactory This class is used by the Digester for the transformation of Variable elements from a BPEL document into VariableImpl objects.
 

Package bexee.model.xmltobpel Description

This package contains BPEL process element and activity factories used by the Digester.

BPEL document transformation (XML-OO mapping)

Rationale and description

A deployed BPEL document needs to be transformed in a tree structure of objects representing a BPEL process type. Bexee will then use such a tree structure for the execution of processes. This transformation is a XML to OO mapping and within bexee this task is accomplished with the Jakarta Digester tool http://jakarta.apache.org/commons/digester/.

Briefly, the Digester is configured with an xml mapping description which describes how xml elements contained in BPEL documents will be mapped to the correspondent BPEL activities and elements. For the creation of activity, Digester is configured to use factories. Each activity type has its own specialized factory. In the following showing the usage of Digester and the creation of BPEL process types, this mapping description is called "bpel-rules.xml".

            Digester overwiev
          

It is possible to let Digester create the objects without using specialized factories, but in the case of bexee it is advantageous to use this customized technique. BPEL activities have complex properties and it is easier to create those properties with specialized factories. In addition, BPEL activities and elements reference other elements, e.g. variables from the same BPEL process type. It is therefore necessary to find other elements (variables, partner links, etc.) and associate them with some activities in the BPEL process.

          
            Elements references
          

In order to be able to find other elements and activities existing in a BPEL process type, the factories used by Digester don't create process elements themselves, but delegate this task to a BPELElementFactory. Such a factory exist once per BPEL process, therefore all specialized activity and element factories used by Digester use the same BPELElementFactory, which exists once per BPEL process type. Every process element is registered at creation and can thus be found once referenced in an activity at a later time of BPEL document parsing.

            BPELElementFactory
          


Code and configuration excerpts

Following an excerpt from the Digester xml-oo mapping description "bpel-rules.xml"

"bpel-rules.xml"

          
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE digester-rules SYSTEM "http://bexee.sourceforge.net/dtd/digester-rules.dtd">
<digester-rules>
  <!--  -->
  <!-- parsing the Process -->
  <!--  -->

  <pattern value="process">
    <factory-create-rule classname="bexee.model.xmltobpel.ProcessImplFactory"/>
    <!--  -->
    <!-- parsing the PartnerLinks -->
    <!--  -->
    <pattern value="partnerLinks">

      <object-create-rule classname="bexee.model.elements.impl.PartnerLinksImpl"/>
      <pattern value="partnerLink">
        <factory-create-rule classname="bexee.model.xmltobpel.PartnerLinkImplFactory"/>
        <set-next-rule methodname="addPartnerLink"/>
      </pattern>
      <set-next-rule methodname="setPartnerLinks"/>

    </pattern>
    <!--  -->
    <!-- parsing the Variables -->
    <!--  -->
    <pattern value="variables">
      <object-create-rule classname="bexee.model.elements.impl.VariablesImpl"/>

      <pattern value="variable">
        <factory-create-rule classname="bexee.model.xmltobpel.VariableImplFactory"/>
        <set-next-rule methodname="addVariable"/>
      </pattern>
      <set-next-rule methodname="setVariables"/>
    </pattern>

  <set-next-rule methodname="setProcess"/>
  </pattern>
  <!--  -->
  <!-- parsing the sequence -->
  <!--  -->
  <pattern value="*/sequence">

    <object-create-rule classname="bexee.model.activity.impl.SequenceImpl"/>
    <set-properties-rule />
    <set-next-rule methodname="activity"/>
  </pattern>
  <!--  -->
  <!-- parsing receive -->

  <!--  -->
  <pattern value="*/receive">
    <factory-create-rule classname="bexee.model.xmltobpel.ReceiveImplFactory"/>
    <set-next-rule methodname="activity"/>
  </pattern>
  <!--  -->

  <!-- parsing invoke -->
  <!--  -->
  <pattern value="*/invoke">
    <factory-create-rule classname="bexee.model.xmltobpel.InvokeImplFactory"/>
    <set-next-rule methodname="activity"/>
  </pattern>

</digester-rules>
          

The java code for a factory responsible for the creation of a Receive BPEL activity:

"ReceiveImplFactory.java"

          
public class ReceiveImplFactory extends AbstractObjectCreationFactory {

    public Object createObject(Attributes attributes) throws Exception {

        BPELElementFactory elementFactory = BPELElementFactory
                .getInstance((BPELProcess) getDigester().getRoot());

        String partnerLink = attributes.getValue(PARTNER_LINK);
        String portType = attributes.getValue(PORT_TYPE);
        String operation = attributes.getValue(OPERATION);
        String variable = attributes.getValue(VARIABLE);
        String createInstance = attributes.getValue(CREATE_INSTANCE);

        return elementFactory.createReceive(getStandardAttributes(attributes),
                partnerLink, portType, operation, variable, createInstance);
    }
}
          

As already mentioned, the activity factory only delegates the creation of an Activity to the BPELElementFactory, following an excerpt from this element factory:

"BPELElementFactory.java"

          
public class BPELElementFactory {

    ...
    ...
    ...          
          
    private Map variables = new Hashtable();

    public Variable createVariable(String name, String messageType,
            String type, String element) {

        Variable variable = new VariableImpl();

        variable.setName(name);
        variable.setMessageType(expandToQName(messageType));
        variable.setType(expandToQName(type));
        variable.setElement(expandToQName(element));

        variables.put(name, variable);

        return variable;
    }
          
    public Object createReceive(StandardAttributes standardAttributes,
            String partnerLinkName, String portTypeString, String operation,
            String variableName, String createInstance) {

        PartnerLink partnerLink = retrievePartnerLink(partnerLinkName);
        QName portType = expandToQName(portTypeString);
        Variable variable = retrieveVariable(variableName);

        Receive receive = new ReceiveImpl(standardAttributes, partnerLink,
                portType, operation, variable, createInstance);

        return receive;
    }

    public Variable retrieveVariable(String variableName) {
        if (StringUtils.isNullOrEmpty(variableName)) {
            return null;
        }
        return (Variable) variables.get(variableName);
    }
    
    ...
    ...
    ...
          


Pawel Kowalski
Last modified: $Revision: 1.1 $, $Date: 2004/12/15 14:18:09 $



Copyright © 2004 Berne University of Applied Sciences. All Rights Reserved.