JBossWeb SVN: r1214 - in trunk/java/org/apache/jasper: compiler and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-10-21 11:59:16 -0400 (Wed, 21 Oct 2009)
New Revision: 1214
Modified:
trunk/java/org/apache/jasper/JspCompilationContext.java
trunk/java/org/apache/jasper/compiler/Generator.java
trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
Log:
- Bring back the mysterious relative uri translation code, it is actually useful sometimes.
Modified: trunk/java/org/apache/jasper/JspCompilationContext.java
===================================================================
--- trunk/java/org/apache/jasper/JspCompilationContext.java 2009-10-20 13:38:32 UTC (rev 1213)
+++ trunk/java/org/apache/jasper/JspCompilationContext.java 2009-10-21 15:59:16 UTC (rev 1214)
@@ -569,14 +569,6 @@
}
return location;
}
- /*
- System.out.print("Look for: " + uri + " TLDs list: ");
- Iterator<String> keys = jspTagLibraries.keySet().iterator();
- while (keys.hasNext()) {
- System.out.print(keys.next() + ", ");
- }
- System.out.println();
- */
}
/**
Modified: trunk/java/org/apache/jasper/compiler/Generator.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Generator.java 2009-10-20 13:38:32 UTC (rev 1213)
+++ trunk/java/org/apache/jasper/compiler/Generator.java 2009-10-21 15:59:16 UTC (rev 1214)
@@ -644,7 +644,7 @@
out.println(");");
if (ctxt.getOptions().isXpoweredBy()) {
- out.printil("response.addHeader(\"X-Powered-By\", \"JSP/2.1\");");
+ out.printil("response.addHeader(\"X-Powered-By\", \"JSP/2.2\");");
}
out
Modified: trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-10-20 13:38:32 UTC (rev 1213)
+++ trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-10-21 15:59:16 UTC (rev 1214)
@@ -145,6 +145,15 @@
this.pi = pi;
this.err = err;
+ if (location == null) {
+ // The URI points to the TLD itself or to a JAR file in which the
+ // TLD is stored
+ location = generateTLDLocation(uri, ctxt);
+ if (location != null) {
+ uri = location[0];
+ }
+ }
+
URL jarFileUrl = null;
if (location == null) {
err.jspError("jsp.error.file.not.found", uriIn);
@@ -159,7 +168,7 @@
org.apache.catalina.deploy.jsp.TagLibraryInfo tagLibraryInfo =
((HashMap<String, org.apache.catalina.deploy.jsp.TagLibraryInfo>)
- ctxt.getServletContext().getAttribute(Globals.JSP_TAG_LIBRARIES)).get(uriIn);
+ ctxt.getServletContext().getAttribute(Globals.JSP_TAG_LIBRARIES)).get(uri);
ArrayList<TagInfo> tagInfos = new ArrayList<TagInfo>();
ArrayList<TagFileInfo> tagFileInfos = new ArrayList<TagFileInfo>();
@@ -207,6 +216,45 @@
this.functions = functionInfos.values().toArray(new FunctionInfo[0]);
}
+ /**
+ * @param uri The uri of the TLD @param ctxt The compilation context
+ *
+ * @return String array whose first element denotes the path to the TLD. If
+ * the path to the TLD points to a jar file, then the second element denotes
+ * the name of the TLD entry in the jar file, which is hardcoded to
+ * META-INF/taglib.tld.
+ */
+ private String[] generateTLDLocation(String uri, JspCompilationContext ctxt)
+ throws JasperException {
+
+ int uriType = uriType(uri);
+ if (uriType == ABS_URI) {
+ err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
+ uri);
+ } else if (uriType == NOROOT_REL_URI) {
+ uri = ctxt.resolveRelativeUri(uri);
+ }
+
+ String[] location = new String[2];
+ location[0] = uri;
+ if (location[0].endsWith("jar")) {
+ URL url = null;
+ try {
+ url = ctxt.getResource(location[0]);
+ } catch (Exception ex) {
+ err.jspError("jsp.error.tld.unable_to_get_jar", location[0], ex
+ .toString());
+ }
+ if (url == null) {
+ err.jspError("jsp.error.tld.missing_jar", location[0]);
+ }
+ location[0] = url.toString();
+ location[1] = "META-INF/taglib.tld";
+ }
+
+ return location;
+ }
+
public TagLibraryInfo[] getTagLibraryInfos() {
Collection coll = pi.getTaglibs();
return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]);
15 years, 2 months
JBossWeb SVN: r1213 - trunk/java/org/apache/tomcat/util/buf.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-10-20 09:38:32 -0400 (Tue, 20 Oct 2009)
New Revision: 1213
Modified:
trunk/java/org/apache/tomcat/util/buf/C2BConverter.java
Log:
- Port character replacement fix.
Modified: trunk/java/org/apache/tomcat/util/buf/C2BConverter.java
===================================================================
--- trunk/java/org/apache/tomcat/util/buf/C2BConverter.java 2009-10-20 13:12:43 UTC (rev 1212)
+++ trunk/java/org/apache/tomcat/util/buf/C2BConverter.java 2009-10-20 13:38:32 UTC (rev 1213)
@@ -47,10 +47,8 @@
public C2BConverter(String charset)
throws IOException {
try {
- byte[] newReplacement = { (byte)'?' };
encoder = Charset.forName(charset).newEncoder();
- encoder = encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
- encoder = encoder.replaceWith(newReplacement);
+ encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
} catch (UnsupportedCharsetException e) {
throw new UnsupportedEncodingException(charset);
}
15 years, 2 months
JBossWeb SVN: r1212 - in branches/2.1.x: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-10-20 09:12:43 -0400 (Tue, 20 Oct 2009)
New Revision: 1212
Modified:
branches/2.1.x/java/org/apache/tomcat/util/buf/C2BConverter.java
branches/2.1.x/webapps/docs/changelog.xml
Log:
- Fix a regression with the replacement fix. Forcing a replacement is a lot more complex, so rely on the default
behavior of the encoder.
Modified: branches/2.1.x/java/org/apache/tomcat/util/buf/C2BConverter.java
===================================================================
--- branches/2.1.x/java/org/apache/tomcat/util/buf/C2BConverter.java 2009-10-19 22:31:30 UTC (rev 1211)
+++ branches/2.1.x/java/org/apache/tomcat/util/buf/C2BConverter.java 2009-10-20 13:12:43 UTC (rev 1212)
@@ -47,10 +47,8 @@
public C2BConverter(String charset)
throws IOException {
try {
- byte[] newReplacement = { (byte)'?' };
encoder = Charset.forName(charset).newEncoder();
encoder = encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
- encoder = encoder.replaceWith(newReplacement);
} catch (UnsupportedCharsetException e) {
throw new UnsupportedEncodingException(charset);
}
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2009-10-19 22:31:30 UTC (rev 1211)
+++ branches/2.1.x/webapps/docs/changelog.xml 2009-10-20 13:12:43 UTC (rev 1212)
@@ -22,6 +22,9 @@
<fix>
<bug>46950</bug>: Allow renegotiation to work for client certificates. (markt)
</fix>
+ <fix>
+ Improve fix for <jboss-jira>JBAS-6442</jboss-jira>, which failed for some encodings. (jfclere, remm)
+ </fix>
</changelog>
</subsection>
</section>
15 years, 2 months
JBossWeb SVN: r1211 - trunk/java/org/apache/catalina/core.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-10-19 18:31:30 -0400 (Mon, 19 Oct 2009)
New Revision: 1211
Modified:
trunk/java/org/apache/catalina/core/StandardContext.java
Log:
- Regression: a listener can implement more than one listener interface.
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-10-19 16:08:33 UTC (rev 1210)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-10-19 22:31:30 UTC (rev 1211)
@@ -250,9 +250,9 @@
/**
- * The set of instantiated application lifecycle listener objects</code>.
+ * The set of instantiated listener objects</code>.
*/
- protected Object otherListenersInstances[] = null;
+ protected Object listenersInstances[] = null;
/**
@@ -3893,12 +3893,11 @@
for (int i = 0; i < results.length; i++) {
if (results[i] instanceof ServletContextListener) {
contextLifecycleListeners.add(results[i]);
- } else {
- otherListeners.add(results[i]);
}
+ otherListeners.add(results[i]);
}
- this.otherListenersInstances = otherListeners.toArray();
+ this.listenersInstances = otherListeners.toArray();
setApplicationLifecycleListeners(contextLifecycleListeners.toArray());
// Send application start events
@@ -3949,15 +3948,11 @@
log.debug("Configuring application event listeners");
// Instantiate the required listeners
- Object listeners[] = otherListenersInstances;
- otherListenersInstances = null;
+ Object listeners[] = listenersInstances;
EventListener listenerInstances[] = applicationListenerInstances;
EventListener results[] = new EventListener[listeners.length + listenerInstances.length];
boolean ok = true;
for (int i = 0; i < listeners.length; i++) {
- if (getLogger().isDebugEnabled())
- getLogger().debug(" Configuring event listener class '" +
- listeners[i] + "'");
try {
results[i] = (EventListener) listeners[i];
} catch (Throwable t) {
@@ -3974,6 +3969,7 @@
getLogger().error(sm.getString("standardContext.applicationSkipped"));
return (false);
}
+ this.listenersInstances = results;
// Sort listeners in two arrays
ArrayList<EventListener> eventListeners = new ArrayList<EventListener>();
@@ -4031,19 +4027,11 @@
ok = false;
}
}
- try {
- getInstanceManager().destroyInstance(listeners[i]);
- } catch (Throwable t) {
- getLogger().error
- (sm.getString("standardContext.listenerStop",
- listeners[i].getClass().getName()), t);
- ok = false;
- }
}
}
// Annotation processing
- listeners = getApplicationSessionLifecycleListeners();
+ listeners = this.listenersInstances;
if (listeners != null && (listeners.length > 0)) {
for (int i = listeners.length - 1; i >= 0; i--) {
if (listeners[i] == null)
@@ -4059,26 +4047,10 @@
}
}
- // Annotation processing
- listeners = getApplicationEventListeners();
- if (listeners != null && (listeners.length > 0)) {
- for (int i = listeners.length - 1; i >= 0; i--) {
- if (listeners[i] == null)
- continue;
- try {
- getInstanceManager().destroyInstance(listeners[i]);
- } catch (Throwable t) {
- getLogger().error
- (sm.getString("standardContext.listenerStop",
- listeners[i].getClass().getName()), t);
- ok = false;
- }
- }
- }
-
setApplicationEventListeners(null);
setApplicationLifecycleListeners(null);
setApplicationSessionLifecycleListeners(null);
+ this.listenersInstances = null;
return (ok);
@@ -4771,7 +4743,7 @@
applicationEventListenersInstances = null;
applicationLifecycleListenersInstances = null;
applicationSessionLifecycleListenersInstances = null;
- otherListenersInstances = null;
+ listenersInstances = null;
instanceManager = null;
authenticator = null;
15 years, 2 months
JBossWeb SVN: r1210 - tags.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-10-19 12:08:33 -0400 (Mon, 19 Oct 2009)
New Revision: 1210
Added:
tags/JBOSSWEB_3_0_0_ALPHA10/
Log:
- New JBW build with latest Servlet API.
Copied: tags/JBOSSWEB_3_0_0_ALPHA10 (from rev 1209, trunk)
15 years, 2 months
JBossWeb SVN: r1209 - 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-10-19 07:28:13 -0400 (Mon, 19 Oct 2009)
New Revision: 1209
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/core/ApplicationContext.java
trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
trunk/java/org/apache/catalina/core/LocalStrings.properties
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/core/StandardWrapper.java
trunk/java/org/apache/catalina/session/StandardSession.java
Log:
- Refactor Context.start. This may cause regressions.
- Now three listener structures: context, session and the rest. Custom session implementations may need to be updated
to use the right array (in AS, CLusteredSession does need an update).
- Add more error conditions.
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-10-19 00:54:10 UTC (rev 1208)
+++ trunk/java/org/apache/catalina/Context.java 2009-10-19 11:28:13 UTC (rev 1209)
@@ -160,6 +160,27 @@
/**
+ * Return the set of initialized application lifecycle listener objects,
+ * in the order they were specified in the web application deployment
+ * descriptor, for this application.
+ *
+ * @exception IllegalStateException if this method is called before
+ * this application has started, or after it has been stopped
+ */
+ public Object[] getApplicationSessionLifecycleListeners();
+
+
+ /**
+ * Store the set of initialized application lifecycle listener objects,
+ * in the order they were specified in the web application deployment
+ * descriptor, for this application.
+ *
+ * @param listeners The set of instantiated listener objects.
+ */
+ public void setApplicationSessionLifecycleListeners(Object listeners[]);
+
+
+ /**
* Return the application available flag for this Context.
*/
public boolean getAvailable();
Modified: trunk/java/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-10-19 00:54:10 UTC (rev 1208)
+++ trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-10-19 11:28:13 UTC (rev 1209)
@@ -900,7 +900,16 @@
if (context.findFilterDef(filterName) != null) {
return null;
}
- // FIXME: Filter instance unicity nonsense
+ // Filter instance unicity
+ for (Container container : context.getParent().findChildren()) {
+ if (container instanceof StandardContext) {
+ for (ApplicationFilterConfig filterConfig : ((StandardContext) container).findApplicationFilterConfigs()) {
+ if (filterConfig.getFilterInstance() == filter) {
+ return null;
+ }
+ }
+ }
+ }
FilterDef filterDef = new FilterDef();
filterDef.setFilterName(filterName);
filterDef.setFilterClass(filter.getClass().getName());
@@ -958,7 +967,14 @@
if (context.findChild(servletName) != null) {
return null;
}
- // FIXME: Servlet instance unicity nonsense
+ // Servlet instance unicity
+ for (Container container : context.getParent().findChildren()) {
+ for (Container wrapper : container.findChildren()) {
+ if (((Wrapper) wrapper).getServlet() == servlet) {
+ return null;
+ }
+ }
+ }
Wrapper wrapper = context.createWrapper();
wrapper.setDynamic(true);
wrapper.setName(servletName);
@@ -1082,6 +1098,10 @@
if (restricted) {
throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
}
+ if (!context.isStarting()) {
+ throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
+ getContextPath()));
+ }
mergeParameters();
if (parameters.get(name) != null) {
return false;
@@ -1097,8 +1117,7 @@
throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
}
if (!context.isStarting()) {
- throw new IllegalStateException(
- sm.getString("applicationContext.setSessionTracking.ise",
+ throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
// Check that only supported tracking modes have been requested
@@ -1109,7 +1128,11 @@
sessionTrackingMode.toString(), getContextPath()));
}
}
- // TODO: Possible SSL tracking mode
+ // If SSL is specified, it should be the only one used
+ if (sessionTrackingModes.contains(SessionTrackingMode.SSL) && sessionTrackingModes.size() > 1) {
+ throw new IllegalArgumentException(sm.getString(
+ "applicationContext.setSessionTracking.ssl", getContextPath()));
+ }
context.setSessionTrackingModes(sessionTrackingModes);
}
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-10-19 00:54:10 UTC (rev 1208)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-10-19 11:28:13 UTC (rev 1209)
@@ -479,6 +479,14 @@
/**
+ * Return the filter instance.
+ */
+ public Filter getFilterInstance() {
+ return (filterInstance != null) ? filterInstance : filter;
+ }
+
+
+ /**
* Return the filter definition we are configured for.
*/
public FilterDef getFilterDef() {
Modified: trunk/java/org/apache/catalina/core/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-10-19 00:54:10 UTC (rev 1208)
+++ trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-10-19 11:28:13 UTC (rev 1209)
@@ -22,8 +22,8 @@
applicationContext.requestDispatcher.iae=Path {0} does not start with a "/" character
applicationContext.resourcePaths.iae=Path {0} does not start with a "/" character
applicationContext.setAttribute.namenull=Name cannot be null
-applicationContext.setSessionTracking.ise=The session tracking modes for context {0} cannot be set whilst the context is running
applicationContext.setSessionTracking.iae=The session tracking mode {0} requested for context {1} is not supported by that context
+applicationContext.setSessionTracking.ssl=The session tracking mode SSL requested for context {1} cannot be combined with other tracking modes
applicationContext.badListenerClass=Bad listener class {0} for context {1}
applicationDispatcher.allocateException=Allocate exception for servlet {0}
applicationDispatcher.deallocateException=Deallocate exception for servlet {0}
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-10-19 00:54:10 UTC (rev 1208)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-10-19 11:28:13 UTC (rev 1209)
@@ -234,18 +234,28 @@
/**
* The set of instantiated application event listener objects</code>.
*/
- protected Object applicationEventListenersObjects[] =
- new Object[0];
+ protected Object applicationEventListenersInstances[] = null;
/**
* The set of instantiated application lifecycle listener objects</code>.
*/
- protected Object applicationLifecycleListenersObjects[] =
- new Object[0];
+ protected Object applicationLifecycleListenersInstances[] = null;
/**
+ * The set of instantiated application session lifecycle listener objects</code>.
+ */
+ protected Object applicationSessionLifecycleListenersInstances[] = null;
+
+
+ /**
+ * The set of instantiated application lifecycle listener objects</code>.
+ */
+ protected Object otherListenersInstances[] = null;
+
+
+ /**
* The set of application parameters defined for this application.
*/
protected ApplicationParameter applicationParameters[] =
@@ -330,9 +340,8 @@
/**
* Session tracking modes.
*/
- // FIXME: see about SSL tracking mode
protected Set<SessionTrackingMode> defaultSessionTrackingModes =
- EnumSet.of(SessionTrackingMode.URL, SessionTrackingMode.COOKIE /*, SessionTrackingMode.SSL*/);
+ EnumSet.of(SessionTrackingMode.URL, SessionTrackingMode.COOKIE /*TODO:, SessionTrackingMode.SSL*/);
/**
@@ -944,7 +953,7 @@
* this application has started, or after it has been stopped
*/
public Object[] getApplicationEventListeners() {
- return (applicationEventListenersObjects);
+ return (applicationEventListenersInstances);
}
@@ -956,7 +965,7 @@
* @param listeners The set of instantiated listener objects.
*/
public void setApplicationEventListeners(Object listeners[]) {
- applicationEventListenersObjects = listeners;
+ applicationEventListenersInstances = listeners;
}
@@ -968,8 +977,33 @@
* @exception IllegalStateException if this method is called before
* this application has started, or after it has been stopped
*/
+ public Object[] getApplicationSessionLifecycleListeners() {
+ return (applicationSessionLifecycleListenersInstances);
+ }
+
+
+ /**
+ * Store the set of initialized application lifecycle listener objects,
+ * in the order they were specified in the web application deployment
+ * descriptor, for this application.
+ *
+ * @param listeners The set of instantiated listener objects.
+ */
+ public void setApplicationSessionLifecycleListeners(Object listeners[]) {
+ applicationSessionLifecycleListenersInstances = listeners;
+ }
+
+
+ /**
+ * Return the set of initialized application lifecycle listener objects,
+ * in the order they were specified in the web application deployment
+ * descriptor, for this application.
+ *
+ * @exception IllegalStateException if this method is called before
+ * this application has started, or after it has been stopped
+ */
public Object[] getApplicationLifecycleListeners() {
- return (applicationLifecycleListenersObjects);
+ return (applicationLifecycleListenersInstances);
}
@@ -981,7 +1015,7 @@
* @param listeners The set of instantiated listener objects.
*/
public void setApplicationLifecycleListeners(Object listeners[]) {
- applicationLifecycleListenersObjects = listeners;
+ applicationLifecycleListenersInstances = listeners;
}
@@ -3818,8 +3852,10 @@
* Configure the set of instantiated application event listeners
* for this Context. Return <code>true</code> if all listeners wre
* initialized successfully, or <code>false</code> otherwise.
+ * Only context listeners are actually set in stone at this point,
+ * all others are stored in a temporary location.
*/
- public boolean listenerStart() {
+ public boolean contextListenerStart() {
if (log.isDebugEnabled())
log.debug("Configuring application event listeners");
@@ -3845,29 +3881,25 @@
for (int i = 0; i < listenerInstances.length; i++) {
results[i + listeners.length] = listenerInstances[i];
}
+ applicationListenerInstances = new EventListener[0];
if (!ok) {
getLogger().error(sm.getString("standardContext.applicationSkipped"));
return (false);
}
// Sort listeners in two arrays
- ArrayList<EventListener> eventListeners = new ArrayList<EventListener>();
- ArrayList<EventListener> lifecycleListeners = new ArrayList<EventListener>();
+ ArrayList<EventListener> otherListeners = new ArrayList<EventListener>();
+ ArrayList<EventListener> contextLifecycleListeners = new ArrayList<EventListener>();
for (int i = 0; i < results.length; i++) {
- if ((results[i] instanceof ServletContextAttributeListener)
- || (results[i] instanceof ServletRequestAttributeListener)
- || (results[i] instanceof ServletRequestListener)
- || (results[i] instanceof HttpSessionAttributeListener)) {
- eventListeners.add(results[i]);
+ if (results[i] instanceof ServletContextListener) {
+ contextLifecycleListeners.add(results[i]);
+ } else {
+ otherListeners.add(results[i]);
}
- if ((results[i] instanceof ServletContextListener)
- || (results[i] instanceof HttpSessionListener)) {
- lifecycleListeners.add(results[i]);
- }
}
- setApplicationEventListeners(eventListeners.toArray());
- setApplicationLifecycleListeners(lifecycleListeners.toArray());
+ this.otherListenersInstances = otherListeners.toArray();
+ setApplicationLifecycleListeners(contextLifecycleListeners.toArray());
// Send application start events
@@ -3907,6 +3939,66 @@
/**
+ * Configure the set of instantiated application event listeners
+ * for this Context. Return <code>true</code> if all listeners wre
+ * initialized successfully, or <code>false</code> otherwise.
+ */
+ public boolean listenerStart() {
+
+ if (log.isDebugEnabled())
+ log.debug("Configuring application event listeners");
+
+ // Instantiate the required listeners
+ Object listeners[] = otherListenersInstances;
+ otherListenersInstances = null;
+ EventListener listenerInstances[] = applicationListenerInstances;
+ EventListener results[] = new EventListener[listeners.length + listenerInstances.length];
+ boolean ok = true;
+ for (int i = 0; i < listeners.length; i++) {
+ if (getLogger().isDebugEnabled())
+ getLogger().debug(" Configuring event listener class '" +
+ listeners[i] + "'");
+ try {
+ results[i] = (EventListener) listeners[i];
+ } catch (Throwable t) {
+ getLogger().error
+ (sm.getString("standardContext.applicationListener",
+ listeners[i]), t);
+ ok = false;
+ }
+ }
+ for (int i = 0; i < listenerInstances.length; i++) {
+ results[i + listeners.length] = listenerInstances[i];
+ }
+ if (!ok) {
+ getLogger().error(sm.getString("standardContext.applicationSkipped"));
+ return (false);
+ }
+
+ // Sort listeners in two arrays
+ ArrayList<EventListener> eventListeners = new ArrayList<EventListener>();
+ ArrayList<EventListener> sessionLifecycleListeners = new ArrayList<EventListener>();
+ for (int i = 0; i < results.length; i++) {
+ if ((results[i] instanceof ServletContextAttributeListener)
+ || (results[i] instanceof ServletRequestAttributeListener)
+ || (results[i] instanceof ServletRequestListener)
+ || (results[i] instanceof HttpSessionAttributeListener)) {
+ eventListeners.add(results[i]);
+ }
+ if (results[i] instanceof HttpSessionListener) {
+ sessionLifecycleListeners.add(results[i]);
+ }
+ }
+
+ setApplicationEventListeners(eventListeners.toArray());
+ setApplicationSessionLifecycleListeners(sessionLifecycleListeners.toArray());
+
+ return (ok);
+
+ }
+
+
+ /**
* Send an application stop event to all interested listeners.
* Return <code>true</code> if all events were sent successfully,
* or <code>false</code> otherwise.
@@ -3951,6 +4043,23 @@
}
// Annotation processing
+ listeners = getApplicationSessionLifecycleListeners();
+ if (listeners != null && (listeners.length > 0)) {
+ for (int i = listeners.length - 1; i >= 0; i--) {
+ if (listeners[i] == null)
+ continue;
+ try {
+ getInstanceManager().destroyInstance(listeners[i]);
+ } catch (Throwable t) {
+ getLogger().error
+ (sm.getString("standardContext.listenerStop",
+ listeners[i].getClass().getName()), t);
+ ok = false;
+ }
+ }
+ }
+
+ // Annotation processing
listeners = getApplicationEventListeners();
if (listeners != null && (listeners.length > 0)) {
for (int i = listeners.length - 1; i >= 0; i--) {
@@ -3969,6 +4078,7 @@
setApplicationEventListeners(null);
setApplicationLifecycleListeners(null);
+ setApplicationSessionLifecycleListeners(null);
return (ok);
@@ -4362,25 +4472,14 @@
lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
}
- // FIXME: listener start order is wrong: context listeners should be started there,
- // but all others should be after complete config
// Configure and call application event listeners
if (ok) {
- if (!listenerStart()) {
+ if (!contextListenerStart()) {
log.error( "Error listenerStart");
ok = false;
}
}
- if (ok) {
- // Notify our interested LifecycleListeners
- lifecycle.fireLifecycleEvent(COMPLETE_CONFIG_EVENT, null);
- }
-
- if (!getConfigured()) {
- ok = false;
- }
-
// Start manager
if (ok && (manager != null) && (manager instanceof Lifecycle)) {
ok = false;
@@ -4388,11 +4487,6 @@
ok = true;
}
- // Start ContainerBackgroundProcessor thread
- if (ok) {
- super.threadStart();
- }
-
// Configure and call application filters
if (ok) {
if (!filterStart()) {
@@ -4406,6 +4500,27 @@
loadOnStartup(findChildren());
}
+ if (ok) {
+ if (!listenerStart()) {
+ log.error( "Error listenerStart");
+ ok = false;
+ }
+ }
+
+ if (ok) {
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(COMPLETE_CONFIG_EVENT, null);
+ }
+
+ if (!getConfigured()) {
+ ok = false;
+ }
+
+ // Start ContainerBackgroundProcessor thread
+ if (ok) {
+ super.threadStart();
+ }
+
} catch (Throwable t) {
// This can happen in rare cases with custom components
ok = false;
@@ -4653,8 +4768,10 @@
distributable = false;
applicationListeners = new String[0];
- applicationEventListenersObjects = new Object[0];
- applicationLifecycleListenersObjects = new Object[0];
+ applicationEventListenersInstances = null;
+ applicationLifecycleListenersInstances = null;
+ applicationSessionLifecycleListenersInstances = null;
+ otherListenersInstances = null;
instanceManager = null;
authenticator = null;
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-10-19 00:54:10 UTC (rev 1208)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-10-19 11:28:13 UTC (rev 1209)
@@ -949,7 +949,7 @@
* Return the associated servlet instance.
*/
public Servlet getServlet() {
- return instance;
+ return (servletInstance != null) ? servletInstance : instance;
}
Modified: trunk/java/org/apache/catalina/session/StandardSession.java
===================================================================
--- trunk/java/org/apache/catalina/session/StandardSession.java 2009-10-19 00:54:10 UTC (rev 1208)
+++ trunk/java/org/apache/catalina/session/StandardSession.java 2009-10-19 11:28:13 UTC (rev 1209)
@@ -354,7 +354,7 @@
// Notify interested application event listeners
Context context = (Context) manager.getContainer();
- Object listeners[] = context.getApplicationLifecycleListeners();
+ Object listeners[] = context.getApplicationSessionLifecycleListeners();
if (listeners != null) {
HttpSessionEvent event =
new HttpSessionEvent(getSession());
@@ -674,7 +674,7 @@
// Notify interested application event listeners
Context context = (Context) manager.getContainer();
- Object listeners[] = context.getApplicationLifecycleListeners();
+ Object listeners[] = context.getApplicationSessionLifecycleListeners();
if (notify && listeners != null && (listeners.length > 0)) {
HttpSessionEvent event =
new HttpSessionEvent(getSession());
15 years, 2 months
JBossWeb SVN: r1208 - in trunk/java: org/apache/catalina and 3 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-10-18 20:54:10 -0400 (Sun, 18 Oct 2009)
New Revision: 1208
Modified:
trunk/java/javax/servlet/AsyncContext.java
trunk/java/javax/servlet/FilterRegistration.java
trunk/java/javax/servlet/ServletRegistration.java
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/Wrapper.java
trunk/java/org/apache/catalina/connector/LocalStrings.properties
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/ApplicationContext.java
trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
trunk/java/org/apache/catalina/core/LocalStrings.properties
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/core/StandardWrapper.java
trunk/java/org/apache/catalina/core/StandardWrapperFacade.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
Log:
- Spec update.
- Implement some error conditions of ServletContext.
Modified: trunk/java/javax/servlet/AsyncContext.java
===================================================================
--- trunk/java/javax/servlet/AsyncContext.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/javax/servlet/AsyncContext.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -410,6 +410,29 @@
/**
+ * Instantiates the given {@link AsyncListener} class.
+ *
+ * <p>The returned AsyncListener instance may be further customized
+ * before it is registered with this AsyncContext via a call to one of
+ * the <code>addListener</code> methods.
+ *
+ * <p>The given AsyncListener class must define a zero argument
+ * constructor, which is used to instantiate it.
+ *
+ * <p>This method supports any annotations applicable to AsyncListener.
+ *
+ * @param clazz the AsyncListener class to instantiate
+ *
+ * @return the new AsyncListener instance
+ *
+ * @throws ServletException if the given <tt>clazz</tt> fails to be
+ * instantiated
+ */
+ public <T extends AsyncListener> T createListener(Class<T> clazz)
+ throws ServletException;
+
+
+ /**
* Sets the timeout (in milliseconds) for this AsyncContext.
*
* <p>The timeout applies to this AsyncContext once the
Modified: trunk/java/javax/servlet/FilterRegistration.java
===================================================================
--- trunk/java/javax/servlet/FilterRegistration.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/javax/servlet/FilterRegistration.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -57,6 +57,9 @@
* <i>declared</i> filter mappings of the ServletContext from which this
* FilterRegistration was obtained.
*
+ * <p>If this method is called multiple times, each successive call
+ * adds to the effects of the former.
+ *
* @param dispatcherTypes the dispatcher types of the filter mapping,
* or null if the default <tt>DispatcherType.REQUEST</tt> is to be used
* @param isMatchAfter true if the given filter mapping should be matched
@@ -99,6 +102,9 @@
* <i>declared</i> filter mappings of the ServletContext from which
* this FilterRegistration was obtained.
*
+ * <p>If this method is called multiple times, each successive call
+ * adds to the effects of the former.
+ *
* @param dispatcherTypes the dispatcher types of the filter mapping,
* or null if the default <tt>DispatcherType.REQUEST</tt> is to be used
* @param isMatchAfter true if the given filter mapping should be matched
Modified: trunk/java/javax/servlet/ServletRegistration.java
===================================================================
--- trunk/java/javax/servlet/ServletRegistration.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/javax/servlet/ServletRegistration.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -52,6 +52,9 @@
* <p>If any of the specified URL patterns are already mapped to a
* different Servlet, no updates will be performed.
*
+ * <p>If this method is called multiple times, each successive call
+ * adds to the effects of the former.
+ *
* @param urlPatterns the URL patterns of the servlet mapping
*
* @return the (possibly empty) Set of URL patterns that are already
@@ -122,20 +125,48 @@
/**
* Sets the {@link ServletSecurityElement} to be applied to the
- * mappings defined for this <code>ServletRegistration</code>. If this
- * method is called multiple times, each successive call overrides the
- * effects of the former.
+ * mappings currently assigned to this
+ * <code>ServletRegistration</code>.
*
+ * <p>Any mappings added to this ServletRegistration after a call
+ * to this method may be secured by a subsequent call to this method.
+ *
+ * <p>If a url-pattern of this ServletRegistration is an exact
+ * target of a <code>security-constraint</code> that was established
+ * via the portable deployment descriptor, then this method does not
+ * change the <code>security-constraint</code> for that pattern, and
+ * the pattern will be included in the return value.
+ *
+ * <p>If a url-pattern of this ServletRegistration is an exact target
+ * of a security constraint that was established via the
+ * {@link javax.servlet.annotation.ServletSecurity} annotation or a
+ * previous call to this method, then this method replaces the
+ * security constraint for that pattern.
+ *
+ * <p>If a url-pattern of this ServletRegistration is neither the
+ * exact target of a security constraint that was established via the
+ * {@link javax.servlet.annotation.ServletSecurity} annotation or
+ * a previous call to this method, nor the exact target of a
+ * </code>security-constraint</code> in the portable deployment
+ * descriptor, then this method establishes the security
+ * constraint for that pattern from the argument
+ * ServletSecurityElement.
+ *
* @param constraint the {@link ServletSecurityElement} to be applied
- * to the patterns mapped to the registration
- *
+ * to the patterns currently mapped to this ServletRegistration
+ *
+ * @return the (possibly empty) Set of URL patterns that were already
+ * the exact target of a <code>security-constraint</code> that was
+ * established via the portable deployment descriptor. This method
+ * has no effect on the patterns included in the returned set.
+ *
* @throws IllegalArgumentException if <tt>constraint</tt> is null
- *
+ *
* @throws IllegalStateException if the {@link ServletContext} from
- * which this ServletRegistration was obtained has already been
- * initialized
+ * which this ServletRegistration was obtained has already been
+ * initialized
*/
- public void setServletSecurity(ServletSecurityElement constraint);
+ public Set<String> setServletSecurity(ServletSecurityElement constraint);
/**
* Sets the {@link MultipartConfigElement} to be applied to the
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/Context.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -35,6 +35,7 @@
import org.apache.catalina.deploy.WebAbsoluteOrdering;
import org.apache.catalina.deploy.jsp.TagLibraryInfo;
import org.apache.catalina.util.CharsetMapper;
+import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.util.http.mapper.Mapper;
@@ -351,6 +352,20 @@
/**
+ * Used to create application instances.
+ */
+ public InstanceManager getInstanceManager();
+
+
+ /**
+ * Set the instance manager associated with this Context.
+ *
+ * @param instanceManager The instance manager
+ */
+ public void setInstanceManager(InstanceManager instanceManager);
+
+
+ /**
* Return the logical name for this web application.
*/
public String getLogicalName();
Modified: trunk/java/org/apache/catalina/Wrapper.java
===================================================================
--- trunk/java/org/apache/catalina/Wrapper.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/Wrapper.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -19,6 +19,8 @@
package org.apache.catalina;
+import java.util.Set;
+
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
@@ -432,8 +434,23 @@
/**
+ * Set an associated ServletSecurity on mappings which are currently associated
+ * with the Servlet. This will not set security on patters which are currently
+ * defined in a security constraint.
+ *
+ * @return the set of patterns for which the servlet security will not be defined
+ */
+ public Set<String> setServletSecurityOnCurrentMappings(ServletSecurityElement servletSecurity);
+
+
+ /**
* Get an associated ServletSecurity, if any.
*/
public ServletSecurityElement getServletSecurity();
+ /**
+ * Get an associated ServletSecurity patterns, if any.
+ */
+ public Set<String> getServletSecurityPatterns();
+
}
Modified: trunk/java/org/apache/catalina/connector/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/connector/LocalStrings.properties 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/connector/LocalStrings.properties 2009-10-19 00:54:10 UTC (rev 1208)
@@ -60,6 +60,7 @@
coyoteRequest.cannotStartAsync=Cannot start async
coyoteRequest.onStartAsyncError=Error invoking onStartAsync on listener of class {0}
coyoteRequest.dispatchNoServletContext=Could not determine or access context for server absolute path [{0}]
+coyoteRequest.createListener=Failed to instantiate class {0}
#
# MapperListener
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -56,6 +56,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
+import java.util.EventListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -3326,6 +3327,17 @@
setTimeout0(realTimeout);
}
+ public <T extends AsyncListener> T createListener(Class<T> clazz)
+ throws ServletException {
+ T listenerInstance = null;
+ try {
+ listenerInstance = (T) context.getInstanceManager().newInstance(clazz);
+ } catch (Exception e) {
+ throw new ServletException(sm.getString("coyoteRequest.createListener", clazz.getName()), e);
+ }
+ return listenerInstance;
+ }
+
}
Modified: trunk/java/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -72,13 +72,18 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
+import javax.servlet.ServletContextListener;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
+import javax.servlet.ServletRequestAttributeListener;
+import javax.servlet.ServletRequestListener;
import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
import javax.servlet.descriptor.JspConfigDescriptor;
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
import javax.servlet.descriptor.TaglibDescriptor;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionListener;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
@@ -870,6 +875,9 @@
throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
+ if (context.findFilterDef(filterName) != null) {
+ return null;
+ }
FilterDef filterDef = new FilterDef();
filterDef.setFilterName(filterName);
filterDef.setFilterClass(className);
@@ -889,6 +897,10 @@
throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
+ if (context.findFilterDef(filterName) != null) {
+ return null;
+ }
+ // FIXME: Filter instance unicity nonsense
FilterDef filterDef = new FilterDef();
filterDef.setFilterName(filterName);
filterDef.setFilterClass(filter.getClass().getName());
@@ -903,9 +915,6 @@
public FilterRegistration.Dynamic addFilter(String filterName,
Class<? extends Filter> filterClass) {
- if (restricted) {
- throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
- }
return addFilter(filterName, filterClass.getName());
}
@@ -919,6 +928,9 @@
throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
+ if (context.findChild(servletName) != null) {
+ return null;
+ }
Wrapper wrapper = context.createWrapper();
wrapper.setDynamic(true);
wrapper.setName(servletName);
@@ -931,9 +943,6 @@
public ServletRegistration.Dynamic addServlet(String servletName,
Class<? extends Servlet> clazz) throws IllegalArgumentException,
IllegalStateException {
- if (restricted) {
- throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
- }
return addServlet(servletName, clazz.getName());
}
@@ -946,6 +955,10 @@
throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
+ if (context.findChild(servletName) != null) {
+ return null;
+ }
+ // FIXME: Servlet instance unicity nonsense
Wrapper wrapper = context.createWrapper();
wrapper.setDynamic(true);
wrapper.setName(servletName);
@@ -1047,8 +1060,7 @@
try {
return (T) context.getInstanceManager().newInstance(c);
} catch (Throwable e) {
- throw new ServletException
- (sm.getString("applicationContext.create"), e);
+ throw new ServletException(sm.getString("applicationContext.create"), e);
}
}
@@ -1061,8 +1073,7 @@
try {
return (T) context.getInstanceManager().newInstance(c);
} catch (Throwable e) {
- throw new ServletException
- (sm.getString("applicationContext.create"), e);
+ throw new ServletException(sm.getString("applicationContext.create"), e);
}
}
@@ -1081,13 +1092,6 @@
}
- /**
- * @throws IllegalStateException if the context has already been initialised
- * @throws IllegalArgumentException TODO SERVLET3 Something to do with SSL
- * but the spec language is not clear
- * If an unsupported tracking mode is
- * requested
- */
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) {
if (restricted) {
throw new UnsupportedOperationException(sm.getString("applicationContext.restricted"));
@@ -1118,7 +1122,20 @@
throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
- context.addApplicationListener(className);
+ EventListener listenerInstance = null;
+ try {
+ Class<?> clazz = context.getLoader().getClassLoader().loadClass(className);
+ listenerInstance = (EventListener) context.getInstanceManager().newInstance(clazz);
+ } catch (Throwable t) {
+ throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass",
+ className, getContextPath()), t);
+ }
+ checkListenerType(listenerInstance);
+ if (context.getApplicationLifecycleListeners() != null && listenerInstance instanceof ServletContextListener) {
+ throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass",
+ className, getContextPath()));
+ }
+ context.addApplicationListenerInstance(listenerInstance);
}
@@ -1130,6 +1147,11 @@
throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
+ checkListenerType(listener);
+ if (context.getApplicationLifecycleListeners() != null && listener instanceof ServletContextListener) {
+ throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass",
+ listener.getClass().getName(), getContextPath()));
+ }
context.addApplicationListenerInstance(listener);
}
@@ -1142,14 +1164,19 @@
throw new IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
+ EventListener listenerInstance = null;
try {
- EventListener listenerInstance =
- (EventListener) context.getInstanceManager().newInstance(listenerClass);
- context.addApplicationListenerInstance(listenerInstance);
+ listenerInstance = (EventListener) context.getInstanceManager().newInstance(listenerClass);
} catch (Exception e) {
- // FIXME: better error
- throw new IllegalStateException(e);
+ throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass",
+ listenerClass.getName(), getContextPath()), e);
}
+ checkListenerType(listenerInstance);
+ if (context.getApplicationLifecycleListeners() != null && listenerInstance instanceof ServletContextListener) {
+ throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass",
+ listenerClass.getName(), getContextPath()));
+ }
+ context.addApplicationListenerInstance(listenerInstance);
}
@@ -1165,10 +1192,10 @@
T listenerInstance = null;
try {
listenerInstance = (T) context.getInstanceManager().newInstance(clazz);
- } catch (Exception e) {
- // FIXME: better error
- throw new ServletException(e);
+ } catch (Throwable t) {
+ throw new ServletException(sm.getString("applicationContext.create"), t);
}
+ checkListenerType(listenerInstance);
return listenerInstance;
}
@@ -1236,6 +1263,19 @@
}
// -------------------------------------------------------- Package Methods
+
+ protected void checkListenerType(EventListener listener) {
+ if (!(listener instanceof ServletContextListener)
+ && !(listener instanceof ServletContextAttributeListener)
+ && !(listener instanceof ServletRequestListener)
+ && !(listener instanceof ServletRequestAttributeListener)
+ && !(listener instanceof HttpSessionListener)
+ && !(listener instanceof HttpSessionAttributeListener)) {
+ throw new IllegalArgumentException(sm.getString("applicationContext.badListenerClass",
+ listener.getClass().getName(), getContextPath()));
+ }
+ }
+
protected StandardContext getContext() {
return this.context;
}
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -155,12 +155,7 @@
*/
private FilterDef filterDef = null;
- /**
- * the InstanceManager used to create and destroy filter instances.
- */
- private transient InstanceManager instanceManager;
-
/**
* JMX registration name
*/
@@ -446,7 +441,7 @@
// Identify the class loader we will be using
if (filterInstance == null) {
String filterClass = filterDef.getFilterClass();
- this.filter = (Filter) getInstanceManager().newInstance(filterClass);
+ this.filter = (Filter) context.getInstanceManager().newInstance(filterClass);
} else {
this.filter = filterInstance;
filterInstance = null;
@@ -528,20 +523,6 @@
// -------------------------------------------------------- Private Methods
- private InstanceManager getInstanceManager() {
- if (instanceManager == null) {
- if (context instanceof StandardContext) {
- instanceManager = ((StandardContext)context).getInstanceManager();
- } else {
- instanceManager = new DefaultInstanceManager(null,
- new HashMap<String, Map<String, String>>(),
- context,
- getClass().getClassLoader());
- }
- }
- return instanceManager;
- }
-
private void registerJMX() {
String parentName = context.getName();
parentName = ("".equals(parentName)) ? "/" : parentName;
Modified: trunk/java/org/apache/catalina/core/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-10-19 00:54:10 UTC (rev 1208)
@@ -24,6 +24,7 @@
applicationContext.setAttribute.namenull=Name cannot be null
applicationContext.setSessionTracking.ise=The session tracking modes for context {0} cannot be set whilst the context is running
applicationContext.setSessionTracking.iae=The session tracking mode {0} requested for context {1} is not supported by that context
+applicationContext.badListenerClass=Bad listener class {0} for context {1}
applicationDispatcher.allocateException=Allocate exception for servlet {0}
applicationDispatcher.deallocateException=Deallocate exception for servlet {0}
applicationDispatcher.forward.ise=Cannot forward after response has been committed
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -4362,6 +4362,8 @@
lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
}
+ // FIXME: listener start order is wrong: context listeners should be started there,
+ // but all others should be after complete config
// Configure and call application event listeners
if (ok) {
if (!listenerStart()) {
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -24,6 +24,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Set;
import java.util.Stack;
import javax.management.ListenerNotFoundException;
@@ -54,6 +55,8 @@
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
import org.apache.catalina.deploy.Multipart;
+import org.apache.catalina.deploy.SecurityCollection;
+import org.apache.catalina.deploy.SecurityConstraint;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.InstanceSupport;
@@ -226,6 +229,12 @@
*/
protected ServletSecurityElement servletSecurity = null;
+
+ /**
+ * Associated servlet security patterns.
+ */
+ protected Set<String> servletSecurityPatterns = null;
+
/**
* The notification sequence number.
@@ -652,6 +661,47 @@
this.servletSecurity = servletSecurity;
support.firePropertyChange("servletSecurity", oldServletSecurity, this.servletSecurity);
}
+
+
+ /**
+ * Set an associated ServletSecurity on mappings which are currently associated
+ * with the Servlet. This will not set security on patters which are currently
+ * defined in a security constraint.
+ *
+ * @return the set of patterns for which the servlet security will not be defined
+ */
+ public Set<String> setServletSecurityOnCurrentMappings(ServletSecurityElement servletSecurity) {
+ ServletSecurityElement oldServletSecurity = this.servletSecurity;
+ this.servletSecurity = servletSecurity;
+ support.firePropertyChange("servletSecurity", oldServletSecurity, this.servletSecurity);
+ // Now find to which mappings this servlet security will apply, and return the list
+ // for which is will not apply
+ Set<String> ignoredPatterns = new HashSet<String>();
+ servletSecurityPatterns = new HashSet<String>();
+ for (String mapping : findMappings()) {
+ servletSecurityPatterns.add(mapping);
+ }
+ SecurityConstraint[] constraints = ((Context) getParent()).findConstraints();
+ for (SecurityConstraint constraint : constraints) {
+ for (SecurityCollection collection : constraint.findCollections()) {
+ for (String pattern : collection.findPatterns()) {
+ if (servletSecurityPatterns.contains(pattern)) {
+ servletSecurityPatterns.remove(pattern);
+ ignoredPatterns.add(pattern);
+ }
+ }
+ }
+ }
+ return ignoredPatterns;
+ }
+
+
+ /**
+ * Get an associated ServletSecurity patterns, if any.
+ */
+ public Set<String> getServletSecurityPatterns() {
+ return servletSecurityPatterns;
+ }
/**
@@ -1170,7 +1220,7 @@
}
if (servletInstance == null) {
- InstanceManager instanceManager = ((StandardContext)getParent()).getInstanceManager();
+ InstanceManager instanceManager = ((Context) getParent()).getInstanceManager();
try {
servlet = (Servlet) instanceManager.newInstance(actualClass);
} catch (ClassCastException e) {
@@ -1428,7 +1478,7 @@
// Annotation processing
if (!((Context) getParent()).getIgnoreAnnotations()) {
- ((StandardContext)getParent()).getInstanceManager().destroyInstance(instance);
+ ((Context) getParent()).getInstanceManager().destroyInstance(instance);
}
} catch (Throwable t) {
@@ -1471,7 +1521,7 @@
}
// Annotation processing
if (!((Context) getParent()).getIgnoreAnnotations()) {
- ((StandardContext)getParent()).getInstanceManager().destroyInstance(s);
+ ((Context) getParent()).getInstanceManager().destroyInstance(s);
}
}
} catch (Throwable t) {
Modified: trunk/java/org/apache/catalina/core/StandardWrapperFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperFacade.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/core/StandardWrapperFacade.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -283,7 +283,7 @@
wrapper.setRunAs(roleName);
}
- public void setServletSecurity(ServletSecurityElement servletSecurity) {
+ public Set<String> setServletSecurity(ServletSecurityElement servletSecurity) {
if (!((Context) wrapper.getParent()).isStarting()) {
throw new IllegalStateException(sm.getString
("servletRegistration.ise", ((Context) wrapper.getParent()).getPath()));
@@ -291,7 +291,7 @@
if (servletSecurity == null) {
throw new IllegalArgumentException(sm.getString("servletRegistration.iae"));
}
- wrapper.setServletSecurity(servletSecurity);
+ return wrapper.setServletSecurityOnCurrentMappings(servletSecurity);
}
public void setMultipartConfig(MultipartConfigElement multipartConfig) {
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-10-18 16:47:36 UTC (rev 1207)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-10-19 00:54:10 UTC (rev 1208)
@@ -2134,9 +2134,29 @@
}
SecurityCollection collection = new SecurityCollection();
collection.addMethod(httpMethodConstraint.getMethodName());
- String[] urlPatterns = wrapper.findMappings();
- for (String urlPattern : urlPatterns) {
- collection.addPattern(urlPattern);
+ if (wrapper.getServletSecurityPatterns() != null) {
+ for (String urlPattern : wrapper.getServletSecurityPatterns()) {
+ collection.addPattern(urlPattern);
+ }
+ } else {
+ String[] urlPatterns = wrapper.findMappings();
+ Set<String> servletSecurityPatterns = new HashSet<String>();
+ for (String urlPattern : urlPatterns) {
+ servletSecurityPatterns.add(urlPattern);
+ }
+ SecurityConstraint[] constraints = context.findConstraints();
+ for (SecurityConstraint constraint2 : constraints) {
+ for (SecurityCollection collection2 : constraint2.findCollections()) {
+ for (String urlPattern : collection2.findPatterns()) {
+ if (servletSecurityPatterns.contains(urlPattern)) {
+ servletSecurityPatterns.remove(urlPattern);
+ }
+ }
+ }
+ }
+ for (String urlPattern : servletSecurityPatterns) {
+ collection.addPattern(urlPattern);
+ }
}
constraint.addCollection(collection);
context.addConstraint(constraint);
@@ -2165,9 +2185,29 @@
constraint.setUserConstraint(org.apache.catalina.realm.Constants.CONFIDENTIAL_TRANSPORT);
}
SecurityCollection collection = new SecurityCollection();
- String[] urlPatterns = wrapper.findMappings();
- for (String urlPattern : urlPatterns) {
- collection.addPattern(urlPattern);
+ if (wrapper.getServletSecurityPatterns() != null) {
+ for (String urlPattern : wrapper.getServletSecurityPatterns()) {
+ collection.addPattern(urlPattern);
+ }
+ } else {
+ String[] urlPatterns = wrapper.findMappings();
+ Set<String> servletSecurityPatterns = new HashSet<String>();
+ for (String urlPattern : urlPatterns) {
+ servletSecurityPatterns.add(urlPattern);
+ }
+ SecurityConstraint[] constraints = context.findConstraints();
+ for (SecurityConstraint constraint2 : constraints) {
+ for (SecurityCollection collection2 : constraint2.findCollections()) {
+ for (String urlPattern : collection2.findPatterns()) {
+ if (servletSecurityPatterns.contains(urlPattern)) {
+ servletSecurityPatterns.remove(urlPattern);
+ }
+ }
+ }
+ }
+ for (String urlPattern : servletSecurityPatterns) {
+ collection.addPattern(urlPattern);
+ }
}
for (String methodOmission : methodOmissions) {
collection.addMethodOmission(methodOmission);
15 years, 2 months
JBossWeb SVN: r1207 - 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-10-18 12:47:36 -0400 (Sun, 18 Oct 2009)
New Revision: 1207
Modified:
trunk/java/org/apache/catalina/Session.java
trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
trunk/java/org/apache/catalina/session/StandardSession.java
Log:
- Revert ...
Modified: trunk/java/org/apache/catalina/Session.java
===================================================================
--- trunk/java/org/apache/catalina/Session.java 2009-10-18 15:12:57 UTC (rev 1206)
+++ trunk/java/org/apache/catalina/Session.java 2009-10-18 16:47:36 UTC (rev 1207)
@@ -253,12 +253,6 @@
/**
- * Add context name in which there is an associated session.
- */
- public void addAssociatedSession(String path);
-
-
- /**
* Return the object bound with the specified name to the internal notes
* for this session, or <code>null</code> if no such binding exists.
*
Modified: trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-10-18 15:12:57 UTC (rev 1206)
+++ trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-10-18 16:47:36 UTC (rev 1207)
@@ -928,7 +928,6 @@
// Compute a crossContext flag
HttpServletRequest hcurrent = (HttpServletRequest) current;
boolean crossContext = false;
- String originalContextPath = null;
if (state.outerRequest instanceof HttpServletRequest) {
HttpServletRequest houterRequest =
(HttpServletRequest) state.outerRequest;
@@ -939,12 +938,9 @@
contextPath = houterRequest.getContextPath();
}
crossContext = !(context.getPath().equals(contextPath));
- if (crossContext && contextPath != null) {
- originalContextPath = (String) contextPath;
- }
}
wrapper = new ApplicationHttpRequest
- (hcurrent, context, crossContext, originalContextPath);
+ (hcurrent, context, crossContext);
} else {
wrapper = new ApplicationRequest(current);
}
Modified: trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java 2009-10-18 15:12:57 UTC (rev 1206)
+++ trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java 2009-10-18 16:47:36 UTC (rev 1207)
@@ -33,11 +33,10 @@
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpSession;
-import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
-import org.apache.catalina.Session;
import org.apache.catalina.Manager;
+import org.apache.catalina.Session;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.StringManager;
@@ -96,12 +95,11 @@
* @param request The servlet request being wrapped
*/
public ApplicationHttpRequest(HttpServletRequest request, Context context,
- boolean crossContext, String originalContextPath) {
+ boolean crossContext) {
super(request);
this.context = context;
this.crossContext = crossContext;
- this.originalContextPath = originalContextPath;
setRequest(request);
}
@@ -117,12 +115,6 @@
/**
- * If cross context, the original context path.
- */
- protected String originalContextPath = null;
-
-
- /**
* The context path for this request.
*/
protected String contextPath = null;
@@ -540,25 +532,11 @@
} catch (IOException e) {
// Ignore
}
+ if ((localSession != null) && !localSession.isValid())
+ localSession = null;
if (localSession == null && create) {
localSession =
context.getManager().createSession(other.getId());
- // Associate the two sessions if possible
- if (originalContextPath != null) {
- Container otherContext = context.getParent().findChild(originalContextPath);
- if (otherContext != null) {
- try {
- Session otherSession = otherContext.getManager().findSession(other.getId());
- if (otherSession != null) {
- localSession.setMaxInactiveInterval(otherSession.getMaxInactiveInterval());
- otherSession.addAssociatedSession(context.getPath());
- localSession.addAssociatedSession(originalContextPath);
- }
- } catch (Exception e) {
- // Ignore
- }
- }
- }
}
if (localSession != null) {
localSession.access();
Modified: trunk/java/org/apache/catalina/session/StandardSession.java
===================================================================
--- trunk/java/org/apache/catalina/session/StandardSession.java 2009-10-18 15:12:57 UTC (rev 1206)
+++ trunk/java/org/apache/catalina/session/StandardSession.java 2009-10-18 16:47:36 UTC (rev 1207)
@@ -263,13 +263,6 @@
protected transient AtomicInteger accessCount = null;
- /**
- * Associated sessions in other contexts.
- */
- protected transient Map<String, Object> associatedSessions = null;
- protected static final Object TOKEN = new Object();
-
-
// ----------------------------------------------------- Session Properties
@@ -498,24 +491,6 @@
expire();
}
- // Expire any associated session
- if (associatedSessions != null) {
- for (String path : associatedSessions.keySet()) {
- Container crossContainer = manager.getContainer().getParent().findChild(path);
- if (crossContainer != null) {
- Manager crossManager = crossContainer.getManager();
- try {
- Session associatedSession = crossManager.findSession(id);
- if (associatedSession instanceof StandardSession) {
- ((StandardSession) associatedSession).maxInactiveInterval = interval;
- }
- } catch (Exception e) {
- // Ignore ...
- }
- }
- }
- }
-
}
@@ -678,17 +653,6 @@
/**
- * Add context name in which there is an associated session.
- */
- public void addAssociatedSession(String path) {
- if (associatedSessions == null) {
- associatedSessions = new ConcurrentHashMap<String, Object>();
- }
- associatedSessions.put(path, TOKEN);
- }
-
-
- /**
* Perform the internal processing required to invalidate this session,
* without triggering an exception if the session has already expired.
*
@@ -776,22 +740,6 @@
}
}
- // Expire any associated session
- if (associatedSessions != null) {
- for (String path : associatedSessions.keySet()) {
- Container crossContainer = manager.getContainer().getParent().findChild(path);
- if (crossContainer != null) {
- Manager crossManager = crossContainer.getManager();
- try {
- Session associatedSession = crossManager.findSession(id);
- associatedSession.expire();
- } catch (Exception e) {
- // Ignore ...
- }
- }
- }
- }
-
// We have completed expire of this session
expiring = false;
@@ -912,7 +860,6 @@
setPrincipal(null);
isNew = false;
isValid = false;
- associatedSessions = null;
manager = null;
}
15 years, 2 months
JBossWeb SVN: r1206 - 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-10-18 11:12:57 -0400 (Sun, 18 Oct 2009)
New Revision: 1206
Modified:
trunk/java/org/apache/catalina/Session.java
trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
trunk/java/org/apache/catalina/session/StandardSession.java
Log:
- Add code to associate cross context sessions together. Bleh.
- Improve types.
Modified: trunk/java/org/apache/catalina/Session.java
===================================================================
--- trunk/java/org/apache/catalina/Session.java 2009-10-17 10:50:39 UTC (rev 1205)
+++ trunk/java/org/apache/catalina/Session.java 2009-10-18 15:12:57 UTC (rev 1206)
@@ -251,6 +251,12 @@
*/
public void expire();
+
+ /**
+ * Add context name in which there is an associated session.
+ */
+ public void addAssociatedSession(String path);
+
/**
* Return the object bound with the specified name to the internal notes
Modified: trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-10-17 10:50:39 UTC (rev 1205)
+++ trunk/java/org/apache/catalina/core/ApplicationDispatcher.java 2009-10-18 15:12:57 UTC (rev 1206)
@@ -928,6 +928,7 @@
// Compute a crossContext flag
HttpServletRequest hcurrent = (HttpServletRequest) current;
boolean crossContext = false;
+ String originalContextPath = null;
if (state.outerRequest instanceof HttpServletRequest) {
HttpServletRequest houterRequest =
(HttpServletRequest) state.outerRequest;
@@ -938,9 +939,12 @@
contextPath = houterRequest.getContextPath();
}
crossContext = !(context.getPath().equals(contextPath));
+ if (crossContext && contextPath != null) {
+ originalContextPath = (String) contextPath;
+ }
}
wrapper = new ApplicationHttpRequest
- (hcurrent, context, crossContext);
+ (hcurrent, context, crossContext, originalContextPath);
} else {
wrapper = new ApplicationRequest(current);
}
Modified: trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java 2009-10-17 10:50:39 UTC (rev 1205)
+++ trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java 2009-10-18 15:12:57 UTC (rev 1206)
@@ -33,6 +33,7 @@
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpSession;
+import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.Session;
@@ -95,11 +96,12 @@
* @param request The servlet request being wrapped
*/
public ApplicationHttpRequest(HttpServletRequest request, Context context,
- boolean crossContext) {
+ boolean crossContext, String originalContextPath) {
super(request);
this.context = context;
this.crossContext = crossContext;
+ this.originalContextPath = originalContextPath;
setRequest(request);
}
@@ -112,6 +114,12 @@
* The context for this request.
*/
protected Context context = null;
+
+
+ /**
+ * If cross context, the original context path.
+ */
+ protected String originalContextPath = null;
/**
@@ -535,6 +543,22 @@
if (localSession == null && create) {
localSession =
context.getManager().createSession(other.getId());
+ // Associate the two sessions if possible
+ if (originalContextPath != null) {
+ Container otherContext = context.getParent().findChild(originalContextPath);
+ if (otherContext != null) {
+ try {
+ Session otherSession = otherContext.getManager().findSession(other.getId());
+ if (otherSession != null) {
+ localSession.setMaxInactiveInterval(otherSession.getMaxInactiveInterval());
+ otherSession.addAssociatedSession(context.getPath());
+ localSession.addAssociatedSession(originalContextPath);
+ }
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ }
}
if (localSession != null) {
localSession.access();
Modified: trunk/java/org/apache/catalina/session/StandardSession.java
===================================================================
--- trunk/java/org/apache/catalina/session/StandardSession.java 2009-10-17 10:50:39 UTC (rev 1205)
+++ trunk/java/org/apache/catalina/session/StandardSession.java 2009-10-18 15:12:57 UTC (rev 1206)
@@ -30,7 +30,6 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -46,6 +45,7 @@
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
+import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.Manager;
@@ -82,6 +82,9 @@
implements HttpSession, Session, Serializable {
+ private static final long serialVersionUID = -4294597583262209053L;
+
+
protected static final boolean ACTIVITY_CHECK =
Globals.STRICT_SERVLET_COMPLIANCE
|| Boolean.valueOf(System.getProperty("org.apache.catalina.session.StandardSession.ACTIVITY_CHECK", "false")).booleanValue();
@@ -128,7 +131,7 @@
/**
* The collection of user data attributes associated with this Session.
*/
- protected Map attributes = new ConcurrentHashMap();
+ protected Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
/**
@@ -190,7 +193,7 @@
/**
* The session event listeners for this Session.
*/
- protected transient ArrayList listeners = new ArrayList();
+ protected transient ArrayList<SessionListener> listeners = new ArrayList<SessionListener>();
/**
@@ -224,7 +227,7 @@
* and event listeners. <b>IMPLEMENTATION NOTE:</b> This object is
* <em>not</em> saved and restored across session serializations!
*/
- protected transient Map notes = new Hashtable();
+ protected transient Map<String, Object> notes = new ConcurrentHashMap<String, Object>();
/**
@@ -260,6 +263,13 @@
protected transient AtomicInteger accessCount = null;
+ /**
+ * Associated sessions in other contexts.
+ */
+ protected transient Map<String, Object> associatedSessions = null;
+ protected static final Object TOKEN = new Object();
+
+
// ----------------------------------------------------- Session Properties
@@ -487,6 +497,24 @@
if (isValid && interval == 0) {
expire();
}
+
+ // Expire any associated session
+ if (associatedSessions != null) {
+ for (String path : associatedSessions.keySet()) {
+ Container crossContainer = manager.getContainer().getParent().findChild(path);
+ if (crossContainer != null) {
+ Manager crossManager = crossContainer.getManager();
+ try {
+ Session associatedSession = crossManager.findSession(id);
+ if (associatedSession instanceof StandardSession) {
+ ((StandardSession) associatedSession).maxInactiveInterval = interval;
+ }
+ } catch (Exception e) {
+ // Ignore ...
+ }
+ }
+ }
+ }
}
@@ -648,7 +676,18 @@
}
+
+ /**
+ * Add context name in which there is an associated session.
+ */
+ public void addAssociatedSession(String path) {
+ if (associatedSessions == null) {
+ associatedSessions = new ConcurrentHashMap<String, Object>();
+ }
+ associatedSessions.put(path, TOKEN);
+ }
+
/**
* Perform the internal processing required to invalidate this session,
* without triggering an exception if the session has already expired.
@@ -737,6 +776,22 @@
}
}
+ // Expire any associated session
+ if (associatedSessions != null) {
+ for (String path : associatedSessions.keySet()) {
+ Container crossContainer = manager.getContainer().getParent().findChild(path);
+ if (crossContainer != null) {
+ Manager crossManager = crossContainer.getManager();
+ try {
+ Session associatedSession = crossManager.findSession(id);
+ associatedSession.expire();
+ } catch (Exception e) {
+ // Ignore ...
+ }
+ }
+ }
+ }
+
// We have completed expire of this session
expiring = false;
@@ -857,6 +912,7 @@
setPrincipal(null);
isNew = false;
isValid = false;
+ associatedSessions = null;
manager = null;
}
@@ -1418,7 +1474,7 @@
// Deserialize the attribute count and attribute values
if (attributes == null)
- attributes = new Hashtable();
+ attributes = new ConcurrentHashMap<String, Object>();
int n = ((Integer) stream.readObject()).intValue();
boolean isValidSave = isValid;
isValid = true;
@@ -1432,11 +1488,11 @@
isValid = isValidSave;
if (listeners == null) {
- listeners = new ArrayList();
+ listeners = new ArrayList<SessionListener>();
}
if (notes == null) {
- notes = new Hashtable();
+ notes = new ConcurrentHashMap<String, Object>();
}
}
15 years, 2 months
JBossWeb SVN: r1205 - tags.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-10-17 06:50:39 -0400 (Sat, 17 Oct 2009)
New Revision: 1205
Added:
tags/JBOSSWEB_3_0_0_ALPHA9/
Log:
- New build.
- Quite a few fixes and impl of error conditions.
Copied: tags/JBOSSWEB_3_0_0_ALPHA9 (from rev 1204, trunk)
15 years, 2 months