Class ObjectToXStream

  extended by org.jboss.soa.esb.actions.AbstractActionLifecycle
      extended by org.jboss.soa.esb.actions.AbstractActionPipelineProcessor
          extended by org.jboss.soa.esb.actions.converters.ObjectToXStream
All Implemented Interfaces:
ActionLifecycle, ActionPipelineProcessor

public class ObjectToXStream
extends AbstractActionPipelineProcessor

Object to XML processor.

Uses the XStream processor to generate an XML message String from the supplied object.

Sample Action Configuration:

<action name="Customer-To-XML" processor="ObjectToXStream">
     <property name="class-alias" value="Customer" /> 
     <property name="exclude-package" value="false" /> 
     <property name="namespace-uri" value="namespace goes here" />
     <property name="aliases"> 
 		<alias name="aliasName" class="className" />
 		<alias name="aliasName" class="className" />
     <property name="namespaces"> 
 		<namespace namespace-uri="" local-part="xyz" /> 
 		<namespace namespace-uri="" local-part="x" />
     <property name="fieldAliases">
      <field-alias alias="aliasName" class="className" fieldName="fieldName"/> 
      <field-alias alias="aliasName" definedIn="className" fieldName="fieldName"/>
     <property name="attributeAliases">
 		<attribute-alias name="aliasName" class="className"/> 
 		<attribute-alias name="aliasName" class="className"/> 
     <property name="implicit-collections">
      <implicit-collection class="className" fieldName="fieldName" fieldType="java.lang.String" />
      <implicit-collection class="className" fieldName="fieldName" fieldType="java.lang.Integer"/>
     <property name="converters"> 
      <converter class="className" />
      <converter class="className" />


  • class-alias Optional. Class alias for the 'incoming-type'.
  • exclude-package Optional, defaults to true. Determines whether package name should be removed from the incoming type.
  • aliases Optional. Specifies extra class aliases.
  • namespace-uri Optional. List of namespaces that will be registerd with XStream.
  • fieldAliases Optional. Specifies field aliases.
  • implicit-collections Optional. Specifies implicit collections which are when you have an xml element that is a place holder for a collection of other elements. In this case you are telling XStream to not include the holder element but instead place its element into the the 'fieldName' in the target class. 'className' is the collection type. 'fieldType' is the type the elements in the collection.
  • converters Optional. Specifies converters that will be registered with XStream.
  • The XML root element is either set from the "class-alias" property or the classes full name. In the later case, the class package is excluded unless "exclude-package" is set to "false"/"no".

    Version 4.0

    Field Summary
    static java.lang.String ATTR_CLASS_ALIAS
    static java.lang.String ATTR_EXCLUDE_PACKAGE
    static java.lang.String ATTR_NAMESPACE_LOCALPART
    static java.lang.String ATTR_NAMESPACE_URI
    static java.lang.String ATTR_XSTREAM_MODE
    Fields inherited from interface org.jboss.soa.esb.actions.ActionPipelineProcessor
    Constructor Summary
    ObjectToXStream(ConfigTree configTree)
              Public constructor.
    Method Summary
    protected  com.thoughtworks.xstream.XStream createXStreamInstance()
              Creates an XStream instance.
    protected  java.util.Map<java.lang.String,java.lang.String> getNamespaces(ConfigTree configTree)
              Will extract the namespace elements from the passed-in configTree
     Message process(Message message)
              Perform the action processing on the specified message.
    Methods inherited from class org.jboss.soa.esb.actions.AbstractActionPipelineProcessor
    processException, processSuccess
    Methods inherited from class org.jboss.soa.esb.actions.AbstractActionLifecycle
    destroy, 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
    destroy, initialise

    Field Detail


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


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


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


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


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


    public ObjectToXStream(ConfigTree configTree)
    Public constructor.

    configTree - Action Properties.
    ConfigurationException - Action not properly configured.
    Method Detail


    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.

    message - The current message being processed.
    The message to be passed to the next stage of the pipeline.
    ActionProcessingException - for errors during processing.


    protected com.thoughtworks.xstream.XStream createXStreamInstance()
    Creates an XStream instance. If namespace mappings have been defined the XStream instance is created with a StaxDriver configured with those mappings.

    aliases - Map of aliases.


    protected java.util.Map<java.lang.String,java.lang.String> getNamespaces(ConfigTree configTree)
    Will extract the namespace elements from the passed-in configTree

    configTree - the configuration for this class
    Map either an empty map or a map containing the name space URI as its key and the corresponding value is the local XML element name to map it to.