You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Serge Knystautas <sk...@gmail.com> on 2006/05/07 23:02:44 UTC

Listening for context usage

I'm trying to figure out how to watch for usage of certain context
keys and wondered if anyone had tips.

Our CMS uses templates everywhere, and a very large percentage of the
generated output could be cached based on the 2 timestamps from our
"page" (content) object and the template.  In addition to populating
VelocityContext with data from the content object, I stick in several
keys that would prevent any caching such as $now (new
java.util.Date()).

What I want to do is watch the Velocity merge process and determine
whether the template used $now.  I know I can create an event
cartridge to watch for method usage and reference insertion, but I
don't think either would catch $formatter.formatDate($now), right?

My other idea was to stick some wrapper code/class/cglib manipulation
of the object into the context, or maybe just extend
VelocityContext(), so that if you asked for a certain key, I would
flag this output as not cacheable.

If anyone has feedback on a better approach or potential pitfalls, I'd
be very appreciative.

--
Serge Knystautas
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Listening for context usage

Posted by Serge Knystautas <sk...@gmail.com>.
Thanks.  It did feel like I was overthinking this.

On 5/7/06, Will Glass-Husain <wg...@forio.com> wrote:
> Why don't you create your own custom implementation of Context?
>
> WILL
>
> Serge Knystautas wrote:
> > I'm trying to figure out how to watch for usage of certain context
> > keys and wondered if anyone had tips.
> >
> > Our CMS uses templates everywhere, and a very large percentage of the
> > generated output could be cached based on the 2 timestamps from our
> > "page" (content) object and the template.  In addition to populating
> > VelocityContext with data from the content object, I stick in several
> > keys that would prevent any caching such as $now (new
> > java.util.Date()).
> >
> > What I want to do is watch the Velocity merge process and determine
> > whether the template used $now.  I know I can create an event
> > cartridge to watch for method usage and reference insertion, but I
> > don't think either would catch $formatter.formatDate($now), right?
> >
> > My other idea was to stick some wrapper code/class/cglib manipulation
> > of the object into the context, or maybe just extend
> > VelocityContext(), so that if you asked for a certain key, I would
> > flag this output as not cacheable.
> >
> > If anyone has feedback on a better approach or potential pitfalls, I'd
> > be very appreciative.
> >
> > --
> > Serge Knystautas
> > Lokitech >> software . strategy . design >> http://www.lokitech.com
> > p. 301.656.5501
> > e. sergek@lokitech.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
> >
> >
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> phone (415) 440-7500 x89
> mobile (415) 235-4293
> wglass@forio.com
> www.forio.com
>

--
Serge Knystautas
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Listening for context usage

Posted by Will Glass-Husain <wg...@forio.com>.
Why don't you create your own custom implementation of Context?

WILL

Serge Knystautas wrote:
> I'm trying to figure out how to watch for usage of certain context
> keys and wondered if anyone had tips.
>
> Our CMS uses templates everywhere, and a very large percentage of the
> generated output could be cached based on the 2 timestamps from our
> "page" (content) object and the template.  In addition to populating
> VelocityContext with data from the content object, I stick in several
> keys that would prevent any caching such as $now (new
> java.util.Date()).
>
> What I want to do is watch the Velocity merge process and determine
> whether the template used $now.  I know I can create an event
> cartridge to watch for method usage and reference insertion, but I
> don't think either would catch $formatter.formatDate($now), right?
>
> My other idea was to stick some wrapper code/class/cglib manipulation
> of the object into the context, or maybe just extend
> VelocityContext(), so that if you asked for a certain key, I would
> flag this output as not cacheable.
>
> If anyone has feedback on a better approach or potential pitfalls, I'd
> be very appreciative.
>
> -- 
> Serge Knystautas
> Lokitech >> software . strategy . design >> http://www.lokitech.com
> p. 301.656.5501
> e. sergek@lokitech.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>

-- 
Forio Business Simulations

Will Glass-Husain
phone (415) 440-7500 x89
mobile (415) 235-4293
wglass@forio.com
www.forio.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org