org.jboss.soa.esb.actions.converters
Class ObjectToXStream
java.lang.Object
org.jboss.soa.esb.actions.AbstractActionLifecycle
org.jboss.soa.esb.actions.AbstractActionPipelineProcessor
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>
<property name="namespaces">
<namespace namespace-uri="http://www.xyz.com" local-part="xyz" />
<namespace namespace-uri="http://www.xyz.com/x" local-part="x" />
</property>
<property name="fieldAliases">
<field-alias alias="aliasName" class="className" fieldName="fieldName"/>
<field-alias alias="aliasName" definedIn="className" fieldName="fieldName"/>
...
</property>
<property name="attributeAliases">
<attribute-alias name="aliasName" class="className"/>
<attribute-alias name="aliasName" class="className"/>
...
</property>
<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>
<property name="converters">
<converter class="className" />
<converter class="className" />
...
</property>
</action>
*
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".
- Since:
- Version 4.0
- Author:
- tom.fennelly@jboss.com, daniel.bevenius@gmail.com
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ATTR_CLASS_ALIAS
public static final java.lang.String ATTR_CLASS_ALIAS
- See Also:
- Constant Field Values
ATTR_EXCLUDE_PACKAGE
public static final java.lang.String ATTR_EXCLUDE_PACKAGE
- See Also:
- Constant Field Values
ATTR_NAMESPACE_URI
public static final java.lang.String ATTR_NAMESPACE_URI
- See Also:
- Constant Field Values
ATTR_NAMESPACE_LOCALPART
public static final java.lang.String ATTR_NAMESPACE_LOCALPART
- See Also:
- Constant Field Values
ATTR_XSTREAM_MODE
public static final java.lang.String ATTR_XSTREAM_MODE
- See Also:
- Constant Field Values
ObjectToXStream
public ObjectToXStream(ConfigTree configTree)
- Public constructor.
- Parameters:
configTree
- Action Properties.
- Throws:
ConfigurationException
- Action not properly configured.
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.
- 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.
createXStreamInstance
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.
- Parameters:
aliases
- Map of aliases.
- Throws:
ActionProcessingException
getNamespaces
protected java.util.Map<java.lang.String,java.lang.String> getNamespaces(ConfigTree configTree)
- Will extract the namespace elements from the passed-in configTree
- Parameters:
configTree
- the configuration for this class
- Returns:
- 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.