Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 19945 invoked from network); 18 Sep 2006 08:58:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Sep 2006 08:58:11 -0000 Received: (qmail 29970 invoked by uid 500); 18 Sep 2006 08:58:10 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 29708 invoked by uid 500); 18 Sep 2006 08:58:09 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 29684 invoked by uid 99); 18 Sep 2006 08:58:09 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Sep 2006 01:58:09 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [81.169.145.181] (HELO natblert.rzone.de) (81.169.145.181) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Sep 2006 01:57:55 -0700 Received: from [172.26.0.105] (216.Red-83-57-53.dynamicIP.rima-tde.net [83.57.53.216]) (authenticated bits=0) by post.webmailer.de (8.13.6/8.13.6) with ESMTP id k8I8v7UV001636 for ; Mon, 18 Sep 2006 10:57:08 +0200 (MEST) Subject: Re: Caching jx *without* flow From: Thorsten Scherler To: dev@cocoon.apache.org In-Reply-To: <450E5340.2030804@mobilebox.pl> References: <1158349311.17986.4.camel@localhost> <450D361D.1070407@mobilebox.pl> <450E4BE7.40103@hippo.nl> <450E5340.2030804@mobilebox.pl> Content-Type: text/plain Date: Mon, 18 Sep 2006 10:57:05 +0200 Message-Id: <1158569825.4930.34.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On Mon, 2006-09-18 at 10:05 +0200, Leszek Gawron wrote: > Niels van Kampenhout wrote: > > Leszek Gawron wrote: > >> Thorsten Scherler wrote: > >>> Hi all, hi Ard, > >>> > >>> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=115194685214066&w=2 > >>> "... > >>>>> Now, the cached jx would depend on these three parameters. > >>>> Very easy to use, and less error prone than the flow part. > >>>>> If somebody is interested in the code I will hear " > >>> > >>> Yes very interested. > >>> http://svn.apache.org/viewvc?view=rev&rev=446701 > >>> https://issues.apache.org/jira/browse/FOR-931 > >>> > >>> Can you attach a patch to this issue or commit it to cocoon directly? > >>> > >>> Would be awesome. > >> Do I get it right: > >> > >> you want to patch JXTG to automatically build up a cache key from > >> cocoon parameters? > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> so cocoon:/foo gets cached with something like "foo=bar&bar=foo"? > >> > >> Why need a patch for that? After all you already have jx:cache-key and > >> jx:cache-validity. > >> > > > > Since Ard is on holiday until the GetTogether, I'll try to answer this > > question. > > > > The reason is, as Ard said, to make it less error prone. People easily > > make mistakes if they have to build a cachekey string themselves, en > > they also easily forget to actually put the jx:cache-key and > > jx:cache-validity attributes in the JX template. I am talking from > > experience! > > > > It also makes the code more readable/transparent/explicit, because you > > don't need the extra flow step anymore in many cases. > > 1. You don't need the extraflow step even right now. jx:cache-key and > jx:cache-validity works no matter what controller was used. > > 2. The solution you are proposing is error prone. The jx object model > does not get narrowed only to cocoon parameters so you are still able to > use cocoon.session, cocoon.request. Hmm, that is why Ard wrote: "> > now, to var ck you append the things that is depends on > (like a request parameter, current week number, etc)" Sure one need to take care to add all request parameter the jx depends on to the sitemap. I do not want to judge which method is more error prone, both have their pros and cons. > > 3. I hardly see the point to make any JXTG customizations if you can do > something like: > > jx:cache-key="${Packages.org.apache.cocoon.template.CocoonParametersCacheKeyBuilder.buildKey( > cocoon.parameters )}" jx:cache-validity="${some validity}"> > <.../> > > > and > > public class CocoonParametersCacheKeyBuilder { > public static String buildKey( Parameters parameters ) { > // you probably need to sort cocoon parameters here so the order is > // explicit > StringBuffer buffer = new StringBuffer(); > String[] parameterNames = parameters.getNames(); > for ( int i = 0; i < parameterNames.length; ++i ) { > String currentParameterName = parameterNames[ i ]; > if ( i > 0 ) > buffer.append( "&" ); > buffer.append( urlEncode( currentParameterName ) ); > buffer.append( "=" ); > buffer.append( urlEncode( parameters.getParameter( > currentParameterName ) ) ); > } > return buffer.toString(); > } > } > Hmm, maybe the documentation is outdated but http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html state "When used inside flow, JXTemplate has access to Java and can therefore evaluate expressions like "java.util.Date()" or "java.util.HashMap()". This does NOT work when JXTemplates are used without flow." Wouldn't that mean that the example would not work without flow? Further regarding the validity as I understand your example this would not allow to use an AggregatedValidity which would be extended for all , or? Or could I do ...