Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » JET as part of Java(Is it possible to use JET programmatically to auto-generate a custom XML template?)
JET as part of Java [message #490190] Wed, 07 October 2009 18:11 Go to next message
Asha Ramegowda is currently offline Asha RamegowdaFriend
Messages: 77
Registered: July 2009
Member
Hi,

We have a custom XML language and an editor for it. And there is a requirement to auto-generate some XML mark-up.

I would like to know is it possible to use JET as an API and bind it to our existing editor and auto-generate this kind of code/mark up?

More precisely, is it possible to use JET as an API in standalone Java applications and generate code/text as required?

Kindly let me know if there is any useful resource on this?

Thank you in advance.

Asha.
Re: JET as part of Java [message #491150 is a reply to message #490190] Tue, 13 October 2009 13:27 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Asha:

The answer depends a bit on what you mean by 'stand alone Java application'.

JET (M2T JET) has dependencies on OSGi and some portions the Eclipse IDE. So, it is not currently possible to run a JET template in a 'plain-old-Java' application.

But, if your 'stand-alone' application is built on the Eclipse RCP, then it is possible to use JET. I know of applications built on the Eclipse RCP that use JET. In fact, I know of at least one instance where JET transformations have been run in a servlet container!

That said, it is not as easy as it should be to use JET in such environments. I have a Helios plan item to make JET more modular. Here's the link to the bugzilla:

http://bugs.eclipse.org/288512

Paul
Re: JET as part of Java [message #491202 is a reply to message #491150] Tue, 13 October 2009 15:49 Go to previous messageGo to next message
Asha Ramegowda is currently offline Asha RamegowdaFriend
Messages: 77
Registered: July 2009
Member
Hi Paul,

Thanks for the reply.
Just a few hours before you replied to this topic, I got to see this demo on http://live.eclipse.org/node/563 which is really useful. Smile.

Actually right now my requirement is to use the JET API as part of a plug-in. I couldn't get the resources that explained how to do this, easily. (I mean the code/text probably can be generated easily, now I understand that Smile, but this resource can't be found in search 'easily').

But indeed we may have a requirement to do the same in the future in a web based application.
So, I thought of asking the question like that, whether I can use JET API independently in a standalone application thinking that would answer to both of my questions.

I got a tutorial with an example on Eclipse Corner Articles which is probably not compatible with the Galileo. So couldn't run the sample though I got to know how it can be used as an API from within a plugin.

If you can point me to any other resources apart from these two that would be of great help.

But definitely these two are quite clear and useful.

Thanks for the reply.

Thank you,

Asha.
Re: JET as part of Java [message #491386 is a reply to message #490190] Wed, 14 October 2009 12:24 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
The Eclipse Corner article you refer to covers the predecessor to M2T JET - the version of JET that ships with EMF. To distinguish the two, I'll call EMF's version of JET 'JET1' and M2T JET 'JET2'.

JET1 is much simpler:
* It only accepts embedded Java statements and expressions as template markup
* It generates a Java class which with a signature:

String generate(Object argument)


You are responsible for calling this method, and for doing something useful with the result. This generally means writing a fair bit of Java code to orchestrate the template.

One of the main pluses of JET one is that the compiled templates have NO dependencies other that what you explicitly introduce. This is good news if you are hoping to run in a 'stand alone' Java environment.

JET2 has a more complex goal that JET1:It strives to allow the development of Eclipse-based code generators without needing to know Java or the Eclipse APIs.

As such, it supports:
* tag libraries (similar to JSP) for template markup
* it includes tags for all template orchestration (e.g. invocation, writing of results)

The JET2 compiler still creates a Java class for each template, but the generate method is more complex. Most importantly, the Java classes have dependencies on some JET2 classes and, indirectly, some Eclipse classes. This makes consumption of JET2 templates outside of Eclipse or OSGi-based applications problematic at this point.

Take a look at this article for a quick overview of a JET2 transformation:

http://www.ibm.com/developerworks/opensource/library/os-ecl- jet/

Finally, JET2 transformations can be invoked from API. Take a look at the runTransformOnXXX methods in JET2Platform:

http://help.eclipse.org/galileo/topic/org.eclipse.jet.doc/re ferences/javadoc/org/eclipse/jet/JET2Platform.html

Paul


Re: JET as part of Java [message #491474 is a reply to message #491386] Wed, 14 October 2009 18:03 Go to previous message
Asha Ramegowda is currently offline Asha RamegowdaFriend
Messages: 77
Registered: July 2009
Member
Hi Paul,

Thank you very much for sharing this information.
That helps especially when it comes to calling JET as an API.
I found one more article on DevX that was useful and can help a beginner understand how to use JET tags and templates.
Posting that link here for the sake of information: http://www.devx.com/opensource/Article/34929/

Thank you,

Asha.
Previous Topic:Transforming emx files (RSM)
Next Topic:How to define Xtend method like: collection.retainAll(e|expression with e) ?
Goto Forum:
  


Current Time: Sat Oct 12 09:30:59 GMT 2024

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

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

Back to the top