This project has retired. For details please refer to its Attic page.
Apache ODE – External Variables

External Variables

External Variables

Declaring External Variables in the Process Definition

External variables are only available on ODE 1.2+

Syntax:

<scope>
   <variables xmlns:xvar=" http://ode.apache.org/externalVariables">
     <variable name="ext-var-name" element="ext-var-type" xvar:id="ext-var-id">
        <xvar:key-map key="key-id">*
            <expression>key-expression</expression>
        </xvar:key-map>
     </variable>
    </variables>
</scope>

External variables are declared in the <variables> section of the <scope> element, just like normal variables. However, unlike regular variables, external variables must specify the additional xvar:id attribute. This attribute identifies the variable as an external variable and links the external variable's declaration to the external variable's configuration in the deployment descriptor.

In addition to this attribute, an external variable may also define a set of key mappings by nesting xvar:key-map elements within the declaration. The key mappings are a collection of name-expression pairs that is used to create a composite key (identity) for the external variable. This composite key is used to retrieve the correct "instance" of the variable from the underlying storage. The key mappings are BPEL expressions ( i.e. XPath expressions) that are evaluated once, at the time that the scope is instantiated. Therefore, the "identity" of an external variable is determined during scope creation, and cannot be changed by the process (for qualifications see Incomplete Keys below).

Finally, any external variables must be of an "element" type, with a schema conforming to the requirements of the underlying storage mechanism.

Consider the following example:

process.bpel
...
<scope>
  <variables>
    <variable name="customer" element="myns:CustomerElement" xvar:id="customer1" >
       <xvar:key-map key="customer-id">
           <expression>$order/customerid</expression>
       </xvar:key-map>
    </variable>
  </variables>
</scope>
...

In the above, the "customer" variable is an external variable. The key for the external variable is derived from the value of the customerid element in the "order" variable. Note that the "order" variable must be declared in a scope above the scope declaring the "customer" external variable, otherwise it would not be possible to resolve the identify of the "customer" variable. In this scenario, the external variable can be "read" even if it was never assigned to in the process.

Incomplete Keys

It is not required that the full identity of the external variable be resolved at scope creation. For example, an external variable may correspond to a database row where the identity is generated by the database during an insert operation. In such a scenario the key mapping can be omitted, and the identity of the external variable will be unknown until the variable is assigned to. Any attempt to access the variable before the first assignment will result in an uninitialized variable fault. In general it is possible to specify external variables where some portions of the identity are determined using the key mappings and some using some other (implementation-specific) mechanism. In any case, if when the variable is read, the key is incomplete an uninitialized variable fault will result.

JDBC Mapping

External Variables - JDBC Mapping

REST Mapping

[External Variables - REST Mapping] TODO