For the sake of showing the list readers that my comments
were not entirely unaccurate:


Me:
---
1) Freemarker is template-only package whereas WebMacro tries to go beyond
that with the resource broker(s), template providers and other possibly nice
but unnecessary (in my case) stuff. I wanted nothing more than a way to say
        Template t = new Template(new File("foo.template"));
        t.output(req.getOutputStream());

To do this, I had to write my own provider for WebMacro that would pick up a
file based on the filename rather than search for it in the classpath
(default). Freemarker didnt need this as it's a simpler system based on
files and the above is what it was explicitly designed for.
---

Justin:
---
Actually, you can just write

     Template t = new FileTemplate(fileName);

the advantage in using the provider is that it caches the compiled
template,whereas loading it fresh each time re-invokes the compiler.
---

I was comparing the same functionality in Freemarker and WebMacro. Caching a
parsed template is a must for a template framework and both Freemarker and
WebMacro do that. However, due to WebMacro's broker architecture, a provider
has to be written whereas no extra effort is required by Freemarker.

As an aside, I dont see why 1) a provider that does this (use files instead
of classpath) is not supplied with WebMacro given the fact that this is a
popular use case 2) an application developer has to care about the
implementation details of the package, i.e. a provider has to be written,
because WebMacro uses a broker internally to allocate resources.


[re: reflection in WebMacro vs adapters in FreeMarker]

Justin:
---
WebMacro uses the reflection API to analyze your class exactly once for each
class, and then caches that data for the life of your servlet environment.
This is the same approach Sun takes with JavaBeans, and is remarkably
efficient.

If WebMacro re-analyzed every object on every access it would be slow.
But it doesn't do that, and is actually very fast.
---

I was operating under the assumption that parsed template is cached, which
is what you're emphasizing above. I stand by my opinion that an adapter is
better than introspection for a reasonably complex document, because in the
former case the control is placed into the developer's hands whereas in the
latter case a framework has to conduct a search for an appropriate method
with correct arguments. F On the other hand, an adapter has to be written
whereas introspection is done for you automagically. This is a tradeoff and
I prefer the adapter approach (see below).

>From prior experience, I know that reflection is expensive.
I've also had the stack blown right out of me in certain cases when I tried
evaluating introspection-laden methods recursively along with host of other
problems (security, etc). Whether WebMacro does this very fast and/or
correctly is a separate question; more important is the point that the
developer is at the mercy of the framework rather than the other way around.
Perhaps this is a matter of personal preference but I like to control my
code rather than the other way around.

I urge the readers to investigate both packages (or any others) and report
their experience to the list, lest my opinion be taken as absolute truth.

Regards,

Alex.


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to