Using Configuration Properties

To make an Integration Flow reusable and generic, all properties that are tenant-specific have to be marked as tenant-specific Configuration Properties in the Integration Flow. Each Configuration Property has to be provided with metadata (e.g. name, type, default value) to ensure that proper values can be filled in during deployment and that validation of configuration values can be applied. Under the hood, Configuration Properties for an Integration Flow are saved as JSON configuration metadata, further explained in Integration Flow Configuration Properties Metadata.

Suppose there are a few Configuration Properties in the metadata of an Integration Flow version:

{
  "integrationFlow": {
    "integrationFlowId": "d1f1b0ed-1241-41f9-beda-553e83561824",
    ...
  },
  "configurationProperties": [{
    "name": "secretAlias",
    "type": "STRING",
    "displayName": "Vecozo secret alias",
    ...
  }, {
    "name": "vecozoUrl",
    "type": "HTTP_URL",
    "displayName": "URL to Vecozo service",
    ...
  }]
}

These configuration properties will be filled @deployment time for a tenant. Suppose deployment looks as follows:

image.png

These configuration property values can be used; - within an Integration Flow definition (e.g. for routing purposes); and - within transformations.

How to use configuration properties in Integration Flow definition

Configuration Properties can be applied as property placeholders within the Integration Flow definition. You can define configuration properties using double curly brackets in most places in integration-flow.xml. Some examples below:

<route id="http-call-route" errorHandlerRef="eh-http">
    <from id="from-main" uri="direct:http-call-route"/>
    <setHeader id="set-certHeaderName-header" name="certHeaderName">
        <constant>{{secretAlias}}</constant>
    </setHeader>
    <setHeader id="set-Content-Type-header" name="Content-Type">
        <constant>text/xml; charset=utf-8</constant>
    </setHeader>
    <setHeader id="set-SOAPAction-header" name="SOAPAction">
        <constant>http://schemas.vecozo.nl/VZ801802/v1/Controleer</constant>
    </setHeader>
    <to id="request-transformation" uri="u4xslt:xslt/request.xsl" />
    <to id="http-call" uri="{{vecozoUrl}}?aliasHeader=certHeaderName&amp;bridgeEndpoint=true" />
</route>

At runtime these placeholders will be replaced with the values of the corresponding Configuration Properties from the Deployment.

How to use configuration properties in transformations

Option 1: Functions in u4xslt component

To use configuration properties in XSLT transformations, you can use U4XSLT Component (u4ik-camel-xslt). The u4xslt: component is an extension of the xslt: component provided in camel. The u4xslt: component allows you to process a message using an XSLT template. This can be ideal when using templating to generate responses for requests. The u4xslt: component has a base library of SAXON Java Extension Functions loaded by default for content enrichment purposes.

The URI format for u4xslt: component is u4xslt:templateName[?options]. The URI format contains templateName, which can be one of the following: the classpath-local URI of the template to invoke the complete URL of the remote template.

You can append query options to the URI in the following format: ?option1=value&option2=value&...

Refer to the Spring Documentation for more detail of the URI syntax.

Example URIs :

URI Description
u4xslt:com/acme/mytransform.xsl Refers to the file com/acme/mytransform.xsl on the classpath
u4xslt:file:///foo/bar.xsl Refers to the file /foo/bar.xsl
u4xslt:http://acme.com/cheese/foo.xsl Refers to the remote http resource

The u4xslt: component has a library containing builtin functions for content enrichment purposes. Java Extension Functions from Saxon are used to implement this functionality. These functions are able to access and retrieve java-properties that are used for e.g. tentant-specific configuration. To use the builtin function one needs to reference component and XSLT in the Integration Flow.

For configuration properties, two functions are supported: - Function "get-property-value": The function get-property-value can be used to retrieve configuration property values that are set in the Deployment or at runtime. Use following syntax to apply the Camel function get-property-value: ext:get-property-value(key as xs:string) The key argument is used to select the value (java properties dot notation). When key is not available as a configuration property, the function will return an empty string "".

IMPORTANT: To use the function in the XSLT add namespace xmlns:ext = "http://extension.unit4.com to the XSLT. Also, don't forget to prefix the function with the namespace ext. The arguments of the function are of type xs:string. Make sure you provide the function with string values as arguments. The result of the function will always be of type xs:string or xsl:sequence

Examples

Example XSLT using get-property-value:

<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:ext = "http://extension.unit4.com"
    exclude-result-prefixes="xs">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/">
        <root>
            <xsl:value-of select="ext:get-property-value('secretalias')" />
        </root>
    </xsl:template>
</xsl:stylesheet>

Option 2: Using headers and params

Using setHeader variables in an Apache Camel route, they can be used as input params to an XSLT file. This way, Configuration Properties can also be applied within an XSLT.

NOTE: In the example Integration Flow definition above, value of Configuration Property "secretAlias" from the tenant's deployment will be put into header "certHeaderName". A header is available as a param in XSLT, the XSLT just needs to declare it at the top level for it to be available.

Example transformation (XSLT):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:system="java:java.lang.System" 
  exclude-result-prefixes="system unit4java xsl">

  <xsl:output method="xml" indent="yes"/>

  <xsl:param name="certHeaderName"/>

  <xsl:template match="/">

    <participant>
      <AssignedDevice>
        <Organization>
          <id root="2.16.528.1.1007.3.3">
            <xsl:attribute name="extension">
              <xsl:value-of select="$certHeaderName"/>
            </xsl:attribute>
          </id>
        </Organization>
      </AssignedDevice>
    </participant>

  </xsl:template>
</xsl:stylesheet>

This way, values of Configuration Properties can be used in transformations.