Doppelte Dekoration bei Verwendung von Filter und Interceptor unterdrückt
[percentcodec] / cachecontrol / src / main / java / de / halbekunst / juplo / cachecontrol / CacheControlInterceptor.java
index fe51187..77d0a86 100644 (file)
@@ -1,5 +1,6 @@
 package de.halbekunst.juplo.cachecontrol;
 
+import de.halbekunst.juplo.cachecontrol.AcceleratorFilter.AccelerationWrapper;
 import de.halbekunst.juplo.cachecontrol.annotations.Cacheable;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -33,8 +34,12 @@ public class CacheControlInterceptor implements HandlerInterceptor {
       return true;
     }
 
+    AccelerationWrapper wrapper = (AccelerationWrapper)request.getAttribute(AcceleratorFilter.RESPONSE_WRAPPER);
+    if (wrapper != null)
+      wrapper.supressGuessing();
+
     /** CacheControll initialisieren (Handler nach annotierte Methoden scannen etc.) */
-    cacheControl.init(handler);
+    cacheControl.init(handler, wrapper);
 
     if (cacheable.eager()) {
       return cacheControl.decorate(request, response, handler);
@@ -52,7 +57,12 @@ public class CacheControlInterceptor implements HandlerInterceptor {
       ModelAndView modelAndView
       ) throws Exception
   {
-    cacheControl.decorate(request, response, handler);
+    /**
+     * Dekoration nur dann anstossen, wenn sie nicht bereits von dem
+     * AcceleratorFilter ausgelöst wird.
+     */
+    if (request.getAttribute(AcceleratorFilter.RESPONSE_WRAPPER) == null)
+      cacheControl.decorate(request, response, handler);
   }
 
   @Override