Access Keys:
Skip to content (Access Key - 0)
community header community tab mule tab ibeans tab muleforge tab

User guide

Version: 1.1

Table Of Contents


Introduction

This is the user guide for the Smooks for Mule module. The Smooks for Mule
module has two different versions. One for Mule 1.4.x and one for Mule 2.1.x. Both versions currently have almost the same features.

Note that this user guide does not explain Smooks itself. The Smooks project has it's own User Guide for that. You can find it here.

Installation

There are installation packages for both the Mule 1.4.x and Mule 2.1.x versions of the Smooks for Mule module. Go to the Download page to download the package for the Mule version that you need. Take a look at the README.txt file for the installation instructions.

Configuration

The following sections explain the configuration options for the components. The configuration options for the Mule 1.4.x and Mule 2.1.x versions are the same.

For Mule 2.1.x the Smooks for Mule module provides a Mule configuration XML Schema. The namespace and schema location are as followed:
Namespace: http://www.muleforge.org/smooks/schema/mule-module-smooks/1.1
Schema location: http://dist.muleforge.org/smooks/schema/mule-module-smooks/1.1/mule-module-smooks.xsd

Transformer Configuration

Mule 1.4.x

The transformer is configured in your Mule Xml configuration file as follows:

mule-config.xml
<transformers>
    <transformer name="SmooksTransformer" className="org.milyn.smooks.mule.Transformer">
            <properties>
                <property name="configFile" value="smooks-config.xml"/>
            </properties>
     </transformer>
</transformers>

And then specified for the inbound and/or outbound routers like this:

mule-config.xml
<inbound-router>
    <endpoint address="stdio://System.in" transformers="SmooksTransformer"/>
</inbound-router>

Mule 2.1.x

The transformer is configured in your Mule Xml configuration file as follows:

mule-config.xml
<smooks:transformer name="smooksTransformer" configFile="/transformer-smooks-config.xml" />

And then specified for the inbound and/or outbound routers like this:

mule-config.xml
<inbound>
    <vm:inbound-endpoint path="messageInput" transformer-refs="smooksTransformer"/>
</inbound>

Configuration Properties (Mule version independent)

Property Description
configFile The Smooks configuration file. Can be a path on the file system or on the classpath.
resultType Type of result expected from Smooks ("STRING", "BYTES", "JAVA", "RESULT", "NORESULT"). When setting the value to "JAVA" then you can set the "javaResultBeanId" attribute. When setting the value to "RESULT" then one of the "resultClass" or "resultFactoryClass" attributes must also be set. Default is "STRING".
javaResultBeanId The BeanId from which the Object is used as message payload if the resultType is set to "JAVA".
resultClass When the resultType is set to "RESULT" then this attribute defines the Result Class which will be used. The class must implement the "javax.xml.transform.Result" interface and must have an argumentless constructor.
resultFactoryClass When the resultType is set to "RESULT" then this attribute defines the ResultFactory Class which will be used to create the Result Class. The class must implement the "org.milyn.smooks.mule.ResultFactory" interface and must have an argumentless constructor.
profile The smooks profile to execute. If a profile name was found on the message then that one is used.
profileMessagePropertyKey The name of the message property which could contain a possible profile name. If the property is set and the value is a string then that value is used as the profile name. Default "MessageProfile".
executionContextAsMessageProperty If set to "true" then the attributes map of the Smooks execution context is added to the message properties. The property key is defined with the executionContextMessagePropertyKey property. Default is "false"
executionContextMessagePropertyKey The property key under which the execution context is put. Default is "SmooksExecutionContext"
excludeNonSerializables If non serializable attributes need to be execluded when setting the Smooks execution context attribute map as a message propeperty. Default is "true"
reportPath Specifies the path and file name for generating a Smooks Execution Report.  This is a development tool. For more information see: Smooks Reporting


Outbound Router Configuration

Mule 1.4.x

The router is configured in your Mule Xml configuration file as follows:

mule-config.xml
<outbound-router>
    <router className="org.milyn.smooks.mule.Router">
        <endpoint name="order" address="jms://order.queue"/>
        <endpoint name="order-important" address="jms://order.important.queue"/>
        <properties>
            <property name="configFile" value="/router-smooks-config.xml" />
        </properties>
    </router>
</outbound-router>

The endpoints need a name because it acts as a reference in the Smooks configuration. The name should be unique and shouldn't be the same as the endpoint address.

In the Smooks configuration you use the org.milyn.smooks.mule.MuleDispatcher to route to one of the endpoints you defined in the Mule configuration. More on the MuleDispatcher can be found in the Smooks MuleDispatcher section.

Mule 2.1.x

The router is configured in your Mule Xml configuration file as follows:

mule-config.xml
<outbound>
    <smooks:router configFile="/smooks-config.xml">
        <jms:outbound-endpoint name="order" queue="order.queue"/>
        <jms:outbound-endpoint name="order-important" queue="order.important.queue"/>
    </smooks:router>
