Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Invoking Expand generator from Java
Invoking Expand generator from Java [message #484710] Tue, 08 September 2009 20:17 Go to next message
John Bito is currently offline John BitoFriend
Messages: 54
Registered: July 2009
Member
As I develop a generator with Xtext, I'm curious about options to reduce
the resource requirements. One thing that seems expensive in my scenario
is initializing the workflow for each model file. My project has several
thousand model files, so it looks like significant time may go into
initializing the MWE workflow.

Since I'm running the process from a Java application that is already
invoking the parser directly (through XtextResourceSet), I wonder if there
is a reasonable API to invoke the Xpand without starting an MWE Workflow.
What I'm not clear on is how I may provide the the instance with the model
instance that will drive template expansion. I see
org.eclipse.xpand2.XpandFacade, but its JavaDoc is bare and searches don't
yield any apparently useful references.

Thanks for you advice!
John
Re: Invoking Expand generator from Java [message #485227 is a reply to message #484710] Thu, 10 September 2009 20:37 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1771
Registered: July 2009
Senior Member
Hi John,

you're on the right track :-)
The XpandFacade can be used like this:

// create an execution context
XpandExecutionContextImpl execCtx = new
XpandExecutionContextImpl(output, null);
execCtx.setFileEncoding("iso-8859-1"); //$NON-NLS-1$
execCtx.registerMetaModel(new JavaBeansMetaModel());

// create a facade
XpandFacade facade = XpandFacade.create(execCtx);

// invoke a template definition
facade.evaluate("foo:bar::MyTemplate::definition", myObject);


Hope that helps.
Cheers,
Sven


John schrieb:
> As I develop a generator with Xtext, I'm curious about options to reduce
> the resource requirements. One thing that seems expensive in my
> scenario is initializing the workflow for each model file. My project
> has several thousand model files, so it looks like significant time may
> go into initializing the MWE workflow.
>
> Since I'm running the process from a Java application that is already
> invoking the parser directly (through XtextResourceSet), I wonder if
> there is a reasonable API to invoke the Xpand without starting an MWE
> Workflow. What I'm not clear on is how I may provide the the instance
> with the model instance that will drive template expansion. I see
> org.eclipse.xpand2.XpandFacade, but its JavaDoc is bare and searches
> don't yield any apparently useful references.
>
> Thanks for you advice!
> John
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


--
Need professional support on Xtext or Xtend?
Mail to: xtext (at) itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Previous Topic:[XPAND] 50 % slowdown compared to OAW XPAND
Next Topic:[Acceleo] Downcasting issue again
Goto Forum:
  


Current Time: Fri Dec 19 04:48:45 GMT 2014

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

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