org.jboss.soa.esb.smooks.SmooksAction class is the second generation action class for executing Smooks processes. (Note that it can do more than just transform messages).
The SmooksAction class can process a wider range of message payloads by using Smooks PayloadProcessor. This includes strings, byte arrays, InputStreams, readers, POJOs and more. As such, it can perform a wide range of transformations including Java-to-Java transformations. It can also perform other types of operations on a source messages stream, including content based payload Splitting and Routing (note that this is not the same as ESB message routing). The SmooksAction enables the full range of Smooks capabilities from within JBoss Enterprise SOA Platform.
Be aware that Smooks does not detect (and report errors on) certain types of configuration errors for resource configurations made through the base <resource-config>. If, for example, the resource (<resource>) is a Smooks Visitor implementation, and you misspell the name of the Visitor class, Smooks will not raise this as an error simply because it doesn't know that the misspelling was supposed to be a class. Remember, Smooks supports lots of different types of resource and not just Java Visitor implementations.
The easiest way to avoid this issue is to use the extended Smooks configuration namespaces for all out-of-the-box functionality. For example, instead of defining Java binding configurations by defining org.milyn.javabean.BeanPopulator <resource-config> configurations, use the http://www.milyn.org/xsd/smooks/javabean-1.2.xsd
configuration namespace (that is, the <jb:bean> config, and so forth).
If you have implemented Smooks Visitor functionality, the easiest way to avoid this issue is to define an extended configuration name-space for this new resource type. This also has the advantage of making the new resource easier to configure as you can leverage the schema support built into JBoss Developer Studio.
The following illustrates the basic SmooksAction configuration:
Example 13.10. SmooksAction
<action name="transform" class="org.jboss.soa.esb.smooks.SmooksAction">
<property name="smooksConfig" value="/smooks/order-to-java.xml" />
Here are the optional configuration properties:
Table 13.9. SmooksAction Optional Configuration Properties
| Property || Description || Default |
| get-payload-location || |
Message Body location containing the message payload.
| Default Payload Location |
| set-payload-location || |
Message Body location where result payload is to be placed.
| Default Payload Location |
| mappedContextObjects || |
Comma separated list of Smooks ExecutionContext objects to be mapped into the EXECUTION_CONTEXT_ATTR_MAP_KEY Map on the ESB Message Body. Default is an empty list. Objects must be Serializable.
| resultType || |
The type of Result to be set as the result Message payload.
| STRING |
| javaResultBeanId || |
Only relevant when
The Smooks bean context beanId to be mapped as the result when the resultType is "JAVA". If not specified, the whole bean context bean Map is mapped as the JAVA result.
| reportPath || |
The path and file name for generating a Smooks Execution Report. This is a development aid and should not to be used in production.
The SmooksAction uses the
MessagePayloadProxy class to obtain and set the payload onto the message. Therefore, unless otherwise configured via the get-payload-location and set-payload-location action properties, the SmooksAction obtains and sets the Message payload on the default message location by using the Message.getBody().get() and Message.getBody().set(Object) methods.
If the supplied Message payload is not one of type String, InputStream, Reader or byte, the SmooksAction processes the payload as a JavaSource, allowing you to perform Java-to-XML and Java-to-Java transformations.