* deployment. If not specified, defaults to the empty string.
*/
public String getWebappVersion();
+
+ /**
+ * Configure whether or not requests listeners will be fired on forwards for
+ * this Context.
+ */
+ public void setFireRequestListenersOnForwards(boolean enable);
+
+ /**
+ * Determine whether or not requests listeners will be fired on forwards for
+ * this Context.
+ */
+ public boolean getFireRequestListenersOnForwards();
+
}
DispatcherType disInt = (DispatcherType) request.getAttribute(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR);
if (disInt != null) {
- if (disInt != DispatcherType.ERROR) {
- state.outerRequest.setAttribute
- (ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
- getCombinedPath());
- state.outerRequest.setAttribute
- (ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
- DispatcherType.FORWARD);
- invoke(state.outerRequest, response, state);
- } else {
- invoke(state.outerRequest, response, state);
+ boolean doInvoke = true;
+
+ if (context.getFireRequestListenersOnForwards() &&
+ !context.fireRequestInitEvent(request)) {
+ doInvoke = false;
}
- }
+ if (doInvoke) {
+ if (disInt != DispatcherType.ERROR) {
+ state.outerRequest.setAttribute
+ (ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
+ getCombinedPath());
+ state.outerRequest.setAttribute
+ (ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
+ DispatcherType.FORWARD);
+ invoke(state.outerRequest, response, state);
+ } else {
+ invoke(state.outerRequest, response, state);
+ }
+
+ if (context.getFireRequestListenersOnForwards()) {
+ context.fireRequestDestroyEvent(request);
+ }
+ }
+ }
}
private String webappVersion = "";
private boolean addWebinfClassesResources = false;
+
+ private boolean fireRequestListenersOnForwards = false;
// ----------------------------------------------------- Context Properties
+ @Override
+ public void setFireRequestListenersOnForwards(boolean enable) {
+ fireRequestListenersOnForwards = enable;
+ }
+
+
+ @Override
+ public boolean getFireRequestListenersOnForwards() {
+ return fireRequestListenersOnForwards;
+ }
+
+
public void setAddWebinfClassesResources(
boolean addWebinfClassesResources) {
this.addWebinfClassesResources = addWebinfClassesResources;
class. (markt)
</fix>
<fix>
+ <bug>50789</bug>: Provide an option to enable ServletRequestListeners
+ for forwards as required by some CDI frameworks. (markt)
+ </fix>
+ <fix>
<bug>50793</bug>: When processing Servlet 3.0 async requests, ensure
that the requestInitialized and requestDestroyed events are only fired
once per request at the correct times. (markt)
sufficient.</p>
</attribute>
+ <attribute name="fireRequestListenersOnForwards" required="false">
+ <p>Set to <code>true</code> to fire any configured
+ ServletRequestListeners when Tomcat forwards a request. This is
+ primarily of use to users of CDI frameworks that use
+ ServletRequestListeners to configure the necessary environment for a
+ request. If not specified, the default value of <code>false</code> is
+ used.</p>
+ </attribute>
+
<attribute name="logEffectiveWebXml" required="false">
<p>Set to <code>true</code> if you want the effective web.xml used for a
web application to be logged (at INFO level) when the application