EMF doesn't have support for generating Java annotations. You can add
them to the generated code by hand.
On 09/07/2012 11:34 AM, Cool Man wrote:
> Hi there,
> Is it possible to annotate an ecore model(or genmodel) with JAXB
> annotations? I need to have JAXB annotations in the generated code.
> Any help is appriciated.
> Thanks a mil
EMF already produces XMI serializations without annotations. Why do you
need JAXB annotations for the same purpose?
On 09/07/2012 12:58 PM, Cool Man wrote:
> Thanks. That is what i am doing at the moment. I use JAXB to write
> java objects(generated from model to model transformation) into xmi
> files; for that i manually annotated generated code.
> I probably need to find some other way to write java objects as xmi
I'm using EMF since couple of weeks and I'm now trying to generate Java classes annotated with JAXB annotations like the ones generated form a XSD. I've exported the .ecore to a .xsd file but this way I loose all the features of EMF.
Why do I need this? Because I want to offer a public REST interface to my application specified by a XSD. This way every client can send plain XML without knowing that JAX-RS (Jersey) deserialize it to EObjects.
I doubt what you're trying to do is sensible and I still don't really get it. You talk about "plain XML" sent by clients, so I get the impression that clients will only have to know the XML Schema to which the "plain XML" must conform. That whole side of things seems unrelated to any JAXB annotations on your side. And of course you know that EMF can generate a model from an XSD and can read and write instances that conform to this XSD so it seems that's sufficient for clients not to care about EMF but only about the XSD and for you to use EMF to read instances conforming to that XSD. So what's missing? Why do you need JAXB annotations? It doesn't sound like the clients need them. I suppose it has something to do with this JAX-RS thing, but I know nothing about that.
Before you go too far down this path, have you tried manually adding the annotations you hope to have generated to see if it even works. As I said EMF implementation classes are not compatible with what's generated by JAXB, so I just don't see how this could possibility all fit together.
It might help if you provide us with a diagram showing your workflow so that we can see:
a) your mandated master information representations
b) your free choice master information representations
c) your mandated derived information representations
d) your free choice derived information representations
e) your mandated conversions and technologies
f) your free choice conversions and technologies