private Set<SessionTrackingMode> defaultSessionTrackingModes = null;
private Set<SessionTrackingMode> supportedSessionTrackingModes = null;
+ /**
+ * Flag that indicates if a new {@link ServletContextListener} may be added
+ * to the application. Once the first {@link ServletContextListener} is
+ * called, not more may be added.
+ */
+ private boolean newServletContextListenerAllowed = true;
+
// --------------------------------------------------------- Public Methods
}
if (t instanceof HttpSessionListener
- || t instanceof ServletContextListener) {
- // TODO SERVLET3 - if ServletContextListener then also need to check caller? spec isn't clear
+ || (t instanceof ServletContextListener &&
+ newServletContextListenerAllowed)) {
context.addApplicationLifecycleListener(t);
match = true;
}
}
+ protected void setNewServletContextListenerAllowed(boolean allowed) {
+ this.newServletContextListenerAllowed = allowed;
+ }
+
// -------------------------------------------------------- Private Methods
if (getLogger().isDebugEnabled())
getLogger().debug("Sending application start events");
+ // Ensure context is not null
+ getServletContext();
+ context.setNewServletContextListenerAllowed(false);
+
Object instances[] = getApplicationLifecycleListeners();
if (instances == null)
return (ok);