Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Using your own context or writer
Using your own context or writer [message #53748] Fri, 05 December 2008 18:09 Go to next message
Paul Hammond is currently offline Paul Hammond
Messages: 17
Registered: July 2009
Junior Member
Hi,

Is it possible to have JET create owns own JET2Context implementation
and/or JET2Writer rather than the standard ones? A factory one could
implement and supply to the JET2 plugin definition or something of that
nature so that JET would call your factory to create a context or writer
when it needed to rather than the default one?

Also what is the difference between c:include and c:invokeTransform?

Finally,

Paul
Re: Using your own context or writer [message #53828 is a reply to message #53748] Mon, 08 December 2008 09:05 Go to previous messageGo to next message
Paul Elder is currently offline Paul Elder
Messages: 849
Registered: July 2009
Senior Member
Paul:

My comments below...

"Paul" <paul_hammond@hotmail.com> wrote in message
news:5fcad3a4ae3c33893b2fb1f0368985d0$1@www.eclipse.org...
> Hi,
>
> Is it possible to have JET create owns own JET2Context implementation
> and/or JET2Writer rather than the standard ones? A factory one could
> implement and supply to the JET2 plugin definition or something of that
> nature so that JET would call your factory to create a context or writer
> when it needed to rather than the default one?
>

It is certainly possible. I'd be interested in know what you are trying to
accomplish that the current implementations lack.

> Also what is the difference between c:include and c:invokeTransform?

c:include executes a single template and then includes the expanded content
(i.e. the writer) back into the current template. So, you might do something
like:

<c:include template="templates/copyright.jet"/>
....

At the beginning of a every template.

c:invokeTransform runs another JET transformation. It has been used to
aggregate separate transformations into a single super transformation. The
current implementation is less than ideal - you do not explicitly pass it a
'model' - instead, it receives a copy of the JET2Context from the invoking
transformation - typical usage is for the invoked transform to check a
specific variable. I hope to make it easier to use (some day).

Paul
Re: Using your own context or writer [message #54494 is a reply to message #53828] Wed, 17 December 2008 11:12 Go to previous message
Paul Hammond is currently offline Paul Hammond
Messages: 17
Registered: July 2009
Junior Member
I guess to a certain extent, it allows you to have easy tap in points.

For instance, supposing I wanted to log everything being added into and
out of the JET2Context, as I have no control over the creation of the
JET2Context, I cannot simply do that.

Or supposing everything being written into the JET2Writer I wanted to
either analyse (without interfering with template generation) or filter
and pass into some other function or process as a side effect etc, or pass
through a translator before writing it back out, who knows.

What I propose is this. We already have to specify a TagInstanceFactory
when we create a transformation in JET.

Just change this to a JetFactory with 3 create methods, the existing
createCustomTag and new createJET2Context and createJET2Writer methods.

You can then supply an AbstractJetFactory implementation in JET which
supplies default methods for the createJET2Context and createJET2Writer
methods, and have the user implement the one createCustomTag method as
before but allow them the power to create their own context or writer
should they need to.

Paul
Previous Topic:Comprehensive list of rules for JET classpath
Next Topic:Debug configurations and passing System properties to JET2
Goto Forum:
  


Current Time: Wed Jul 23 16:12:36 EDT 2014

Powered by FUDForum. Page generated in 0.01743 seconds