01: /*
02: * $Id: XStreamWireFormat.java 11377 2008-03-16 18:18:33Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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: public XStreamWireFormat() throws IllegalAccessException,
27: InstantiationException, ClassNotFoundException {
28: this (XStreamFactory.XSTREAM_XPP_DRIVER, null, null);
29: }
30:
31: public XStreamWireFormat(String driverClassName, Map aliases,
32: List converters) throws IllegalAccessException,
33: InstantiationException, ClassNotFoundException {
34: XmlToObject in = new XmlToObject();
35: in.setDriverClassName(driverClassName);
36: in.setAliases(aliases);
37: in.setConverters(converters);
38: setInboundTransformer(in);
39:
40: ObjectToXml out = new ObjectToXml();
41: out.setDriverClassName(driverClassName);
42: out.setAliases(aliases);
43: out.setConverters(converters);
44: // TODO This is currently needed as a workaround for MULE-2881, this needs to
45: // be removed is this is not the solution to MULE-2881
46: out.setAcceptUMOMessage(true);
47: setOutboundTransformer(out);
48: }
49:
50: }
|