Skip to main content



      Home
Home » Modeling » EMF » jet template engine in standalone application
jet template engine in standalone application [message #376642] Wed, 15 January 2003 05:35 Go to next message
Eclipse UserFriend
Hi,

I have been using the JET template engine to generate some XML files. The
way I've used it is to write some templates and have them compiled to Java
classes with the JETBuilder (and Java Builder). The resulting class can
then be used standalone by invoking its generate method. All this is very
easy and straightforward.

I was wondering if it is possible to use the parts of JET which parse the
template and create a Java source file for it in a standalone application.
In other words, I'd like to use the JETBuilder outside Eclipse. Is this
possible? How would I do that? Would it even be possible to use the
dynamic templates in this fashion?

TIA,

--
knut
Re: jet template engine in standalone application [message #376643 is a reply to message #376642] Wed, 15 January 2003 10:19 Go to previous messageGo to next message
Eclipse UserFriend
Knut,

JETBuilder is very Eclipse dependent. JETCompiler, which is the class that
actually takes a template and turns it into a java file, has only a small
Eclipse dependency. You might be able to easily create a subclass that
overrides that part and then run it standalone.

Frank.


Knut Wannheden wrote:

> Hi,
>
> I have been using the JET template engine to generate some XML files. The
> way I've used it is to write some templates and have them compiled to Java
> classes with the JETBuilder (and Java Builder). The resulting class can
> then be used standalone by invoking its generate method. All this is very
> easy and straightforward.
>
> I was wondering if it is possible to use the parts of JET which parse the
> template and create a Java source file for it in a standalone application.
> In other words, I'd like to use the JETBuilder outside Eclipse. Is this
> possible? How would I do that? Would it even be possible to use the
> dynamic templates in this fashion?
>
> TIA,
>
> --
> knut
Re: jet template engine in standalone application [message #376645 is a reply to message #376643] Thu, 16 January 2003 06:34 Go to previous messageGo to next message
Eclipse UserFriend
Frank,

Thank you for your reply.

I noticed that the JETCompiler class has some dependencies on the
org.eclipse.core.runtime plugin. It is used for dealing with URIs and
resolving URIs with the "platform" protocol. Also it uses the java.net.URL
implementation to deal with URLs. Wouldn't it be possible to rip those
parts out and replace it with the URI and URIConverter implementation of
EMF? Or would that create undesired dependencies?

--
knut

>
> JETBuilder is very Eclipse dependent. JETCompiler, which is the class that
> actually takes a template and turns it into a java file, has only a small
> Eclipse dependency. You might be able to easily create a subclass that
> overrides that part and then run it standalone.
>
> Frank.
>
>
> Knut Wannheden wrote:
>
> > Hi,
> >
> > I have been using the JET template engine to generate some XML files.
The
> > way I've used it is to write some templates and have them compiled to
Java
> > classes with the JETBuilder (and Java Builder). The resulting class can
> > then be used standalone by invoking its generate method. All this is
very
> > easy and straightforward.
> >
> > I was wondering if it is possible to use the parts of JET which parse
the
> > template and create a Java source file for it in a standalone
application.
> > In other words, I'd like to use the JETBuilder outside Eclipse. Is this
> > possible? How would I do that? Would it even be possible to use the
> > dynamic templates in this fashion?
> >
> > TIA,
> >
> > --
> > knut
>
Re: jet template engine in standalone application [message #376646 is a reply to message #376645] Thu, 16 January 2003 07:28 Go to previous messageGo to next message
Eclipse UserFriend
> I noticed that the JETCompiler class has some dependencies on the
> org.eclipse.core.runtime plugin. It is used for dealing with URIs and
> resolving URIs with the "platform" protocol. Also it uses the
java.net.URL
> implementation to deal with URLs. Wouldn't it be possible to rip those
> parts out and replace it with the URI and URIConverter implementation of
> EMF? Or would that create undesired dependencies?
>

OK, I had to give it a try. I tried to use the EMF URI and URIConverter
instead, but ran into problems. The URIConverterImpl class uses the
EcorePlugin.resolvePlatformResourcePath(String) method to create an
InputStream or OutputStream for a platform URI. But the
EcorePlugin#platformResourceMap which should contain mappings from project
names to URIs is empty. Isn't this automatically initialized when *not* in
headless environment? Further, the URIConverterImpl contains some commented
test code in the default constructor to initialize this map. But as noted,
it's commented out.

This isn't really a serious problem for me, as I don't intend to work with
platform URIs in headless environment. But I was surprised that
EcorePlugin#platformResourceMap wasn't initialized when running in Eclipse.

What would be required to use the dynamic templating mechanism in a headless
environment? Can this be done?

Cheers,

--
knut
Re: jet template engine in standalone application [message #376656 is a reply to message #376646] Fri, 17 January 2003 14:00 Go to previous message
Eclipse UserFriend
Knut,

First of all, you are right that we don't want to put a dependency on the ecore
plugin in JET. JET is a low level plugin that is also used independent of EMF.

The platformResourceMap is only used when EMF is running standalone. When
Eclipse is around (headless or not), the platform://resource scheme is
implemented using standard Eclipse APIs. In the standalone environment, you can
populate the platformResourceMap to provide the mapping of platform URI prefixes
(projects) to physical filesystem directories, where the serialized EMF
documents will be, so that cross document references, for example, can be
navigated in the standalone environment. If you don't want to use the same EMF
documents inside and outside eclipse, none of this is needed.

Back to JET, I think that for a pure standalone use, we can avoid this stuff
entirely. To use dynamic templates standalone, I think that avoiding the
platform project/resource stuff in the template path code is the main thing that
needs to be avoided. I think that overriding it with standard java File API
would be pretty easy.

Frank.


Knut Wannheden wrote:

> > I noticed that the JETCompiler class has some dependencies on the
> > org.eclipse.core.runtime plugin. It is used for dealing with URIs and
> > resolving URIs with the "platform" protocol. Also it uses the
> java.net.URL
> > implementation to deal with URLs. Wouldn't it be possible to rip those
> > parts out and replace it with the URI and URIConverter implementation of
> > EMF? Or would that create undesired dependencies?
> >
>
> OK, I had to give it a try. I tried to use the EMF URI and URIConverter
> instead, but ran into problems. The URIConverterImpl class uses the
> EcorePlugin.resolvePlatformResourcePath(String) method to create an
> InputStream or OutputStream for a platform URI. But the
> EcorePlugin#platformResourceMap which should contain mappings from project
> names to URIs is empty. Isn't this automatically initialized when *not* in
> headless environment? Further, the URIConverterImpl contains some commented
> test code in the default constructor to initialize this map. But as noted,
> it's commented out.
>
> This isn't really a serious problem for me, as I don't intend to work with
> platform URIs in headless environment. But I was surprised that
> EcorePlugin#platformResourceMap wasn't initialized when running in Eclipse.
>
> What would be required to use the dynamic templating mechanism in a headless
> environment? Can this be done?
>
> Cheers,
>
> --
> knut
Previous Topic:Where can I find .ecore or .cat file for EMF 1.1?
Next Topic:How to plug to Notifier from generated EMF.Edit objects?
Goto Forum:
  


Current Time: Sun Nov 02 15:31:17 EST 2025

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

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

Back to the top