On Tue, Aug 7, 2012 at 12:10 AM, Claude Brisson <cla...@renegat.net> wrote:

> > > By use of the appropriate velocityEngine.evaluate() method that
> > > takes the template as a String. It will bypass Velocity's internal
> > > cache, but our first goal is to respect the API, then to try to
> > > optimize.
> > >
> > > Speaking about it, since the engine has access to the filename, we
> > > could try to still use the cache. Velocity's cache is here to not
> > > only bypass the actual reading of the file, but also the parsing
> > > process - and since the OS will already cache the file in memory,
> > > it's the parsing of the template which is the most interesting to
> > > avoid via the caching mechanism. Here, we're given the content of
> > > the file at the same time as its name (via the special property
> > > "javax.script.filename"). So we can still do some caching, by just
> > > ignoring the newly provided content when the filename is present in
> > > the cache.
> > >
> > > For this to work properly, we may have to implement our own
> > > Velocity ResourceLoader.w
> > >
> >
> > So what you basically intending is to provide an additional context
> > parameter which has the file name of the template(so that to read it
> > inside evaluate method and use that for
> > velocityEngine.getTemplate(filename) ) while providing the script it
> > self to the evaluate method ?
>
> See page 151 of the specs. There is a bunch of reserved property names.
> Populating them is optional (and not always meaningful), but for our
> caching problem, systematically filling javax.script.filename with the
> template filename looks appropriate.
>
> We don't want to use the getTemplate() method, since we are already
> given a String or a Reader towards the template. But since we also know
> the filename it comes from, we can cache and reuse the parsed template
> each time we get the same filename.
>
> Few clarifications,

"since we are already given a String or a Reader towards the template" you
meant passing String or reader to
velocityEngine.evaluate(velocityContext, outPut, fileName, reader); ?

currently what I do is

                Template template = velocityEngine.getTemplate(vm-name);
                template.merge(velocityContext, outPut);

If I do not use velocityEngine.getTemplate(vm-name) how could I do
the  template.merge(velocityContext, outPut); step . I think this merge
call is the one which enrich the writer with the rendered output which we
at the end used to print.

Please correct me if I am wrong.


> GSOC officials say <<Monday, 13 August is our soft
> "pencils down" date. We suggest that students have completed their
> projects by this date and spend a week writing documentation and
> wrapping up their projects. We require that students stop all coding on
> 20 August.>>
>
> It's one week from now. I think that trying to achieve this last
> feature (Velocity resource caching based only on the filename) is a
> reachable goal.
>

++1


>
>
>   Claude
>



-- 
Thanks
/Dishara

Reply via email to