Author: remy.maucherat(a)jboss.com
Date: 2009-06-11 14:06:11 -0400 (Thu, 11 Jun 2009)
New Revision: 1108
Modified:
trunk/ROADMAP.txt
trunk/java/org/apache/catalina/Wrapper.java
trunk/java/org/apache/catalina/connector/MapperListener.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/core/StandardWrapper.java
trunk/java/org/apache/catalina/deploy/SecurityCollection.java
trunk/java/org/apache/catalina/deploy/SecurityConstraint.java
trunk/java/org/apache/catalina/realm/RealmBase.java
trunk/java/org/apache/catalina/startup/WebRuleSet.java
Log:
- Add the new web elements. Not sure I got the omission thing right, though. Enabled is a
todo.
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-06-11 13:57:24 UTC (rev 1107)
+++ trunk/ROADMAP.txt 2009-06-11 18:06:11 UTC (rev 1108)
@@ -2,12 +2,9 @@
Standalone:
- Access control annotations
-- Update digester XML parsing rules for web.xml updates (session tracking-mode,
cookie-config, servlet enabled,
- servlets and filters async-supported, http-method-omission)
- Enforce web.xml fragments merging rules
-- Migrate relevant components to JAR repository (in paticular classloader)
- Lazy webapp startup valve
-- Abstract JMX in custom modeler better
+- JMX abstraction: redo MapperListener with regular listeners, and abstract JMX in
modeler
- JSP 2.2 changes
- EL 1.1 changes
Modified: trunk/java/org/apache/catalina/Wrapper.java
===================================================================
--- trunk/java/org/apache/catalina/Wrapper.java 2009-06-11 13:57:24 UTC (rev 1107)
+++ trunk/java/org/apache/catalina/Wrapper.java 2009-06-11 18:06:11 UTC (rev 1108)
@@ -120,6 +120,20 @@
/**
+ * Return the enabled value.
+ */
+ public boolean getEnabled();
+
+
+ /**
+ * Set the enabled value.
+ *
+ * @param value New async supported value
+ */
+ public void setEnabled(boolean enabled);
+
+
+ /**
* Return the InstanceSupport object for this Wrapper instance.
*/
public InstanceSupport getInstanceSupport();
Modified: trunk/java/org/apache/catalina/connector/MapperListener.java
===================================================================
--- trunk/java/org/apache/catalina/connector/MapperListener.java 2009-06-11 13:57:24 UTC
(rev 1107)
+++ trunk/java/org/apache/catalina/connector/MapperListener.java 2009-06-11 18:06:11 UTC
(rev 1108)
@@ -513,6 +513,7 @@
("mapperListener.registerWrapper",
wrapperName, contextName));
+ // FIXME: need to handle enabled flag
String[] mappings = (String[])
mBeanServer.invoke(objectName, "findMappings", null, null);
Object wrapper =
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-11 13:57:24 UTC (rev
1107)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-11 18:06:11 UTC (rev
1108)
@@ -29,6 +29,7 @@
import java.util.EnumSet;
import java.util.EventListener;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@@ -314,7 +315,7 @@
/**
* Session tracking modes.
*/
- protected Set<SessionTrackingMode> sessionTrackingModes =
defaultSessionTrackingModes;
+ protected Set<SessionTrackingMode> sessionTrackingModes = null;
/**
@@ -1710,7 +1711,11 @@
public Set<SessionTrackingMode> getSessionTrackingModes() {
- return sessionTrackingModes;
+ if (sessionTrackingModes == null) {
+ return defaultSessionTrackingModes;
+ } else {
+ return sessionTrackingModes;
+ }
}
@@ -1720,6 +1725,19 @@
}
+ public void addSessionTrackingMode(String trackingMode) {
+ SessionTrackingMode mode = SessionTrackingMode.valueOf(trackingMode);
+ if (mode == null) {
+ // FIXME: error message
+ throw new IllegalArgumentException();
+ }
+ if (sessionTrackingModes == null) {
+ sessionTrackingModes = new HashSet<SessionTrackingMode>();
+ }
+ sessionTrackingModes.add(mode);
+ }
+
+
/**
* Return the "replace welcome files" property.
*/
@@ -2476,6 +2494,7 @@
public void addServletMapping(String pattern, String name,
boolean jspWildCard) {
// Validate the proposed mapping
+ Wrapper wrapper = (Wrapper) findChild(name);
if (findChild(name) == null)
throw new IllegalArgumentException
(sm.getString("standardContext.servletMap.name", name));
@@ -2488,16 +2507,17 @@
String name2 = (String) servletMappings.get(pattern);
if (name2 != null) {
// Don't allow more than one servlet on the same pattern
- Wrapper wrapper = (Wrapper) findChild(name2);
- wrapper.removeMapping(pattern);
+ Wrapper wrapper2 = (Wrapper) findChild(name2);
+ wrapper2.removeMapping(pattern);
mapper.removeWrapper(pattern);
}
servletMappings.put(pattern, name);
- Wrapper wrapper = (Wrapper) findChild(name);
wrapper.addMapping(pattern);
// Update context mapper
- mapper.addWrapper(pattern, wrapper, jspWildCard);
+ if (wrapper.getEnabled()) {
+ mapper.addWrapper(pattern, wrapper, jspWildCard);
+ }
fireContainerEvent("addServletMapping", pattern);
@@ -4189,6 +4209,8 @@
try {
+
+
// Create context attributes that will be required
if (ok) {
postContextAttributes();
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-06-11 13:57:24 UTC (rev
1107)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-06-11 18:06:11 UTC (rev
1108)
@@ -112,6 +112,12 @@
/**
+ * Enabled flag.
+ */
+ protected boolean enabled = true;
+
+
+ /**
* The date and time at which this servlet will become available (in
* milliseconds since the epoch), or zero if the servlet is available.
* If this value equals Long.MAX_VALUE, the unavailability of this
@@ -310,14 +316,6 @@
/**
- * Return the Servlet description.
- */
- public String getDescription() {
- return description;
- }
-
-
- /**
* Set the async supported value.
*
* @param value New async supported value
@@ -330,6 +328,14 @@
/**
+ * Return the Servlet description.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+
+ /**
* Set the description.
*/
public void setDescription(String description) {
@@ -354,6 +360,26 @@
/**
+ * Return the enabled value.
+ */
+ public boolean getEnabled() {
+ return enabled;
+ }
+
+
+ /**
+ * Set the enabled value.
+ *
+ * @param value New enabled value
+ */
+ public void setEnabled(boolean value) {
+ boolean oldEnabled = this.enabled;
+ this.enabled = value;
+ support.firePropertyChange("enabled", oldEnabled, enabled);
+ }
+
+
+ /**
* Return the available date/time for this servlet, in milliseconds since
* the epoch. If this date/time is Long.MAX_VALUE, it is considered to mean
* that unavailability is permanent and any request for this servlet will return
Modified: trunk/java/org/apache/catalina/deploy/SecurityCollection.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/SecurityCollection.java 2009-06-11 13:57:24 UTC
(rev 1107)
+++ trunk/java/org/apache/catalina/deploy/SecurityCollection.java 2009-06-11 18:06:11 UTC
(rev 1108)
@@ -98,6 +98,12 @@
/**
+ * The HTTP methods not covered by this web resource collection.
+ */
+ private String methodOmissions[] = new String[0];
+
+
+ /**
* The name of this web resource collection.
*/
private String name = null;
@@ -176,6 +182,22 @@
/**
+ * Add an HTTP request method to be skipped from this web resource collection.
+ */
+ public void addMethodOmission(String method) {
+
+ if (method == null)
+ return;
+ String results[] = new String[methodOmissions.length + 1];
+ for (int i = 0; i < methodOmissions.length; i++)
+ results[i] = methodOmissions[i];
+ results[methodOmissions.length] = method;
+ methodOmissions = results;
+
+ }
+
+
+ /**
* Add a URL pattern to be part of this web resource collection.
*/
public void addPattern(String pattern) {
@@ -226,6 +248,37 @@
/**
+ * Return <code>true</code> if the specified HTTP request method is
+ * not part of this web resource collection.
+ *
+ * @param method Request method to check
+ */
+ public boolean findMethodOmission(String method) {
+
+ if (methods.length == 0)
+ return (true);
+ for (int i = 0; i < methodOmissions.length; i++) {
+ if (methodOmissions[i].equals(method))
+ return (true);
+ }
+ return (false);
+
+ }
+
+
+ /**
+ * Return the set of HTTP request methods that are not part of this web
+ * resource collection, or a zero-length array if no request methods
+ * is omitted.
+ */
+ public String[] findMethodOmissions() {
+
+ return (methodOmissions);
+
+ }
+
+
+ /**
* Is the specified pattern part of this web resource collection?
*
* @param pattern Pattern to be compared
@@ -284,6 +337,36 @@
/**
+ * Remove the specified HTTP request method from those that are not part
+ * of this web resource collection.
+ *
+ * @param method Request method to be removed
+ */
+ public void removeMethodOmission(String method) {
+
+ if (method == null)
+ return;
+ int n = -1;
+ for (int i = 0; i < methodOmissions.length; i++) {
+ if (methodOmissions[i].equals(method)) {
+ n = i;
+ break;
+ }
+ }
+ if (n >= 0) {
+ int j = 0;
+ String results[] = new String[methodOmissions.length - 1];
+ for (int i = 0; i < methodOmissions.length; i++) {
+ if (i != n)
+ results[j++] = methodOmissions[i];
+ }
+ methodOmissions = results;
+ }
+
+ }
+
+
+ /**
* Remove the specified URL pattern from those that are part of this
* web resource collection.
*
Modified: trunk/java/org/apache/catalina/deploy/SecurityConstraint.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/SecurityConstraint.java 2009-06-11 13:57:24 UTC
(rev 1107)
+++ trunk/java/org/apache/catalina/deploy/SecurityConstraint.java 2009-06-11 18:06:11 UTC
(rev 1108)
@@ -304,6 +304,8 @@
for (int i = 0; i < collections.length; i++) {
if (!collections[i].findMethod(method))
continue;
+ if (collections[i].findMethodOmission(method))
+ continue;
String patterns[] = collections[i].findPatterns();
for (int j = 0; j < patterns.length; j++) {
if (matchPattern(uri, patterns[j]))
Modified: trunk/java/org/apache/catalina/realm/RealmBase.java
===================================================================
--- trunk/java/org/apache/catalina/realm/RealmBase.java 2009-06-11 13:57:24 UTC (rev
1107)
+++ trunk/java/org/apache/catalina/realm/RealmBase.java 2009-06-11 18:06:11 UTC (rev
1108)
@@ -493,6 +493,9 @@
}
for(int j=0; j < collection.length; j++){
+ if(collection[j].findMethodOmission(method)) {
+ continue;
+ }
String [] patterns = collection[j].findPatterns();
// If patterns is null, continue to avoid an NPE
@@ -537,6 +540,9 @@
}
for(int j=0; j < collection.length; j++){
+ if(collection[j].findMethodOmission(method)) {
+ continue;
+ }
String [] patterns = collection[j].findPatterns();
// If patterns is null, continue to avoid an NPE
@@ -606,6 +612,9 @@
int pos = -1;
for(int j=0; j < collection.length; j++){
String [] patterns = collection[j].findPatterns();
+ if(collection[j].findMethodOmission(method)) {
+ continue;
+ }
// If patterns is null, continue to avoid an NPE
// See Bugzilla 30624
Modified: trunk/java/org/apache/catalina/startup/WebRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-06-11 13:57:24 UTC (rev
1107)
+++ trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-06-11 18:06:11 UTC (rev
1108)
@@ -202,6 +202,10 @@
"addFilterDef",
"org.apache.catalina.deploy.FilterDef");
+ digester.addCallMethod(prefix + elementName +
"/filter/async-supported",
+ "setAsyncSupported", 1, new Class[] { Boolean.TYPE });
+ digester.addCallParam(prefix + elementName + "/filter/async-supported",
0);
+
digester.addCallMethod(prefix + elementName + "/filter/description",
"setDescription", 0);
digester.addCallMethod(prefix + elementName + "/filter/display-name",
@@ -325,6 +329,8 @@
"org.apache.catalina.deploy.SecurityCollection");
digester.addCallMethod(prefix + elementName +
"/security-constraint/web-resource-collection/http-method",
"addMethod", 0);
+ digester.addCallMethod(prefix + elementName +
"/security-constraint/web-resource-collection/http-method-omission",
+ "addMethodOmission", 0);
digester.addCallMethod(prefix + elementName +
"/security-constraint/web-resource-collection/url-pattern",
"addPattern", 0);
digester.addCallMethod(prefix + elementName +
"/security-constraint/web-resource-collection/web-resource-name",
@@ -339,9 +345,17 @@
"addChild",
"org.apache.catalina.Container");
+ digester.addCallMethod(prefix + elementName +
"/servlet/async-supported",
+ "setAsyncSupported", 1, new Class[] { Boolean.TYPE });
+ digester.addCallParam(prefix + elementName +
"/servlet/async-supported", 0);
+
digester.addCallMethod(prefix + elementName + "/servlet/description",
"setDescription", 0);
+ digester.addCallMethod(prefix + elementName + "/servlet/enabled",
+ "setEnabled", 1, new Class[] { Boolean.TYPE });
+ digester.addCallParam(prefix + elementName + "/servlet/enabled", 0);
+
digester.addCallMethod(prefix + elementName + "/servlet/init-param",
"addInitParameter", 2);
digester.addCallParam(prefix + elementName +
"/servlet/init-param/param-name",
@@ -378,6 +392,30 @@
"setSessionTimeout", 1,
new Class[] { Integer.TYPE });
digester.addCallParam(prefix + elementName +
"/session-config/session-timeout", 0);
+ digester.addCallMethod(prefix + elementName +
"/session-config/tracking-mode", "addSessionTrackingMode", 0);
+
+ digester.addObjectCreate(prefix + elementName +
"/session-config/cookie-config",
+ "org.apache.catalina.deploy.SessionCookie");
+ digester.addSetNext(prefix + elementName +
"/session-config/cookie-config",
+ "setSessionCookie",
+ "org.apache.catalina.deploy.SessionCookie");
+ digester.addCallMethod(prefix + elementName +
"/session-config/cookie-config/cookie-name",
+ "setName", 0);
+ digester.addCallMethod(prefix + elementName +
"/session-config/cookie-config/cookie-domain",
+ "setDomain", 0);
+ digester.addCallMethod(prefix + elementName +
"/session-config/cookie-config/cookie-path",
+ "setPath", 0);
+ digester.addCallMethod(prefix + elementName +
"/session-config/cookie-config/cookie-comment",
+ "setComment", 0);
+ digester.addCallMethod(prefix + elementName +
"/session-config/cookie-config/http-only",
+ "setHttpOnly", 1, new Class[] { Boolean.TYPE });
+ digester.addCallParam(prefix + elementName +
"/session-config/cookie-config/http-only", 0);
+ digester.addCallMethod(prefix + elementName +
"/session-config/cookie-config/secure",
+ "setSecure", 1, new Class[] { Boolean.TYPE });
+ digester.addCallParam(prefix + elementName +
"/session-config/cookie-config/secure", 0);
+ digester.addCallMethod(prefix + elementName +
"/session-config/cookie-config/max-age",
+ "setMaxAge", 1, new Class[] { Integer.TYPE });
+ digester.addCallParam(prefix + elementName +
"/session-config/cookie-config/max-age", 0);
digester.addCallMethod(prefix + elementName + "/taglib",
"addTaglib", 2);