Author: costin
Date: Mon Jul 10 11:42:39 2006
New Revision: 420610
URL: http://svn.apache.org/viewvc?rev=420610&view=rev
Log:
More fixes and enhancements to the micro-tomcat experiment
Added:
tomcat/sandbox/bin/Coyote-Http11.launch
tomcat/sandbox/bin/Tomcat6Sandbox.launch
tomcat/sandbox/java/org/apache/coyote/servlet/servlets/RequestInfoFilter.java
tomcat/sandbox/java/org/apache/tomcat/servlets/file/WebdavServlet.java
tomcat/sandbox/java/org/apache/tomcat/servlets/sec/
tomcat/sandbox/java/org/apache/tomcat/servlets/sec/IPFilter.java
tomcat/sandbox/java/org/apache/tomcat/servlets/sec/SimpleIPFilter.java
tomcat/sandbox/java/org/apache/tomcat/servlets/util/
tomcat/sandbox/java/org/apache/tomcat/servlets/util/URLEncoder.java
- copied, changed from r415842,
tomcat/sandbox/java/org/apache/tomcat/servlets/file/URLEncoder.java
Removed:
tomcat/sandbox/Tomcat6Sandbox.launch
tomcat/sandbox/java/org/apache/coyote/servlet/util/RequestUtil.java
tomcat/sandbox/java/org/apache/tomcat/servlets/file/URLEncoder.java
tomcat/sandbox/java/org/apache/tomcat/servlets/file/XsltDirServlet.java
tomcat/sandbox/java/org/apache/tomcat/standalone/SingleMain.java
tomcat/sandbox/java/org/apache/tomcat/standalone/WebappsMain.java
tomcat/sandbox/java/org/apache/tomcat/util/log/JdkLoggerConfig.java
tomcat/sandbox/java/org/apache/tomcat/util/log/JdkLoggerFormatter.java
tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPool.java
tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPoolRunnable.java
tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadWithAttributes.java
Modified:
tomcat/sandbox/build.xml
tomcat/sandbox/java/org/apache/commons/logging/LogConfigurationException.java
tomcat/sandbox/java/org/apache/coyote/servlet/FilterChainImpl.java
tomcat/sandbox/java/org/apache/coyote/servlet/FilterConfigImpl.java
tomcat/sandbox/java/org/apache/coyote/servlet/Host.java
tomcat/sandbox/java/org/apache/coyote/servlet/ServletContextImpl.java
tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestImpl.java
tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestWrapperImpl.java
tomcat/sandbox/java/org/apache/coyote/servlet/WebappFilterMapper.java
tomcat/sandbox/java/org/apache/tomcat/servlets/file/DefaultServlet.java
tomcat/sandbox/java/org/apache/tomcat/standalone/ETomcat.java
tomcat/sandbox/java/org/apache/tomcat/util/buf/ByteChunk.java
tomcat/sandbox/java/org/apache/tomcat/util/net/http11/Http11Processor.java
tomcat/sandbox/java/org/apache/tomcat/util/net/http11/Http11Protocol.java
tomcat/sandbox/java/org/apache/tomcat/util/net/nio/NioEndpoint.java
tomcat/sandbox/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java
tomcat/sandbox/resources/coyote-servlet.MF
tomcat/sandbox/resources/runtime.MF
Added: tomcat/sandbox/bin/Coyote-Http11.launch
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/bin/Coyote-Http11.launch?rev=420610&view=auto
==============================================================================
--- tomcat/sandbox/bin/Coyote-Http11.launch (added)
+++ tomcat/sandbox/bin/Coyote-Http11.launch Mon Jul 10 11:42:39 2006
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.apache.coyote.servlet.CoyoteMain"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="sandbox"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/sandbox"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY"
value="${workspace_loc:sandbox}"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables"
value="true"/>
+</launchConfiguration>
Added: tomcat/sandbox/bin/Tomcat6Sandbox.launch
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/bin/Tomcat6Sandbox.launch?rev=420610&view=auto
==============================================================================
--- tomcat/sandbox/bin/Tomcat6Sandbox.launch (added)
+++ tomcat/sandbox/bin/Tomcat6Sandbox.launch Mon Jul 10 11:42:39 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH"
value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.apache.catalina.startup.Catalina"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"?> <runtimeClasspathEntry
containerPath="org.eclipse.jdt.launching.JRE_CONTAINER"
javaProject="sandbox" path="1"
type="4"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"?> <runtimeClasspathEntry
id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento
exportedEntriesOnly="false"
project="sandbox"/> </runtimeClasspathEntry> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"?> <runtimeClasspathEntry
path="3" projectName="tomcat6"
type="1"/> "/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="start"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="sandbox"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS"
value="-Dcom.sun.management.jmxremote"/>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/sandbox"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY"
value="${workspace_loc:tomcat6/build}"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables"
value="true"/>
+</launchConfiguration>
Modified: tomcat/sandbox/build.xml
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/build.xml?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/build.xml (original)
+++ tomcat/sandbox/build.xml Mon Jul 10 11:42:39 2006
@@ -10,7 +10,7 @@
<property name="tc.base" location=".." />
- <!-- Source dependencies -->
+ <!-- Source dependencies -->
<property name="target.vm" value="1.5"/>
<property name="source.vm" value="1.5"/>
@@ -41,8 +41,6 @@
<property name="tc6.classes" location="${tc6.home}/.settings/output"/>
- <!-- ======================= Single-jar minimal tomcat =========== -->
-
<path id="runtime-deps" >
<pathelement location="${base.path}/tomcat-deps/jasper-compiler-jdt.jar" />
</path>
@@ -85,6 +83,7 @@
<mkdir dir="${sandbox.home}/classes" />
<javac destdir="${sandbox.home}/classes" source="${source.vm}"
target="${target.vm}"
+ includeJavaRuntime="false"
deprecation="false"
debug="false" >
<src path="${sandbox.home}/java" />
@@ -92,31 +91,15 @@
<path refid="runtime-deps" />
<pathelement location="${tc6.classes}"/>
</classpath>
+ <exclude name="org/apache/tomcat/standalone/**"/>
</javac>
<copy todir="${sandbox.home}/classes" >
<fileset dir="${sandbox.home}/java" includes="**/*.properties **/*.xml"/>
</copy>
</target>
- <target name="compile-tc6">
- <mkdir dir="${tc6.classes}" />
- <javac destdir="${tc6.classes}"
- source="${source.vm}"
- target="${target.vm}"
- deprecation="false"
- debug="false" >
- <src path="${tc6.home}/java" />
- <classpath>
- <path refid="runtime-deps" />
- </classpath>
- </javac>
- <copy todir="${tc6.classes}" >
- <fileset dir="${tc6.home}/java" includes="**/*.properties **/*.xml"/>
- </copy>
- </target>
-
<target name="compile"
- depends="compile-sandbox,compile-tc6"/>
+ depends="compile-sandbox"/>
<target name="clean-compile">
<delete dir="${sandbox.home}/classes" includes="**"/>
@@ -133,26 +116,10 @@
<jar jarfile="runtime/tomcat-runtime.jar"
manifest="resources/runtime.MF">
<fileset dir="${tc6.classes}" >
- <exclude name="org/apache/tomcat/util/buf/**"/>
- <exclude name="org/apache/coyote/http11/*"/>
- <exclude name="org/apache/tomcat/util/buf/**"/>
- <exclude name="org/apache/tomcat/util/net/jsse/**"/>
- <exclude name="org/apache/tomcat/util/threads/Expirer**"/>
- <exclude name="org/apache/tomcat/util/threads/Reaper**"/>
- <exclude name="org/apache/tomcat/util/threads/ThreadPoolListener.*"/>
- <exclude name="org/apache/tomcat/util/threads/ThreadPool.*"/>
- <exclude name="org/apache/tomcat/util/threads/Control**"/>
- <exclude name="org/apache/tomcat/util/threads/Monitor**"/>
- <exclude name="org/apache/tomcat/util/net/**"/>
<exclude name="org/apache/jasper/**"/>
</fileset>
<fileset dir="${sandbox.home}/classes" >
- <exclude name="org/apache/tomcat/util/net/Leader**"/>
- <exclude name="org/apache/tomcat/util/net/Master**"/>
- <exclude name="org/apache/tomcat/util/net/SSL**"/>
- <exclude name="org/apache/tomcat/util/net/jsse/**"/>
- <exclude name="org/apache/tomcat/util/net/ServerSocketFactory**"/>
- <exclude name="org/apache/tomcat/util/net/Default**"/>
+ <include name="org/apache/tomcat/standalone/**"/>
</fileset>
</jar>
@@ -161,29 +128,30 @@
<target name="coyote-servlet.jar" depends="compile,pack_coyote-servlet.jar"/>
<target name="pack_coyote-servlet.jar" >
- <jar destfile="runtime/coyote-servlet.jar"
manifest="resources/coyote-servlet.MF">
+ <jar destfile="coyote-servlet.jar" manifest="resources/coyote-servlet.MF">
<fileset dir="classes" >
- <include name="org/apache/commons/**"/>
+ <include name="org/apache/commons/logging/*.class"/>
<include name="org/apache/coyote/servlet/**"/>
+ <include name="org/apache/tomcat/servlets/**"/>
<include name="org/apache/tomcat/util/buf/**"/>
<include name="org/apache/tomcat/util/loader/**"/>
- <include name="org/apache/tomcat/util/log/**"/>
<include name="org/apache/tomcat/util/net/**"/>
- <include name="org/apache/tomcat/util/threads/**"/>
- <include name="org/apache/tomcat/servlets/file/**"/>
</fileset>
<fileset dir="${tc6.classes}" >
<include name="javax/servlet/*"/>
<include name="javax/servlet/http/*"/>
<include name="org/apache/coyote/*"/>
- <include name="org/apache/coyote/http11/Constants**"/>
- <include name="org/apache/coyote/http11/*Filter.class"/>
+ <include name="org/apache/coyote/http11/Constants.class"/>
+ <include name="org/apache/coyote/http11/InputFilter.class"/>
+ <include name="org/apache/coyote/http11/OutputFilter.class"/>
<include name="org/apache/coyote/http11/LocalStrings.properties"/>
<include name="org/apache/coyote/http11/filters/**"/>
<include name="org/apache/tomcat/util/collections/*"/>
- <include name="org/apache/tomcat/util/net/URL*"/>
- <include name="org/apache/tomcat/util/http/**"/>
+ <include name="org/apache/tomcat/util/http/*"/>
+ <include
name="org/apache/tomcat/util/http/res/LocalStrings.properties"/>
<include name="org/apache/tomcat/util/res/**"/>
+ <include name="org/apache/tomcat/util/*"/>
+ <include name="org/apache/tomcat/util/net/URL*"/>
<include name="org/apache/tomcat/util/*"/>
</fileset>
</jar>
Modified:
tomcat/sandbox/java/org/apache/commons/logging/LogConfigurationException.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/commons/logging/LogConfigurationException.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
---
tomcat/sandbox/java/org/apache/commons/logging/LogConfigurationException.java
(original)
+++
tomcat/sandbox/java/org/apache/commons/logging/LogConfigurationException.java
Mon Jul 10 11:42:39 2006
@@ -33,9 +33,7 @@
* Construct a new exception with <code>null</code> as its detail message.
*/
public LogConfigurationException() {
-
super();
-
}
@@ -45,9 +43,7 @@
* @param message The detail message
*/
public LogConfigurationException(String message) {
-
super(message);
-
}
@@ -58,9 +54,7 @@
* @param cause The underlying cause
*/
public LogConfigurationException(Throwable cause) {
-
- this((cause == null) ? null : cause.toString(), cause);
-
+ this( ((cause == null) ? null : cause.toString()), cause);
}
@@ -72,7 +66,7 @@
*/
public LogConfigurationException(String message, Throwable cause) {
- super(message + " (Caused by " + cause + ")");
+ super(message);
this.cause = cause; // Two-argument version requires JDK 1.4 or later
}
Modified: tomcat/sandbox/java/org/apache/coyote/servlet/FilterChainImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/coyote/servlet/FilterChainImpl.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/coyote/servlet/FilterChainImpl.java
(original)
+++ tomcat/sandbox/java/org/apache/coyote/servlet/FilterChainImpl.java Mon Jul
10 11:42:39 2006
@@ -42,32 +42,19 @@
* @version $Revision: 303523 $ $Date: 2004-11-22 08:35:18 -0800 (Mon, 22 Nov
2004) $
*/
-final class FilterChainImpl implements FilterChain {
+public final class FilterChainImpl implements FilterChain {
- public static final int INCREMENT = 10;
+ public static final int INCREMENT = 8;
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new chain instance with no defined filters.
- */
public FilterChainImpl() {
-
super();
-
}
-
- // ----------------------------------------------------- Instance Variables
-
-
/**
* Filters.
*/
private FilterConfigImpl[] filters =
- new FilterConfigImpl[0];
+ new FilterConfigImpl[8];
/**
@@ -89,6 +76,9 @@
private Servlet servlet = null;
+ private ServletConfigImpl wrapper;
+
+
/**
* The string manager for our package.
*/
@@ -96,29 +86,6 @@
StringManager.getManager("org.apache.coyote.servlet");
- /**
- * The InstanceSupport instance associated with our Wrapper (used to
- * send "before filter" and "after filter" events.
- */
-// private InstanceSupport support = null;
-
-
- /**
- * Static class array used when the SecurityManager is turned on and
- * <code>doFilter</code is invoked.
- */
- private static Class[] classType = new Class[]{ServletRequest.class,
- ServletResponse.class,
- FilterChain.class};
-
- /**
- * Static class array used when the SecurityManager is turned on and
- * <code>service</code is invoked.
- */
- private static Class[] classTypeUsedInService = new Class[]{
- ServletRequest.class,
-
ServletResponse.class};
-
// ---------------------------------------------------- FilterChain Methods
@@ -184,7 +151,7 @@
*
* @param filterConfig The FilterConfig for the servlet to be executed
*/
- void addFilter(FilterConfigImpl filterConfig) {
+ public void addFilter(FilterConfigImpl filterConfig) {
if (n == filters.length) {
FilterConfigImpl[] newFilters =
new FilterConfigImpl[n + INCREMENT];
@@ -207,13 +174,32 @@
/**
* Set the servlet that will be executed at the end of this chain.
- *
- * @param servlet The Wrapper for the servlet to be executed
+ * Set by the mapper filter
*/
- public void setServlet(Servlet servlet) {
-
+ public void setServlet(ServletConfigImpl wrapper, Servlet servlet) {
+ this.wrapper = wrapper;
this.servlet = servlet;
-
}
+ // ------ Getters for information ------------
+
+ public int getSize() {
+ return n;
+ }
+
+ public FilterConfigImpl getFilter(int i) {
+ return filters[i];
+ }
+
+ public Servlet getServlet() {
+ return servlet;
+ }
+
+ public ServletConfigImpl getServletConfig() {
+ return wrapper;
+ }
+
+ public int getPos() {
+ return pos;
+ }
}
Modified: tomcat/sandbox/java/org/apache/coyote/servlet/FilterConfigImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/coyote/servlet/FilterConfigImpl.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/coyote/servlet/FilterConfigImpl.java
(original)
+++ tomcat/sandbox/java/org/apache/coyote/servlet/FilterConfigImpl.java Mon Jul
10 11:42:39 2006
@@ -42,7 +42,7 @@
*
*
*/
-final class FilterConfigImpl implements FilterConfig, Serializable {
+public final class FilterConfigImpl implements FilterConfig, Serializable {
public FilterConfigImpl(ServletContextImpl context) {
super();
Modified: tomcat/sandbox/java/org/apache/coyote/servlet/Host.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/coyote/servlet/Host.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/coyote/servlet/Host.java (original)
+++ tomcat/sandbox/java/org/apache/coyote/servlet/Host.java Mon Jul 10 11:42:39
2006
@@ -566,7 +566,9 @@
// destroy our child containers, if any
//Container children[] = findChildren();
// super.destroy();
- for (Object child: children.values()) {
+ Iterator valI = children.values().iterator();
+ while (valI.hasNext()) {
+ Object child = valI.next();
((ServletContextImpl)child).destroy();
}
Modified: tomcat/sandbox/java/org/apache/coyote/servlet/ServletContextImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/coyote/servlet/ServletContextImpl.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/coyote/servlet/ServletContextImpl.java
(original)
+++ tomcat/sandbox/java/org/apache/coyote/servlet/ServletContextImpl.java Mon
Jul 10 11:42:39 2006
@@ -48,6 +48,7 @@
import org.apache.coyote.servlet.util.MappingData;
import org.apache.coyote.servlet.webxml.WebXml;
import org.apache.tomcat.servlets.file.DefaultServlet;
+import org.apache.tomcat.servlets.file.WebdavServlet;
import org.apache.tomcat.util.buf.CharChunk;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.loader.Repository;
@@ -1070,7 +1071,7 @@
// Add default mappings.
ServletConfig fileS =
- facade.createServletWrapper(this, "default", new DefaultServlet());
+ facade.createServletWrapper(this, "default", new WebdavServlet());
facade.addMapping("/", fileS);
WebXml webXml = new WebXml(this);
Modified: tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestImpl.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestImpl.java
(original)
+++ tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestImpl.java Mon
Jul 10 11:42:39 2006
@@ -45,21 +45,13 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-//import org.apache.catalina.Globals;
-//import org.apache.catalina.Realm;
-
-//import org.apache.catalina.util.ParameterMap;
-//import org.apache.catalina.util.RequestUtil;
-//import org.apache.catalina.util.StringParser;
-
import org.apache.coyote.ActionCode;
import org.apache.coyote.servlet.util.Enumerator;
import org.apache.coyote.servlet.util.MappingData;
import org.apache.coyote.servlet.util.MessageReader;
import org.apache.coyote.servlet.util.ParameterMap;
-import org.apache.coyote.servlet.util.RequestUtil;
+import org.apache.tomcat.servlets.util.RequestUtil;
import org.apache.coyote.servlet.util.StringParser;
-
import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.buf.StringCache;
@@ -737,7 +729,7 @@
/**
* Get filter chain associated with the request.
*/
- public FilterChain getFilterChain() {
+ public FilterChainImpl getFilterChain() {
return (this.filterChain);
}
Modified:
tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestWrapperImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestWrapperImpl.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
---
tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestWrapperImpl.java
(original)
+++
tomcat/sandbox/java/org/apache/coyote/servlet/ServletRequestWrapperImpl.java
Mon Jul 10 11:42:39 2006
@@ -32,7 +32,7 @@
import javax.servlet.http.HttpSession;
import org.apache.coyote.servlet.util.Enumerator;
-import org.apache.coyote.servlet.util.RequestUtil;
+import org.apache.tomcat.servlets.util.RequestUtil;
import org.apache.tomcat.util.res.StringManager;
//import org.apache.catalina.Globals;
Modified: tomcat/sandbox/java/org/apache/coyote/servlet/WebappFilterMapper.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/coyote/servlet/WebappFilterMapper.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/coyote/servlet/WebappFilterMapper.java
(original)
+++ tomcat/sandbox/java/org/apache/coyote/servlet/WebappFilterMapper.java Mon
Jul 10 11:42:39 2006
@@ -21,8 +21,6 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -32,8 +30,7 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
-
-import org.apache.coyote.servlet.util.RequestUtil;
+import org.apache.tomcat.servlets.util.RequestUtil;
/**
* First filter after the context and servlet are mapped. It will add
@@ -149,7 +146,7 @@
filterChain = new FilterChainImpl();
}
- filterChain.setServlet(servlet);
+ filterChain.setServlet(wrapper, servlet);
// If there are no filter mappings, we are done
if ((filterMaps.size() == 0))
Added:
tomcat/sandbox/java/org/apache/coyote/servlet/servlets/RequestInfoFilter.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/coyote/servlet/servlets/RequestInfoFilter.java?rev=420610&view=auto
==============================================================================
---
tomcat/sandbox/java/org/apache/coyote/servlet/servlets/RequestInfoFilter.java
(added)
+++
tomcat/sandbox/java/org/apache/coyote/servlet/servlets/RequestInfoFilter.java
Mon Jul 10 11:42:39 2006
@@ -0,0 +1,86 @@
+/*
+ */
+package org.apache.coyote.servlet.servlets;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Enumeration;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletRequestWrapper;
+import javax.servlet.ServletResponse;
+import javax.servlet.ServletResponseWrapper;
+
+import org.apache.coyote.servlet.FilterChainImpl;
+import org.apache.coyote.servlet.ServletRequestImpl;
+import org.apache.coyote.servlet.ServletResponseImpl;
+import org.apache.tomcat.util.http.MimeHeaders;
+
+public class RequestInfoFilter implements Filter {
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void doFilter(ServletRequest request,
+ ServletResponse response,
+ FilterChain chain)
+ throws IOException, ServletException {
+
+ PrintStream out = System.err;
+ while (request instanceof ServletRequestWrapper) {
+ request = ((ServletRequestWrapper)request).getRequest();
+ }
+ ServletRequestImpl req = (ServletRequestImpl)request;
+ // TODO: cookies, session, headers
+ out.println("Q(" +
+ req.getMethod() + " H:" +
+ req.getServerName() + " L:" +
+ req.getContentLength() + " C:" +
+ req.getContextPath() + " S:" +
+ req.getServletPath() + " P:" +
+ req.getPathInfo() + " Q:" +
+ req.getQueryString() + " " +
+ ")");
+ FilterChainImpl filterChain = req.getFilterChain();
+ for( int i=0; i<filterChain.getSize(); i++) {
+ out.println("F: " +filterChain.getFilter(i).getFilterName());
+ }
+ out.println("S: " + filterChain.getServletConfig().getServletName());
+
+ Enumeration headerNames = req.getHeaderNames();
+ while (headerNames.hasMoreElements()) {
+ String hn = (String)headerNames.nextElement();
+ Enumeration headers = req.getHeaders(hn);
+ while(headers.hasMoreElements()) {
+ out.println(hn + ": " + headers.nextElement());
+ }
+ }
+ chain.doFilter(request, response);
+ while (response instanceof ServletResponseWrapper) {
+ response = ((ServletResponseWrapper)response).getResponse();
+ }
+ if ( response instanceof ServletResponseImpl) {
+ ServletResponseImpl res = (ServletResponseImpl)response;
+ out.println("R(" + res.getStatus() + " " +
+ res.getContentLength() + " " +
+ res.getContentType() + " " +
+ ")");
+ MimeHeaders headerNames2 =
res.getCoyoteResponse().getMimeHeaders();
+ for( int i = 0; i < headerNames2.size(); i++ ) {
+ out.println(headerNames2.getName(i) + ": " +
+ headerNames2.getValue(i));
+ }
+ } else {
+ out.println("R(Unexpected wrapped object)");
+ }
+ out.println();
+ }
+
+ public void destroy() {
+ }
+
+}
Modified:
tomcat/sandbox/java/org/apache/tomcat/servlets/file/DefaultServlet.java
URL:
http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/tomcat/servlets/file/DefaultServlet.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/tomcat/servlets/file/DefaultServlet.java
(original)
+++ tomcat/sandbox/java/org/apache/tomcat/servlets/file/DefaultServlet.java Mon
Jul 10 11:42:39 2006
@@ -23,7 +23,6 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -46,6 +45,7 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.util.ServerInfo;
+import org.apache.tomcat.servlets.util.URLEncoder;
import org.apache.tomcat.util.res.StringManager;
/**
@@ -60,25 +60,24 @@
// ----------------------------------------------------- Instance Variables
- /**
- * HTTP date format.
- */
- protected static final SimpleDateFormat format =
- new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
-
+
/**
* Should we generate directory listings?
*/
protected boolean listings = true;
-
/**
- * Read only flag. By default, it's set to true.
+ * Array containing the safe characters set.
*/
- protected boolean readOnly = true;
+ protected static URLEncoder urlEncoder;
+ /**
+ * Allow a readme file to be included.
+ */
+ protected String readmeFile = null;
+ // TODO: find a better default
/**
* The input buffer size to use when serving resources.
*/
@@ -90,31 +89,19 @@
protected int output = 2048;
/**
- * Size of file transfer buffer in bytes.
- */
- protected static final int BUFFER_SIZE = 4096;
-
- /**
- * Array containing the safe characters set.
- */
- protected static URLEncoder urlEncoder;
-
- /**
- * Allow a readme file to be included.
- */
- protected String readmeFile = null;
-
- /**
* File encoding to be used when reading static files. If none is specified
* the platform default is used.
*/
protected String fileEncoding = null;
+
+ ThreadLocal formatTL = new ThreadLocal();
/**
* Full range marker.
*/
protected static ArrayList FULL = new ArrayList();
-
+
+ // Context base dir
protected File basePath;
protected String basePathName;
@@ -185,24 +172,14 @@
;
}
try {
- value = getServletConfig().getInitParameter("readonly");
- if (value != null)
- readOnly = (new Boolean(value)).booleanValue();
- } catch (Throwable t) {
- ;
- }
- try {
value = getServletConfig().getInitParameter("output");
output = Integer.parseInt(value);
} catch (Throwable t) {
;
}
- try {
- value = getServletConfig().getInitParameter("fileEncoding");
- fileEncoding = value;
- } catch (Throwable t) {
- ;
- }
+ fileEncoding = getServletConfig().getInitParameter("fileEncoding");
+
+ readmeFile = getServletConfig().getInitParameter("readmeFile");
// Sanity check on the specified buffer sizes
@@ -227,7 +204,8 @@
/**
- * Return the relative path associated with this servlet.
+ * Return the relative path associated with this servlet.
+ * Multiple sources are used - include attribute, servlet path, etc
*
* @param request The servlet request we are processing
*/
@@ -260,19 +238,8 @@
result = "/";
}
return (result);
-
}
-
- /**
- * Process a GET request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
@@ -283,15 +250,6 @@
}
- /**
- * Process a HEAD request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
protected void doHead(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
@@ -302,15 +260,6 @@
}
- /**
- * Process a POST request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
@@ -318,189 +267,6 @@
}
- /**
- * Process a POST request for the specified resource.
- *
- * @param req The servlet request we are processing
- * @param resp The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- protected void doPut(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
-
- if (readOnly) {
- resp.sendError(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
- String path = getRelativePath(req);
-
- if (path.indexOf("..") >= 0) {
- // not supported, too dangerous
- // what else to escape ?
- resp.setStatus(404);
- return;
- }
-
- File resFile = new File(basePath, path);
- boolean exists = resFile.exists();
-
-
- // extra check
- if (!resFile.getCanonicalPath().startsWith(basePathName)) {
- //log.info("File outside basedir " + basePathS + " " + f);
- resp.setStatus(404);
- return;
- }
-
-
- boolean result = true;
-
- // Temp. content file used to support partial PUT
- File contentFile = null;
-
- Range range = parseContentRange(req, resp);
-
- InputStream resourceInputStream = null;
-
- // Append data specified in ranges to existing content for this
- // resource - create a temp. file on the local filesystem to
- // perform this operation
- // Assume just one range is specified for now
- if (range != null) {
- //contentFile = executePartialPut(req, range, path);
- //resourceInputStream = new FileInputStream(contentFile);
- resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
- return;
- } else {
- resourceInputStream = req.getInputStream();
- }
-
- try {
- // will override
- FileOutputStream fos = new FileOutputStream(resFile);
- copy(resourceInputStream, fos);
- } catch(IOException e) {
- result = false;
- }
-
- if (result) {
- if (exists) {
- resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
- } else {
- resp.setStatus(HttpServletResponse.SC_CREATED);
- }
- } else {
- resp.sendError(HttpServletResponse.SC_CONFLICT);
- }
-
- }
-
-
- /**
- * Handle a partial PUT. New content specified in request is appended to
- * existing content in oldRevisionContent (if present). This code does
- * not support simultaneous partial updates to the same resource.
- */
-// protected File executePartialPut(HttpServletRequest req, Range range,
-// String path)
-// throws IOException {
-//
-// // Append data specified in ranges to existing content for this
-// // resource - create a temp. file on the local filesystem to
-// // perform this operation
-// File tempDir = (File) getServletContext().getAttribute
-// ("javax.servlet.context.tempdir");
-// // Convert all '/' characters to '.' in resourcePath
-// String convertedResourcePath = path.replace('/', '.');
-// File contentFile = new File(tempDir, convertedResourcePath);
-// if (contentFile.createNewFile()) {
-// // Clean up contentFile when Tomcat is terminated
-// contentFile.deleteOnExit();
-// }
-//
-// RandomAccessFile randAccessContentFile =
-// new RandomAccessFile(contentFile, "rw");
-//
-// Resource oldResource = null;
-// try {
-// Object obj = resources.lookup(path);
-// if (obj instanceof Resource)
-// oldResource = (Resource) obj;
-// } catch (NamingException e) {
-// }
-//
-// // Copy data in oldRevisionContent to contentFile
-// if (oldResource != null) {
-// BufferedInputStream bufOldRevStream =
-// new BufferedInputStream(oldResource.streamContent(),
-// BUFFER_SIZE);
-//
-// int numBytesRead;
-// byte[] copyBuffer = new byte[BUFFER_SIZE];
-// while ((numBytesRead = bufOldRevStream.read(copyBuffer)) != -1) {
-// randAccessContentFile.write(copyBuffer, 0, numBytesRead);
-// }
-//
-// bufOldRevStream.close();
-// }
-//
-// randAccessContentFile.setLength(range.length);
-//
-// // Append data in request input stream to contentFile
-// randAccessContentFile.seek(range.start);
-// int numBytesRead;
-// byte[] transferBuffer = new byte[BUFFER_SIZE];
-// BufferedInputStream requestBufInStream =
-// new BufferedInputStream(req.getInputStream(), BUFFER_SIZE);
-// while ((numBytesRead = requestBufInStream.read(transferBuffer)) !=
-1) {
-// randAccessContentFile.write(transferBuffer, 0, numBytesRead);
-// }
-// randAccessContentFile.close();
-// requestBufInStream.close();
-//
-// return contentFile;
-//
-// }
-
-
- /**
- * Process a POST request for the specified resource.
- *
- * @param req The servlet request we are processing
- * @param resp The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
-
- if (readOnly) {
- resp.sendError(HttpServletResponse.SC_FORBIDDEN);
- return;
- }
-
- String path = getRelativePath(req);
-
- File resFile = new File(basePath, path);
-
- boolean exists = resFile.exists();
-
- if (exists) {
- boolean result = resFile.delete();
- if (result) {
- resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
- } else {
- resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
- }
- } else {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }
-
- }
/**
@@ -533,15 +299,8 @@
* @param resourceAttributes The resource information
*/
protected String getETag(File resourceAttributes) {
- String result = null;
-// if ((result = resourceAttributes.getETag(true)) != null) {
-// return result;
-// } else if ((result = resourceAttributes.getETag()) != null) {
-// return result;
-// } else {
- return "W/\"" + resourceAttributes.length() + "-"
+ return "W/\"" + resourceAttributes.length() + "-"
+ resourceAttributes.lastModified() + "\"";
-// }
}
@@ -772,13 +531,15 @@
}
-
protected String lastModifiedHttp(File resFile) {
String lastModifiedHttp = null;
- // TODO: use thread local, no sync lock
- synchronized (format) {
- lastModifiedHttp = format.format(new Date(resFile.lastModified()));
+ SimpleDateFormat format = (SimpleDateFormat)formatTL.get();
+ if (format == null) {
+ format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz",
+ Locale.US);
+ formatTL.set(format);
}
+ lastModifiedHttp = format.format(new Date(resFile.lastModified()));
return lastModifiedHttp;
}
@@ -1921,5 +1682,68 @@
}
return null;
}
-
+
+ /**
+ * Return a context-relative path, beginning with a "/", that represents
+ * the canonical version of the specified path after ".." and "." elements
+ * are resolved out. If the specified path attempts to go outside the
+ * boundaries of the current context (i.e. too many ".." path elements
+ * are present), return <code>null</code> instead.
+ *
+ * @param path Path to be normalized
+ */
+ protected String normalize(String path) {
+
+ if (path == null)
+ return null;
+
+ // Create a place for the normalized path
+ String normalized = path;
+
+ if (normalized == null)
+ return (null);
+
+ if (normalized.equals("/."))
+ return "/";
+
+ // Normalize the slashes and add leading slash if necessary
+ if (normalized.indexOf('\\') >= 0)
+ normalized = normalized.replace('\\', '/');
+ if (!normalized.startsWith("/"))
+ normalized = "/" + normalized;
+
+ // Resolve occurrences of "//" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("//");
+ if (index < 0)
+ break;
+ normalized = normalized.substring(0, index) +
+ normalized.substring(index + 1);
+ }
+
+ // Resolve occurrences of "/./" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("/./");
+ if (index < 0)
+ break;
+ normalized = normalized.substring(0, index) +
+ normalized.substring(index + 2);
+ }
+
+ // Resolve occurrences of "/../" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("/../");
+ if (index < 0)
+ break;
+ if (index == 0)
+ return (null); // Trying to go outside our context
+ int index2 = normalized.lastIndexOf('/', index - 1);
+ normalized = normalized.substring(0, index2) +
+ normalized.substring(index + 3);
+ }
+
+ // Return the normalized path that we have completed
+ return (normalized);
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]