JBossWiki : JbpmBpelCustomFunctions
Wiki Home: JbpmBpelCustomFunctions [EN]
[Permalink]
[Recent Changes]
[History]
[RSS Feed][RDF Feed][Atom Feed][Print]

XPath in BPEL processes

The BPEL 2.0 spec requires support of XPath 1.0 as the query and expression language of BPEL processes. It provides extension points to support other languages as well.

The XPath 1.0 spec defines a core function library that implementations must always include in the context of evaluation. It further allows custom functions to be available as well. BPEL 2.0 itself specifies a few functions to aid in describing business process behavior. It is common for BPEL implementations to provide extension functions and devise a mechanism for users to add their own functions. The next section describes such mechanism for jBPM BPEL.

Introducing Jaxen

jBPM BPEL uses the Jaxen engine for XPath expression evaluation. The Jaxen documentation includes a guide to writing extension functions. The guide has two parts. The first part tells how to write a class that represents a function. The second tells about installing the function into Jaxen programatically.

Both parts apply to jBPM BPEL, although the product provides an alternate, declarative way to install functions into Jaxen. To use it, examine the jbpm.cfg.xml file supplied with the jBPM BPEL distro (1.1 GA and later). Notice the following entries:

<string name="resource.expression.functions" value="org/jbpm/bpel/sublang/xpath/expression.functions.xml" />
<string name="resource.join.condition.functions" value="org/jbpm/bpel/sublang/xpath/join.condition.functions.xml" />
<string name="resource.query.functions" value="org/jbpm/bpel/sublang/xpath/query.functions.xml" />

These entries point to classpath resources within jbpm-bpel.jar which enumerate the functions available to expressions, join conditions and queries. To install additional functions:

  1. copy the functions resource you want to extend to a new file
  2. declare the function in the new file
  3. put the new file in the classpath
  4. point to the new classpath resource from jbpm.cfg.xml

The functions XML file

Let's take expression.functions.xml as example.

<functionContext class="org.jaxen.XPathFunctionContext"
  xmlns:bpel11="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
  xmlns:bpel2="http://schemas.xmlsoap.org/ws/2004/03/business-process/">

  <function name="bpel11:getVariableData" class="org.jbpm.bpel.sublang.xpath.GetVariableDataFunction" />
  <function name="bpel11:getVariableProperty" class="org.jbpm.bpel.sublang.xpath.GetVariablePropertyFunction" />
  <function name="bpel2:getVariableProperty" class="org.jbpm.bpel.sublang.xpath.GetVariablePropertyFunction" />

</functionContext>

The table below describes the relevant information items in the file above.

Information ItemDescription
/functionContext/@classThe org.jaxen.FunctionContext implementation to instantiate. The implementation used here, org.jaxen.XPathFunctionContext, provides the XPath core function library.
/functionContext/function/@nameThe qualified name that identifies a function.
/functionContext/function/@classThe Java class that implements a function. As described in the Jaxen guide, this class must implement org.jaxen.Function.


Other languages:

Log in to make links between pages

The page last changed on Fri Jul 27 16:13:56 EDT 2007 by alex.guizar@jboss.com