tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [1/2] git commit: Remove deprecated method from ResponseCompressionAnalyzer
Date Mon, 11 Jun 2012 17:20:53 GMT
Updated Branches:
  refs/heads/master bfe1a19c3 -> 856188fd3


Remove deprecated method from ResponseCompressionAnalyzer


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/856188fd
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/856188fd
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/856188fd

Branch: refs/heads/master
Commit: 856188fd3cee035f4f6be4a1a7f8bf40116c3325
Parents: 9136a57
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Mon Jun 11 10:20:39 2012 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Mon Jun 11 10:20:39 2012 -0700

----------------------------------------------------------------------
 .../internal/gzip/BufferedGZipOutputStream.java    |   14 ++++++----
 .../internal/gzip/GZIPEnabledResponse.java         |    8 +++---
 .../apache/tapestry5/internal/gzip/GZipFilter.java |   20 +++++++++-----
 .../services/ResponseCompressionAnalyzerImpl.java  |   18 ++-----------
 .../services/ResponseCompressionAnalyzer.java      |   16 +-----------
 .../ResponseCompressionAnalyzerTest.groovy         |    2 +-
 6 files changed, 30 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/856188fd/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/BufferedGZipOutputStream.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/BufferedGZipOutputStream.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/BufferedGZipOutputStream.java
index 4508ece..3c4c362 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/BufferedGZipOutputStream.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/BufferedGZipOutputStream.java
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
 package org.apache.tapestry5.internal.gzip;
 
 import org.apache.tapestry5.internal.InternalConstants;
-import org.apache.tapestry5.services.ResponseCompressionAnalyzer;
+import org.apache.tapestry5.services.assets.CompressionAnalyzer;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
@@ -35,7 +35,7 @@ public class BufferedGZipOutputStream extends ServletOutputStream
 
     private final HttpServletResponse response;
 
-    private final ResponseCompressionAnalyzer analyzer;
+    private final CompressionAnalyzer analyzer;
 
     private final int cutover;
 
@@ -48,7 +48,7 @@ public class BufferedGZipOutputStream extends ServletOutputStream
     private OutputStream currentOutputStream;
 
     public BufferedGZipOutputStream(String contentType, HttpServletResponse response, int
cutover,
-                                    ResponseCompressionAnalyzer analyzer)
+                                    CompressionAnalyzer analyzer)
     {
         this.contentType = contentType;
         this.response = response;
@@ -77,11 +77,13 @@ public class BufferedGZipOutputStream extends ServletOutputStream
         boolean useCompression = gzip && analyzer.isCompressable(contentType);
 
         OutputStream possiblyCompressed = useCompression
-                                          ? new GZIPOutputStream(responseOutputStream)
-                                          : responseOutputStream;
+                ? new GZIPOutputStream(responseOutputStream)
+                : responseOutputStream;
 
         if (useCompression)
+        {
             response.setHeader(InternalConstants.CONTENT_ENCODING_HEADER, InternalConstants.GZIP_CONTENT_ENCODING);
+        }
 
         currentOutputStream =
                 new BufferedOutputStream(possiblyCompressed);

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/856188fd/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZIPEnabledResponse.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZIPEnabledResponse.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZIPEnabledResponse.java
index 5e30941..736adb5 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZIPEnabledResponse.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZIPEnabledResponse.java
@@ -1,4 +1,4 @@
-// Copyright 2009, 2010 The Apache Software Foundation
+// Copyright 2009, 2010, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
 package org.apache.tapestry5.internal.gzip;
 
 import org.apache.tapestry5.internal.InternalConstants;
-import org.apache.tapestry5.services.ResponseCompressionAnalyzer;
+import org.apache.tapestry5.services.assets.CompressionAnalyzer;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
@@ -31,12 +31,12 @@ public class GZIPEnabledResponse extends HttpServletResponseWrapper
 
     private final HttpServletResponse response;
 
-    private final ResponseCompressionAnalyzer analyzer;
+    private final CompressionAnalyzer analyzer;
 
     private boolean contentLengthSet = false;
 
     public GZIPEnabledResponse(HttpServletResponse response, HttpServletRequest request,
int cutover,
-            ResponseCompressionAnalyzer analyzer)
+                               CompressionAnalyzer analyzer)
     {
         super(response);
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/856188fd/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZipFilter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZipFilter.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZipFilter.java
index 8859f55..a1b06fc 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZipFilter.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/gzip/GZipFilter.java
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.services.HttpServletRequestFilter;
 import org.apache.tapestry5.services.HttpServletRequestHandler;
 import org.apache.tapestry5.services.ResponseCompressionAnalyzer;
+import org.apache.tapestry5.services.assets.CompressionAnalyzer;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -31,24 +32,29 @@ public class GZipFilter implements HttpServletRequestFilter
 {
     private final int cutover;
 
-    private final ResponseCompressionAnalyzer analyzer;
+    private final ResponseCompressionAnalyzer responseAnalyzer;
+
+    private final CompressionAnalyzer compressionAnalyzer;
 
     public GZipFilter(
             @Symbol(SymbolConstants.MIN_GZIP_SIZE)
             int cutover,
 
-            ResponseCompressionAnalyzer analyzer)
+            ResponseCompressionAnalyzer responseAnalyzer,
+
+            CompressionAnalyzer compressionAnalyzer)
     {
         this.cutover = cutover;
-        this.analyzer = analyzer;
+        this.responseAnalyzer = responseAnalyzer;
+        this.compressionAnalyzer = compressionAnalyzer;
     }
 
     public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler
handler)
             throws IOException
     {
-        HttpServletResponse newResponse = analyzer.isGZipSupported()
-                                          ? new GZIPEnabledResponse(response, request, cutover,
analyzer)
-                                          : response;
+        HttpServletResponse newResponse = responseAnalyzer.isGZipSupported()
+                ? new GZIPEnabledResponse(response, request, cutover, compressionAnalyzer)
+                : response;
 
         return handler.service(request, newResponse);
     }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/856188fd/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerImpl.java
