Hi James,
answer inline:
> -----Original Message-----
> From: James Strachan [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 07, 2002 9:41 PM
>
> ----- Original Message -----
> From: "Paulo Gaspar" <[EMAIL PROTECTED]>
> > Hi James,
> >
> >
> > I think that pnuts is not so efficient when using it trough BSF,
> > but I do not remeber the specifics so well anymore.
>
> Actually I've just done the BSF integration with Jelly and you're right. I
> think I'll add a tag library to go direct to pnuts shortly, certainly
> getting access to pnuts compiling would be better for sure. BSF
> just allows
> you to get a CodeBuffer which contains the Java code in it, which you have
> to compile & classload yourself.
In my experience it is worth the trouble. When compiled I notice no
difference from Java code and compiling it the 1t time takes much
less time than a similar JSP script (which is natural since the
compilation is all done in memory).
Keep in mind the class loader issues. Posting the fix to the pnuts
list together with its reason is in my todo list for some time, I
will try to do it this week so that it can benefit your work too.
Basically, I remember that one of the problems is avoided if you
always initialize the Context's class loader. The other problem
also has to do with having a ClassLoader set to null.
I only noticed these issues when running the code from a Servlet
outside JBuilder. Inside JBuilder it runs fine.
> ...
>
> This all looks great stuff Paulo.
Thanks!
=:o)
> I'd be interested in finding out more on how you integrate pnuts with XML.
Well, this thing is a bit like Cocoon with a much lower level of XML
obsession.
=;o)
I read the xml configuration/structure via Avalon's configuration
mechanism
jakarta-avalon\src\java\org\apache\avalon\framework\configuration
and I manage the components using something like Avalon's
ComponentManager. Although mine is a VERY HEAVILY modified version, the
ideas are basically the same.
Then the trick is to expose some bits of the ComponentManager to the
script as part of an "object model" that also includes request
information and things like that (for a Servlet, but this could be used
for any other kinds of software).
Since I am not very original, there is even a "main" run somewhere,
although I have no use for things like:
<forEach>, <if>, <choose><when><otherwise>
The xml bit only controls "high level" flow, as in:
<run name="main">
<choose-folder>
<when uri="kino/film">
<run-pnuts direct-out="true" >
<text-url url="${film.pnut}" />
</run-pnuts>
</when>
<when uri="kino/adress">
<run-pnuts direct-out="true" >
<text-url url="${adress.pnut}" />
</run-pnuts>
</when>
...
<otherwise>
<match-uri wildcard="module/my-module/**">
<run-module prefix="module/my-module/"
module="my-module" />
</match-uri>
...
</otherwise>
</choose-folder>
</run>
More detailed logic I leave for the scripting bits or I would end
up inventing YAPL (Yet Another Programming Language).
=;o)
> Maybe Jelly could be a useful engine for you?
Maybe I am messing around with something like Jelly. The problem
is that we are not sure we want to Open Source its core.
But there are many other bits that we want.
Look, my problem is still spending the time to repackage those
bits in order to make them available, but if you are interested
I can post them just "half packed", which means that the source
will be:
- Not very well documented or not documented at all;
- Some dependencies will be removed in a rough way, BUT I will
document that.
But I actually have interesting bits like the
- PnutsModifiableScript;
- StaticPnutsScript;
or the
- PnutsRunInstance.
(This bits imply some other bits of code, of course).
> Much of the above code should
> be pretty easy to use in Jelly. Fairly soon there'll be JSTL-style
> <forEach>, <if>, <choose><when><otherwise>, <expr> and <set> tags
> that work
> with JavaScript/BSF/JPython, Beanshell, Velocity and Pnuts. The
> idea is that
> we can bind any element name to a 'tag' to do anything, be it pnuts,
> Velocity stuff, JavaScript, XSLT, XPath, SQL or whatnot.
Your idea seems very similar to what I am doing. I hope you follow
Avalon and Cocoon because that helps a lot even when you do not
agree with everything they do or say (I sure don't).
Another interesting bit is Ant's Myrmidon proposal (by Peter Donald)
from where I got the Converter and Configurator ideas. The
Configurator is big step beyond Avalon's Configuration stuff.
And, BTW, it works. There are already several small things in
production using this stuff and the development cycle was MUCH
faster. And it really looks like the gain will be even larger for
larger sites. Java + Velocity + XML-and-Pnuts-glue is a
Very Good Thing (tm).
> James
Have fun,
Paulo
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>