Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Integrate with EMF code generation
Integrate with EMF code generation [message #416398] Wed, 30 January 2008 11:45 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ed (and others),
I would like users of Teneo to be able to generate jpa annotations in their model code. My thought
is that people install the Teneo plugins and EMF plugins and then with minimal
additions/configurations in their genmodel or project be able to generate jpa annotations in their
emf-generated code (using the standard EMF code generation menu options). Teneo generates the jpa
annotations but now I need to get them into the model code.

For this I can use dynamic templates (and provide these templates in a Teneo plugin), but more
importantly I need to prepare a separate model which is used by the templates, related to this I
have a classloading question.
For example I would like to add the following code to the templates (before the getter in the template):
jpaAnnotator.getAnnotations(EStructuralFeature eFeature)

however for this to work the EMF code generation plugin needs to know which class/instance
jpaAnnotator is (i.e. which plugin provides it and how to create it).
In addition it would be nice if the jpaAnnotator could get hold of the actual location of the ecore
or model files in the workspace so that it can read additional property/xml files. Is this something
which can be retrieved from the genmodel instance?

Are there specific extension points which I can use for this? Or is there a standard approach I can
follow?

I looked through previous posts on this topic but my main remaining question is especially the
classloading issue (how are the teneo plugins 'dynamically' added to the classpath of the emf
plugins) and how to inject an jpaAnnotator instance in the EMF code generation environment.

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Integrate with EMF code generation [message #416399 is a reply to message #416398] Wed, 30 January 2008 11:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040604060103040708060303
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin,

Comments below.

Martin Taal wrote:
> Hi Ed (and others),
> I would like users of Teneo to be able to generate jpa annotations in
> their model code. My thought is that people install the Teneo plugins
> and EMF plugins and then with minimal additions/configurations in
> their genmodel or project be able to generate jpa annotations in their
> emf-generated code (using the standard EMF code generation menu
> options). Teneo generates the jpa annotations but now I need to get
> them into the model code.
I see.
>
> For this I can use dynamic templates (and provide these templates in a
> Teneo plugin), but more importantly I need to prepare a separate model
> which is used by the templates, related to this I have a classloading
> question.
It would seem nicer if we had some type of extensibility mechanism. This
bugzilla hints about that

https://bugs.eclipse.org/bugs/show_bug.cgi?id=176726

> For example I would like to add the following code to the templates
> (before the getter in the template):
> jpaAnnotator.getAnnotations(EStructuralFeature eFeature)
>
> however for this to work the EMF code generation plugin needs to know
> which class/instance jpaAnnotator is (i.e. which plugin provides it
> and how to create it).
> In addition it would be nice if the jpaAnnotator could get hold of the
> actual location of the ecore or model files in the workspace so that
> it can read additional property/xml files. Is this something which can
> be retrieved from the genmodel instance?
GenModel does support GenAnnotations, so it's definitely possible to
associate additional information with the GenModel (at any level)
without actually extending the model.
>
> Are there specific extension points which I can use for this? Or is
> there a standard approach I can follow?
Not yet, but I'd certainly be interested in working with you to arrange
for that to be possible.
>
> I looked through previous posts on this topic but my main remaining
> question is especially the classloading issue (how are the teneo
> plugins 'dynamically' added to the classpath of the emf plugins) and
> how to inject an jpaAnnotator instance in the EMF code generation
> environment.
I'd like to arrive at some type of mechanism whereby you'd not need
dynamic templates nor a derived GenModel to achieve this goal.
Obviously we'd need some type of APIs in the GenModel that would allow
the generator templates to fetch the annotations needed for the class
and for the generated methods (operations and feature accessors). I
think you already have annotations on the Ecore model that you could
interpret to produce the Java 5.0 annotations, so perhaps what's needed
is some type of registry that allows folks to plugin such interpreters
or maybe there's a GenModel property that lists the interpreters that
should be invoked for the model; it could specify both the plugin ID and
the class name.

As I said, ideally I'd like to come up with something that does not
require dynamic templates nor a derived GenModel because that seems
heavy weight and it makes combining different extensions impossible.


--------------040604060103040708060303
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Martin,<br>
<br>
Comments below.<br>
<br>
Martin Taal wrote:
<blockquote cite="mid:fnpo0a$2ul$1@build.eclipse.org" type="cite">Hi Ed
(and others),
<br>
I would like users of Teneo to be able to generate jpa annotations in
their model code. My thought is that people install the Teneo plugins
and EMF plugins and then with minimal additions/configurations in their
genmodel or project be able to generate jpa annotations in their
emf-generated code (using the standard EMF code generation menu
options). Teneo generates the jpa annotations but now I need to get
them into the model code.
<br>
</blockquote>
I see.<br>
<blockquote cite="mid:fnpo0a$2ul$1@build.eclipse.org" type="cite"><br>
For this I can use dynamic templates (and provide these templates in a
Teneo plugin), but more importantly I need to prepare a separate model
which is used by the templates, related to this I have a classloading
question.
<br>
</blockquote>
It would seem nicer if we had some type of extensibility mechanism.
This bugzilla hints about that<br>
<blockquote><a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=176726">https://bugs.eclipse.org/bugs/show_bug.cgi?id=176726</a><br>
</blockquote>
<blockquote cite="mid:fnpo0a$2ul$1@build.eclipse.org" type="cite">For
example I would like to add the following code to the templates (before
the getter in the template):
<br>
jpaAnnotator.getAnnotations(EStructuralFeature eFeature)
<br>
<br>
however for this to work the EMF code generation plugin needs to know
which class/instance jpaAnnotator is (i.e. which plugin provides it and
how to create it).
<br>
In addition it would be nice if the jpaAnnotator could get hold of the
actual location of the ecore or model files in the workspace so that it
can read additional property/xml files. Is this something which can be
retrieved from the genmodel instance?
<br>
</blockquote>
GenModel does support GenAnnotations, so it's definitely possible to
associate additional information with the GenModel (at any level)
without actually extending the model.<br>
<blockquote cite="mid:fnpo0a$2ul$1@build.eclipse.org" type="cite"><br>
Are there specific extension points which I can use for this? Or is
there a standard approach I can follow?
<br>
</blockquote>
Not yet, but I'd certainly be interested in working with you to arrange
for that to be possible.<br>
<blockquote cite="mid:fnpo0a$2ul$1@build.eclipse.org" type="cite"><br>
I looked through previous posts on this topic but my main remaining
question is especially the classloading issue (how are the teneo
plugins 'dynamically' added to the classpath of the emf plugins) and
how to inject an jpaAnnotator instance in the EMF code generation
environment.
<br>
</blockquote>
I'd like to arrive at some type of mechanism whereby you'd not need
dynamic templates nor a derived GenModel to achieve this goal.&nbsp;
Obviously we'd need some type of APIs in the GenModel that would allow
the generator templates to fetch the annotations needed for the class
and for the generated methods (operations and feature accessors).&nbsp; I
think you already have annotations on the Ecore model that you could
interpret to produce the Java 5.0 annotations, so perhaps what's needed
is some type of registry that allows folks to plugin such interpreters
or maybe there's a GenModel property that lists the interpreters that
should be invoked for the model; it could specify both the plugin ID
and the class name.<br>
<br>
As I said, ideally I'd like to come up with something that does not
require dynamic templates nor a derived GenModel because that seems
heavy weight and it makes combining different extensions impossible.<br>
<br>
</body>
</html>

--------------040604060103040708060303--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Integrate with EMF code generation [message #416411 is a reply to message #416399] Wed, 30 January 2008 16:12 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ed,
Hmmm yes I would also prefer to work without dynamic templates. Genmodel property is fine, or an
extension point, which one is easier to in your opinion?

The annotator class (which can then be specified in the genmodel or the extension point) could have
an interface like this (just thinking out loud here):

interface EMFAnnotator {

/** is called once before the generation step, maybe other context classes can be passed
also/instead? */
initialize(GenModel genModel);

/** Returns an annotation for a specific GenClass */
String getAnnotations(GenClass genClass);

/** Returns an annotation for a property */
String getMemberAnnotations(GenFeature genFeature);

/** Returns an annotation for a getter */
String getGetterAnnotations(GenFeature genFeature);

/** Returns an annotation for a setter */
String getSetterAnnotations(GenFeature genFeature);
}

In the emf templates there should then be calls made to a EMFAnnotatorController (or something
similar) which calls the registered EMFAnnotators and returns the string to be placed in the source
code.
The annotations also need to be added to the importmanager, this should be done by the EMFAnnotator
implementations so they should also have access to the importmanager.

gr. Martin

Ed Merks wrote:
> Martin,
>
> Comments below.
>
> Martin Taal wrote:
>> Hi Ed (and others),
>> I would like users of Teneo to be able to generate jpa annotations in
>> their model code. My thought is that people install the Teneo plugins
>> and EMF plugins and then with minimal additions/configurations in
>> their genmodel or project be able to generate jpa annotations in their
>> emf-generated code (using the standard EMF code generation menu
>> options). Teneo generates the jpa annotations but now I need to get
>> them into the model code.
> I see.
>>
>> For this I can use dynamic templates (and provide these templates in a
>> Teneo plugin), but more importantly I need to prepare a separate model
>> which is used by the templates, related to this I have a classloading
>> question.
> It would seem nicer if we had some type of extensibility mechanism. This
> bugzilla hints about that
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176726
>
>> For example I would like to add the following code to the templates
>> (before the getter in the template):
>> jpaAnnotator.getAnnotations(EStructuralFeature eFeature)
>>
>> however for this to work the EMF code generation plugin needs to know
>> which class/instance jpaAnnotator is (i.e. which plugin provides it
>> and how to create it).
>> In addition it would be nice if the jpaAnnotator could get hold of the
>> actual location of the ecore or model files in the workspace so that
>> it can read additional property/xml files. Is this something which can
>> be retrieved from the genmodel instance?
> GenModel does support GenAnnotations, so it's definitely possible to
> associate additional information with the GenModel (at any level)
> without actually extending the model.
>>
>> Are there specific extension points which I can use for this? Or is
>> there a standard approach I can follow?
> Not yet, but I'd certainly be interested in working with you to arrange
> for that to be possible.
>>
>> I looked through previous posts on this topic but my main remaining
>> question is especially the classloading issue (how are the teneo
>> plugins 'dynamically' added to the classpath of the emf plugins) and
>> how to inject an jpaAnnotator instance in the EMF code generation
>> environment.
> I'd like to arrive at some type of mechanism whereby you'd not need
> dynamic templates nor a derived GenModel to achieve this goal.
> Obviously we'd need some type of APIs in the GenModel that would allow
> the generator templates to fetch the annotations needed for the class
> and for the generated methods (operations and feature accessors). I
> think you already have annotations on the Ecore model that you could
> interpret to produce the Java 5.0 annotations, so perhaps what's needed
> is some type of registry that allows folks to plugin such interpreters
> or maybe there's a GenModel property that lists the interpreters that
> should be invoked for the model; it could specify both the plugin ID and
> the class name.
>
> As I said, ideally I'd like to come up with something that does not
> require dynamic templates nor a derived GenModel because that seems
> heavy weight and it makes combining different extensions impossible.
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Integrate with EMF code generation [message #416415 is a reply to message #416411] Wed, 30 January 2008 17:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Martin,

Please open a new bugzilla feature request for this proposal. The
existing bug I mentioned would be best to implement using the same
extension mechanism so that there are no first and second class citizens
for this type of generated annotation support. The extension might even
help specify the merge rules that would apply to these annotations...


Martin Taal wrote:
> Hi Ed,
> Hmmm yes I would also prefer to work without dynamic templates.
> Genmodel property is fine, or an extension point, which one is easier
> to in your opinion?
>
> The annotator class (which can then be specified in the genmodel or
> the extension point) could have an interface like this (just thinking
> out loud here):
>
> interface EMFAnnotator {
>
> /** is called once before the generation step, maybe other context
> classes can be passed also/instead? */
> initialize(GenModel genModel);
>
> /** Returns an annotation for a specific GenClass */
> String getAnnotations(GenClass genClass);
>
> /** Returns an annotation for a property */
> String getMemberAnnotations(GenFeature genFeature);
>
> /** Returns an annotation for a getter */
> String getGetterAnnotations(GenFeature genFeature);
>
> /** Returns an annotation for a setter */
> String getSetterAnnotations(GenFeature genFeature);
> }
>
> In the emf templates there should then be calls made to a
> EMFAnnotatorController (or something similar) which calls the
> registered EMFAnnotators and returns the string to be placed in the
> source code.
> The annotations also need to be added to the importmanager, this
> should be done by the EMFAnnotator implementations so they should also
> have access to the importmanager.
>
> gr. Martin
>
> Ed Merks wrote:
>> Martin,
>>
>> Comments below.
>>
>> Martin Taal wrote:
>>> Hi Ed (and others),
>>> I would like users of Teneo to be able to generate jpa annotations
>>> in their model code. My thought is that people install the Teneo
>>> plugins and EMF plugins and then with minimal
>>> additions/configurations in their genmodel or project be able to
>>> generate jpa annotations in their emf-generated code (using the
>>> standard EMF code generation menu options). Teneo generates the jpa
>>> annotations but now I need to get them into the model code.
>> I see.
>>>
>>> For this I can use dynamic templates (and provide these templates in
>>> a Teneo plugin), but more importantly I need to prepare a separate
>>> model which is used by the templates, related to this I have a
>>> classloading question.
>> It would seem nicer if we had some type of extensibility mechanism.
>> This bugzilla hints about that
>>
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176726
>>
>>> For example I would like to add the following code to the templates
>>> (before the getter in the template):
>>> jpaAnnotator.getAnnotations(EStructuralFeature eFeature)
>>>
>>> however for this to work the EMF code generation plugin needs to
>>> know which class/instance jpaAnnotator is (i.e. which plugin
>>> provides it and how to create it).
>>> In addition it would be nice if the jpaAnnotator could get hold of
>>> the actual location of the ecore or model files in the workspace so
>>> that it can read additional property/xml files. Is this something
>>> which can be retrieved from the genmodel instance?
>> GenModel does support GenAnnotations, so it's definitely possible to
>> associate additional information with the GenModel (at any level)
>> without actually extending the model.
>>>
>>> Are there specific extension points which I can use for this? Or is
>>> there a standard approach I can follow?
>> Not yet, but I'd certainly be interested in working with you to
>> arrange for that to be possible.
>>>
>>> I looked through previous posts on this topic but my main remaining
>>> question is especially the classloading issue (how are the teneo
>>> plugins 'dynamically' added to the classpath of the emf plugins) and
>>> how to inject an jpaAnnotator instance in the EMF code generation
>>> environment.
>> I'd like to arrive at some type of mechanism whereby you'd not need
>> dynamic templates nor a derived GenModel to achieve this goal.
>> Obviously we'd need some type of APIs in the GenModel that would
>> allow the generator templates to fetch the annotations needed for the
>> class and for the generated methods (operations and feature
>> accessors). I think you already have annotations on the Ecore model
>> that you could interpret to produce the Java 5.0 annotations, so
>> perhaps what's needed is some type of registry that allows folks to
>> plugin such interpreters or maybe there's a GenModel property that
>> lists the interpreters that should be invoked for the model; it could
>> specify both the plugin ID and the class name.
>>
>> As I said, ideally I'd like to come up with something that does not
>> require dynamic templates nor a derived GenModel because that seems
>> heavy weight and it makes combining different extensions impossible.
>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Integrate with EMF code generation [message #416419 is a reply to message #416415] Thu, 31 January 2008 07:43 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ed,
Here it is:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=217220

gr. Martin

Ed Merks wrote:
> Martin,
>
> Please open a new bugzilla feature request for this proposal. The
> existing bug I mentioned would be best to implement using the same
> extension mechanism so that there are no first and second class citizens
> for this type of generated annotation support. The extension might even
> help specify the merge rules that would apply to these annotations...
>
>
> Martin Taal wrote:
>> Hi Ed,
>> Hmmm yes I would also prefer to work without dynamic templates.
>> Genmodel property is fine, or an extension point, which one is easier
>> to in your opinion?
>>
>> The annotator class (which can then be specified in the genmodel or
>> the extension point) could have an interface like this (just thinking
>> out loud here):
>>
>> interface EMFAnnotator {
>>
>> /** is called once before the generation step, maybe other context
>> classes can be passed also/instead? */
>> initialize(GenModel genModel);
>> /** Returns an annotation for a specific GenClass */
>> String getAnnotations(GenClass genClass);
>>
>> /** Returns an annotation for a property */
>> String getMemberAnnotations(GenFeature genFeature);
>>
>> /** Returns an annotation for a getter */
>> String getGetterAnnotations(GenFeature genFeature);
>>
>> /** Returns an annotation for a setter */
>> String getSetterAnnotations(GenFeature genFeature);
>> }
>>
>> In the emf templates there should then be calls made to a
>> EMFAnnotatorController (or something similar) which calls the
>> registered EMFAnnotators and returns the string to be placed in the
>> source code.
>> The annotations also need to be added to the importmanager, this
>> should be done by the EMFAnnotator implementations so they should also
>> have access to the importmanager.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Martin,
>>>
>>> Comments below.
>>>
>>> Martin Taal wrote:
>>>> Hi Ed (and others),
>>>> I would like users of Teneo to be able to generate jpa annotations
>>>> in their model code. My thought is that people install the Teneo
>>>> plugins and EMF plugins and then with minimal
>>>> additions/configurations in their genmodel or project be able to
>>>> generate jpa annotations in their emf-generated code (using the
>>>> standard EMF code generation menu options). Teneo generates the jpa
>>>> annotations but now I need to get them into the model code.
>>> I see.
>>>>
>>>> For this I can use dynamic templates (and provide these templates in
>>>> a Teneo plugin), but more importantly I need to prepare a separate
>>>> model which is used by the templates, related to this I have a
>>>> classloading question.
>>> It would seem nicer if we had some type of extensibility mechanism.
>>> This bugzilla hints about that
>>>
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=176726
>>>
>>>> For example I would like to add the following code to the templates
>>>> (before the getter in the template):
>>>> jpaAnnotator.getAnnotations(EStructuralFeature eFeature)
>>>>
>>>> however for this to work the EMF code generation plugin needs to
>>>> know which class/instance jpaAnnotator is (i.e. which plugin
>>>> provides it and how to create it).
>>>> In addition it would be nice if the jpaAnnotator could get hold of
>>>> the actual location of the ecore or model files in the workspace so
>>>> that it can read additional property/xml files. Is this something
>>>> which can be retrieved from the genmodel instance?
>>> GenModel does support GenAnnotations, so it's definitely possible to
>>> associate additional information with the GenModel (at any level)
>>> without actually extending the model.
>>>>
>>>> Are there specific extension points which I can use for this? Or is
>>>> there a standard approach I can follow?
>>> Not yet, but I'd certainly be interested in working with you to
>>> arrange for that to be possible.
>>>>
>>>> I looked through previous posts on this topic but my main remaining
>>>> question is especially the classloading issue (how are the teneo
>>>> plugins 'dynamically' added to the classpath of the emf plugins) and
>>>> how to inject an jpaAnnotator instance in the EMF code generation
>>>> environment.
>>> I'd like to arrive at some type of mechanism whereby you'd not need
>>> dynamic templates nor a derived GenModel to achieve this goal.
>>> Obviously we'd need some type of APIs in the GenModel that would
>>> allow the generator templates to fetch the annotations needed for the
>>> class and for the generated methods (operations and feature
>>> accessors). I think you already have annotations on the Ecore model
>>> that you could interpret to produce the Java 5.0 annotations, so
>>> perhaps what's needed is some type of registry that allows folks to
>>> plugin such interpreters or maybe there's a GenModel property that
>>> lists the interpreters that should be invoked for the model; it could
>>> specify both the plugin ID and the class name.
>>>
>>> As I said, ideally I'd like to come up with something that does not
>>> require dynamic templates nor a derived GenModel because that seems
>>> heavy weight and it makes combining different extensions impossible.
>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:Preserving XML comments during serialization and deserialization of XML document
Next Topic:[newbie qns] reflection and class impl
Goto Forum:
  


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

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

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

Back to the top