org.jboss.soa.esb.actions.converters
Class SmooksTransformer

java.lang.Object
  extended by org.jboss.soa.esb.actions.converters.SmooksTransformer
All Implemented Interfaces:
ActionProcessor, TransformationService

public class SmooksTransformer
extends java.lang.Object
implements TransformationService, ActionProcessor

Smooks Transformer.

This processor hooks the Milyn Smooks XML Transformation/Processing Engine into a message processing pipeline to support XML message transformations.

Since:
Version 4.0
Author:
tom.fennelly@jboss.com

Field Summary
static java.lang.String EXTRACTED_BEANS_HASH
          Key for storing/accessing any potential message Body bean HashMaps as populated by the Smooks Javabean Cartridge.
static java.lang.String FROM
           
static java.lang.String FROM_TYPE
           
static java.lang.String SET_BEANHASH_TO_PAYLOAD
          Config property key for setting a true/false flag to indicate whether or not a bean hashs should be set as the message payload before exiting the process method.
static java.lang.String TO
           
static java.lang.String TO_TYPE
           
 
Constructor Summary
SmooksTransformer(ConfigTree propertiesTree)
          Public constructor.
SmooksTransformer(java.lang.String name, ConfigTree propertiesTree)
          Public constructor.
 
Method Summary
 java.io.Serializable getErrorNotification(Message message)
          Get the "Error" notification message for this processor.
protected static java.lang.String[] getMessageUseragentProfiles(java.lang.String messageFromType, java.lang.String messageFrom, java.lang.String messageToType, java.lang.String messageTo)
          Get the profile list based on the supplied message flow properties.
protected static java.lang.String getMessageUseragentString(java.lang.String messageFromType, java.lang.String messageFrom, java.lang.String messageToType, java.lang.String messageTo)
          Construct the Smooks useragent string based on the supplied message flow properties.
 java.io.Serializable getOkNotification(Message message)
          Get the "OK" notification message for this processor.
protected  void initSmooks(java.util.List<KeyValuePair> properties)
          Initialise the static SmooksStandalone instance.
 Message process(Message message)
          Perform the processing action on the message
static void reset()
          Reset the transformer.
 Message transform(Message message)
          Transform the supplied message object and return the transformation result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTRACTED_BEANS_HASH

public static final java.lang.String EXTRACTED_BEANS_HASH
Key for storing/accessing any potential message Body bean HashMaps as populated by the Smooks Javabean Cartridge.

See Also:
Constant Field Values

SET_BEANHASH_TO_PAYLOAD

public static final java.lang.String SET_BEANHASH_TO_PAYLOAD
Config property key for setting a true/false flag to indicate whether or not a bean hashs should be set as the message payload before exiting the process method.

See Also:
Constant Field Values

FROM

public static final java.lang.String FROM
See Also:
Constant Field Values

FROM_TYPE

public static final java.lang.String FROM_TYPE
See Also:
Constant Field Values

TO

public static final java.lang.String TO
See Also:
Constant Field Values

TO_TYPE

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

SmooksTransformer

public SmooksTransformer(java.lang.String name,
                         ConfigTree propertiesTree)
                  throws ConfigurationException
Public constructor.

Parameters:
actionName - Action name.
propertiesTree - Action Properties.
Throws:
ConfigurationException
ConfigurationException - Action not properly configured.

SmooksTransformer

public SmooksTransformer(ConfigTree propertiesTree)
                  throws ConfigurationException
Public constructor.

Parameters:
propertiesTree - Action Properties.
Throws:
ConfigurationException
ConfigurationException - Action not properly configured.
Method Detail

transform

public Message transform(Message message)
                  throws TransformationException
Description copied from interface: TransformationService
Transform the supplied message object and return the transformation result.

Specified by:
transform in interface TransformationService
Parameters:
message - The message to be transformed.
Returns:
The transformed message.
Throws:
TransformationException - An Exception occured during the transformation process.

process

public Message process(Message message)
                throws ActionProcessingException
Description copied from interface: ActionProcessor
Perform the processing action on the message

Specified by:
process in interface ActionProcessor
Parameters:
message - The message to be processed.
Returns:
Message - result of process
Throws:
ActionProcessingException - Exception during payload processing.

getMessageUseragentProfiles

protected static java.lang.String[] getMessageUseragentProfiles(java.lang.String messageFromType,
                                                                java.lang.String messageFrom,
                                                                java.lang.String messageToType,
                                                                java.lang.String messageTo)
Get the profile list based on the supplied message flow properties.

Parameters:
messageFromType - The type string for the message source.
messageFrom - The Message Exchange Participant name for the message source.
messageToType - The type string for the message target.
messageTo - The Message Exchange Participant name for the message target.
Returns:
The list of profiles.

getMessageUseragentString

protected static java.lang.String getMessageUseragentString(java.lang.String messageFromType,
                                                            java.lang.String messageFrom,
                                                            java.lang.String messageToType,
                                                            java.lang.String messageTo)
Construct the Smooks useragent string based on the supplied message flow properties.

Parameters:
messageFromType - The type string for the message source.
messageFrom - The EPR string for the message source.
messageToType - The type string for the message target.
messageTo - The EPR srting for the message target.
Returns:
Smooks useragent string for the message flow.

getOkNotification

public java.io.Serializable getOkNotification(Message message)
Description copied from interface: ActionProcessor
Get the "OK" notification message for this processor.

Specified by:
getOkNotification in interface ActionProcessor
Parameters:
message - The message Object.
Returns:
The OK message.

getErrorNotification

public java.io.Serializable getErrorNotification(Message message)
Description copied from interface: ActionProcessor
Get the "Error" notification message for this processor.

Specified by:
getErrorNotification in interface ActionProcessor
Parameters:
message - The message Object.
Returns:
The Error message.

initSmooks

protected void initSmooks(java.util.List<KeyValuePair> properties)
                   throws ConfigurationException
Initialise the static SmooksStandalone instance.

We may need to write a Smooks Container implementation specifically for JBossESB's needs. SmooksStandalone is fine for a start though.

Parameters:
properties - Action configuration properties.
Throws:
ConfigurationException - Failed to load Smooks configurations.

reset

public static void reset()
Reset the transformer.

Clears the internal static smooks instance.