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

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

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

Smooks Transformer.

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

Action Configuration

This action is configured as follows:
 <action name="transformAB" class="org.jboss.soa.esb.actions.converters.SmooksTransformer">
        <property name="from" value="A" />
        <property name="from-type" value="text/xml:messageAtA" />
        <property name="to" value="B" />
        <property name="to-type" value="text/xml:messageAtB" />
 </action>
 

Configuartion Loading & Administration Console Integration

This class picks up its list of transformation resource configurations from a list file specified in the "configuration.list.file.uri" parameter of the "transformation" section of the ESB configuration file. This configuration should specify a URI to this list file and is loaded using the URIResourceLocator. The default list file is "classpath:/smooks-cdr.lst" (note classpath based URIs are supported).

This file contains a list of URIs that reference Smooks resource configurations files. Again, URIResourceLocator is used to load these configurations. "classpath:/" is the default if no scheme is specified. This is also where the Administration Console is integrated with this class. The list file needs to specify the following a HTTP based URI for accessing the configurations under management by the Administration console:

        http://localhost:8080/jboss-esb-console/transform/smooks-config.jsp
 
... where the host and port values need to be modified appropriately.

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

Field Summary
static java.lang.String CONFIGURATION_SECTION
          Configuration section key.
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
           
 
Fields inherited from interface org.jboss.soa.esb.actions.ActionPipelineProcessor
PROCESS_EXCEPTION_METHOD, PROCESS_METHOD, PROCESS_SUCCESS_METHOD
 
Constructor Summary
SmooksTransformer(ConfigTree propertiesTree)
          Public constructor.
SmooksTransformer(java.lang.String name, ConfigTree propertiesTree)
          Public constructor.
 
Method Summary
 void destroy()
          Destroy the action instance.
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.
 void initialise()
          Initialise the SmooksStandalone instance.
 Message process(Message message)
          Perform the action processing on the specified message.
 void processException(Message message, java.lang.Throwable th)
          Process an exception generated by the pipeline processing.
 void processSuccess(Message message)
          Process a successful pipeline process.
 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

CONFIGURATION_SECTION

public static final java.lang.String CONFIGURATION_SECTION
Configuration section key.

See Also:
Constant Field Values

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:
name - Action name.
propertiesTree - Action Properties.
Throws:
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: ActionPipelineProcessor
Perform the action processing on the specified message. This method is invoked for each message passing throught the pipeline.

Specified by:
process in interface ActionPipelineProcessor
Parameters:
message - The current message being processed.
Returns:
The message to be passed to the next stage of the pipeline.
Throws:
ActionProcessingException - for errors during 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.

processException

public void processException(Message message,
                             java.lang.Throwable th)
Description copied from interface: ActionPipelineProcessor
Process an exception generated by the pipeline processing. Invoked when the processing of a subsequent stage of the pipeline generates an exception.

Specified by:
processException in interface ActionPipelineProcessor
Parameters:
message - The original message.
th - The throwable raised by the pipeline processing

processSuccess

public void processSuccess(Message message)
Description copied from interface: ActionPipelineProcessor
Process a successful pipeline process. Invoked when the pipeline processing completes successfully.

Specified by:
processSuccess in interface ActionPipelineProcessor
Parameters:
message - The original message.

initialise

public void initialise()
                throws ActionLifecycleException
Initialise the SmooksStandalone instance.

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

Specified by:
initialise in interface ActionLifecycle
Throws:
ActionLifecycleException - Failed to load Smooks configurations.

destroy

public void destroy()
             throws ActionLifecycleException
Description copied from interface: ActionLifecycle
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
Throws:
ActionLifecycleException

reset

public void reset()
Reset the transformer.

Clears the internal static smooks instance.