Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » MoDisco for annotation processing
MoDisco for annotation processing [message #639808] Wed, 17 November 2010 21:32 Go to next message
Laurent Legrand is currently offline Laurent LegrandFriend
Messages: 3
Registered: November 2010
Location: France
Junior Member
Hello,

I'm discovering MoDisco and I'm wondering if MoDisco could be used to do some Java annotation validation.

The idea is to first declare a Model Facet Set on top of the Java metamodel containing:
* A Facet will correspond to a Java annotation. For instance, for the Java annotation MyAnnotation, there will be a corresponding MyAnnotationFacet
* A Facet will extends EClass from the Java metamodel depending on the java.lang.annotation.Target specified on the Java annotation declaration. For instance, if MyAnnotation has Method as target, MyAnnotationFacet will extend MethodDeclaration.
* A FacetStructuralFeature will be declared for each property defined in the Java annotation
* ...

Once done, If I'm right, the Model Browser will highlight in a Java model the elements annotated with MyAnnotation thanks to MyAnnotationFacet.

But could I go a step further and use the faceted model (the virtual one on top of the Java model) for annotation validation in a project? Could I use an EMF based constraint language (OCL, Epsilon) to check rules against instances of classes defined in the Facet Set (I mean define rules using MyAnnotationFacet) ?

I hope my question makes sense.

Regards,

Laurent
Re: MoDisco for annotation processing [message #639884 is a reply to message #639808] Thu, 18 November 2010 09:22 Go to previous messageGo to next message
Gregoire Dupe is currently offline Gregoire DupeFriend
Messages: 75
Registered: September 2009
Location: France
Member
Laurent Legrand wrote on Wed, 17 November 2010 16:32
Hello,

I'm discovering MoDisco and I'm wondering if MoDisco could be used to do some Java annotation validation.

The idea is to first declare a Model Facet Set on top of the Java metamodel containing:
* A Facet will correspond to a Java annotation. For instance, for the Java annotation MyAnnotation, there will be a corresponding MyAnnotationFacet
* A Facet will extends EClass from the Java metamodel depending on the java.lang.annotation.Target specified on the Java annotation declaration. For instance, if MyAnnotation has Method as target, MyAnnotationFacet will extend MethodDeclaration.
* A FacetStructuralFeature will be declared for each property defined in the Java annotation
* ...



This looks good.

Laurent Legrand wrote on Wed, 17 November 2010 16:32

But could I go a step further and use the faceted model (the virtual one on top of the Java model) for annotation validation in a project? Could I use an EMF based constraint language (OCL, Epsilon) to check rules against instances of classes defined in the Facet Set (I mean define rules using MyAnnotationFacet) ?



The only way to use the facets in a program is the MoDisco's Java API. (cf. http://wiki.eclipse.org/MoDisco/Components/FacetManager/Docu mentation/0.8#How_to_programmatically_use_the_MoDisco_facet_ set_catalog)

We plan to provide a mechanism to be able to use any languages next year (Juin 2012).

Regards,
Gregoire Dupe
Re: MoDisco for annotation processing [message #640121 is a reply to message #639884] Fri, 19 November 2010 08:40 Go to previous messageGo to next message
Laurent Legrand is currently offline Laurent LegrandFriend
Messages: 3
Registered: November 2010
Location: France
Junior Member
Thanks for the answer.

Unfortunately, I will have to stick to Java annotation processors.

But what do you think of the approach?
do you think it is valuable or is it better to
* directly extending the Java metamodel
* applying a M2M (from a Java model to my model)
* and then verifying constraints?

Regards,

Laurent
Re: MoDisco for annotation processing [message #640240 is a reply to message #640121] Fri, 19 November 2010 18:04 Go to previous messageGo to next message
Gregoire Dupe is currently offline Gregoire DupeFriend
Messages: 75
Registered: September 2009
Location: France
Member
Hi,

It should work. After you will have transformed the Java model to an extended Java model, you can then use MoDisco's queries, facets and customizations to visualize the constraint violations in the model browser.

Here are some presentations which contain examples which look like what you want to do:
http://fmadiot.blogspot.com/2010/11/eclipse-modeling-week.ht ml
http://www.eclipsecon.org/2010/sessions/?page=sessions&i d=1173

Regards,
Gregoire
Re: MoDisco for annotation processing [message #640704 is a reply to message #640240] Mon, 22 November 2010 21:19 Go to previous message
Laurent Legrand is currently offline Laurent LegrandFriend
Messages: 3
Registered: November 2010
Location: France
Junior Member
Thank you for the links Grégoire. I will look at them.

Laurent
Previous Topic:Setting element 'ID's in KDM and traversing references
Next Topic:Pb with java reverse
Goto Forum:
  


Current Time: Fri Apr 19 07:44:45 GMT 2024

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

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

Back to the top