cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r344108 - in /cocoon/blocks: portal-sample/trunk/samples/profiles/copletdata/ portal/trunk/java/org/apache/cocoon/portal/coplet/ portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/ portal/trunk/java/org/apache/cocoon/portal/even...
Date Mon, 14 Nov 2005 12:22:22 GMT
Author: cziegeler
Date: Mon Nov 14 04:22:10 2005
New Revision: 344108

URL: http://svn.apache.org/viewcvs?rev=344108&view=rev
Log:
Fix gallery coplet and add new caching options

Modified:
    cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceDataFeatures.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java

Modified: cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml?rev=344108&r1=344107&r2=344108&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml (original)
+++ cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml Mon Nov 14 04:22:10
2005
@@ -233,6 +233,14 @@
          <name>image-uri-prefix</name>
          <value xsi:type="java:java.lang.String">coplets/gallery/images</value>
       </attribute>
+      <attribute>
+        <name>ignore-sizing-events</name>
+        <value xsi:type="java:java.lang.Boolean">false</value>
+      </attribute>
+      <attribute>
+        <name>ignore-simple-sizing-events</name>
+        <value xsi:type="java:java.lang.Boolean">true</value>
+      </attribute>
    </coplet-data>
    <coplet-data id="GalleryViewer">
       <title>Gallery Viewer</title>

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceDataFeatures.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceDataFeatures.java?rev=344108&r1=344107&r2=344108&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceDataFeatures.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceDataFeatures.java
Mon Nov 14 04:22:10 2005
@@ -55,6 +55,22 @@
     }
 
     /**
+     * Get the new size of the sizing event.
+     */
+    public static int getSize(CopletInstanceEvent cie) {
+        if ( cie instanceof CopletInstanceSizingEvent ) {
+            return ((CopletInstanceSizingEvent)cie).getSize();
+        }
+        if ( cie instanceof CopletJXPathEvent ) {
+            CopletJXPathEvent e = (CopletJXPathEvent)cie;
+            if ( "size".equals(e.getPath()) && e.getValue() != null ) {
+                return Integer.valueOf(e.getValue().toString()).intValue();
+            }
+        }
+        return -1;
+    }
+
+    /**
      * Search for a layout containing the coplet instance data.
      */
     public static CopletLayout searchLayout(String copletId, Layout rootLayout) {

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=344108&r1=344107&r2=344108&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 Nov 14 04:22:10 2005
@@ -63,9 +63,12 @@
      * for the global cache. */
     public static final String CONFIGURATION_CACHE_GLOBAL_USE_ATTRIBUTES= "cache-global-use-attributes";
 
-    /** The configuration name for ignoring sizing events to clear the cache. */
+    /** The configuration name for ignoring all sizing events to clear the cache. */
     public static final String CONFIGURATION_IGNORE_SIZING_EVENTS = "ignore-sizing-events";
 
+    /** The configuration name for ignoring just min/normal sizing events to clear the cache.
*/
+    public static final String CONFIGURATION_IGNORE_SIMPLE_SIZING_EVENTS = "ignore-simple-sizing-events";
+
     /** The temporary attribute name for the storing the cached coplet content. */
     public static final String CACHE = "cacheData";
 
@@ -193,14 +196,26 @@
         boolean ignoreSizing = ((Boolean)this.getConfiguration(coplet, CONFIGURATION_IGNORE_SIZING_EVENTS,
Boolean.TRUE)).booleanValue();
 
         if ( !ignoreSizing || !CopletInstanceDataFeatures.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.removeTemporaryAttribute(CACHE);
+            boolean cleanupCache = true;
+            boolean ignoreSimpleSizing = ((Boolean)this.getConfiguration(coplet, CONFIGURATION_IGNORE_SIMPLE_SIZING_EVENTS,
Boolean.FALSE)).booleanValue();
+            if ( ignoreSimpleSizing && CopletInstanceDataFeatures.isSizingEvent(event)
) {
+                int newSize = CopletInstanceDataFeatures.getSize(event);
+                int oldSize = coplet.getSize();
+                if (  (oldSize == CopletInstanceData.SIZE_NORMAL || oldSize == CopletInstanceData.SIZE_MINIMIZED
)
+                   && (newSize == CopletInstanceData.SIZE_NORMAL || newSize == CopletInstanceData.SIZE_MINIMIZED
)) {
+                    cleanupCache = false;
+                }
+            }
+            if ( cleanupCache ) {
+                // 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.removeTemporaryAttribute(CACHE);
+                }
             }
         }
     }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java?rev=344108&r1=344107&r2=344108&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
Mon Nov 14 04:22:10 2005
@@ -202,6 +202,14 @@
     }
 
     protected void send(Event event, HierarchyInfo hierarchy, boolean recursive) {
+        // first call listeners for parents
+        if ( recursive ) {
+            final Iterator parentIterator = hierarchy.getParents().iterator();
+            while ( parentIterator.hasNext() ) {
+                final HierarchyInfo current = (HierarchyInfo)parentIterator.next();
+                this.send(event, current, false);
+            }
+        }
         final List receiverInfos = hierarchy.getReceiverInfos();
         int index = 0;
         // we don't use an iterator to avoid problems if a receiver is added while we're
sending
@@ -218,14 +226,6 @@
                                      +" and event " + event, ignore);
             }
             index++;
-        }
-        // now call listeners for parents
-        if ( recursive ) {
-            final Iterator parentIterator = hierarchy.getParents().iterator();
-            while ( parentIterator.hasNext() ) {
-                final HierarchyInfo current = (HierarchyInfo)parentIterator.next();
-                this.send(event, current, false);
-            }
         }
     }
 



Mime
View raw message