cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r389703 - in /cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl: CachingSource.java CachingSourceFactory.java InspectableTraversableCachingSource.java TraversableCachingSource.java
Date Wed, 29 Mar 2006 08:05:35 GMT
Author: jbq
Date: Wed Mar 29 00:05:32 2006
New Revision: 389703

URL: http://svn.apache.org/viewcvs?rev=389703&view=rev
Log:
Reported by Jens Maukisch: Replace remainingParameters.getQueryString() with
remainingParameters.getEncodedQueryString()

Also adding a new configuration parameter « event-aware » to remove a hard-coded
hack: if (validities.length == 2)

I had this patch since ages but waited for someone to complain ;)

Modified:
    cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSource.java
    cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSourceFactory.java
    cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/InspectableTraversableCachingSource.java
    cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/TraversableCachingSource.java

Modified: cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSource.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSource.java?rev=389703&r1=389702&r2=389703&view=diff
==============================================================================
--- cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSource.java
(original)
+++ cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSource.java
Wed Mar 29 00:05:32 2006
@@ -114,6 +114,8 @@
     /** asynchronic refresh strategy ? */
     final protected boolean async;
 
+    final protected boolean eventAware;
+
     /**
      * Construct a new object.
      */
@@ -122,15 +124,17 @@
                          final Source source,
                          final int expires,
                          final String cacheName,
-                         final boolean async) {
+                         final boolean async,
+                         final boolean eventAware) {
         this.protocol = protocol;
         this.uri = uri;
         this.source = source;
         this.expires = expires;
         this.cacheName = cacheName;
         this.async = async;
-        
-        String key = "source:" + source.getURI();
+        this.eventAware = eventAware;
+
+        String key = "source:" + getSourceURI();
         if (cacheName != null) {
             key += ":" + cacheName;
         }
@@ -550,11 +554,11 @@
         initMeta(meta, source);
         return meta;
     }
-    
+
     protected SourceMeta createMeta() {
         return new SourceMeta();
     }
-    
+
     protected void initMeta(SourceMeta meta, Source source) throws IOException {
         final long lastModified = source.getLastModified();
         if (lastModified > 0) {
@@ -568,10 +572,10 @@
 
     private boolean checkValidity() {
         if (this.response == null) return false;
-        
+
         final SourceValidity[] validities = this.response.getValidityObjects();
         boolean valid = true;
-        if (validities.length == 2) {
+        if (! eventAware) {
             final ExpiresValidity expiresValidity = (ExpiresValidity) validities[0];
             final SourceValidity sourceValidity = validities[1];
 
@@ -598,8 +602,7 @@
                     getLogger().debug("Cached response of source " + getSourceURI() + " is
NOT expired.");
                 }
             }
-        }
-        else {
+        } else {
             // assert(validities.length == 1 && validities[0] instanceof EventValidity)
             if (getLogger().isDebugEnabled()) {
                 getLogger().debug("Cached response of source does not expire");

Modified: cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSourceFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSourceFactory.java?rev=389703&r1=389702&r2=389703&view=diff
==============================================================================
--- cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSourceFactory.java
(original)
+++ cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/CachingSourceFactory.java
Wed Mar 29 00:05:32 2006
@@ -99,6 +99,13 @@
  *  <td><code>false</code></td>
  * </tr>
  * <tr>
+ *  <th>event-aware (boolean)</th>
+ *  <td>Whether to use event-based cache invalidation.</td>
+ *  <td>opt</td>
+ *  <td>String</td>
+ *  <td><code>false</code></td>
+ * </tr>
+ * <tr>
  *  <th>default-expires (int)</th>
  *  <td>Default expiration value for if it is not specified on the Source itself.</td>
  *  <td>opt</td>
@@ -117,6 +124,7 @@
     // ---------------------------------------------------- Constants
     
     public static final String ASYNC_PARAM = "async";
+    public static final String EVENT_AWARE_PARAM = "event-aware";
     public static final String FAILSAFE_PARAM = "failsafe";
     public static final String CACHE_ROLE_PARAM = "cache-role";
     public static final String REFRESHER_ROLE_PARAM = "refresher-role";
@@ -130,6 +138,9 @@
     /** Asynchronous ? */
     private boolean async;
 
+    /** Event aware ? */
+    private boolean eventAware;
+
     /** The role of the cache */
     private String cacheRole;
 
@@ -172,7 +183,10 @@
 
         // 'async' parameter
         this.async = parameters.getParameterAsBoolean(ASYNC_PARAM, false);
-        
+
+        // 'event-aware' parameter
+        this.eventAware = parameters.getParameterAsBoolean(EVENT_AWARE_PARAM, false);
+
         // 'cache-role' parameter
         this.cacheRole = parameters.getParameter(CACHE_ROLE_PARAM, Cache.ROLE);
         if (this.getLogger().isDebugEnabled()) {
@@ -288,7 +302,7 @@
                     remainingParameters.removeParameter(name);
                 }
             }
-            queryString = remainingParameters.getQueryString();
+            queryString = remainingParameters.getEncodedQueryString();
             if (queryString != null) {
                 uri += "?" + queryString;
             }
@@ -319,10 +333,10 @@
                                    this.cacheRole,
                                    params);
         }
-        
+
         return source;
     }
-    
+
     /**
      * Factory method for creating a new CachingSource. Delegates to createCachingSource()
      */
@@ -361,14 +375,16 @@
                                                                  (InspectableSource) wrappedSource,
                                                                  expires,
                                                                  cacheName,
-                                                                 async);
+                                                                 async,
+                                                                 eventAware);
             } else {
                 source = new TraversableCachingSource(scheme,
                                                       uri,
                                                       (TraversableSource) wrappedSource,
                                                       expires,
                                                       cacheName,
-                                                      async);
+                                                      async,
+                                                      eventAware);
             }
         } else {
             source = new CachingSource(scheme,
@@ -376,7 +392,8 @@
                                        wrappedSource,
                                        expires,
                                        cacheName,
-                                       async);
+                                       async,
+                                       eventAware);
         }
 
         // set the required components directly for speed
