org.jboss.soa.esb.smooks
Class SmooksAction

java.lang.Object
  extended by org.jboss.soa.esb.actions.AbstractActionLifecycle
      extended by org.jboss.soa.esb.actions.AbstractActionPipelineProcessor
          extended by org.jboss.soa.esb.smooks.SmooksAction
All Implemented Interfaces:
ActionLifecycle, ActionPipelineProcessor
Direct Known Subclasses:
SmooksAction

public class SmooksAction
extends AbstractActionPipelineProcessor

Smooks action pipeline processor.

Usage:

 <action name="transform" class="org.jboss.soa.esb.smooks.SmooksAction">
        <property name="smooksConfig" value="smooks-config.xml" />
 </action>
 
Optional properties:
 <property name="get-payload-location" value="input" />
 <property name="set-payload-location" value="ouput" />
 <property name="excludeNonSerializables" value="false" />
 <property name="resultType" value="STRING" />
 <property name="reportPath" value="/tmp/smooks-report.html" />
 <property name="messageProfile" value="fromServiceA" />
 
Description of configuration properties:

Exposing the Smooks ExecutionContext to other ESB Actions

After Smooks has performed the filtering operation on the message payload, it maps the contents of the ExecutionContext onto a Map on the the ESB message, making it available to other actions in the ESB. This Map can be accessed by using the EXECUTION_CONTEXT_ATTR_MAP_KEY key as follows:
 message.getBody().get( SmooksAction.EXECUTION_CONTEXT_ATTR_MAP_KEY );
 

Specifying the Source and Result Types

From the ESB Message data type, this action is able to automatically determine the type of Source to use (via the Smooks PayloadProcessor). The Result type to be used can be specified via the "resultType" property, as outlined above.

It is expected that the above mechanism will be satisfactory for most usecase, but not all. For the other usecases, this action supports SourceResult payloads on the ESB Message. This allows you to manually specify other Source and Result types, which is of particular interest with respect to the Result type e.g. for streaming the Result to a file etc.

Message Profiling

Smooks Profiling allows you to use a single Smooks instance to transform multiple source messages. As an example, imagine a situation where messages of different formats are delivered to a Service. Before consuming the messages, the Service needs to transform these message payloads to a common format. To accomplish this, you can use profiling.

The action can have the default profile name configured through the "messageProfile" property. Each incoming ESB message can specify it's profile name through the message property of the same name ("messageProfile"). For more on profiling, see the profiling example.

Author:
tom.fennelly@jboss.com, daniel.bevenius@gmail.com

Field Summary
static java.lang.String EXECUTION_CONTEXT_ATTR_MAP_KEY
           
 
Fields inherited from interface org.jboss.soa.esb.actions.ActionPipelineProcessor
PROCESS_EXCEPTION_METHOD, PROCESS_METHOD, PROCESS_SUCCESS_METHOD
 
Constructor Summary
SmooksAction(ConfigTree configTree)
           
 
Method Summary
 void destroy()
          Destroy the action instance.
protected  java.util.Map getSerializableObjectsMap(java.util.Map smooksAttribuesMap)
          Will return a Map containing only the Serializable objects that exist in the passed-in Map if excludeNonSerializables is true.
 Message process(Message message)
          Executes the actual Smooks tranformation.
 
Methods inherited from class org.jboss.soa.esb.actions.AbstractActionPipelineProcessor
processException, processSuccess
 
Methods inherited from class org.jboss.soa.esb.actions.AbstractActionLifecycle
initialise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.soa.esb.actions.ActionLifecycle
initialise
 

Field Detail

EXECUTION_CONTEXT_ATTR_MAP_KEY

public static final java.lang.String EXECUTION_CONTEXT_ATTR_MAP_KEY
See Also:
Constant Field Values
Constructor Detail

SmooksAction

public SmooksAction(ConfigTree configTree)
             throws ConfigurationException
Throws:
ConfigurationException
Method Detail

process

public Message process(Message message)
                throws ActionProcessingException
Executes the actual Smooks tranformation.

Parameters:
message - The ESB Message object
Returns:
The ESB Message object with the output of the transformation.
Throws:
ActionProcessingException - for errors during processing.

destroy

public void destroy()
             throws ActionLifecycleException
Description copied from class: AbstractActionLifecycle
Destroy the action instance.

This method is called prior to the release of the action instance. All resources associated with this action instance should be released as the instance will no longer be used.

Specified by:
destroy in interface ActionLifecycle
Overrides:
destroy in class AbstractActionLifecycle
Throws:
ActionLifecycleException

getSerializableObjectsMap

protected java.util.Map getSerializableObjectsMap(java.util.Map smooksAttribuesMap)
Will return a Map containing only the Serializable objects that exist in the passed-in Map if excludeNonSerializables is true.

Parameters:
smooksAttribuesMap - - Map containing attributes from the Smooks ExecutionContext
Returns:
Map - Map containing only the Serializable objects from the passed-in map.