Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 89771 invoked from network); 15 Aug 2005 09:13:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Aug 2005 09:13:58 -0000 Received: (qmail 62937 invoked by uid 500); 15 Aug 2005 09:13:57 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 62788 invoked by uid 500); 15 Aug 2005 09:13:56 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 62774 invoked by uid 99); 15 Aug 2005 09:13:56 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 15 Aug 2005 02:13:56 -0700 Received: (qmail 89712 invoked by uid 65534); 15 Aug 2005 09:13:56 -0000 Message-ID: <20050815091356.89711.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r232779 - /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java Date: Mon, 15 Aug 2005 09:13:55 -0000 To: cvs@cocoon.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.3 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: cziegeler Date: Mon Aug 15 02:13:51 2005 New Revision: 232779 URL: http://svn.apache.org/viewcvs?rev=232779&view=rev Log: Ingore sizing events Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java?rev=232779&r1=232778&r2=232779&view=diff ============================================================================== --- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java (original) +++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java Mon Aug 15 02:13:51 2005 @@ -25,6 +25,7 @@ import org.apache.cocoon.portal.PortalService; import org.apache.cocoon.portal.coplet.CopletInstanceData; import org.apache.cocoon.portal.event.CopletInstanceEvent; +import org.apache.cocoon.portal.event.impl.ChangeCopletInstanceAspectDataEvent; import org.apache.excalibur.source.SourceValidity; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; @@ -38,12 +39,21 @@ * the user session. * * @author Gerald Kahrer - * + * @author Carsten Ziegeler * @version CVS $Id$ */ public class CachingURICopletAdapter extends URICopletAdapter { + /** The configuration name for enabling/disabling the cache. */ + public static final String CONFIGURATION_ENABLE_CACHING = "cache-enabled"; + + /** The configuration name for using the global cache. */ + public static final String CONFIGURATION_CACHE_GLOBAL= "cache-global"; + + /** The configuration name for ignoring sizing events to clear the cache. */ + public static final String CONFIGURATION_IGNORE_SIZING_EVENTS = "ignore-sizing-events"; + /** The attribute name for the storing the cached coplet content. */ public static final String CACHE = "cacheData"; @@ -90,9 +100,9 @@ final ContentHandler contentHandler) throws SAXException { // Is caching enabled? - boolean cachingEnabled = ((Boolean)this.getConfiguration(coplet, "cache-enabled", Boolean.TRUE)).booleanValue(); + boolean cachingEnabled = ((Boolean)this.getConfiguration(coplet, CONFIGURATION_ENABLE_CACHING, Boolean.TRUE)).booleanValue(); // do we cache globally? - boolean cacheGlobal = ((Boolean)this.getConfiguration(coplet, "cache-global", Boolean.FALSE)).booleanValue(); + boolean cacheGlobal = ((Boolean)this.getConfiguration(coplet, CONFIGURATION_CACHE_GLOBAL, Boolean.FALSE)).booleanValue(); Object data = null; // If caching is enabed and the cache is still valid, then use the cache @@ -163,15 +173,32 @@ public void handleCopletInstanceEvent(CopletInstanceEvent event) { final CopletInstanceData coplet = (CopletInstanceData) event.getTarget(); - // do we cache globally? - boolean cacheGlobal = ((Boolean)this.getConfiguration(coplet, "cache-global", Boolean.FALSE)).booleanValue(); - if ( cacheGlobal ) { - final String key = this.getCacheKey(coplet, - (String) coplet.getCopletData().getAttribute("uri")); - this.cache.remove(key); - } else { - coplet.removeAttribute(CACHE); + // do we ignore SizingEvents + boolean ignoreSizing = ((Boolean)this.getConfiguration(coplet, CONFIGURATION_IGNORE_SIZING_EVENTS, Boolean.TRUE)).booleanValue(); + + if ( !ignoreSizing || !isSizingEvent(event)) { + // do we cache globally? + boolean cacheGlobal = ((Boolean)this.getConfiguration(coplet, CONFIGURATION_CACHE_GLOBAL, Boolean.FALSE)).booleanValue(); + if ( cacheGlobal ) { + final String key = this.getCacheKey(coplet, + (String) coplet.getCopletData().getAttribute("uri")); + this.cache.remove(key); + } else { + coplet.removeAttribute(CACHE); + } + } + } + + /** + * Tests if the event is a sizing event for the coplet. + */ + protected boolean isSizingEvent(CopletInstanceEvent event) { + if ( event instanceof ChangeCopletInstanceAspectDataEvent ) { + if (((ChangeCopletInstanceAspectDataEvent)event).getAspectName().equals("size")) { + return true; + } } + return false; } /**