JBossWeb SVN: r999 - branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/jasper/runtime.
by jbossweb-commits@lists.jboss.org
Author: mmillson
Date: 2009-04-08 17:24:35 -0400 (Wed, 08 Apr 2009)
New Revision: 999
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/jasper/runtime/BodyContentImpl.java
Log:
Fix LIMIT_BUFFER=true ArrayIndexOutOfBoundsException for [JBWEB-136].
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/jasper/runtime/BodyContentImpl.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/jasper/runtime/BodyContentImpl.java 2009-04-08 17:06:46 UTC (rev 998)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/jasper/runtime/BodyContentImpl.java 2009-04-08 21:24:35 UTC (rev 999)
@@ -50,10 +50,7 @@
// Enclosed writer to which any output is written
private Writer writer;
-
- // See comment in setWriter()
- private int bufferSizeSave;
-
+
/**
* Constructor.
*/
@@ -506,6 +503,19 @@
closed = true;
}
}
+
+ /**
+ * This method returns the size of the buffer used by the JspWriter.
+ *
+ * @return the size of the buffer in bytes, or 0 is unbuffered.
+ */
+ public int getBufferSize() {
+ // According to the spec, the JspWriter returned by
+ // JspContext.pushBody(java.io.Writer writer) must behave as
+ // though it were unbuffered. This means that its getBufferSize()
+ // must always return 0.
+ return (writer == null) ? bufferSize : 0;
+ }
/**
* @return the number of bytes unused in the buffer
@@ -558,22 +568,7 @@
void setWriter(Writer writer) {
this.writer = writer;
closed = false;
- if (writer != null) {
- // According to the spec, the JspWriter returned by
- // JspContext.pushBody(java.io.Writer writer) must behave as
- // though it were unbuffered. This means that its getBufferSize()
- // must always return 0. The implementation of
- // JspWriter.getBufferSize() returns the value of JspWriter's
- // 'bufferSize' field, which is inherited by this class.
- // Therefore, we simply save the current 'bufferSize' (so we can
- // later restore it should this BodyContentImpl ever be reused by
- // a call to PageContext.pushBody()) before setting it to 0.
- if (bufferSize != 0) {
- bufferSizeSave = bufferSize;
- bufferSize = 0;
- }
- } else {
- bufferSize = bufferSizeSave;
+ if (writer == null) {
clearBody();
}
}
15 years, 1 month
JBossWeb SVN: r998 - in trunk/java/org/apache/catalina: core and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-08 13:06:46 -0400 (Wed, 08 Apr 2009)
New Revision: 998
Modified:
trunk/java/org/apache/catalina/connector/LocalStrings.properties
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/LocalStrings.properties
Log:
- Add strings before I forget.
Modified: trunk/java/org/apache/catalina/connector/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/connector/LocalStrings.properties 2009-04-08 16:56:47 UTC (rev 997)
+++ trunk/java/org/apache/catalina/connector/LocalStrings.properties 2009-04-08 17:06:46 UTC (rev 998)
@@ -53,6 +53,7 @@
coyoteRequest.authFailed=Failed to authenticate a principal
coyoteRequest.noAsync=The servlet or filters that are being used by this request do not support async operation
coyoteRequest.servletStack=Current Servlet stack for thread {0}
+coyoteRequest.closed=Response has been closed already
#
# MapperListener
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-08 16:56:47 UTC (rev 997)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-08 17:06:46 UTC (rev 998)
@@ -2904,7 +2904,9 @@
throw new IllegalStateException(sm.getString("coyoteRequest.noAsync"));
}
// FIXME: if (asyncContext != null && !processing) { throw ISE }
- // FIXME: if (response.isClosed()) { throw ISE }
+ if (response.isClosed()) {
+ throw new IllegalStateException(sm.getString("coyoteRequest.closed"));
+ }
setTimeout(timeout);
if (asyncContext == null) {
asyncContext = new AsyncContextImpl
Modified: trunk/java/org/apache/catalina/core/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-04-08 16:56:47 UTC (rev 997)
+++ trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-04-08 17:06:46 UTC (rev 998)
@@ -212,6 +212,10 @@
standardWrapper.unloadException=Servlet {0} threw unload() exception
standardWrapper.unloading=Cannot allocate servlet {0} because it is being unloaded
standardWrapper.waiting=Waiting for {0} instance(s) to be deallocated
+standardWrapper.async.listenerError=Listener processing for servlet {0} threw exception
+standardWrapper.async.runnableError=Runnable for servlet {0} threw exception
+standardWrapper.async.runnableError=Async dispatcher for servlet {0} threw exception
+standardWrapper.async.invalidContext=Invalid async context for servlet {0}
defaultInstanceManager.restrictedServletsResource=Restricted servlets property file not found
defaultInstanceManager.privilegedServlet=Servlet of class {0} is privileged and cannot be loaded by this web application
15 years, 1 month
JBossWeb SVN: r997 - trunk/java/org/apache/catalina/connector.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-08 12:56:47 -0400 (Wed, 08 Apr 2009)
New Revision: 997
Modified:
trunk/java/org/apache/catalina/connector/Request.java
Log:
- Add isAsyncSupported code.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-08 16:47:25 UTC (rev 996)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-08 16:56:47 UTC (rev 997)
@@ -2863,7 +2863,22 @@
}
public boolean isAsyncSupported() {
- // FIXME: Check all the filter chain
+ int filterChainCount = currentFilterChain;
+ for (int i = 0; i < filterChainCount; i++) {
+ ApplicationFilterChain filterChain = filterChains.get(i);
+ int n = filterChain.getFilterCount();
+ int pos = filterChain.getPointer();
+ for (int j = 0; j < pos; j++) {
+ if (!filterChain.getFilters()[j].getFilterDef().getAsyncSupported()) {
+ return false;
+ }
+ }
+ if (pos == n) {
+ if (!filterChain.getWrapper().getAsyncSupported()) {
+ return false;
+ }
+ }
+ }
return true;
}
15 years, 1 month
JBossWeb SVN: r996 - in trunk/java/org/apache/catalina: core and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-08 12:47:25 -0400 (Wed, 08 Apr 2009)
New Revision: 996
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
trunk/java/org/apache/catalina/security/SecurityClassLoad.java
Log:
- Should implement async dispatch.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-08 12:34:27 UTC (rev 995)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-08 16:47:25 UTC (rev 996)
@@ -130,6 +130,11 @@
|| Boolean.valueOf(System.getProperty("org.apache.catalina.connector.Request.WRAPPED_RESPONSE_IN_LOGIN", "false")).booleanValue();
+ protected static final boolean CHECK_ASYNC =
+ Globals.STRICT_SERVLET_COMPLIANCE
+ || Boolean.valueOf(System.getProperty("org.apache.catalina.connector.Request.CHECK_ASYNC", "true")).booleanValue();
+
+
// ----------------------------------------------------------- Constructors
@@ -2871,7 +2876,7 @@
}
public AsyncContext startAsync() throws IllegalStateException {
- return startAsync(getRequest(), response.getResponse());
+ return startAsync(null, null);
}
public AsyncContext startAsync(ServletRequest servletRequest,
@@ -2880,14 +2885,26 @@
if (timeout <= 0) {
timeout = Integer.MAX_VALUE;
}
- if (!isAsyncSupported()) {
+ if (CHECK_ASYNC && !isAsyncSupported()) {
throw new IllegalStateException(sm.getString("coyoteRequest.noAsync"));
}
// FIXME: if (asyncContext != null && !processing) { throw ISE }
// FIXME: if (response.isClosed()) { throw ISE }
setTimeout(timeout);
- asyncContext = new AsyncContextImpl(servletRequest, servletResponse);
- eventMode = true;
+ if (asyncContext == null) {
+ asyncContext = new AsyncContextImpl
+ ((servletRequest == null) ? getRequest() : servletRequest,
+ (servletResponse == null) ? response.getResponse() : servletResponse);
+ eventMode = true;
+ } else {
+ if (servletRequest != null) {
+ asyncContext.setRequest(servletRequest);
+ }
+ if (servletResponse != null) {
+ asyncContext.setResponse(servletResponse);
+ }
+ asyncContext.reset();
+ }
return asyncContext;
}
@@ -2995,6 +3012,7 @@
protected String path = null;
protected Runnable runnable = null;
protected boolean useAttributes = false;
+ protected boolean ready = true;
public AsyncContextImpl(ServletRequest request, ServletResponse response) {
this.request = request;
@@ -3051,6 +3069,18 @@
resume();
}
+ public boolean isReady() {
+ return ready;
+ }
+
+ public void setRequest(ServletRequest request) {
+ this.request = request;
+ }
+
+ public void setResponse(ServletResponse response) {
+ this.response = response;
+ }
+
public ServletContext getServletContext() {
return servletContext;
}
@@ -3067,6 +3097,14 @@
return runnable;
}
+ public void reset() {
+ servletContext = null;
+ path = null;
+ runnable = null;
+ useAttributes = false;
+ ready = true;
+ }
+
public Map<AsyncEvent, AsyncListener> getAsyncListeners() {
return asyncListeners;
}
Modified: trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-04-08 12:34:27 UTC (rev 995)
+++ trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-04-08 16:47:25 UTC (rev 996)
@@ -24,6 +24,7 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import javax.servlet.AsyncContext;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
@@ -99,12 +100,31 @@
}
+ protected class PrivilegedAsync implements PrivilegedExceptionAction {
+ private ServletRequest request;
+ private ServletResponse response;
+ private boolean attributes;
+
+ PrivilegedAsync(ServletRequest request, ServletResponse response, boolean attributes)
+ {
+ this.request = request;
+ this.response = response;
+ this.attributes = attributes;
+ }
+
+ public Object run() throws ServletException, IOException {
+ doAsync(request, response, attributes);
+ return null;
+ }
+ }
+
+
/**
* Used to pass state when the request dispatcher is used. Using instance
* variables causes threading issues and state is too complex to pass and
* return single ServletRequest or ServletResponse objects.
*/
- private class State {
+ private static class State {
State(ServletRequest request, ServletResponse response,
boolean including) {
this.outerRequest = request;
@@ -280,6 +300,86 @@
/**
+ * Async forward this request and response to another resource for processing.
+ * Any runtime exception, IOException, or ServletException thrown by the
+ * called servlet will be propogated to the caller.
+ *
+ * @param request The servlet request to be forwarded
+ * @param response The servlet response to be forwarded
+ *
+ * @exception IOException if an input/output error occurs
+ * @exception ServletException if a servlet exception occurs
+ */
+ public void async(ServletRequest request, ServletResponse response, boolean attributes)
+ throws ServletException, IOException
+ {
+ if (Globals.IS_SECURITY_ENABLED) {
+ try {
+ AccessController.doPrivileged(new PrivilegedAsync(request, response, attributes));
+ } catch (PrivilegedActionException pe) {
+ Exception e = pe.getException();
+ if (e instanceof ServletException)
+ throw (ServletException) e;
+ throw (IOException) e;
+ }
+ } else {
+ doAsync(request,response, attributes);
+ }
+ }
+
+ private void doAsync(ServletRequest request, ServletResponse response, boolean attributes)
+ throws ServletException, IOException
+ {
+
+ // Set up to handle the specified request and response
+ State state = new State(request, response, false);
+
+ if (Globals.STRICT_SERVLET_COMPLIANCE) {
+ // Check SRV.8.2 / SRV.14.2.5.1 compliance
+ checkSameObjects(request, response);
+ }
+
+ if (attributes) {
+ wrapResponse(state);
+ ApplicationHttpRequest wrequest =
+ (ApplicationHttpRequest) wrapRequest(state);
+ String contextPath = context.getPath();
+ HttpServletRequest hrequest = state.hrequest;
+ if (hrequest.getAttribute(AsyncContext.ASYNC_REQUEST_URI) == null) {
+ wrequest.setAttribute(AsyncContext.ASYNC_REQUEST_URI,
+ hrequest.getRequestURI());
+ wrequest.setAttribute(AsyncContext.ASYNC_CONTEXT_PATH,
+ hrequest.getContextPath());
+ wrequest.setAttribute(AsyncContext.ASYNC_SERVLET_PATH,
+ hrequest.getServletPath());
+ wrequest.setAttribute(AsyncContext.ASYNC_PATH_INFO,
+ hrequest.getPathInfo());
+ wrequest.setAttribute(AsyncContext.ASYNC_QUERY_STRING,
+ hrequest.getQueryString());
+ }
+
+ wrequest.setContextPath(contextPath);
+ wrequest.setRequestURI(requestURI);
+ wrequest.setServletPath(servletPath);
+ wrequest.setPathInfo(pathInfo);
+ if (queryString != null) {
+ wrequest.setQueryString(queryString);
+ wrequest.setQueryParams(queryString);
+ }
+ }
+
+ state.outerRequest.setAttribute
+ (ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
+ requestPath);
+ state.outerRequest.setAttribute
+ (ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
+ Integer.valueOf(ApplicationFilterFactory.ASYNC_INTEGER));
+ invoke(state.outerRequest, response, state);
+
+ }
+
+
+ /**
* Forward this request and response to another resource for processing.
* Any runtime exception, IOException, or ServletException thrown by the
* called servlet will be propogated to the caller.
@@ -447,7 +547,6 @@
}
-
/**
* Include the response from another resource in the current response.
* Any runtime exception, IOException, or ServletException thrown by the
@@ -828,14 +927,11 @@
// Instantiate a new wrapper at this point and insert it in the chain
ServletRequest wrapper = null;
if ((current instanceof ApplicationHttpRequest) ||
- (current instanceof Request) ||
(current instanceof HttpServletRequest)) {
// Compute a crossContext flag
HttpServletRequest hcurrent = (HttpServletRequest) current;
boolean crossContext = false;
- if ((state.outerRequest instanceof ApplicationHttpRequest) ||
- (state.outerRequest instanceof Request) ||
- (state.outerRequest instanceof HttpServletRequest)) {
+ if (state.outerRequest instanceof HttpServletRequest) {
HttpServletRequest houterRequest =
(HttpServletRequest) state.outerRequest;
Object contextPath = houterRequest.getAttribute
@@ -888,14 +984,13 @@
// Instantiate a new wrapper at this point and insert it in the chain
ServletResponse wrapper = null;
- if ((current instanceof ApplicationHttpResponse) ||
- (current instanceof Response) ||
- (current instanceof HttpServletResponse))
+ if (current instanceof HttpServletResponse) {
wrapper =
new ApplicationHttpResponse((HttpServletResponse) current,
state.including);
- else
+ } else {
wrapper = new ApplicationResponse(current, state.including);
+ }
if (previous == null)
state.outerResponse = wrapper;
else
Modified: trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java 2009-04-08 12:34:27 UTC (rev 995)
+++ trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java 2009-04-08 16:47:25 UTC (rev 996)
@@ -27,6 +27,7 @@
import java.util.Map;
import java.util.NoSuchElementException;
+import javax.servlet.AsyncContext;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
@@ -72,7 +73,10 @@
Globals.INCLUDE_SERVLET_PATH_ATTR, Globals.INCLUDE_PATH_INFO_ATTR,
Globals.INCLUDE_QUERY_STRING_ATTR, Globals.FORWARD_REQUEST_URI_ATTR,
Globals.FORWARD_CONTEXT_PATH_ATTR, Globals.FORWARD_SERVLET_PATH_ATTR,
- Globals.FORWARD_PATH_INFO_ATTR, Globals.FORWARD_QUERY_STRING_ATTR };
+ Globals.FORWARD_PATH_INFO_ATTR, Globals.FORWARD_QUERY_STRING_ATTR,
+ AsyncContext.ASYNC_REQUEST_URI, AsyncContext.ASYNC_CONTEXT_PATH,
+ AsyncContext.ASYNC_SERVLET_PATH, AsyncContext.ASYNC_PATH_INFO,
+ AsyncContext.ASYNC_QUERY_STRING };
/**
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-08 12:34:27 UTC (rev 995)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-08 16:47:25 UTC (rev 996)
@@ -48,6 +48,7 @@
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.Iterator;
import javax.management.MalformedObjectNameException;
@@ -57,6 +58,7 @@
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
import javax.servlet.UnavailableException;
import javax.servlet.http.HttpServletResponse;
@@ -65,6 +67,7 @@
import org.apache.catalina.connector.ClientAbortException;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
+import org.apache.catalina.connector.ResponseFacade;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.valves.ValveBase;
import org.apache.tomcat.util.log.SystemLogHandler;
@@ -439,11 +442,41 @@
}
ApplicationDispatcher dispatcher =
(ApplicationDispatcher) servletContext.getRequestDispatcher(asyncContext.getPath());
- // FIXME: Add an async method to Application dispatcher
// Invoke the dispatcher async method with the attributes flag
- asyncContext.getUseAttributes();
+ try {
+ dispatcher.async(asyncContext.getRequest(), asyncContext.getResponse(),
+ asyncContext.getUseAttributes());
+ } catch (Throwable e) {
+ container.getLogger().error(sm.getString("standardWrapper.async.dispatchError",
+ getContainer().getName()), e);
+ exception(request, response, e);
+ }
+ // If there is no new startAsync, then close the response
+ if (!asyncContext.isReady()) {
+ if (asyncContext.getResponse() instanceof ResponseFacade) {
+ response.setSuspended(true);
+ } else {
+ // Close anyway
+ try {
+ PrintWriter writer = response.getWriter();
+ writer.close();
+ } catch (IllegalStateException e) {
+ try {
+ ServletOutputStream stream = response.getOutputStream();
+ stream.close();
+ } catch (IllegalStateException f) {
+ ;
+ } catch (IOException f) {
+ ;
+ }
+ } catch (IOException e) {
+ ;
+ }
+ }
+ event.close();
+ }
} else {
- // FIXME: should not happen
+ throw new IllegalStateException(sm.getString("standardWrapper.async.invalidContext"));
}
return;
}
Modified: trunk/java/org/apache/catalina/security/SecurityClassLoad.java
===================================================================
--- trunk/java/org/apache/catalina/security/SecurityClassLoad.java 2009-04-08 12:34:27 UTC (rev 995)
+++ trunk/java/org/apache/catalina/security/SecurityClassLoad.java 2009-04-08 16:47:25 UTC (rev 996)
@@ -55,6 +55,9 @@
"core.ApplicationContextFacade$1");
loader.loadClass
(basePackage +
+ "core.ApplicationDispatcher$PrivilegedAsync");
+ loader.loadClass
+ (basePackage +
"core.ApplicationDispatcher$PrivilegedForward");
loader.loadClass
(basePackage +
15 years, 1 month
JBossWeb SVN: r995 - in trunk: java/org/apache/catalina/core and 8 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-08 08:34:27 -0400 (Wed, 08 Apr 2009)
New Revision: 995
Modified:
trunk/build.xml
trunk/dist.xml
trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
trunk/java/org/apache/catalina/manager/Constants.java
trunk/java/org/apache/catalina/manager/ManagerServlet.java
trunk/java/org/apache/catalina/manager/host/Constants.java
trunk/java/org/apache/catalina/servlets/WebdavServlet.java
trunk/java/org/apache/catalina/valves/AccessLogValve.java
trunk/java/org/apache/naming/resources/FileDirContext.java
trunk/java/org/apache/tomcat/util/http/MimeMap.java
trunk/java/org/apache/tomcat/util/res/StringManager.java
trunk/webapps/docs/changelog.xml
Log:
- Port various very minor patches from Tomcat.
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/build.xml 2009-04-08 12:34:27 UTC (rev 995)
@@ -82,6 +82,7 @@
<mkdir dir="${tomcat.build}/bin"/>
<mkdir dir="${tomcat.build}/conf"/>
<mkdir dir="${tomcat.build}/lib"/>
+ <mkdir dir="${tomcat.build}/logs"/>
<mkdir dir="${tomcat.build}/temp"/>
<mkdir dir="${tomcat.build}/webapps"/>
Modified: trunk/dist.xml
===================================================================
--- trunk/dist.xml 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/dist.xml 2009-04-08 12:34:27 UTC (rev 995)
@@ -533,7 +533,7 @@
<!-- Packages the source code distribution in tar.gz format -->
<target name="package-src-tgz">
<fixcrlf srcdir="${tomcat.dist}/src"
- excludes="**/*.jar,**/*.gif,**/*.bmp,**/*.jpg,**/*.ico,**/*.war,**/*.exe.**/*.pdf,**/*.bin,**/*.dia" eol="lf"/>
+ excludes="**/*.jar,**/*.gif,**/*.bmp,**/*.jpg,**/*.ico,**/*.war,**/*.exe,**/*.pdf,**/*.bin,**/*.dia" eol="lf"/>
<tar longfile="gnu" compression="gzip"
tarfile="${tomcat.release}/v${version}/src/${final-src.name}.tar.gz">
<tarfileset dir="${tomcat.dist}/src" prefix="${final-src.name}" />
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -389,7 +389,6 @@
* matches the dispatcher types specified in the FilterMap
*/
private boolean matchDispatcher(FilterMap filterMap, int dispatcher) {
- // FIXME: add async
switch (dispatcher) {
case FORWARD : {
if (filterMap.getDispatcherMapping() == FilterMap.FORWARD ||
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -440,7 +440,7 @@
ApplicationDispatcher dispatcher =
(ApplicationDispatcher) servletContext.getRequestDispatcher(asyncContext.getPath());
// FIXME: Add an async method to Application dispatcher
- // Invoke the dispatcher
+ // Invoke the dispatcher async method with the attributes flag
asyncContext.getUseAttributes();
} else {
// FIXME: should not happen
Modified: trunk/java/org/apache/catalina/manager/Constants.java
===================================================================
--- trunk/java/org/apache/catalina/manager/Constants.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/catalina/manager/Constants.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -111,7 +111,7 @@
"<?xml version=\"1.0\" encoding=\""+CHARSET+"\"?>";
public static final String XML_STYLE =
- "<?xml-stylesheet type=\"text/xsl\" href=\"/manager/xform.xsl\" ?>";
+ "<?xml-stylesheet type=\"text/xsl\" href=\"xform.xsl\" ?>";
}
Modified: trunk/java/org/apache/catalina/manager/ManagerServlet.java
===================================================================
--- trunk/java/org/apache/catalina/manager/ManagerServlet.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/catalina/manager/ManagerServlet.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -852,10 +852,10 @@
Container[] contexts = host.findChildren();
for (int i = 0; i < contexts.length; i++) {
Context context = (Context) contexts[i];
- String displayPath = context.getPath();
- if( displayPath.equals("") )
- displayPath = "/";
if (context != null ) {
+ String displayPath = context.getPath();
+ if( displayPath.equals("") )
+ displayPath = "/";
if (context.getAvailable()) {
writer.println(sm.getString("managerServlet.listitem",
displayPath,
Modified: trunk/java/org/apache/catalina/manager/host/Constants.java
===================================================================
--- trunk/java/org/apache/catalina/manager/host/Constants.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/catalina/manager/host/Constants.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -98,12 +98,5 @@
public static final String CHARSET="utf-8";
- // FIXME need we this?
- public static final String XML_DECLARATION =
- "<?xml version=\"1.0\" encoding=\""+CHARSET+"\"?>";
-
- public static final String XML_STYLE =
- "<?xml-stylesheet type=\"text/xsl\" href=\"/manager/xform.xsl\" ?>";
-
}
Modified: trunk/java/org/apache/catalina/servlets/WebdavServlet.java
===================================================================
--- trunk/java/org/apache/catalina/servlets/WebdavServlet.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/catalina/servlets/WebdavServlet.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -19,6 +19,7 @@
package org.apache.catalina.servlets;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
@@ -463,7 +464,7 @@
Node propNode = null;
- if (req.getInputStream().available() > 0) {
+ if (req.getContentLength() > 0) {
DocumentBuilder documentBuilder = getDocumentBuilder();
try {
@@ -494,9 +495,11 @@
}
}
} catch (SAXException e) {
- // Something went wrong - use the defaults.
+ // Something went wrong - bad request
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST);
} catch (IOException e) {
- // Something went wrong - use the defaults.
+ // Something went wrong - bad request
+ resp.sendError(WebdavStatus.SC_BAD_REQUEST);
}
}
@@ -1662,14 +1665,20 @@
path, destinationPath);
if ((!result) || (!errorList.isEmpty())) {
-
- sendReport(req, resp, errorList);
+ if (errorList.size() == 1) {
+ resp.sendError(errorList.elements().nextElement().intValue());
+ } else {
+ sendReport(req, resp, errorList);
+ }
return false;
-
}
// Copy was successful
- resp.setStatus(WebdavStatus.SC_CREATED);
+ if (exists) {
+ resp.setStatus(WebdavStatus.SC_NO_CONTENT);
+ } else {
+ resp.setStatus(WebdavStatus.SC_CREATED);
+ }
// Removing any lock-null resource which would be present at
// the destination path
@@ -1707,8 +1716,7 @@
try {
resources.createSubcontext(dest);
} catch (NamingException e) {
- errorList.put
- (dest, new Integer(WebdavStatus.SC_CONFLICT));
+ errorList.put(dest, WebdavStatus.SC_CONFLICT);
return false;
}
@@ -1728,8 +1736,7 @@
copyResource(resources, errorList, childSrc, childDest);
}
} catch (NamingException e) {
- errorList.put
- (dest, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
+ errorList.put(dest, WebdavStatus.SC_INTERNAL_SERVER_ERROR);
return false;
}
@@ -1739,15 +1746,17 @@
try {
resources.bind(dest, object);
} catch (NamingException e) {
- errorList.put
- (source,
- new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
+ if (e.getCause() instanceof FileNotFoundException) {
+ // We know the source exists so it must be the
+ // destination dir that can't be found
+ errorList.put(source, WebdavStatus.SC_CONFLICT);
+ } else {
+ errorList.put(source, WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
return false;
}
} else {
- errorList.put
- (source,
- new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR));
+ errorList.put(source, WebdavStatus.SC_INTERNAL_SERVER_ERROR);
return false;
}
Modified: trunk/java/org/apache/catalina/valves/AccessLogValve.java
===================================================================
--- trunk/java/org/apache/catalina/valves/AccessLogValve.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/catalina/valves/AccessLogValve.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -856,8 +856,7 @@
// Initialize the timeZone, Date formatters, and currentDate
timezone = TimeZone.getDefault();
timeZoneNoDST = calculateTimeZoneOffset(timezone.getRawOffset());
- Calendar calendar = Calendar.getInstance(timezone);
- int offset = calendar.get(Calendar.DST_OFFSET);
+ int offset = timezone.getDSTSavings();
timeZoneDST = calculateTimeZoneOffset(timezone.getRawOffset() + offset);
if (fileDateFormat == null || fileDateFormat.length() == 0)
Modified: trunk/java/org/apache/naming/resources/FileDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/FileDirContext.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/naming/resources/FileDirContext.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -581,8 +581,10 @@
is.close();
}
} catch (IOException e) {
- throw new NamingException
+ NamingException ne = new NamingException
(sm.getString("resources.bindFailed", e));
+ ne.initCause(e);
+ throw ne;
}
}
Modified: trunk/java/org/apache/tomcat/util/http/MimeMap.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/MimeMap.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/tomcat/util/http/MimeMap.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -32,9 +32,10 @@
// Defaults - all of them are "well-known" types,
// you can add using normal web.xml.
- public static Hashtable defaultMap=new Hashtable(101);
+ public static Hashtable<String,String> defaultMap=new Hashtable<String,String>(101);
static {
defaultMap.put("txt", "text/plain");
+ defaultMap.put("css", "text/css");
defaultMap.put("html","text/html");
defaultMap.put("htm", "text/html");
defaultMap.put("gif", "image/gif");
@@ -143,6 +144,10 @@
return map.keys();
}
+ public String getMimeType(String ext) {
+ return getContentTypeFor(ext);
+ }
+
public String getContentType(String extn) {
String type = (String)map.get(extn.toLowerCase());
if( type == null ) type=(String)defaultMap.get( extn );
Modified: trunk/java/org/apache/tomcat/util/res/StringManager.java
===================================================================
--- trunk/java/org/apache/tomcat/util/res/StringManager.java 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/java/org/apache/tomcat/util/res/StringManager.java 2009-04-08 12:34:27 UTC (rev 995)
@@ -130,108 +130,17 @@
* @param key
* @param args
*/
-
- public String getString(String key, Object[] args) {
- String iString = null;
+ public String getString(final String key, final Object... args) {
String value = getString(key);
-
- // this check for the runtime exception is some pre 1.1.6
- // VM's don't do an automatic toString() on the passed in
- // objects and barf out
-
- try {
- // ensure the arguments are not null so pre 1.2 VM's don't barf
- if(args==null){
- args = new Object[1];
- }
-
- Object[] nonNullArgs = args;
- for (int i=0; i<args.length; i++) {
- if (args[i] == null) {
- if (nonNullArgs==args){
- nonNullArgs=(Object[])args.clone();
- }
- nonNullArgs[i] = "null";
- }
- }
- if( value==null ) value=key;
- MessageFormat mf = new MessageFormat(value);
- mf.setLocale(locale);
- iString = mf.format(nonNullArgs, new StringBuffer(), null).toString();
- } catch (IllegalArgumentException iae) {
- StringBuffer buf = new StringBuffer();
- buf.append(value);
- for (int i = 0; i < args.length; i++) {
- buf.append(" arg[" + i + "]=" + args[i]);
- }
- iString = buf.toString();
+ if (value == null) {
+ value = key;
}
- return iString;
- }
- /**
- * Get a string from the underlying resource bundle and format it
- * with the given object argument. This argument can of course be
- * a String object.
- *
- * @param key
- * @param arg
- */
-
- public String getString(String key, Object arg) {
- Object[] args = new Object[] {arg};
- return getString(key, args);
+ MessageFormat mf = new MessageFormat(value);
+ mf.setLocale(locale);
+ return mf.format(args, new StringBuffer(), null).toString();
}
-
- /**
- * Get a string from the underlying resource bundle and format it
- * with the given object arguments. These arguments can of course
- * be String objects.
- *
- * @param key
- * @param arg1
- * @param arg2
- */
-
- public String getString(String key, Object arg1, Object arg2) {
- Object[] args = new Object[] {arg1, arg2};
- return getString(key, args);
- }
- /**
- * Get a string from the underlying resource bundle and format it
- * with the given object arguments. These arguments can of course
- * be String objects.
- *
- * @param key
- * @param arg1
- * @param arg2
- * @param arg3
- */
-
- public String getString(String key, Object arg1, Object arg2,
- Object arg3) {
- Object[] args = new Object[] {arg1, arg2, arg3};
- return getString(key, args);
- }
-
- /**
- * Get a string from the underlying resource bundle and format it
- * with the given object arguments. These arguments can of course
- * be String objects.
- *
- * @param key
- * @param arg1
- * @param arg2
- * @param arg3
- * @param arg4
- */
-
- public String getString(String key, Object arg1, Object arg2,
- Object arg3, Object arg4) {
- Object[] args = new Object[] {arg1, arg2, arg3, arg4};
- return getString(key, args);
- }
// --------------------------------------------------------------
// STATIC SUPPORT METHODS
// --------------------------------------------------------------
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-04-08 03:30:04 UTC (rev 994)
+++ trunk/webapps/docs/changelog.xml 2009-04-08 12:34:27 UTC (rev 995)
@@ -48,8 +48,14 @@
Move InstanceManager and PeriodicEventListener to org.apache.tomcat. (markt)
</update>
<fix>
- Wrong MKCOL status code for errors. (markt)
+ <bug>46982</bug>: Use DST offset not current offset in the access log valve. (markt)
</fix>
+ <fix>
+ Various WebDAV test suite failures. (markt)
+ </fix>
+ <fix>
+ <bug>46933</bug>: Simplify StringManager using Java 5 features. Based on a patch by Jens Kapitza. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
15 years, 1 month
JBossWeb SVN: r994 - in trunk: java/org/apache/catalina/connector and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-07 23:30:04 -0400 (Tue, 07 Apr 2009)
New Revision: 994
Modified:
trunk/.project
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/ApplicationContext.java
trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
Log:
- Work on the async impl. ApplicationDispatcher.async is missing (but it does not do much, so not too hard),
and the path handling is not that great.
Modified: trunk/.project
===================================================================
--- trunk/.project 2009-04-08 03:28:20 UTC (rev 993)
+++ trunk/.project 2009-04-08 03:30:04 UTC (rev 994)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>jbossweb-2.1.x</name>
+ <name>jbossweb-3.0.x</name>
<comment></comment>
<projects>
</projects>
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-08 03:28:20 UTC (rev 993)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-08 03:30:04 UTC (rev 994)
@@ -2994,6 +2994,7 @@
protected ServletContext servletContext = null;
protected String path = null;
protected Runnable runnable = null;
+ protected boolean useAttributes = false;
public AsyncContextImpl(ServletRequest request, ServletResponse response) {
this.request = request;
@@ -3006,11 +3007,24 @@
}
public void dispatch() {
+ if (request == getRequestFacade()) {
+ // Get the path directly
+ path = getRequestPathMB().toString();
+ } else if (request instanceof HttpServletRequest) {
+ // Rebuild the path
+ path = ((HttpServletRequest) request).getRequestURI();
+ if (servletContext != null) {
+ path = path.substring(servletContext.getContextPath().length());
+ } else {
+ path = path.substring(context.getName().length());
+ }
+ }
resume();
}
public void dispatch(String path) {
this.path = path;
+ useAttributes = true;
resume();
}
@@ -3045,6 +3059,10 @@
return path;
}
+ public boolean getUseAttributes() {
+ return useAttributes;
+ }
+
public Runnable getRunnable() {
return runnable;
}
Modified: trunk/java/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-04-08 03:28:20 UTC (rev 993)
+++ trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-04-08 03:30:04 UTC (rev 994)
@@ -24,7 +24,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.EnumSet;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
@@ -52,7 +51,6 @@
import org.apache.catalina.Wrapper;
import org.apache.catalina.deploy.ApplicationParameter;
import org.apache.catalina.deploy.FilterDef;
-import org.apache.catalina.deploy.SessionCookie;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.ResourceSet;
Modified: trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-04-08 03:28:20 UTC (rev 993)
+++ trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-04-08 03:30:04 UTC (rev 994)
@@ -186,10 +186,7 @@
this.pathInfo = pathInfo;
this.queryString = queryString;
this.name = name;
- if (wrapper instanceof StandardWrapper)
- this.support = ((StandardWrapper) wrapper).getInstanceSupport();
- else
- this.support = new InstanceSupport(wrapper);
+ this.support = wrapper.getInstanceSupport();
}
@@ -824,8 +821,6 @@
break;
if (current instanceof ApplicationRequest)
break;
- if (current instanceof Request)
- break;
previous = current;
current = ((ServletRequestWrapper) current).getRequest();
}
@@ -887,8 +882,6 @@
break;
if (current instanceof ApplicationResponse)
break;
- if (current instanceof Response)
- break;
previous = current;
current = ((ServletResponseWrapper) current).getResponse();
}
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-08 03:28:20 UTC (rev 993)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-08 03:30:04 UTC (rev 994)
@@ -48,10 +48,14 @@
import java.io.IOException;
+import java.util.Iterator;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
import javax.servlet.http.HttpServletResponse;
@@ -63,7 +67,6 @@
import org.apache.catalina.connector.Response;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.valves.ValveBase;
-import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.log.SystemLogHandler;
import org.jboss.servlet.http.HttpEvent;
import org.jboss.servlet.http.HttpEventServlet;
@@ -221,16 +224,12 @@
exception(request, response, e);
servlet = null;
}
- MessageBytes requestPathMB = null;
- if (request != null) {
- requestPathMB = request.getRequestPathMB();
- }
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
ApplicationFilterFactory.REQUEST_INTEGER);
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
- requestPathMB);
+ request.getRequestPathMB());
// Create the filter chain for this request
ApplicationFilterFactory factory =
ApplicationFilterFactory.getInstance();
@@ -397,6 +396,58 @@
public void event(Request request, Response response, HttpEvent event)
throws IOException, ServletException {
+ // Async processing
+ Request.AsyncContextImpl asyncContext = (Request.AsyncContextImpl) request.getAsyncContext();
+ if (asyncContext != null) {
+ if (event.getType() == EventType.END || event.getType() == EventType.ERROR
+ || event.getType() == EventType.TIMEOUT) {
+ // Invoke the listeners with onComplete or onTimeout
+ boolean timeout = (event.getType() == EventType.TIMEOUT) ? true : false;
+ Iterator<AsyncEvent> asyncEvents = asyncContext.getAsyncListeners().keySet().iterator();
+ while (asyncEvents.hasNext()) {
+ AsyncEvent asyncEvent = asyncEvents.next();
+ AsyncListener asyncListener = asyncContext.getAsyncListeners().get(asyncEvent);
+ try {
+ if (timeout) {
+ asyncListener.onTimeout(asyncEvent);
+ } else {
+ asyncListener.onComplete(asyncEvent);
+ }
+ } catch (Throwable e) {
+ container.getLogger().error(sm.getString("standardWrapper.async.listenerError",
+ getContainer().getName()), e);
+ exception(request, response, e);
+ }
+ }
+ } else if (asyncContext.getRunnable() != null) {
+ // Execute the runnable
+ try {
+ asyncContext.getRunnable().run();
+ } catch (Throwable e) {
+ container.getLogger().error(sm.getString("standardWrapper.async.runnableError",
+ getContainer().getName()), e);
+ exception(request, response, e);
+ }
+ } else if (asyncContext.getPath() != null) {
+ // Remap the request, set the dispatch attributes, create the filter chain
+ // and invoke the Servlet
+ Context context = (Context) getContainer().getParent();
+ ServletContext servletContext = context.getServletContext();
+ if (asyncContext.getServletContext() != null) {
+ // Cross context
+ servletContext = asyncContext.getServletContext();
+ }
+ ApplicationDispatcher dispatcher =
+ (ApplicationDispatcher) servletContext.getRequestDispatcher(asyncContext.getPath());
+ // FIXME: Add an async method to Application dispatcher
+ // Invoke the dispatcher
+ asyncContext.getUseAttributes();
+ } else {
+ // FIXME: should not happen
+ }
+ return;
+ }
+
// Initialize local variables we may need
Throwable throwable = null;
// This should be a Request attribute...
@@ -433,45 +484,13 @@
servlet = null;
}
- MessageBytes requestPathMB = null;
- if (request != null) {
- requestPathMB = request.getRequestPathMB();
- }
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
ApplicationFilterFactory.ASYNC_INTEGER);
request.setAttribute
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
- requestPathMB);
+ request.getRequestPathMB());
- // FIXME: Implement async mode, which means invoking listeners or the Servlet, etc
- Request.AsyncContextImpl asyncContext = (Request.AsyncContextImpl) request.getAsyncContext();
- if (asyncContext != null) {
- if (event.getType() == EventType.END || event.getType() == EventType.ERROR) {
- // Invoke the listeners with onComplete
- // FIXME
- } else if (event.getType() == EventType.TIMEOUT) {
- // Invoke the listeners with onTimeout
- // FIXME
- } else if (asyncContext.getRunnable() != null) {
- // Execute the runnable
- // FIXME
- } else if (asyncContext.getPath() != null) {
- // Remap the request, set the dispatch attributes, create the filter chain
- // and invoke the Servlet
- // FIXME: Also check how cross context works, but it is be ok to do from here
- // (or do another distpatcher object similar to the current request dispatcher)
- if (asyncContext.getServletContext() != null) {
- // Cross context
- // FIXME
- }
- } else {
- // Create the filter chain and reinvoke the same Servlet
- // FIXME
- }
- return; // FIXME
- }
-
// Get the current (unchanged) filter chain for this request
ApplicationFilterChain filterChain =
(ApplicationFilterChain) request.getFilterChain();
15 years, 1 month
JBossWeb SVN: r993 - in trunk/java/org: jboss/web/cluster/advertise and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-07 23:28:20 -0400 (Tue, 07 Apr 2009)
New Revision: 993
Modified:
trunk/java/org/apache/coyote/http11/Http11Processor.java
trunk/java/org/jboss/web/cluster/advertise/AdvertiseListener.java
Log:
- Minor fixes.
Modified: trunk/java/org/apache/coyote/http11/Http11Processor.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11Processor.java 2009-04-07 23:09:34 UTC (rev 992)
+++ trunk/java/org/apache/coyote/http11/Http11Processor.java 2009-04-08 03:28:20 UTC (rev 993)
@@ -810,7 +810,6 @@
int keepAliveLeft = maxKeepAliveRequests;
int soTimeout = socket.getSoTimeout();
- int oldSoTimeout = soTimeout;
int threadRatio = (endpoint.getCurrentThreadsBusy() * 100)
/ endpoint.getMaxThreads();
@@ -818,15 +817,6 @@
keepAliveLeft = 1;
}
- if (soTimeout != oldSoTimeout) {
- try {
- socket.setSoTimeout(soTimeout);
- } catch (Throwable t) {
- log.debug(sm.getString("http11processor.socket.timeout"), t);
- error = true;
- }
- }
-
boolean keptAlive = false;
while (!error && keepAlive && !event) {
Modified: trunk/java/org/jboss/web/cluster/advertise/AdvertiseListener.java
===================================================================
--- trunk/java/org/jboss/web/cluster/advertise/AdvertiseListener.java 2009-04-07 23:09:34 UTC (rev 992)
+++ trunk/java/org/jboss/web/cluster/advertise/AdvertiseListener.java 2009-04-08 03:28:20 UTC (rev 993)
@@ -175,9 +175,9 @@
/** Remove the AdvertisedServer from the collection.
* @param server Server to remove.
*/
- public void removeServer(AdvertisedServer server)
+ public void removeServer(String name)
{
- servers.remove(server);
+ servers.remove(name);
}
private void init()
15 years, 1 month
JBossWeb SVN: r992 - in trunk/java/org/apache/catalina: core and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-07 19:09:34 -0400 (Tue, 07 Apr 2009)
New Revision: 992
Modified:
trunk/java/org/apache/catalina/connector/LocalStrings.properties
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
Log:
- Do some message string FIXMEs.
- Add a toString which displays the stack (will likely be moved).
Modified: trunk/java/org/apache/catalina/connector/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/connector/LocalStrings.properties 2009-04-07 21:39:25 UTC (rev 991)
+++ trunk/java/org/apache/catalina/connector/LocalStrings.properties 2009-04-07 23:09:34 UTC (rev 992)
@@ -49,6 +49,10 @@
coyoteRequest.attributeEvent=Exception thrown by attributes event listener
coyoteRequest.parseParameters=Exception thrown whilst processing POSTed parameters
coyoteRequest.postTooLarge=Parameters were not parsed because the size of the posted data was too big. Use the maxPostSize attribute of the connector to resolve this if the application should accept large POSTs.
+coyoteRequest.noAuthenticator=No authenticator available for programmatic login
+coyoteRequest.authFailed=Failed to authenticate a principal
+coyoteRequest.noAsync=The servlet or filters that are being used by this request do not support async operation
+coyoteRequest.servletStack=Current Servlet stack for thread {0}
#
# MapperListener
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-07 21:39:25 UTC (rev 991)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-07 23:09:34 UTC (rev 992)
@@ -90,7 +90,9 @@
import org.apache.catalina.Session;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.ApplicationFilterChain;
+import org.apache.catalina.core.ApplicationFilterConfig;
import org.apache.catalina.core.ApplicationFilterFactory;
+import org.apache.catalina.deploy.FilterDef;
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.ParameterMap;
@@ -251,7 +253,7 @@
/**
* Async timeout.
*/
- protected long asyncTimeout = 300000L;
+ protected long asyncTimeout = 600000L;
/**
@@ -2878,6 +2880,11 @@
if (timeout <= 0) {
timeout = Integer.MAX_VALUE;
}
+ if (!isAsyncSupported()) {
+ throw new IllegalStateException(sm.getString("coyoteRequest.noAsync"));
+ }
+ // FIXME: if (asyncContext != null && !processing) { throw ISE }
+ // FIXME: if (response.isClosed()) { throw ISE }
setTimeout(timeout);
asyncContext = new AsyncContextImpl(servletRequest, servletResponse);
eventMode = true;
@@ -2893,8 +2900,7 @@
return context.getAuthenticator().login(this, response);
}
} else {
- // FIXME: error message for no available authenticator
- throw new ServletException();
+ throw new ServletException(sm.getString("coyoteRequest.noAuthenticator"));
}
}
@@ -2902,9 +2908,9 @@
Realm realm = context.getRealm();
userPrincipal = realm.authenticate(username, password);
if (userPrincipal == null) {
- throw new ServletException();
+ throw new ServletException(sm.getString("coyoteRequest.authFailed"));
}
- authType = context.getLoginConfig().getAuthMethod();
+ authType = "LOGIN";
}
public void logout() throws ServletException {
@@ -2936,6 +2942,47 @@
}
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(sm.getString("coyoteRequest.servletStack", Thread.currentThread().getName()));
+ if (eventMode) {
+ buf.append(" [event]");
+ }
+ if (asyncContext != null) {
+ buf.append(" [async]");
+ }
+ buf.append("\r\n");
+ int filterChainCount = currentFilterChain;
+ for (int i = 0; i < filterChainCount; i++) {
+ ApplicationFilterChain filterChain = filterChains.get(i);
+ ApplicationFilterConfig[] filterConfigs = filterChain.getFilters();
+ int n = filterChain.getFilterCount();
+ int pos = filterChain.getPointer();
+ for (int j = 0; j < n; j++) {
+ FilterDef filterDef = filterConfigs[j].getFilterDef();
+ if (pos == j) {
+ buf.append("-> ");
+ } else {
+ buf.append(" ");
+ }
+ buf.append("[F] ").append(filterDef.getFilterName()).append(" [")
+ .append(filterDef.getFilterClass()).append("] ").append(filterDef.getAsyncSupported() ? "[A]" : "")
+ .append("\r\n");
+ }
+ if (pos == n) {
+ buf.append("-> ");
+ } else {
+ buf.append(" ");
+ }
+ Wrapper wrapper = filterChain.getWrapper();
+ buf.append("[S] ").append(wrapper.getName()).append(" [")
+ .append(wrapper.getServletClass()).append("] ").append(wrapper.getAsyncSupported() ? "[A]" : "")
+ .append("\r\n");
+ }
+ return buf.toString();
+ }
+
+
// ------------------------------------------ AsyncContextImpl Inner Class
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-04-07 21:39:25 UTC (rev 991)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-04-07 23:09:34 UTC (rev 992)
@@ -51,7 +51,7 @@
* @version $Revision$ $Date$
*/
-final class ApplicationFilterConfig implements FilterConfig, Serializable {
+public final class ApplicationFilterConfig implements FilterConfig, Serializable {
protected static StringManager sm =
@@ -242,7 +242,7 @@
/**
* Return the filter definition we are configured for.
*/
- FilterDef getFilterDef() {
+ public FilterDef getFilterDef() {
return (this.filterDef);
15 years, 1 month
JBossWeb SVN: r991 - in trunk/java/org/apache/catalina: connector and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-07 17:39:25 -0400 (Tue, 07 Apr 2009)
New Revision: 991
Modified:
trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/connector/RequestFacade.java
Log:
- Timeout and login.
Modified: trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java
===================================================================
--- trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java 2009-04-07 17:21:32 UTC (rev 990)
+++ trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java 2009-04-07 21:39:25 UTC (rev 991)
@@ -397,8 +397,8 @@
*/
public boolean login(Request request, HttpServletResponse response)
throws IOException, ServletException {
- // FIXME
- return false;
+ // FIXME: use the wrapper
+ return login(request, request.getResponse());
}
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-07 17:21:32 UTC (rev 990)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-07 21:39:25 UTC (rev 991)
@@ -123,6 +123,11 @@
Boolean.valueOf(System.getProperty("org.apache.catalina.connector.Request.SESSION_ID_CHECK", "false")).booleanValue();
+ protected static final boolean WRAPPED_RESPONSE_IN_LOGIN =
+ Globals.STRICT_SERVLET_COMPLIANCE
+ || Boolean.valueOf(System.getProperty("org.apache.catalina.connector.Request.WRAPPED_RESPONSE_IN_LOGIN", "false")).booleanValue();
+
+
// ----------------------------------------------------------- Constructors
@@ -2855,19 +2860,25 @@
return true;
}
- public void setAsyncTimeout(long timeout) {
- this.asyncTimeout = timeout;
+ public long getAsyncTimeout() {
+ return this.asyncTimeout;
}
+ public void setAsyncTimeout(long asyncTimeout) {
+ this.asyncTimeout = asyncTimeout;
+ }
+
public AsyncContext startAsync() throws IllegalStateException {
return startAsync(getRequest(), response.getResponse());
}
public AsyncContext startAsync(ServletRequest servletRequest,
ServletResponse servletResponse) throws IllegalStateException {
- // FIXME: check isAsyncSupported
- // FIXME: get async timeout according to what was configured in the filter chains
- setTimeout((asyncTimeout > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) asyncTimeout);
+ int timeout = (asyncTimeout > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) asyncTimeout;
+ if (timeout <= 0) {
+ timeout = Integer.MAX_VALUE;
+ }
+ setTimeout(timeout);
asyncContext = new AsyncContextImpl(servletRequest, servletResponse);
eventMode = true;
return asyncContext;
@@ -2875,9 +2886,12 @@
public boolean login(HttpServletResponse response) throws IOException,
ServletException {
- // FIXME: Ignoring the response param, which will hopefully go away
if (context.getAuthenticator() != null) {
- return context.getAuthenticator().login(this, this.response);
+ if (!WRAPPED_RESPONSE_IN_LOGIN || response instanceof ResponseFacade) {
+ return context.getAuthenticator().login(this, this.response);
+ } else {
+ return context.getAuthenticator().login(this, response);
+ }
} else {
// FIXME: error message for no available authenticator
throw new ServletException();
@@ -2890,8 +2904,7 @@
if (userPrincipal == null) {
throw new ServletException();
}
- // FIXME: authType value
- authType = "LOGIN";
+ authType = context.getLoginConfig().getAuthMethod();
}
public void logout() throws ServletException {
@@ -2922,11 +2935,7 @@
throw new IllegalStateException();
}
- public ServletResponse getServletResponse() {
- return response;
- }
-
// ------------------------------------------ AsyncContextImpl Inner Class
Modified: trunk/java/org/apache/catalina/connector/RequestFacade.java
===================================================================
--- trunk/java/org/apache/catalina/connector/RequestFacade.java 2009-04-07 17:21:32 UTC (rev 990)
+++ trunk/java/org/apache/catalina/connector/RequestFacade.java 2009-04-07 21:39:25 UTC (rev 991)
@@ -1001,16 +1001,26 @@
}
- public void setAsyncTimeout(long timeout) {
+ public void setAsyncTimeout(long timeout) {
if (request == null) {
throw new IllegalStateException(
- sm.getString("requestFacade.nullRequest"));
+ sm.getString("requestFacade.nullRequest"));
}
request.setAsyncTimeout(timeout);
}
+ public long getAsyncTimeout() {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.getAsyncTimeout();
+ }
+
+
public AsyncContext startAsync() throws IllegalStateException {
if (request == null) {
throw new IllegalStateException(
@@ -1080,16 +1090,6 @@
}
- public ServletResponse getServletResponse() {
- if (request == null) {
- throw new IllegalStateException(
- sm.getString("requestFacade.nullRequest"));
- }
-
- return request.getResponse().getResponse();
- }
-
-
public boolean login(HttpServletResponse response) throws IOException,
ServletException {
if (request == null) {
15 years, 1 month
JBossWeb SVN: r990 - in trunk/java/org/apache/catalina: connector and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-07 13:21:32 -0400 (Tue, 07 Apr 2009)
New Revision: 990
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/Wrapper.java
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
trunk/java/org/apache/catalina/core/ApplicationFilterChain.java
trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
Log:
- Add call to the login method. Error reporting could probably use some work (in some cases, a SE could be thrown).
- Add tracking of chains.
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/Context.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -80,6 +80,21 @@
/**
+ * Return the authenticator that is configured for this context, or
+ * null if no authenticator has been configured.
+ */
+ public Authenticator getAuthenticator();
+
+
+ /**
+ * Set the authenticator for this context.
+ *
+ * @param authenticator the new Authenticator for this context
+ */
+ public void setAuthenticator(Authenticator authenticator);
+
+
+ /**
* Store the set of initialized application event listener objects,
* in the order they were specified in the web application deployment
* descriptor, for this application.
Modified: trunk/java/org/apache/catalina/Wrapper.java
===================================================================
--- trunk/java/org/apache/catalina/Wrapper.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/Wrapper.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -24,7 +24,9 @@
import javax.servlet.ServletRegistration;
import javax.servlet.UnavailableException;
+import org.apache.catalina.util.InstanceSupport;
+
/**
* A <b>Wrapper</b> is a Container that represents an individual servlet
* definition from the deployment descriptor of the web application. It
@@ -102,6 +104,12 @@
/**
+ * Return the InstanceSupport object for this Wrapper instance.
+ */
+ public InstanceSupport getInstanceSupport();
+
+
+ /**
* Return the context-relative URI of the JSP file for this servlet.
*/
public String getJspFile();
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -2851,9 +2851,8 @@
}
public boolean isAsyncSupported() {
- // FIXME: Normally, this should be about checking that the Servlet has
- // async supported, and that all filters in the chain do too ?
- return false;
+ // FIXME: Check all the filter chain
+ return true;
}
public void setAsyncTimeout(long timeout) {
@@ -2876,22 +2875,23 @@
public boolean login(HttpServletResponse response) throws IOException,
ServletException {
- // FIXME: wrapped response is super evil :(
- if (response instanceof ResponseFacade) {
-
+ // FIXME: Ignoring the response param, which will hopefully go away
+ if (context.getAuthenticator() != null) {
+ return context.getAuthenticator().login(this, this.response);
+ } else {
+ // FIXME: error message for no available authenticator
+ throw new ServletException();
}
- return false;
}
public void login(String username, String password) throws ServletException {
Realm realm = context.getRealm();
userPrincipal = realm.authenticate(username, password);
- // FIXME: not sure how the login should be completed: set in the session, SSO, etc etc ?
- // (apparently, no according to the javadoc)
if (userPrincipal == null) {
throw new ServletException();
}
- authType = "?";
+ // FIXME: authType value
+ authType = "LOGIN";
}
public void logout() throws ServletException {
Modified: trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -622,21 +622,21 @@
// Get the FilterChain Here
ApplicationFilterFactory factory = ApplicationFilterFactory.getInstance();
- ApplicationFilterChain filterChain = factory.createFilterChain(request,
- wrapper,servlet);
+ ApplicationFilterChain filterChain = factory.createFilterChain(request, wrapper);
// Call the service() method for the allocated servlet instance
try {
String jspFile = wrapper.getJspFile();
- if (jspFile != null)
+ if (jspFile != null) {
request.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
- else
+ } else {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ }
support.fireInstanceEvent(InstanceEvent.BEFORE_DISPATCH_EVENT,
servlet, request, response);
// for includes/forwards
if ((servlet != null) && (filterChain != null)) {
- filterChain.doFilter(request, response);
- }
+ filterChain.doFilter(request, response);
+ }
// Servlet Service Method is called by the FilterChain
request.removeAttribute(Globals.JSP_FILE_ATTR);
support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT,
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterChain.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterChain.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterChain.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -62,6 +62,8 @@
import org.apache.catalina.Globals;
import org.apache.catalina.InstanceEvent;
+import org.apache.catalina.Wrapper;
+import org.apache.catalina.connector.RequestFacade;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.util.InstanceSupport;
import org.apache.catalina.util.StringManager;
@@ -119,11 +121,13 @@
// ----------------------------------------------------- Instance Variables
- // FIXME: Add a requestFacade field to be able to call release when done
- // FIXME: Add accessors for the internal structures
- // FIXME: Keep the wrapper, to be able to access the servlet registration
- // FIXME: Add an exec pointer field to know which element of the chain we are running
+
+ /**
+ * Associated request facade.
+ */
+ private RequestFacade requestFacade = null;
+
/**
* Filters.
*/
@@ -132,6 +136,12 @@
/**
+ * The int which is used to track the component currently executed.
+ */
+ private int pointer = 0;
+
+
+ /**
* The int which is used to maintain the current position
* in the filter chain.
*/
@@ -141,16 +151,16 @@
/**
* The int which gives the current number of filters in the chain.
*/
- private int n = 0;
+ private int filterCount = 0;
/**
- * The servlet instance to be executed by this chain.
+ * The wrapper to be executed by this chain.
*/
- private Servlet servlet = null;
+ private Wrapper wrapper = null;
- /**
+ /**
* The string manager for our package.
*/
private static final StringManager sm =
@@ -158,13 +168,6 @@
/**
- * 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.
*/
@@ -244,8 +247,10 @@
ServletResponse response)
throws IOException, ServletException {
+ InstanceSupport support = wrapper.getInstanceSupport();
+
// Call the next filter if there is one
- if (pos < n) {
+ if (pos < filterCount) {
ApplicationFilterConfig filterConfig = filters[pos++];
Filter filter = null;
try {
@@ -296,6 +301,7 @@
}
// We fell off the end of the chain -- call the servlet instance
+ Servlet servlet = wrapper.getServlet();
try {
if (Globals.STRICT_SERVLET_COMPLIANCE) {
lastServicedRequest.set(request);
@@ -424,8 +430,9 @@
throws IOException, ServletException {
// Call the next filter if there is one
- if (pos < n) {
+ if (pos < filterCount) {
ApplicationFilterConfig filterConfig = filters[pos++];
+ pointer++;
HttpEventFilter filter = null;
try {
filter = (HttpEventFilter) filterConfig.getFilter();
@@ -451,7 +458,9 @@
/*support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
filter, event);*/
+ pointer--;
} catch (IOException e) {
+ pointer--;
/*
if (filter != null)
support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
@@ -459,6 +468,7 @@
*/
throw e;
} catch (ServletException e) {
+ pointer--;
/*
if (filter != null)
support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
@@ -466,6 +476,7 @@
*/
throw e;
} catch (RuntimeException e) {
+ pointer--;
/*
if (filter != null)
support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
@@ -473,6 +484,7 @@
*/
throw e;
} catch (Throwable e) {
+ pointer--;
/*if (filter != null)
support.fireInstanceEvent(InstanceEvent.AFTER_FILTER_EVENT,
filter, event, e);*/
@@ -483,6 +495,8 @@
}
// We fell off the end of the chain -- call the servlet instance
+ Servlet servlet = wrapper.getServlet();
+ pointer++;
try {
/*
support.fireInstanceEvent(InstanceEvent.BEFORE_SERVICE_EVENT,
@@ -505,25 +519,30 @@
/*
support.fireInstanceEvent(InstanceEvent.AFTER_SERVICE_EVENT,
servlet, request, response);*/
+ pointer--;
} catch (IOException e) {
+ pointer--;
/*
support.fireInstanceEvent(InstanceEvent.AFTER_SERVICE_EVENT,
servlet, request, response, e);
*/
throw e;
} catch (ServletException e) {
+ pointer--;
/*
support.fireInstanceEvent(InstanceEvent.AFTER_SERVICE_EVENT,
servlet, request, response, e);
*/
throw e;
} catch (RuntimeException e) {
+ pointer--;
/*
support.fireInstanceEvent(InstanceEvent.AFTER_SERVICE_EVENT,
servlet, request, response, e);
*/
throw e;
} catch (Throwable e) {
+ pointer--;
/*
support.fireInstanceEvent(InstanceEvent.AFTER_SERVICE_EVENT,
servlet, request, response, e);
@@ -546,13 +565,13 @@
*/
void addFilter(ApplicationFilterConfig filterConfig) {
- if (n == filters.length) {
+ if (filterCount == filters.length) {
ApplicationFilterConfig[] newFilters =
- new ApplicationFilterConfig[n + INCREMENT];
- System.arraycopy(filters, 0, newFilters, 0, n);
+ new ApplicationFilterConfig[filterCount + INCREMENT];
+ System.arraycopy(filters, 0, newFilters, 0, filterCount);
filters = newFilters;
}
- filters[n++] = filterConfig;
+ filters[filterCount++] = filterConfig;
}
@@ -562,13 +581,14 @@
*/
void release() {
- for (int i = 0; i < n; i++) {
+ for (int i = 0; i < filterCount; i++) {
filters[i] = null;
}
- n = 0;
+ filterCount = 0;
pos = 0;
- servlet = null;
- support = null;
+ pointer = 0;
+ wrapper = null;
+ requestFacade.releaseFilterChain();
}
@@ -578,40 +598,50 @@
*/
void reuse() {
pos = 0;
+ pointer = 0;
}
/**
- * Set the servlet that will be executed at the end of this chain.
+ * Set the wrapper that will be executed at the end of this chain.
*
- * @param servlet The Wrapper for the servlet to be executed
+ * @param servlet The Wrapper to be executed
*/
- void setServlet(Servlet servlet) {
+ void setWrapper(Wrapper wrapper) {
- this.servlet = servlet;
+ this.wrapper = wrapper;
}
/**
- * Set the InstanceSupport object used for event notifications
- * for this filter chain.
+ * Set the RequestFacade object used for removing the association of the
+ * chain from the request facade.
*
- * @param support The InstanceSupport object for our Wrapper
+ * @param requestFacade The RequestFacade object
*/
- void setSupport(InstanceSupport support) {
+ void setRequestFacade(RequestFacade requestFacade) {
- this.support = support;
+ this.requestFacade = requestFacade;
}
- // -------------------------------------------- AsyncProterties Inner Class
-
-
- protected class AsyncProperties {
- public boolean asyncSupported = true;
- public long timeout = -1;
+ public ApplicationFilterConfig[] getFilters() {
+ return filters;
}
+ public int getFilterCount() {
+ return filterCount;
+ }
+
+ public int getPointer() {
+ return pointer;
+ }
+
+ public Wrapper getWrapper() {
+ return wrapper;
+ }
+
+
}
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterFactory.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -123,10 +123,9 @@
* a filter chain at all, return <code>null</code>.
*
* @param request The servlet request we are processing
- * @param servlet The servlet instance to be wrapped
+ * @param wrapper The servlet instance to be wrapped
*/
- public ApplicationFilterChain createFilterChain
- (ServletRequest request, Wrapper wrapper, Servlet servlet) {
+ public ApplicationFilterChain createFilterChain(ServletRequest request, Wrapper wrapper) {
// get the dispatcher type
int dispatcher = -1;
@@ -146,7 +145,7 @@
if (request instanceof HttpServletRequest)
hreq = (HttpServletRequest)request;
// If there is no servlet to execute, return null
- if (servlet == null)
+ if (wrapper.getServlet() == null)
return (null);
boolean event = false;
@@ -187,15 +186,10 @@
requestFacade.setFilterChain(filterChain);
}
}
- // FIXME: Set the request field in the chain so that the chain removes itself when it recycles
+ filterChain.setRequestFacade(requestFacade);
}
-
-
- filterChain.setServlet(servlet);
+ filterChain.setWrapper(wrapper);
- filterChain.setSupport
- (((StandardWrapper)wrapper).getInstanceSupport());
-
// Acquire the filter mappings for this Context
StandardContext context = (StandardContext) wrapper.getParent();
FilterMap filterMaps[] = context.findFilterMaps();
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -63,6 +63,7 @@
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionListener;
+import org.apache.catalina.Authenticator;
import org.apache.catalina.Container;
import org.apache.catalina.ContainerListener;
import org.apache.catalina.Context;
@@ -231,6 +232,12 @@
/**
+ * The application authenticator for this Context. This is simply a reference
+ * and the authenticator should still be set as a valve.
+ */
+ private Authenticator authenticator = null;
+
+ /**
* The application available flag for this Context.
*/
private boolean available = false;
@@ -1009,6 +1016,31 @@
/**
+ * Return the application authenticator for this Context.
+ */
+ public Authenticator getAuthenticator() {
+
+ return (this.authenticator);
+
+ }
+
+
+ /**
+ * Set the application authenticator for this Context.
+ *
+ * @param authenticator The new application authenticator
+ */
+ public void setAuthenticator(Authenticator authenticator) {
+
+ Authenticator oldAuthenticator = this.authenticator;
+ this.authenticator = authenticator;
+ support.firePropertyChange("authenticator", oldAuthenticator,
+ this.authenticator);
+
+ }
+
+
+ /**
* Return the application available flag for this Context.
*/
public boolean getAvailable() {
@@ -4806,6 +4838,8 @@
applicationLifecycleListenersObjects = new Object[0];
instanceManager = null;
+ authenticator = null;
+
if(log.isDebugEnabled())
log.debug("resetContext " + oname);
}
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -235,7 +235,7 @@
ApplicationFilterFactory factory =
ApplicationFilterFactory.getInstance();
ApplicationFilterChain filterChain =
- factory.createFilterChain(request, wrapper, servlet);
+ factory.createFilterChain(request, wrapper);
// Reset event flag value after creating the filter chain
request.setEventMode(false);
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-04-07 01:50:57 UTC (rev 989)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-04-07 17:21:32 UTC (rev 990)
@@ -579,6 +579,9 @@
}
}
+ if (authenticator instanceof Authenticator) {
+ context.setAuthenticator((Authenticator) authenticator);
+ }
if (authenticator != null && context instanceof ContainerBase) {
Pipeline pipeline = ((ContainerBase) context).getPipeline();
if (pipeline != null) {
15 years, 1 month