XMLEncoding introduced objects
Carlos Villela <carlos-hikPBsva6T/[email protected]>
| Newsgroups | gmane.comp.java.aspectwerkz.devel |
|---|---|
| Message-ID | <1060171410.737.4.camel@tylenol> |
Hi folks!
I'm trying to use that funky new javabeans xml encoding/decoding classes
to provide some long-term persistence for my objects in Inectis (the
weirdest content management system, ever).
Strange thing is that, when XMLEncoding any of my introduced objects
(which use proper javabean naming convention for properties), I can't
see any output of their introduction attributes.
As this explanation definitely sucked, I'll provide an example:
// A simple, empty object
public class MyObject {
}
// Introduction interface
public interface HasName extends java.io.Serializable {
void setName(String name);
String getName();
}
// Introduction implementation
public class HasNameImpl implements HasName {
private String name;
// getters and setters go here
}
// The test class.
// The introductions are defined as perInstance, btw.
public class TestXMLEncode {
public static void main(String[] args) {
MyObject obj = new MyObject();
((HasName)obj).setName("Testing, testing, 1, 2, 3");
XMLEncoder enc = new XMLEncoder(System.out);
enc.writeObject(obj);
enc.close();
}
}
This produces something like this:
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.4.1" class="java.beans.XMLDecoder">
<object class="foo.bar.MyObject"/>
</java>
As you can see, the "name" property introduced (which is definitely
available, as it's possible to see it looking at the generated BeanInfo
object using java.beans.Introspector.getBeanInfo(MyObject.class)).
So, what's wrong here? I dont really have a clue, but other ideas on how
can I serialize/deserialize these objects are definitely welcome :)
[]'s
-cv