Return-Path: Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 99796 invoked from network); 3 Apr 2000 21:25:34 -0000 Received: from pop.systemy.it (194.20.140.28) by locus.apache.org with SMTP; 3 Apr 2000 21:25:34 -0000 Received: from apache.org (pv7-pri.systemy.it [194.21.255.7]) by pop.systemy.it (8.8.8/8.8.3) with ESMTP id XAA18118 for ; Mon, 3 Apr 2000 23:25:30 +0200 Message-ID: <38E903DA.5198FE44@apache.org> Date: Mon, 03 Apr 2000 22:49:30 +0200 From: Stefano Mazzocchi Organization: Apache Software Foundation X-Mailer: Mozilla 4.72 [en] (Windows NT 5.0; I) X-Accept-Language: it,en MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: Re: [PATCH] Performance fix to call hasChanged for XSP pages References: <20000403130830.26674.qmail@hotmail.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N Robin Green wrote: > > IMO this is a bug, though only a performance bug - XSPPage implements > Changeable, but the javadocs for Changeable say: > > public boolean hasChanged(java.lang.Object context) > > "...This method is guaranteed to be called after at least a single call to > any production methods getStream or getDocument." > > But if you put a hasChanged method in an XSP page, it is never called > (AFAIK). Here is the fix: > > diff -u -r1.17 XSPProcessor.java > --- xml-cocoon/src/org/apache/cocoon/processor/xsp/XSPProcessor.java > 2000/03/30 00:37:18 1.17 > +++ xml-cocoon/src/org/apache/cocoon/processor/xsp/XSPProcessor.java > 2000/04/03 13:03:03 > @@ -534,7 +534,22 @@ > } > > public boolean hasChanged(Object context) { > - return true; > + > + if (!(context instanceof HttpServletRequest)) > + return true; // Can't interpret context > + > + HttpServletRequest request = (HttpServletRequest) context; > + String filename = Utils.getBasename(request, servletContext); > + > + // Get page from Cocoon cache > + PageEntry pageEntry = (PageEntry) this.store.get(filename); > + > + // New page? > + if (pageEntry == null) return true; > + > + // NOT pageEntry.hasChanged ()! We are calling the hasChanged method > + // of the XSP page itself. > + return pageEntry.getPage ().hasChanged (context); > } > > public String getStatus() { > > ______________________________________________________ > Get Your Private, Free Email at http://www.hotmail.com Great patch!!! Thanks, I applied it right away. -- Stefano Mazzocchi One must still have chaos in oneself to be able to give birth to a dancing star. Friedrich Nietzsche -------------------------------------------------------------------- Missed us in Orlando? Make it up with ApacheCON Europe in London! ------------------------- http://ApacheCon.Com ---------------------