@@ -394,7 +411,7 @@
         }
         return source;
     }
-    
+
     /**
      * Release a {@link Source} object.
      */

Modified: cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/InspectableTraversableCachingSource.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/InspectableTraversableCachingSource.java?rev=389703&r1=389702&r2=389703&view=diff
==============================================================================
--- cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/InspectableTraversableCachingSource.java
(original)
+++ cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/InspectableTraversableCachingSource.java
Wed Mar 29 00:05:32 2006
@@ -40,8 +40,9 @@
                                                InspectableSource source, 
                                                int expires,
                                                String cacheName,
-                                               boolean async) {
-        super(protocol, uri, (TraversableSource) source, expires, cacheName, async);
+                                               boolean async,
+                                               boolean eventAware) {
+        super(protocol, uri, (TraversableSource) source, expires, cacheName, async, eventAware);
         this.isource = source;
     }
 
@@ -136,7 +137,8 @@
                                                         (InspectableSource) wrapped,
                                                         super.expires,
                                                         super.cacheName,
-                                                        super.async);
+                                                        super.async,
+                                                        super.eventAware);
     }
     
     protected static class InspectableSourceMeta extends TraversableSourceMeta {

Modified: cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/TraversableCachingSource.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/TraversableCachingSource.java?rev=389703&r1=389702&r2=389703&view=diff
==============================================================================
--- cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/TraversableCachingSource.java
(original)
+++ cocoon/blocks/scratchpad/trunk/java/org/apache/cocoon/components/source/impl/TraversableCachingSource.java
Wed Mar 29 00:05:32 2006
@@ -37,8 +37,9 @@
                                     TraversableSource source,
                                     int expires,
                                     String cacheName,
-                                    boolean async) {
-        super(protocol, uri, source, expires, cacheName, async);
+                                    boolean async,
+                                    boolean eventAware) {
+        super(protocol, uri, source, expires, cacheName, async, eventAware);
         this.tsource = source;
     }
     
@@ -163,7 +164,8 @@
                                              (TraversableSource) wrapped,
                                              super.expires,
                                              super.cacheName,
-                                             super.async);
+                                             super.async,
+                                             super.eventAware);
     }
 
     protected void initializeSource(TraversableCachingSource source) throws SourceException
{



Mime
View raw message