Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [acceleo-dev] Dynamic polyphormism + overriding for templates and queries

Hello,


Acceleo uses the same guidelines as EMF Compare for gerrit reviews, you can get most information from https://wiki.eclipse.org/EMF_Compare/Gerrit . The most basic requirement is that you need to have signed an Eclipse Contributor Agreement (ECA) with the eclipse foundation. For this you will have to follow the instructions from https://wiki.eclipse.org/Development_Resources/Contributing_via_Git#Eclipse_Contributor_Agreement .


Please let me know if some of the instructions are unclear or out of date.


We will try and review this as soon as possible.


Laurent Goubet

Obeo


On 04/11/2019 19:03, pere lengo wrote:
Good Evening,

I am writing because, some time ago I funded a MDA company, that vastly implemented Acceleo as a code generation mechanism.

As part of the architecture of the framework  a crucial part of the requirements of the framework required dynamic overriding and polyphormism, in order to allow (for example) setting different name rules for various companies as per their naming standards requirements.

One of the major problems found is that the overriding mechanism is not suitable for generators that are not open-sourced because it is mandatory to import the extended template and use it explicitly, which makes extension mechanism very limited. A similar problem applies to queries, that cannot be overriden.
Another very interesting extension mechanism that requires implicit import declaration is Polyphormism. However, the fact that it requires an implicit import also makes it less usable.

As an example of what I attempted to achieve:

-I have a _javascript_ generator that generates a _javascript_ function that has to invoke a remote server.
-The client code could be generated for REST protocol, JSON-RPC protocol, or whatever protocol the architect decides, depending on the UML stereotypes applied to ports connecting the client and server component.
-I want to be able to generate the client for more than these two protocols without having to import the new generators in the old templates.

To solve all of these problems, I've patched a couple of classes, to allow dynamic polyphormism without imports and query dynamic overriding mechanisms.

For example, we want to make a call to a template as follows:
[generateClientInstanceByTecnology(sourceTecnology,targetTecnology, targetInterface, sourcePorts, sourceComponent, targetPorts, targetComponent, model)/]

Which invokes:
[template public generateClientInstanceByTecnology (sourceTecnology : Stereotype, targetTecnology : Stereotype,  targetInterface : Interface , sourcePorts : Set(Port), sourceComponent : Component, targetPorts : Set(Port), targetComponent : Component,  model : Model) ]
[ generateClientInstanceByTecnology2(sourceTecnology.getStereotypeMetaClass(), targetTecnology.getStereotypeMetaClass(), targetInterface, sourcePorts, sourceComponent, targetPorts, targetComponent, model)/]
[/template]

And the default implementation:
[template public generateClientInstanceByTecnology2 (sourceTecnology : OclAny, targetTecnology : OclAny,  targetInterface : Interface , sourcePorts : Set(Port), sourceComponent : Component, targetPorts : Set(Port), targetComponent : Component,  model : Model)  ]
// FIXME - Non available generators for
// [sourceTecnology/]
// and
// [targetTecnology/]
[/template]

An implementor can extend this generator for example for Dojo (_javascript_ framework) clients, requesting HTTP servers in this way:
[template public generateClientInstanceByTecnology2 (sourceTecnology : Dojotoolkit , targetTecnology : Http, targetInterface : Interface , sourcePorts : Set(Port), sourceComponent : Component, targetPorts : Set(Port), targetComponent : Component,  model : Model) ]
....
[/template]

Another implementor can extend this generator for example for Angular (_javascript_ framework) clients, requesting JSON-RPC servers in this way:
[template public generateClientInstanceByTecnology2 (sourceTecnology : Angular, targetTecnology : JsonRpc, targetInterface : Interface , sourcePorts : Set(Port), sourceComponent : Component, targetPorts : Set(Port), targetComponent : Component,  model : Model) ]
....
[/template]

I would like to know what the requirements to push the code to the repository are and how to document these functionalities.
I have this patch applied to R3_3_maintenance branch- do you think that it is necessary to upgrade it to the master version and make appropiate tests to validate it? If so, I kindly request your assitance for the pulling phase.

Many thanks,

Pere Joseph Rodríguez



_______________________________________________
acceleo-dev mailing list
acceleo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/acceleo-dev
--

Laurent Goubet
Consultant
+33 2 51 13 51 42

7 Boulevard Ampère - Carquefou - France
obeo.fr | twitter | linkedin

begin:vcard
fn:Laurent Goubet
n:Goubet;Laurent
org:<a href="http://www.obeo.fr";>Obeo</a>
email;internet:laurent.goubet@xxxxxxx
url:http://www.obeo.fr
version:2.1
end:vcard


Back to the top