abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r559923 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/util/ server/src/main/java/org/apache/abdera/protocol/server/servlet/
Date Thu, 26 Jul 2007 18:22:34 GMT
Author: jmsnell
Date: Thu Jul 26 11:22:33 2007
New Revision: 559923

URL: http://svn.apache.org/viewvc?view=rev&rev=559923
Log:
Use the new CompressionUtil for the CompressionFilter

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/CompressionUtil.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractFilter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/CompressionFilter.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/CompressionUtil.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/CompressionUtil.java?view=diff&rev=559923&r1=559922&r2=559923
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/CompressionUtil.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/CompressionUtil.java
Thu Jul 26 11:22:33 2007
@@ -29,6 +29,15 @@
 
   public enum CompressionCodec { GZIP, XGZIP, DEFLATE }
   
+  public static CompressionCodec getCodec(String name) {
+    CompressionCodec codec = null;
+    if (name == null) return null;
+    try {
+       codec = CompressionCodec.valueOf(name.toUpperCase().trim());
+    } catch (Exception e) {}
+    return codec;
+  }
+  
   public static OutputStream getEncodedOutputStream(
     OutputStream out, 
     CompressionCodec encoding) 

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractFilter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractFilter.java?view=diff&rev=559923&r1=559922&r2=559923
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractFilter.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractFilter.java
Thu Jul 26 11:22:33 2007
@@ -23,11 +23,11 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.Reader;
 import java.util.zip.DeflaterOutputStream;
-import java.util.zip.GZIPOutputStream;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterConfig;
@@ -40,6 +40,8 @@
 import javax.servlet.http.HttpServletResponseWrapper;
 
 import org.apache.abdera.i18n.io.RewindableInputStream;
+import org.apache.abdera.util.CompressionUtil;
+import org.apache.abdera.util.CompressionUtil.CompressionCodec;
 
 /**
  * Utility class that serves as the basis for a variety of Filter implementations
@@ -72,11 +74,11 @@
     
     public CompressingResponseWrapper(
       HttpServletResponse response, 
-      String method) 
+      CompressionCodec codec) 
         throws IOException {
       super(response);
       out = new CompressingServletOutputStream(
-        method, response.getOutputStream());
+        codec, response.getOutputStream());
     }
     
     @Override
@@ -112,14 +114,11 @@
   public static class CompressingServletOutputStream 
     extends ServletOutputStream {
 
-    private DeflaterOutputStream dout;
+    private OutputStream dout;
     
-    public CompressingServletOutputStream(String method, ServletOutputStream out) {
+    public CompressingServletOutputStream(CompressionCodec codec, ServletOutputStream out)
{
       try {
-        if ("gzip".equalsIgnoreCase(method)) 
-          dout = new GZIPOutputStream(out);
-        if ("compress".equalsIgnoreCase(method))
-          dout = new DeflaterOutputStream(out);
+        dout = CompressionUtil.getEncodedOutputStream(out,codec);        
       } catch (IOException e) {}
     }
     

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/CompressionFilter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/CompressionFilter.java?view=diff&rev=559923&r1=559922&r2=559923
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/CompressionFilter.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/CompressionFilter.java
Thu Jul 26 11:22:33 2007
@@ -28,6 +28,8 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.abdera.protocol.server.util.ServerUtils;
+import org.apache.abdera.util.CompressionUtil;
+import org.apache.abdera.util.CompressionUtil.CompressionCodec;
 
 /**
  * A filter that applies either GZip or Compress encoding on a response
@@ -53,9 +55,10 @@
         new String[0];
     for (String enc : encodings) {
       if (CompressingResponseWrapper.canHandle(enc)) {
+        CompressionCodec codec = CompressionUtil.getCodec(enc);
         CompressingResponseWrapper resp = 
           new CompressingResponseWrapper(
-            (HttpServletResponse) response, enc);
+            (HttpServletResponse) response, codec);
         chain.doFilter(request, response);
         resp.finish();
         return;



Mime
View raw message