siegfried escreveu:
Hi
> Can someone point me to a simple example that defines some java
> classes with annotations
>
I think (imho) you should make the "whole" process ... I mean, follow
some steps to get your "annotated classes".
1.) Run the binding compiler against a .xsd schema ... there are
lots of them on the net ;-) ... or you can use your own .xsd
2.) This process will generate your special classes (you need
everything from JAXB in the classpath and at least JDK 5 AFAIK)
the articles I'll mention in the end of this email will help.
> , instantiates these classes,
>
The binding compiler (xjc) is awesome because it gives you a class
called "ObjectFactory" that you usually take to create instances
of the "xmlschema based classes" ;-)
> and serializes them to a file to demonstrate such annotations as
> @XmlAttribute.
>
I'm not sure what you meant .... but in my case the standard
java.beans.XMLEncoder/Decoder did the trick for the
Serialization/Desserialization of these
generated classes.
The only issue I've faced was related to Serialize "Collection based
properties" but anyway I wrote a plugin (Collection setter) that did the
trick for me
it's at
https://jaxb2-commons.dev.java.net/
>
>
> I guess a second example would be nice that shows how to instantiate
> the java classes by deserializing them from the flat file created by
> the first example.
>
XMLDecoder can handle this file and desserialize it back to the
"annotated classes" ;-)
There are some nice examples at
http://wiki.java.net/bin/view/Javawsxml/JaxbArticles too, they were very
useful for me.
XMLEncoder/Decoder examples can be found at
http://java.sun.com/products/jfc/tsc/articles/persistence4/
>
>
> Thanks
>
> Siegfried
>
Regards
Marcos