</outbound>

The endpoints need a name because it acts as a reference in the Smooks configuration. The name should be unique and shouldn't be the same as the endpoint address.

In the Smooks configuration you use the org.milyn.smooks.mule.MuleDispatcher to route to one of the endpoints you defined in the Mule configuration. More on the MuleDispatcher can be found in the Smooks MuleDispatcher section.

Configuration Properties (Mule version independent)

Property Description
configFile The Smooks configuration file. Can be a path on the file system or on the classpath.
profile The smooks profile to execute. If a profile name was found on the message then that one is used.
profileMessagePropertyKey The name of the message property which could contain a possible profile name. If the property is set and the value is a string then that value is used as the profile name. Default "MessageProfile".
executionContextAsMessageProperty If set to "true" then the attributes map of the Smooks execution context is added to the message properties of every message that gets created by this router. The property key is defined with the executionContextMessagePropertyKey property. Default is "false"
executionContextMessagePropertyKey The property key under which the execution context is put. Default is "SmooksExecutionContext"
excludeNonSerializables If non serializable attributes need to be execluded when setting the Smooks execution context attribute map as a message propeperty. Default is "true"
honorSynchronicity If the synchronicity of the endpoint should override the general synchronicity settings (only in the Mule 1.4.x version)
reportPath Specifies the path and file name for generating a Smooks Execution Report.  This is a development tool. For more information see: Smooks Userguid: Checking the Smooks Execution Process

Smooks MuleDispatcher

For the MuleDispatcher in Smooks the Smooks for Mule module provides a configuration XML Schema. The namespace is as followes:
Namespace: http://dist.muleforge.org/smooks/schema/smooks-mule-1.1.xsd
Recommended prefix: mule

A MuleDispatcher is defined as follows:

smooks-config.xml
<mule:dispatcher endpointName="order" dispatchOnElement="order">
    <mule:messagePayload beanId="order" />
</mule:dispatcher>

The xml schema is fully documented. But here is a short overview of the configuration properties:

Property Description
dispatchOnElement The element on which the message will be dispatched.
dispatchOnElementNS Namespace control for the "dispatchOnElement" property.
endpointName The name of the endpoint which will be used when routing the message. If no endpoint can be found under that name then an exception is thrown.
resultBeanId If the endpoint returns a result then the payload of that result is bounded to the resultBeanId. When the resultBeanId isn't set then the result is discarded. If the resultBeanId is set then the endpoint is forced to distpatch synchronous.
dispatchBefore If the message is dispatched before the element else the message is dispatched after the element.
/messagePayload The message payload configuration.
/messagePayload/beanId The bean id of the bean which will be used as the message payload.
/messagePayload/expression A MVEL script. The result of the script is used as the message payload. This overrides the beanId property. The context of the MVEL script contains all the beans of the bean map.
/messageProperties Properties that will be set on the message before dispatching. The MuleDispatcher messageProperties attribute section explains how to set the message properties
/messageProperties/BeanId The bean id of the bean which will be used for the message properties. The bean must be a Map<String, Object> else an IllegalCastException will be thrown.

MuleDispatcher messageProperties attribute
Message properties are defined as folows:

<mule:dispatcher endpointName="endpoint" dispatchOnElement="root" >
    <mule:messageProperties beanId="messageProperties">
        <mule:property name="prop1" value="prop1Value" />
        <mule:property name="prop2">
            <mule:expression>"prop2Value"</mule:expression>
         </mule:property>
         <mule:property name="intProp" value="10" decoder="Integer" />
         <mule:property name="dateProp" value="2008-07-11 12:30:56" decoder="Date" >
	         <mule:decodeParam name="format">yyyy-MM-dd HH:mm:ss</mule:decodeParam>
	    </mule:property>
    </mule:messageProperties>
</mule:dispatcher>

The following points explain the four properties:

  • The first property uses the 'value' attribute to set the value.
  • The second property uses the result of an MVEL expression as its value. The expression is evaluated just before the message is dispatched.
  • The third property uses the 'decoder' attribute to define an Integer type. This will convert the value into an Integer. This uses the standard DataDecoder feature from Smooks.
  • The fourth property uses the 'decoder' attribute to define a Date type. This will convert the value into a Date. The configuration of the Date decoder is set with the 'decoderParam' child elements.

Description of the 'property' properties

Property Description
name The message property name (required)
value The value of the property. The property element content can also be set. If both are set then the value attribute is used.
decoder The type of the property value. This uses the standard DataDecoder feature from Smooks. DataDecoders can be configured using a "decoder:decoderName" resource-config selector. The decoderName must be set as type then. (Default: String)
/expression A MVEL expression from which the result is used as property value. The MVEL context contains all the beans from the bean map. The type and value attribute are ignored when the element content is set.



Adaptavist Theme Builder (3.3.3-conf210) Powered by Atlassian Confluence 2.10, the Enterprise Wiki.
Free theme builder license