Author: remy.maucherat(a)jboss.com
Date: 2009-06-06 18:18:39 -0400 (Sat, 06 Jun 2009)
New Revision: 1088
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/Globals.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/startup/WebRuleSet.java
Log:
- Add a Servlet version string.
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-06-06 22:18:10 UTC (rev 1087)
+++ trunk/java/org/apache/catalina/Context.java 2009-06-06 22:18:39 UTC (rev 1088)
@@ -407,6 +407,20 @@
/**
+ * Return the Servlet API version defined for the webapp.
+ */
+ public String getVersion();
+
+
+ /**
+ * Set the Servlet API version defined for the webapp.
+ *
+ * @param version The version
+ */
+ public void setVersion(String version);
+
+
+ /**
* Return the reloadable flag for this web application.
*/
public boolean getReloadable();
Modified: trunk/java/org/apache/catalina/Globals.java
===================================================================
--- trunk/java/org/apache/catalina/Globals.java 2009-06-06 22:18:10 UTC (rev 1087)
+++ trunk/java/org/apache/catalina/Globals.java 2009-06-06 22:18:39 UTC (rev 1088)
@@ -157,12 +157,11 @@
/**
- * The servlet context attribute under which we record the set of
- * JSP tag libraries locations (as an object of type HashMap<String, String>)
- * for this application.
+ * The servlet context attribute under which we record the Servlet API version
+ * support declared for this webapp.
*/
- public static final String JSP_TAG_LIBRARIES_LOCATION =
- "org.apache.catalina.JSP_TAG_LIBRARIES_LOCATION";
+ public static final String SERVLET_VERSION =
+ "org.apache.catalina.SERVLET_VERSION";
/**
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-06 22:18:10 UTC (rev
1087)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-06 22:18:39 UTC (rev
1088)
@@ -503,7 +503,13 @@
*/
protected String publicId = null;
+
+ /**
+ * Version number.
+ */
+ protected String version = null;
+
/**
* The reloadable flag for this web application.
*/
@@ -1582,6 +1588,26 @@
/**
+ * Return the Servlet API version defined for the webapp.
+ */
+ public String getVersion() {
+ return this.version;
+ }
+
+
+ /**
+ * Set the Servlet API version defined for the webapp.
+ *
+ * @param version The version
+ */
+ public void setVersion(String version) {
+ String oldVersion = this.version;
+ this.version = version;
+ support.firePropertyChange("version", oldVersion, version);
+ }
+
+
+ /**
* Return the reloadable flag for this web application.
*/
public boolean getReloadable() {
@@ -2284,11 +2310,11 @@
*/
public void addJspPropertyGroup(JspPropertyGroup propertyGroup) {
// Add any JSP mapping specified, as it needs to be mapped to the JSP Servlet
- String[] urlPatterns = propertyGroup.getUrlPatterns();
- for (int i = 0; i < urlPatterns.length; i++) {
- addJspMapping(urlPatterns[i]);
+ ArrayList<String> urlPatterns = propertyGroup.getUrlPatterns();
+ for (int i = 0; i < urlPatterns.size(); i++) {
+ addJspMapping(urlPatterns.get(i));
// Split off the groups to individual mappings
- jspPropertyGroups.put(urlPatterns[i], propertyGroup);
+ jspPropertyGroups.put(urlPatterns.get(i), propertyGroup);
}
}
@@ -4809,12 +4835,12 @@
*/
protected void postContextAttributes() {
ServletContext context = getServletContext();
+ context.setAttribute(Globals.SERVLET_VERSION, version);
context.setAttribute(Globals.RESOURCES_ATTR, getResources());
context.setAttribute(Globals.WELCOME_FILES_ATTR, welcomeFiles);
// Jasper attributes
context.setAttribute(Globals.JSP_PROPERTY_GROUPS, jspPropertyGroups);
context.setAttribute(Globals.JSP_TAG_LIBRARIES, jspTagLibraries);
- context.setAttribute(Globals.JSP_TAG_LIBRARIES_LOCATION, taglibs);
// Instance manager (also used by Jasper)
context.setAttribute(InstanceManager.class.getName(), instanceManager);
}
Modified: trunk/java/org/apache/catalina/startup/WebRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-06-06 22:18:10 UTC (rev
1087)
+++ trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-06-06 22:18:39 UTC (rev
1088)
@@ -946,6 +946,30 @@
}
/**
+ * A Rule that sets the version field on the context.
+ */
+final class VersionRule extends Rule {
+
+ public VersionRule() {
+ }
+
+ public void begin(String namespace, String name, Attributes attributes)
+ throws Exception {
+ Context context = (Context) digester.peek(digester.getCount() - 1);
+ String value = attributes.getValue("version");
+ if (value != null) {
+ context.setVersion(value);
+ }
+ if (digester.getLogger().isDebugEnabled()) {
+ digester.getLogger().debug
+ (context.getClass().getName() + ".setIgnoreAnnotations( " +
+ context.getIgnoreAnnotations() + ")");
+ }
+ }
+
+}
+
+/**
* A Rule that sets soap headers on the ContextHandler.
*
*/
Show replies by date