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

Deprecated. Use SmooksAction.

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

Smooks Transformer.

This processor hooks the Milyn Smooks Data Transformation/Processing Engine into a message processing pipeline.

A wide range of source (XML, CSV, EDI etc) and target (XML, Java, CSV, EDI etc) formats are supported.

Transformation Configuration

This action works in one of 2 ways:
  1. Out of a Smooks resource configuration whose URL is specified directly on the action via the "resource-config" property. If no URI scheme ("http", "file" etc) is specified on the resource config, the resource is assumed to reside on the local classpath.

    Example :

    <property name="resource-config" value="/smooks-res.xml" />
  2. Out of a centralised Smooks resource configuration datasource managed by the Transformation Admin Console. This datasource is configured in the smooks.esb deployment. See the "console.url" property in the "smooks.esb.properties" file.
If both of the above are specified, the action will use the locally specified config defined on the "resource-config" property. If neither are specified, an error will result.

This transformer also supports Smooks profiles 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>
 

Transformation Input/Output Configuration

This action gets the transformation input, and sets the transformation output based on the "input-location" and "output-location" configuration properties. These properties name the Message.Body location where the transformation input and output are attached.

If either these properties are not set, the action class defaults that value to being "defaultEntry". In other words, if "input-location" is not configured on the action, the action will attempt to load the transformation input from the Message.Body location named "defaultEntry". If the "output-location" is not configured on the action, the action will set the transformation result/output in the Message.Body location named "defaultEntry".

Java Transformation Input/Output Configuration

This action supports source (XML, CSV, EDI etc) to Java object transformation/binding. See the "Transform_*" quickstarts for examples of this and also check out the Smooks Tutorials.

The constructed Java object model can be used as part of a model driven transform, or can simply be used by other ESB action instances that follow the SmooksTransformer in an action pipeline.

Such Java object graphs are available to subsequent pipeline action instances because they are attached to the ESB Message output by this action and input to the following action(s). They are bound to the Message instance Body (Message.getBody().add(String key, Object object)) under a key based directly on the objects "beanId" as defined in the Smooks Javabean config.

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

Field Summary
static java.lang.String EXTRACTED_BEANS_HASH
          Deprecated. The Smooks ExecutionContext is attached to the message and can be accessed through the
static java.lang.String FROM
          Deprecated.  
static java.lang.String FROM_TYPE
          Deprecated.  
static java.lang.String INPUT_LOCATION
          Deprecated. Config key for the message body location on which the input message is attached.
static java.lang.String JAVA_OUTPUT
          Deprecated. Config key for the name of the Smooks Execution context object to be output to the "output-location".
static java.lang.String OUTPUT_LOCATION
          Deprecated. Config key for the message body location on which the output message is attached.
static java.lang.String RESOURCE_CONFIG
          Deprecated. Action config Smooks configuration key.
static java.lang.String TO
          Deprecated.  
static java.lang.String TO_TYPE
          Deprecated.  
static java.lang.String UPDATE_TOPIC
          Deprecated.  
 
Fields inherited from interface org.jboss.soa.esb.actions.ActionPipelineProcessor
PROCESS_EXCEPTION_METHOD, PROCESS_METHOD, PROCESS_SUCCESS_METHOD
 
Constructor Summary
SmooksTransformer(ConfigTree propertiesTree)
          Deprecated. Public constructor.
 
Method Summary
 void destroy()
          Deprecated. Destroy the action instance.
protected static java.lang.String[] getMessageProfiles(java.lang.String messageFromType, java.lang.String messageFrom, java.lang.String messageToType, java.lang.String messageTo)
          Deprecated. Get the profile list based on the supplied message flow properties.
protected static java.lang.String getMessageProfileString(java.lang.String messageFromType, java.lang.String messageFrom, java.lang.String messageToType, java.lang.String messageTo)
          Deprecated. Construct the Smooks profile string based on the supplied message flow properties.
 void initialise()
          Deprecated. Initialise the Smooks instance.
 Message process(Message message)
          Deprecated. Perform the action processing on the specified message.
 void processException(Message message, java.lang.Throwable th)
          Deprecated. Process an exception generated by the pipeline processing.
 void processSuccess(Message message)
          Deprecated. Process a successful pipeline process.
 Message transform(Message message)
          Deprecated. 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
Deprecated. The Smooks ExecutionContext is attached to the message and can be accessed through the
Key for storing/accessing any potential message Body bean HashMaps as populated by the Smooks Javabean Cartridge.

See Also:
Constant Field Values

RESOURCE_CONFIG

public static final java.lang.String RESOURCE_CONFIG
Deprecated. 
Action config Smooks configuration key.

See Also:
Constant Field Values

INPUT_LOCATION

public static final java.lang.String INPUT_LOCATION
Deprecated. 
Config key for the message body location on which the input message is attached.

See Also:
Constant Field Values

OUTPUT_LOCATION

public static final java.lang.String OUTPUT_LOCATION
Deprecated. 
Config key for the message body location on which the output message is attached.

See Also:
Constant Field Values

JAVA_OUTPUT

public static final java.lang.String JAVA_OUTPUT
Deprecated. 
Config key for the name of the Smooks Execution context object to be output to the "output-location".

See Also:
Constant Field Values

FROM

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

FROM_TYPE

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

TO

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

TO_TYPE

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

UPDATE_TOPIC

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

SmooksTransformer

public SmooksTransformer(ConfigTree propertiesTree)
                  throws ConfigurationException
Deprecated. 
Public constructor.

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

initialise

public void initialise()
                throws ActionLifecycleException
Deprecated. 
Initialise the Smooks instance.

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

destroy

public void destroy()
             throws ActionLifecycleException
Deprecated. 
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

transform

public Message transform(Message message)
                  throws TransformationException
Deprecated. 
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
Deprecated. 
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.

getMessageProfiles

protected static java.lang.String[] getMessageProfiles(java.lang.String messageFromType,
                                                       java.lang.String messageFrom,
                                                       java.lang.String messageToType,
                                                       java.lang.String messageTo)
Deprecated. 
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.

getMessageProfileString

protected static java.lang.String getMessageProfileString(java.lang.String messageFromType,
                                                          java.lang.String messageFrom,
                                                          java.lang.String messageToType,
                                                          java.lang.String messageTo)
Deprecated. 
Construct the Smooks profile 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 profile string for the message flow.

processException

public void processException(Message message,
                             java.lang.Throwable th)
Deprecated. 
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)
Deprecated. 
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.