View Javadoc

1   /*
2    * $Id: XStreamWireFormat.java 11377 2008-03-16 18:18:33Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.xml.transformer.wire;
12  
13  import org.mule.module.xml.transformer.ObjectToXml;
14  import org.mule.module.xml.transformer.XStreamFactory;
15  import org.mule.module.xml.transformer.XmlToObject;
16  import org.mule.transformer.wire.TransformerPairWireFormat;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  /**
22   * Serializes objects using XStream. This is equivelent of using the ObjectToXml and
23   * XmlToObject except that there is no source or return type checking.
24   */
25  public class XStreamWireFormat extends TransformerPairWireFormat
26  {
27      public XStreamWireFormat() throws IllegalAccessException, InstantiationException, ClassNotFoundException
28      {
29          this(XStreamFactory.XSTREAM_XPP_DRIVER, null, null);
30      }
31  
32      public XStreamWireFormat(String driverClassName, Map aliases, List converters)
33          throws IllegalAccessException, InstantiationException, ClassNotFoundException
34      {
35          XmlToObject in = new XmlToObject();
36          in.setDriverClassName(driverClassName);
37          in.setAliases(aliases);
38          in.setConverters(converters);
39          setInboundTransformer(in);
40  
41          ObjectToXml out = new ObjectToXml();
42          out.setDriverClassName(driverClassName);
43          out.setAliases(aliases);
44          out.setConverters(converters);
45          // TODO This is currently needed as a workaround for MULE-2881, this needs to
46          // be removed is this is not the solution to MULE-2881
47          out.setAcceptUMOMessage(true);
48          setOutboundTransformer(out);
49      }
50  
51  }