Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Change Templates at Runtime
[Xpand] Change Templates at Runtime [message #1219668] Thu, 05 December 2013 10:40 Go to next message
Phi Fa is currently offline Phi FaFriend
Messages: 2
Registered: December 2013
Junior Member
Hi guys,
I'm totally new to Xpand and have the following problem.

I work on an Eclipse Application, which also generates code via Xpand from an EMF Model.

Now I want to change some templates of the codegeneration at applications runtime, but before the codegenerator starts. The main application is extended with some plugins which can change at runtime, but every time only one plugin is running (singleton). The current running plugin shell provide the concrete template.

For example:

File A (main template):
...
«DEFINE A FOR Element»
«EXPAND FileB::B»


Plugin 1
File B (dynamic template provided by plugin):
«DEFINE B FOR Element»
//some stuff


Plugin 2:
File B (dynamic template provided by plugin):
«DEFINE B FOR Element»
//some stuff


The problem is at the moment I don't have a really good idea how to do it right and nice....

My ideas:

The names and location of the templates provided by the plugin are always the same.

I was hoping, it is possible to refer to another template from the main template via a path, but it seems, this isn't possible.

Another idea is to modify the bundles jar at runtime and store the dynamic templates in the same package as the main template. At the beginning in this package are some default dynamic templates. I don't know if it is possible to modify a bundle at runtime and this would be a solution I don't prefer.

Is there a way to tell the codegenerator to look in a defined directory for getting the dynamic templates?

Or anyone has a better idea?

Regards







Re: [Xpand] Change Templates at Runtime [message #1220700 is a reply to message #1219668] Fri, 13 December 2013 07:43 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
With Xpand there is no other way than using its AOP feature to configure
different implementations from outside.

If you've just started to implement your code generator,
I strongly suggest to use Xtend (www.xtend-lang.org) instead, as it will
allow you to solve this easily with dependency injection and it has
numereous other advantages.

Sven

Am 12/5/13 2:34 PM, schrieb Phi Fa:
> Hi guys,
> I'm totally new to Xpand and have the following problem.
>
> I work on an Eclipse Application, which also generates code via Xpand
> from an EMF Model.
>
> Now I want to change some templates of the codegeneration at
> applications runtime, but before the codegenerator starts. The main
> application is extended with some plugins which can change at runtime,
> but every time only one plugin is running (singleton). The current
> running plugin shell provide the concrete template.
>
> For example:
>
> File A (main template):
>
> ..
> «DEFINE A FOR Element»
> «EXPAND FileB::B»
>
>
> Plugin 1
> File B (dynamic template provided by plugin):
>
> «DEFINE B FOR Element»
> //some stuff
>
>
> Plugin 2:
> File B (dynamic template provided by plugin):
>
> «DEFINE B FOR Element»
> //some stuff
>
>
> The problem is at the moment I don't have a really good idea how to do
> it right and nice....
>
> My ideas:
>
> The names and location of the templates provided by the plugin are
> always the same.
>
> I was hoping, it is possible to refer to another template from the main
> template via a path, but it seems, this isn't possible.
>
> Another idea is to modify the bundles jar at runtime and store the
> dynamic templates in the same package as the main template. At the
> beginning in this package are some default dynamic templates. I don't
> know if it is possible to modify a bundle at runtime and this would be a
> solution I don't prefer.
>
> Is there a way to tell the codegenerator to look in a defined directory
> for getting the dynamic templates?
> Or anyone has a better idea?
>
> Regards
>
>
>
>
>
>
>
>


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Previous Topic:[Xpand/MWE] Scoping of global variables and element properties
Next Topic:[Acceleo] How to Break a For Loop
Goto Forum:
  


Current Time: Thu Mar 28 20:08:11 GMT 2024

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

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

Back to the top