Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to do JAXB annotations in ecore?
How to do JAXB annotations in ecore? [message #894447] Mon, 09 July 2012 09:34 Go to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
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
kosala
Re: How to do JAXB annotations in ecore? [message #894464 is a reply to message #894447] Mon, 09 July 2012 10:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Kosala,

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
> kosala


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to do JAXB annotations in ecore? [message #894468 is a reply to message #894464] Mon, 09 July 2012 10:58 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Ed,

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 files.

Kosala
Re: How to do JAXB annotations in ecore? [message #894478 is a reply to message #894468] Mon, 09 July 2012 11:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Kosala,

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:
> Ed,
>
> 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
> files.
>
> Kosala


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to do JAXB annotations in ecore? [message #894497 is a reply to message #894478] Mon, 09 July 2012 12:42 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Hi Ed,

I could not find how to save a java object into xmi file using XMI serialization.

For example, I have a device object which i need to save as an xmi file.

Thanks
Kosala
Re: How to do JAXB annotations in ecore? [message #894506 is a reply to message #894497] Mon, 09 July 2012 13:28 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala YapaFriend
Messages: 159
Registered: September 2010
Senior Member
Ed,

Thanks. I could sort out that. Kosala
Re: How to do JAXB annotations in ecore? [message #1759233 is a reply to message #894506] Sat, 08 April 2017 07:54 Go to previous message
Veselin Markov is currently offline Veselin MarkovFriend
Messages: 15
Registered: February 2012
Junior Member
Hello,

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.

There is an Eclipse plugin - EMF REST - on the web but it and does not do exactly what I need and have couple of bugs. It uses its own JET templates to generate the annotations. See https://github.com/SOM-Research/emf-rest/blob/master/emf-rest-src/emf-rest/templates/model/Class.javajet line 791. Is it possible to integrate a solution like that into EMF? Maybe a parameter that enables the generation of the annotations?

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.

Gegards
Veselin
Re: How to do JAXB annotations in ecore? [message #1759241 is a reply to message #1759233] Sat, 08 April 2017 00:51 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
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.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to do JAXB annotations in ecore? [message #1759247 is a reply to message #1759233] Sat, 08 April 2017 07:24 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

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

Regards

Ed Willink
Previous Topic:XML Namespace not being propagated
Next Topic:Resources loaded from platform:/plugin URIs are not considered read-only by EcoreEditor
Goto Forum:
  


Current Time: Thu Apr 25 23:12:19 GMT 2024

Powered by FUDForum. Page generated in 0.05216 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top