This documentation is for WSO2 ESB version 4.5.0. View documentation for the latest release.

Mediation Library

Mediation Library (New in version 4.5) is a mechanism to group Templates and automatically expose it as a self contained set of function modules. It can be considered as a container consisting a set of templates grouped in a particular order. Currently a mediation library is shipped as a ".zip" file and should be deployed inside {$WSO2ESB_HOME}/repository/deployment/server/synapse-libs . If a given template container is successfully deployed, all templates within the library will be accessible to any user. 

Following is a sample skeleton structure of a mediation library.

Following are these components at an overview.

  • artifacts.xml - This contains mediation library name , package name information and template groupings(eg: template_dir-1, template_dir-2)
<artifacts>
    <artifact name="mediation.lib.name" package="mediation.lib.package.name">
        <dependency artifact="template.group.name"/>*
        <description>sample mediation library</description>?
    </artifact>
</artifacts>
  • artifact.xml - This contains information about each individual template group.

ie: - names of the templates in the group , corresponding configuration file ,etc

<artifact name="template.group.name" type="synapse/template">
    <subArtifacts>
        <artifact name="template.name">
            <file>template_file.xml</file>
            <description>a sample mediation library function</description>?
        </artifact>*
    </subArtifacts>
</artifact>
  • template_file.xml - This contains the implementation of each individual template configuration
  • lib - This is the directory to add any classes for class loading or can contain the .class files from the root level.


Also utilizing a mediation library is a three step process

1. Create and deploy the library

2. Importing the library into ESB

Users should deploy a import_lib_name.xml into {$WSO2ESB_HOME}/repository/deployment/server/synapse-configs/default/imports

<import xmlns="http://ws.apache.org/ns/synapse" name="mediation.lib.name" package="mediation.lib.package.name" />

note

Here the name="mediation.lib.name" and package="mediation.lib.package.name” must be the artifact name and the package name in the artifacts.xml file mentioned ealier. This is called the ‘qualified name' of the mediation library.

3. Execute functions of library using a template invoker.

Templates can be invoked through any entry point available in WSO2 ESB (proxy services and sequences). Target template is a combination of the package of mediation library and the target template name.

target = {mediation_lib_package_name}.{template_name}

<call-template target="mediation.lib.package.name.template.name">
    <with-param name="..." value="..."/>*
</call-template>

WSO2 ESB allows add, deleteimport mediation libraries and delete imports