Author: pete
Date: Sat Sep 11 11:43:13 2010
New Revision: 996124

URL: http://svn.apache.org/viewvc?rev=996124&view=rev
Log:
remove AbstractResource#isCacheable() and AbstractResource#setCacheable() since 
it's replaced by setDefaultCacheDuration(0)

Modified:
    
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/captcha/kittens/KittenCaptchaPanel.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
    
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java

Modified: 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/captcha/kittens/KittenCaptchaPanel.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/captcha/kittens/KittenCaptchaPanel.java?rev=996124&r1=996123&r2=996124&view=diff
==============================================================================
--- 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/captcha/kittens/KittenCaptchaPanel.java
 (original)
+++ 
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/captcha/kittens/KittenCaptchaPanel.java
 Sat Sep 11 11:43:13 2010
@@ -40,6 +40,7 @@ import org.apache.wicket.markup.html.ima
 import org.apache.wicket.markup.html.image.NonCachingImage;
 import org.apache.wicket.markup.html.panel.Panel;
 import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.protocol.http.RequestUtils;
 import org.apache.wicket.request.Request;
 import org.apache.wicket.request.cycle.RequestCycle;
 import org.apache.wicket.request.http.WebResponse;
@@ -391,7 +392,7 @@ public class KittenCaptchaPanel extends 
                protected void configureResponse(ResourceResponse response, 
Attributes attributes)
                {
                        super.configureResponse(response, attributes);
-                       response.setCacheable(false);
+                       
response.setCacheDuration(RequestUtils.MAX_CACHE_DURATION);
                }
 
                /**

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java?rev=996124&r1=996123&r2=996124&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
 Sat Sep 11 11:43:13 2010
@@ -292,31 +292,9 @@ public abstract class AbstractResource i
                }
 
                /**
-                * Cachable resources are cached on client. This flag affects 
the <code>Expires</code> and
-                * <code>Cache-Control</code> headers.
-                * 
-                * @see #setCacheDuration(long)
-                * 
-                * @param cacheable
-                *            resource may be cached (true/false)
-                */
-               public void setCacheable(boolean cacheable)
-               {
-                       this.cacheable = cacheable;
-               }
-
-               /**
-                * @return returns whether this resource is cacheable
-                */
-               public boolean isCacheable()
-               {
-                       return cacheable;
-               }
-
-               /**
                 * Sets the duration for which this resource should be cached 
on client (in seconds). #see
                 * {...@link IResourceSettings#setDefaultCacheDuration(int)}
-                * 
+                *
                 * @param cacheDuration
                 *            caching duration in seconds
                 */
@@ -374,22 +352,11 @@ public abstract class AbstractResource i
        protected void configureCache(final WebRequest request, final 
WebResponse response,
                final ResourceResponse data, final Attributes attributes)
        {
-               if (data.isCacheable())
-               {
-                       long now = System.currentTimeMillis();
+               final int duration = data.getCacheDuration();
 
-                       // Time of message generation
-                       response.setDateHeader("Date", now);
-
-                       // Time for cache expiry
-                       response.setDateHeader("Expires", now + 
(data.getCacheDuration() * 1000L));
-
-                       // Allow caching even for public proxies or CDN 
providers
-                       response.setHeader(CACHE_CONTROL, "public, max-age=" + 
data.getCacheDuration());
-
-                       // Let caches distinguish between compressed and 
uncompressed
-                       // versions of the resource so they can serve them 
properly
-                       response.setHeader("Vary", "Accept-Encoding");
+               if(duration > 0)
+               {
+                       RequestUtils.enableCaching(response, duration, false);
                }
                else
                {

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java?rev=996124&r1=996123&r2=996124&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/resource/PackageResource.java
 Sat Sep 11 11:43:13 2010
@@ -19,9 +19,11 @@ package org.apache.wicket.request.resour
 import java.io.IOException;
 import java.util.Locale;
 
+import org.apache.wicket.Application;
 import org.apache.wicket.ThreadContext;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.html.IPackageResourceGuard;
+import org.apache.wicket.protocol.http.RequestUtils;
 import org.apache.wicket.util.io.IOUtils;
 import org.apache.wicket.util.lang.Packages;
 import org.apache.wicket.util.lang.WicketObjects;
@@ -87,11 +89,6 @@ public class PackageResource extends Abs
 
 
        /**
-        * should response be cacheable in browser?
-        */
-       private boolean cacheable = true;
-
-       /**
         * Hidden constructor.
         *
         * @param scope     This argument will be used to get the class loader 
for loading the package
@@ -144,26 +141,6 @@ public class PackageResource extends Abs
        }
 
        /**
-        * returns is resource is cacheable
-        *
-        * @return <code>true</code> if cacheable
-        */
-       public boolean isCacheable()
-       {
-               return cacheable;
-       }
-
-       /**
-        * sets is resource is cacheable
-        *
-        * @param cacheable <code>true</code> if cacheable
-        */
-       public void setCacheable(boolean cacheable)
-       {
-               this.cacheable = cacheable;
-       }
-
-       /**
         * creates a new resource response based on the request attributes
         *
         * @param attributes current request attributes from client
@@ -230,7 +207,6 @@ public class PackageResource extends Abs
                                return sendResourceError(resourceResponse, 500, 
"Unable to open resource stream");
                        }
                }
-               resourceResponse.setCacheable(isCacheable());
                return resourceResponse;
        }
 

Modified: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java?rev=996124&r1=996123&r2=996124&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java
 (original)
+++ 
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java
 Sat Sep 11 11:43:13 2010
@@ -99,7 +99,7 @@ public class WicketFilterTest extends Te
                                protected ResourceResponse 
newResourceResponse(Attributes attributes)
                                {
                                        ResourceResponse response = 
super.newResourceResponse(attributes);
-                                       response.setCacheable(true);
+                                       
response.setCacheDuration(RequestUtils.MAX_CACHE_DURATION);
                                        return response;
                                }
                        };


Reply via email to