|JET as part of Java [message #490190]
||Wed, 07 October 2009 18:11
| Asha Ramegowda
Registered: July 2009
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.
|Re: JET as part of Java [message #491386 is a reply to message #490190]
||Wed, 14 October 2009 12:24
| Paul Elder
Registered: July 2009
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:
Finally, JET2 transformations can be invoked from API. Take a look at the runTransformOnXXX methods in JET2Platform:
Powered by FUDForum
. Page generated in 0.03067 seconds