Author: costin
Date: Sat Jun 14 09:01:09 2008
New Revision: 667824
URL: http://svn.apache.org/viewvc?rev=667824&view=rev
Log:
Small fixes, added a GzipInputFilter to match the output ( for client side )
Added:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/http11/filters/GzipInputFilter.java
(with props)
Modified:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/Request.java
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/juli/JdkLoggerFormatter.java
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/IntrospectionUtils.java
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/ByteChunk.java
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/MessageBytes.java
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/modeler/Registry.java
Modified:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/Request.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/Request.java?rev=667824&r1=667823&r2=667824&view=diff
==============================================================================
--- tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/Request.java
(original)
+++ tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/Request.java Sat
Jun 14 09:01:09 2008
@@ -23,11 +23,10 @@
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.buf.UDecoder;
-
-import org.apache.tomcat.util.http.MimeHeaders;
-import org.apache.tomcat.util.http.Parameters;
import org.apache.tomcat.util.http.ContentType;
import org.apache.tomcat.util.http.Cookies;
+import org.apache.tomcat.util.http.MimeHeaders;
+import org.apache.tomcat.util.http.Parameters;
/**
* This is a low-level, efficient representation of a server request. Most
Added:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/http11/filters/GzipInputFilter.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/http11/filters/GzipInputFilter.java?rev=667824&view=auto
==============================================================================
---
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/http11/filters/GzipInputFilter.java
(added)
+++
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/http11/filters/GzipInputFilter.java
Sat Jun 14 09:01:09 2008
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.coyote.http11.filters;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.coyote.InputBuffer;
+import org.apache.coyote.Request;
+import org.apache.coyote.http11.InputFilter;
+import org.apache.coyote.http11.OutputFilter;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+/**
+ * Gzip output filter.
+ *
+ * @author Remy Maucherat
+ */
+public class GzipInputFilter implements InputFilter {
+
+
+ // -------------------------------------------------------------- Constants
+
+
+ protected static final String ENCODING_NAME = "gzip";
+ protected static final ByteChunk ENCODING = new ByteChunk();
+
+
+ // ----------------------------------------------------- Static Initializer
+
+
+ static {
+ ENCODING.setBytes(ENCODING_NAME.getBytes(), 0, ENCODING_NAME.length());
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * Next buffer in the pipeline.
+ */
+ protected InputBuffer buffer;
+
+
+ /**
+ * Compression output stream.
+ */
+ protected GZIPInputStream compressionStream = null;
+
+
+ /**
+ * Fake internal output stream.
+ */
+ protected InputStream fakeInputStream = new FakeInputStream();
+
+
+ // --------------------------------------------------- OutputBuffer Methods
+
+
+ /**
+ * Write some bytes.
+ *
+ * @return number of bytes written by the filter
+ */
+ public int doRead(ByteChunk chunk, Request req)
+ throws IOException {
+ if (compressionStream == null) {
+ compressionStream = new GZIPInputStream(fakeInputStream);
+ }
+ int rd =
+ compressionStream.read(chunk.getBytes(), chunk.getStart(),
+ chunk.getBytes().length);
+ if (rd > 0) {
+ chunk.setEnd(rd);
+ }
+ return rd;
+ }
+
+ public int available() {
+ try {
+ if (compressionStream == null) {
+ compressionStream = new GZIPInputStream(fakeInputStream);
+ }
+ return compressionStream.available();
+ } catch(IOException ex) {
+ ex.printStackTrace();
+ return 0;
+ }
+ }
+
+
+
+ // --------------------------------------------------- OutputFilter Methods
+
+
+ /**
+ * Some filters need additional parameters from the response. All the
+ * necessary reading can occur in that method, as this method is called
+ * after the response header processing is complete.
+ */
+ public void setRequest(Request req) {
+ }
+
+
+ /**
+ * Set the next buffer in the filter pipeline.
+ */
+ public void setBuffer(InputBuffer buffer) {
+ this.buffer = buffer;
+ }
+
+
+ /**
+ * End the current request. It is acceptable to write extra bytes using
+ * buffer.doWrite during the execution of this method.
+ */
+ public long end()
+ throws IOException {
+ if (compressionStream == null) {
+ compressionStream = new GZIPInputStream(fakeInputStream);
+ }
+ //compressionStream.finish();
+ compressionStream.close();
+ return ((OutputFilter) buffer).end();
+ }
+
+
+ /**
+ * Make the filter ready to process the next request.
+ */
+ public void recycle() {
+ // Set compression stream to null
+ compressionStream = null;
+ }
+
+
+ /**
+ * Return the name of the associated encoding; Here, the value is
+ * "identity".
+ */
+ public ByteChunk getEncodingName() {
+ return ENCODING;
+ }
+
+
+ // ------------------------------------------- FakeOutputStream Inner Class
+
+
+ protected class FakeInputStream
+ extends InputStream {
+ protected ByteChunk outputChunk = new ByteChunk();
+ protected byte[] singleByteBuffer = new byte[1];
+ public int read()
+ throws IOException {
+ outputChunk.setBytes(singleByteBuffer, 0, 1);
+ int rd = buffer.doRead(outputChunk, null);
+ if (rd <= 0) {
+ throw new IOException("EOF");
+ }
+ int res = outputChunk.substract();
+ return res;
+ }
+ public int read(byte[] b, int off, int len)
+ throws IOException {
+ outputChunk.setBytes(b, off, len);
+ int rd = buffer.doRead(outputChunk, null);
+ outputChunk.substract(b, off, len);
+ //ChunkHelper.dump("Read " + rd, b, off, len);
+ return rd;
+ }
+ public void flush() throws IOException {}
+ public void close() throws IOException {}
+ }
+
+
+
+}
Propchange:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/coyote/http11/filters/GzipInputFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/juli/JdkLoggerFormatter.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/juli/JdkLoggerFormatter.java?rev=667824&r1=667823&r2=667824&view=diff
==============================================================================
---
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/juli/JdkLoggerFormatter.java
(original)
+++
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/juli/JdkLoggerFormatter.java
Sat Jun 14 09:01:09 2008
@@ -80,9 +80,11 @@
default: buf.append(" ");
}
-
// Append the name of the log instance if so configured
- buf.append(name);
+ buf.append(Thread.currentThread().getId()).append(" ");
+
+ buf.append(name); //.append(" ");
+
// pad to 20 chars
for( int i=0; i<8-buf.length(); i++ ) { buf.append(" "); }
Modified:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/IntrospectionUtils.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/IntrospectionUtils.java?rev=667824&r1=667823&r2=667824&view=diff
==============================================================================
---
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/IntrospectionUtils.java
(original)
+++
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/IntrospectionUtils.java
Sat Jun 14 09:01:09 2008
@@ -29,6 +29,8 @@
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
// Depends: JDK1.1
@@ -37,9 +39,7 @@
*/
public final class IntrospectionUtils {
-
- private static org.apache.juli.logging.Log log=
- org.apache.juli.logging.LogFactory.getLog( IntrospectionUtils.class );
+ static Logger log = Logger.getLogger(IntrospectionUtils.class.getName());
/**
* Call execute() - any ant-like task should work
@@ -73,13 +73,13 @@
params[1] = Object.class;
executeM = findMethod(c, "setAttribute", params);
if (executeM == null) {
- if (log.isDebugEnabled())
- log.debug("No setAttribute in " + proxy.getClass());
+ if (log.isLoggable(Level.INFO))
+ log.info("No setAttribute in " + proxy.getClass());
return;
}
if (false)
- if (log.isDebugEnabled())
- log.debug("Setting " + n + "=" + v + " in " + proxy);
+ if (log.isLoggable(Level.INFO))
+ log.info("Setting " + n + "=" + v + " in " + proxy);
executeM.invoke(proxy, new Object[] { n, v });
return;
}
@@ -94,8 +94,8 @@
params[0] = String.class;
executeM = findMethod(c, "getAttribute", params);
if (executeM == null) {
- if (log.isDebugEnabled())
- log.debug("No getAttribute in " + proxy.getClass());
+ if (log.isLoggable(Level.INFO))
+ log.info("No getAttribute in " + proxy.getClass());
return null;
}
return executeM.invoke(proxy, new Object[] { n });
@@ -224,10 +224,10 @@
* Debug method, display the classpath
*/
public static void displayClassPath(String msg, URL[] cp) {
- if (log.isDebugEnabled()) {
- log.debug(msg);
+ if (log.isLoggable(Level.INFO)) {
+ log.info(msg);
for (int i = 0; i < cp.length; i++) {
- log.debug(cp[i].getFile());
+ log.info(cp[i].getFile());
}
}
}
@@ -369,7 +369,7 @@
}
} catch (IllegalArgumentException ex2) {
- log.warn("IAE " + o + " " + name + " " + value, ex2);
+ log.log(Level.WARNING, "IAE " + o + " " + name + " " + value, ex2);
} catch (SecurityException ex1) {
if (dbg > 0)
d("SecurityException for " + o.getClass() + " " + name + "="
@@ -423,7 +423,7 @@
}
} catch (IllegalArgumentException ex2) {
- log.warn("IAE " + o + " " + name, ex2);
+ log.log(Level.WARNING, "IAE " + o + " " + name, ex2);
} catch (SecurityException ex1) {
if (dbg > 0)
d("SecurityException for " + o.getClass() + " " + name + ")");
@@ -589,8 +589,8 @@
// That's a bug, but we can work around and be nice.
f = new File(System.getProperty("java.home") +
"/lib/tools.jar");
if (f.exists()) {
- if (log.isDebugEnabled())
- log.debug("Detected strange java.home value "
+ if (log.isLoggable(Level.INFO))
+ log.info("Detected strange java.home value "
+ System.getProperty("java.home")
+ ", it should point to jre");
}
@@ -1022,7 +1022,7 @@
static final int dbg = 0;
static void d(String s) {
- if (log.isDebugEnabled())
- log.debug("IntrospectionUtils: " + s);
+ if (log.isLoggable(Level.INFO))
+ log.info("IntrospectionUtils: " + s);
}
}
Modified:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/ByteChunk.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/ByteChunk.java?rev=667824&r1=667823&r2=667824&view=diff
==============================================================================
---
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/ByteChunk.java
(original)
+++
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/ByteChunk.java
Sat Jun 14 09:01:09 2008
@@ -151,7 +151,7 @@
* @return
*/
public ByteBuffer getReadByteBuffer() {
- if (bb == null) {
+ if (bb == null || bb.array() != buff) {
bb = ByteBuffer.wrap(buff);
}
bb.position(start);
@@ -169,7 +169,7 @@
* @return
*/
public ByteBuffer getWriteByteBuffer() {
- if (bb == null) {
+ if (bb == null || bb.array() != buff) {
bb = ByteBuffer.wrap(buff);
}
bb.position(end);
Modified:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/MessageBytes.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/MessageBytes.java?rev=667824&r1=667823&r2=667824&view=diff
==============================================================================
---
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/MessageBytes.java
(original)
+++
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/buf/MessageBytes.java
Sat Jun 14 09:01:09 2008
@@ -17,11 +17,11 @@
package org.apache.tomcat.util.buf;
-import java.text.*;
-import java.util.*;
-import java.io.Serializable;
import java.io.IOException;
+import java.io.Serializable;
import java.nio.ByteBuffer;
+import java.text.DateFormat;
+import java.util.Date;
/**
* This class is used to represent a subarray of bytes in an HTTP message.
@@ -285,8 +285,10 @@
// inefficient
toString();
type=T_CHARS;
- char cc[]=strValue.toCharArray();
- charC.setChars(cc, 0, cc.length);
+ if (strValue != null) {
+ char cc[]=strValue.toCharArray();
+ charC.setChars(cc, 0, cc.length);
+ }
}
Modified:
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/modeler/Registry.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/modeler/Registry.java?rev=667824&r1=667823&r2=667824&view=diff
==============================================================================
---
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/modeler/Registry.java
(original)
+++
tomcat/sandbox/tomcat-lite/tomcat-coyote/org/apache/tomcat/util/modeler/Registry.java
Sat Jun 14 09:01:09 2008
@@ -22,6 +22,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
+import java.lang.management.ManagementFactory;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -593,7 +594,7 @@
log.debug("Using existing MBeanServer " +
(System.currentTimeMillis() - t1 ));
}
} else {
- server=MBeanServerFactory.createMBeanServer();
+ server = ManagementFactory.getPlatformMBeanServer();
if( log.isDebugEnabled() ) {
log.debug("Creating MBeanServer"+
(System.currentTimeMillis() - t1 ));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]