index 3e1ac6f..7432019 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerImpl.java
@@ -18,10 +18,8 @@ import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.internal.TapestryInternalUtils;
 import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.services.ResponseCompressionAnalyzer;
-import org.apache.tapestry5.services.assets.CompressionAnalyzer;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.Collection;
 
 public class ResponseCompressionAnalyzerImpl implements ResponseCompressionAnalyzer
 {
@@ -29,16 +27,11 @@ public class ResponseCompressionAnalyzerImpl implements ResponseCompressionAnaly
 
     private final boolean gzipCompressionEnabled;
 
-    private final CompressionAnalyzer analyzer;
-
-    // configuration is left here for partial compatibility with end-user modules that contribute
a value; they
-    // should contribute to CompressionAnalyzer instead.
-    public ResponseCompressionAnalyzerImpl(HttpServletRequest request, CompressionAnalyzer
analyzer, @Deprecated
-    Collection<String> configuration, @Symbol(SymbolConstants.GZIP_COMPRESSION_ENABLED)
-    boolean gzipCompressionEnabled)
+    public ResponseCompressionAnalyzerImpl(HttpServletRequest request,
+                                           @Symbol(SymbolConstants.GZIP_COMPRESSION_ENABLED)
+                                           boolean gzipCompressionEnabled)
     {
         this.request = request;
-        this.analyzer = analyzer;
         this.gzipCompressionEnabled = gzipCompressionEnabled;
     }
 
@@ -72,9 +65,4 @@ public class ResponseCompressionAnalyzerImpl implements ResponseCompressionAnaly
 
         return false;
     }
-
-    public boolean isCompressable(String contentType)
-    {
-        return analyzer.isCompressable(contentType);
-    }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/856188fd/tapestry-core/src/main/java/org/apache/tapestry5/services/ResponseCompressionAnalyzer.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/ResponseCompressionAnalyzer.java
b/tapestry-core/src/main/java/org/apache/tapestry5/services/ResponseCompressionAnalyzer.java
index fdc43a8..ffe0239 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/ResponseCompressionAnalyzer.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/ResponseCompressionAnalyzer.java
@@ -19,7 +19,7 @@ import org.apache.tapestry5.services.assets.CompressionAnalyzer;
 /**
  * Used to determine if the client supports GZIP compression of the response.
  *
- * @see ResponseCompressionAnalyzer
+ * @see CompressionAnalyzer
  * @since 5.1.0.0
  */
 public interface ResponseCompressionAnalyzer
@@ -31,18 +31,4 @@ public interface ResponseCompressionAnalyzer
      * @return true if gzip is supported by client
      */
     boolean isGZipSupported();
-
-    /**
-     * Checks to see if the indicated content type is compressable. Many formats are already
compressed; pushing them
-     * through a GZip filter consumes cycles and makes them larger.
-     * <p/>
-     * Contribute content type strings to the service's configuration to mark them as not
compressable.
-     *
-     * @param contentType
-     *         the mime type of the content, such as "text/html" or "image/jpeg".
-     * @return true if compression is worthwhile
-     * @deprecated Deprecated in Tapestry 5.3. This method is to be removed at a later date.
The service's configuration
-     *             is no longer used. Instead, contribute to and use {@link CompressionAnalyzer}.
-     */
-    boolean isCompressable(String contentType);
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/856188fd/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerTest.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerTest.groovy
b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerTest.groovy
index dcc9998..3b2f4c1 100644
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerTest.groovy
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/ResponseCompressionAnalyzerTest.groovy
@@ -17,7 +17,7 @@ class ResponseCompressionAnalyzerTest extends TestBase {
 
     replay()
 
-    ResponseCompressionAnalyzer rca = new ResponseCompressionAnalyzerImpl(request, null,
null, true)
+    ResponseCompressionAnalyzer rca = new ResponseCompressionAnalyzerImpl(request, true)
 
     assert rca.isGZipSupported() == false
 


Mime
View raw message