Trying to use XStream JavaBeanConverter and problem. Most likely, I missed something simple, or did not understand how to convert XStream well enough.
@XStreamAlias("test")
public class TestObject
{
private String foo;
public String getFoo()
{
return foo.toLowerCase();
}
public void setFoo(String foo)
{
this.foo = foo;
}
}
public void test() throws Exception
{
XStream x = new XStream(new XppDriver());
x.autodetectAnnotations(true);
x.processAnnotations(TestObject.class);
x.registerConverter(new JavaBeanConverter(x.getMapper()));
TestObject o = new TestObject();
o.setFoo("BAR");
String xml = x.toXML(o);
System.out.println(xml);
}
I tried adding trace to the method TestObject.getFoo(), and it looks like it is being called by XStream, but the data is not being written to the output stream.
Looking at the source for the JavaBeanConverter, it looks like my implementation should work, which makes me think that I did not configure something correctly during the installation of XStream.
Did I just miss something simple?
Thank!
Change 1Also, if that helps, I use the following Maven divs for this ...
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.xstream</artifactId>
<version>1.3_3</version>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.xpp3</artifactId>
<version>1.1.4c_3</version>
</dependency>
Edit 2I changed the method TestObject.getFoo()to better explain my purpose.
/ "" .
, , Serializable readResolve().
readResolve, setter ( ), readResolve ( XML- I).
JavaBeanConverter XStream... /.
, .
.