Author: remy.maucherat(a)jboss.com
Date: 2010-03-29 12:16:02 -0400 (Mon, 29 Mar 2010)
New Revision: 1424
Modified:
trunk/PATCHES.txt
trunk/java/org/apache/catalina/InstanceEvent.java
trunk/java/org/apache/catalina/core/LocalStrings.properties
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
Log:
- Add missing before/after request events.
Modified: trunk/PATCHES.txt
===================================================================
--- trunk/PATCHES.txt 2010-03-25 23:00:05 UTC (rev 1423)
+++ trunk/PATCHES.txt 2010-03-29 16:16:02 UTC (rev 1424)
@@ -79,13 +79,10 @@
Changes to APR init
784083
-Useless alias feature, rather redundant with overlays, and has no place in the DirContext
implementation
+Useless alias feature, redundant with overlays
890139
EL coercion patch
-918851 919914 920055 920110
-Parser changes to "fix" EL processing when EL is disabled, likely to cause
regressions
-
920449
Generating broken pages using included error pages
Modified: trunk/java/org/apache/catalina/InstanceEvent.java
===================================================================
--- trunk/java/org/apache/catalina/InstanceEvent.java 2010-03-25 23:00:05 UTC (rev 1423)
+++ trunk/java/org/apache/catalina/InstanceEvent.java 2010-03-29 16:16:02 UTC (rev 1424)
@@ -90,8 +90,8 @@
/**
- * The event indicating that the <code>service()</code> method of a
- * servlet accessed via a request dispatcher is about to be called.
+ * The event indicating that the <code>doFilter()</code> method of a
+ * filter chain accessed via a request dispatcher is about to be called.
* The <code>servlet</code> property contains a reference to the
* dispatched-to servlet instance, and the <code>request</code> and
* <code>response</code> properties contain the current request and
@@ -102,8 +102,8 @@
/**
- * The event indicating that the <code>service()</code> method of a
- * servlet accessed via a request dispatcher has returned. The
+ * The event indicating that the <code>doFilter()</code> method of a
+ * filter chain accessed via a request dispatcher has returned. The
* <code>servlet</code> property contains a reference to the
* dispatched-to servlet instance, and the <code>request</code> and
* <code>response</code> properties contain the current request and
@@ -115,6 +115,30 @@
/**
* The event indicating that the <code>doFilter()</code> method of a
+ * filter chain is about to be called.
+ * The <code>servlet</code> property contains a reference to the
+ * associated servlet instance, and the <code>request</code> and
+ * <code>response</code> properties contain the current request and
+ * response being processed. The <code>wrapper</code> property will
+ * contain a reference to the dispatched-to Wrapper.
+ */
+ public static final String BEFORE_REQUEST_EVENT = "beforeRequest";
+
+
+ /**
+ * The event indicating that the <code>doFilter()</code> method of a
+ * filter chain has returned. The
+ * <code>servlet</code> property contains a reference to the
+ * associated servlet instance, and the <code>request</code> and
+ * <code>response</code> properties contain the current request and
+ * response being processed. The <code>wrapper</code> property will
+ * contain a reference to the dispatched-to Wrapper.
+ */
+ public static final String AFTER_REQUEST_EVENT = "afterRequest";
+
+
+ /**
+ * The event indicating that the <code>doFilter()</code> method of a
* Filter is about to be called. The <code>filter</code> property
* contains a reference to the relevant filter instance, and the
* <code>request</code> and <code>response</code> properties
contain
Modified: trunk/java/org/apache/catalina/core/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/core/LocalStrings.properties 2010-03-25 23:00:05 UTC
(rev 1423)
+++ trunk/java/org/apache/catalina/core/LocalStrings.properties 2010-03-29 16:16:02 UTC
(rev 1424)
@@ -210,6 +210,7 @@
standardWrapper.loadException=Servlet {0} threw load() exception
standardWrapper.missingClass=Wrapper cannot find servlet class {0} or a class it depends
on
standardWrapper.missingLoader=Wrapper cannot find Loader for servlet {0}
+standardWrapper.noInstanceSupport=Servlet {0} does not have any instance support
standardWrapper.notChild=Wrapper container may not have child containers
standardWrapper.notClass=No servlet class has been specified for servlet {0}
standardWrapper.notContext=Parent container of a Wrapper must be a Context
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2010-03-25 23:00:05 UTC
(rev 1423)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2010-03-29 16:16:02 UTC
(rev 1424)
@@ -61,12 +61,16 @@
import javax.servlet.UnavailableException;
import javax.servlet.http.HttpServletResponse;
+import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
+import org.apache.catalina.InstanceEvent;
+import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.ClientAbortException;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.connector.Request.AsyncListenerRegistration;
+import org.apache.catalina.util.InstanceSupport;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.valves.ValveBase;
import org.apache.tomcat.util.log.SystemLogHandler;
@@ -103,6 +107,7 @@
private volatile int eventCount;
private volatile int requestCount;
private volatile int errorCount;
+ private InstanceSupport support;
/**
@@ -115,6 +120,16 @@
// --------------------------------------------------------- Public Methods
+ public void setContainer(Container container) {
+ super.setContainer(container);
+ if (container instanceof Wrapper) {
+ support = ((Wrapper) container).getInstanceSupport();
+ }
+ if (support == null) {
+ throw new
IllegalStateException(sm.getString("standardWrapper.noInstanceSupport",
container.getName()));
+ }
+ }
+
/**
* Invoke the servlet we are managing, respecting the rules regarding
* servlet lifecycle and SingleThreadModel support.
@@ -248,6 +263,8 @@
request.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
else
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.BEFORE_REQUEST_EVENT,
+ servlet, request, response);
if ((servlet != null) && (filterChain != null)) {
// Swallow output if needed
if (context.getSwallowOutput()) {
@@ -282,16 +299,22 @@
request.removeAttribute(Globals.JSP_FILE_ATTR);
} catch (ClientAbortException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
throwable = e;
exception(request, response, e);
} catch (IOException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
container.getLogger().error(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
throwable = e;
exception(request, response, e);
} catch (UnavailableException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
container.getLogger().error(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
// throwable = e;
@@ -312,6 +335,8 @@
// do not want to do exception(request, response, e) processing
} catch (ServletException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
Throwable rootCause = StandardWrapper.getRootCause(e);
if (!(rootCause instanceof ClientAbortException)) {
container.getLogger().error(sm.getString("standardWrapper.serviceException",
@@ -321,6 +346,8 @@
exception(request, response, e);
} catch (Throwable e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
container.getLogger().error(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
throwable = e;
@@ -460,8 +487,9 @@
request.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
else
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.BEFORE_REQUEST_EVENT,
+ servlet, request, response);
if ((servlet != null) && (filterChain != null)) {
-
// Swallow output if needed
if (context.getSwallowOutput()) {
try {
@@ -476,27 +504,34 @@
} else {
filterChain.doFilterEvent(request.getEvent());
}
-
}
request.removeAttribute(Globals.JSP_FILE_ATTR);
} catch (ClientAbortException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
throwable = e;
exception(request, response, e);
} catch (IOException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
container.getLogger().error(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
throwable = e;
exception(request, response, e);
} catch (UnavailableException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
container.getLogger().error(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
// Do not save exception in 'throwable', because we
// do not want to do exception(request, response, e) processing
} catch (ServletException e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
Throwable rootCause = StandardWrapper.getRootCause(e);
if (!(rootCause instanceof ClientAbortException)) {
container.getLogger().error(sm.getString("standardWrapper.serviceException",
@@ -506,6 +541,8 @@
exception(request, response, e);
} catch (Throwable e) {
request.removeAttribute(Globals.JSP_FILE_ATTR);
+ support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
+ servlet, request, response);
container.getLogger().error(sm.getString("standardWrapper.serviceException",
wrapper.getName()), e);
throwable = e;