tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1390899 - in /tomcat/sandbox/trunk-resources: java/org/apache/catalina/ java/org/apache/catalina/core/ java/org/apache/catalina/webresources/ test/org/apache/catalina/webresources/
Date Thu, 27 Sep 2012 08:57:58 GMT
Author: markt
Date: Thu Sep 27 08:57:58 2012
New Revision: 1390899

URL: http://svn.apache.org/viewvc?rev=1390899&view=rev
Log:
Make cachingAllowed configurable

Modified:
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardContext.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
    tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java?rev=1390899&r1=1390898&r2=1390899&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java Thu Sep 27
08:57:58 2012
@@ -238,6 +238,9 @@ public interface WebResourceRoot extends
      */
     boolean getAllowLinking();
 
+    void setCachingAllowed(boolean cachingAllowed);
+    boolean isCachingAllowed();
+
     /**
      * Set the Time-To-Live (TTL) for cache entries.
      *

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardContext.java?rev=1390899&r1=1390898&r2=1390899&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/core/StandardContext.java Thu
Sep 27 08:57:58 2012
@@ -4784,11 +4784,13 @@ public class StandardContext extends Con
         boolean ok = true;
 
         resources.setAllowLinking(isAllowLinking());
-        resources.start();
 
         resources.setCacheTtl(getCacheTTL());
+        resources.setCachingAllowed(isCachingAllowed());
+
+        resources.start();
+
         // TODO: Implement caching.
-        // isCachingAllowed()
         // getCacheMaxSize()
         // getCacheMaxObjectSize()
 

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java?rev=1390899&r1=1390898&r2=1390899&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
Thu Sep 27 08:57:58 2012
@@ -62,6 +62,7 @@ public class StandardRoot extends Lifecy
     private ArrayList<WebResourceSet> postResources = new ArrayList<>();
 
     private Cache cache = new Cache(this);
+    private boolean cachingAllowed = true;
 
     // Constructs to make iteration over all WebResourceSets simpler
     private ArrayList<WebResourceSet> mainResources = new ArrayList<>();
@@ -158,7 +159,11 @@ public class StandardRoot extends Lifecy
 
     @Override
     public WebResource getResource(String path) {
-        return cache.getResource(path);
+        if (isCachingAllowed()) {
+            return cache.getResource(path);
+        } else {
+            return getResourceInternal(path);
+        }
     }
 
     protected WebResource getResourceInternal(String path) {
@@ -295,10 +300,22 @@ public class StandardRoot extends Lifecy
         return allowLinking;
     }
 
+    @Override
+    public void setCachingAllowed(boolean cachingAllowed) {
+        this.cachingAllowed = cachingAllowed;
+    }
+
+    @Override
+    public boolean isCachingAllowed() {
+        return cachingAllowed;
+    }
+
+    @Override
     public long getCacheTtl() {
         return cache.getTtl();
     }
 
+    @Override
     public void setCacheTtl(long cacheTtl) {
         cache.setTtl(cacheTtl);
     }

Modified: tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java?rev=1390899&r1=1390898&r2=1390899&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
(original)
+++ tomcat/sandbox/trunk-resources/test/org/apache/catalina/webresources/TesterWebResourceRoot.java
Thu Sep 27 08:57:58 2012
@@ -147,6 +147,16 @@ public class TesterWebResourceRoot imple
     }
 
     @Override
+    public void setCachingAllowed(boolean cachingAllowed) {
+        // NO-OP
+    }
+
+    @Override
+    public boolean isCachingAllowed() {
+        return false;
+    }
+
+    @Override
     public void setCacheTtl(long ttl) {
         // NO-OP
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message