Author: fhanik Date: Sat Feb 25 07:46:37 2006 New Revision: 380938 URL: http://svn.apache.org/viewcvs?rev=380938&view=rev Log: Completed the first round of successful tests
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/groups/group/interceptors/GzipInterceptor.java Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/groups/group/interceptors/GzipInterceptor.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/groups/group/interceptors/GzipInterceptor.java?rev=380938&r1=380937&r2=380938&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/groups/group/interceptors/GzipInterceptor.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/groups/group/interceptors/GzipInterceptor.java Sat Feb 25 07:46:37 2006 @@ -25,6 +25,7 @@ import java.io.ByteArrayInputStream; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; +import java.util.Arrays; @@ -35,7 +36,8 @@ * @version 1.0 */ public class GzipInterceptor extends ChannelInterceptorBase { - + public static final int DEFAULT_BUFFER_SIZE = 2048; + public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws IOException { try { msg.setMessage(compress(msg.getMessage())); @@ -55,7 +57,7 @@ } } - public byte[] compress(byte[] data) throws IOException { + public static byte[] compress(byte[] data) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); GZIPOutputStream gout = new GZIPOutputStream(bout); gout.write(data); @@ -64,14 +66,29 @@ return bout.toByteArray(); } - public byte[] decompress(byte[] data) throws IOException { + /** + * @todo Fix to create an automatically growing buffer. + * @param data byte[] + * @return byte[] + * @throws IOException + */ + public static byte[] decompress(byte[] data) throws IOException { ByteArrayInputStream bin = new ByteArrayInputStream(data); GZIPInputStream gin = new GZIPInputStream(bin); - byte[] tmp = new byte[data.length]; + byte[] tmp = new byte[DEFAULT_BUFFER_SIZE]; int length = gin.read(tmp); byte[] result = new byte[length]; System.arraycopy(tmp,0,result,0,length); return result; + } + + public static void main(String[] arg) throws Exception { + byte[] data = new byte[1024]; + Arrays.fill(data,(byte)1); + byte[] compress = compress(data); + byte[] decompress = decompress(compress); + System.out.println("Debug test"); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]