Author: markt
Date: Fri Apr 17 16:30:56 2009
New Revision: 766075

URL: http://svn.apache.org/viewvc?rev=766075&view=rev
Log:
Update Servlet 3.0 classes to spec snapshot as of early March 2009. Still not 
final. 

Added:
    tomcat/trunk/java/javax/servlet/AsyncDispatcher.java   (with props)
Removed:
    tomcat/trunk/java/javax/servlet/AsyncContext.java
    tomcat/trunk/java/javax/servlet/http/HttpUtils.java
Modified:
    tomcat/trunk/java/javax/servlet/AsyncEvent.java
    tomcat/trunk/java/javax/servlet/AsyncListener.java
    tomcat/trunk/java/javax/servlet/ServletContext.java
    tomcat/trunk/java/javax/servlet/ServletRequest.java
    tomcat/trunk/java/javax/servlet/ServletRequestWrapper.java
    tomcat/trunk/java/javax/servlet/SessionTrackingMode.java
    tomcat/trunk/java/javax/servlet/http/HttpServlet.java
    tomcat/trunk/java/org/apache/catalina/connector/Request.java
    tomcat/trunk/java/org/apache/catalina/connector/RequestFacade.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
    tomcat/trunk/java/org/apache/catalina/core/DummyRequest.java
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
    tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java

Added: tomcat/trunk/java/javax/servlet/AsyncDispatcher.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/AsyncDispatcher.java?rev=766075&view=auto
==============================================================================
--- tomcat/trunk/java/javax/servlet/AsyncDispatcher.java (added)
+++ tomcat/trunk/java/javax/servlet/AsyncDispatcher.java Fri Apr 17 16:30:56 
2009
@@ -0,0 +1,26 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package javax.servlet;
+
+/**
+ * @since 3.0
+ * TODO SERVLET3 - Add comments
+ */
+public interface AsyncDispatcher {
+    void forward(ServletRequest request, ServletResponse response)
+            throws IllegalStateException;
+}

Propchange: tomcat/trunk/java/javax/servlet/AsyncDispatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/trunk/java/javax/servlet/AsyncDispatcher.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision

Modified: tomcat/trunk/java/javax/servlet/AsyncEvent.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/AsyncEvent.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/AsyncEvent.java (original)
+++ tomcat/trunk/java/javax/servlet/AsyncEvent.java Fri Apr 17 16:30:56 2009
@@ -19,7 +19,7 @@
 /**
  * @since 3.0
  * $Id$
- * TODO SERVLET3
+ * TODO SERVLET3 - Add comments
  */
 public class AsyncEvent {
     private ServletRequest request;

Modified: tomcat/trunk/java/javax/servlet/AsyncListener.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/AsyncListener.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/AsyncListener.java (original)
+++ tomcat/trunk/java/javax/servlet/AsyncListener.java Fri Apr 17 16:30:56 2009
@@ -17,13 +17,14 @@
 package javax.servlet;
 
 import java.io.IOException;
+import java.util.EventListener;
 
 /**
  * @since 3.0
  * $Id$
- * TODO SERVLET3
+ * TODO SERVLET3 - Add comments
  */
-public interface AsyncListener {
-    void onComplete(AsyncEvent event) throws IOException;
+public interface AsyncListener extends EventListener {
+    void onDoneAsync(AsyncEvent event) throws IOException;
     void onTimeout(AsyncEvent event) throws IOException;
 }

Modified: tomcat/trunk/java/javax/servlet/ServletContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/ServletContext.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/ServletContext.java (original)
+++ tomcat/trunk/java/javax/servlet/ServletContext.java Fri Apr 17 16:30:56 2009
@@ -643,14 +643,38 @@
      */
     
     public String getServletContextName();
+
+
+    /**
+     * 
+     * @param servletName
+     * @param description
+     * @param className
+     * @param initParameters
+     * @param loadOnStartup
+     * @throws IllegalArgumentException If the servlet name already exists
+     * @throws IllegalStateException    If the context has already been
+     *                                  initialised
+     * @since 3.0
+     */
+    public void addServlet(String servletName, String description,
+            String className, Map<String,String> initParameters,
+            int loadOnStartup)
+            throws IllegalArgumentException, IllegalStateException;
+    
     
     /**
      * 
      * @param servletName
      * @param urlPatterns
+     * @throws IllegalArgumentException If urlPatters is null or empty
+     * @throws IllegalStateException    If the context has already been
+     *                                  initialised
+     * 
      * @since 3.0
      */
-    public void addServletMapping(String servletName, String[] urlPatterns);
+    public void addServletMapping(String servletName, String[] urlPatterns)
+            throws IllegalArgumentException, IllegalStateException;
 
     /**
      * 
@@ -658,12 +682,15 @@
      * @param description
      * @param className
      * @param initParameters
-     * @param isAsyncSupported
+     * @throws IllegalArgumentException If the filter name already exists
+     * @throws IllegalStateException    If the context has already been
+     *                                  initialised
+     * 
      * @since 3.0
      */
     public void addFilter(String filterName, String description,
-            String className, Map<String,String> initParameters,
-            boolean isAsyncSupported);
+            String className, Map<String,String> initParameters)
+            throws IllegalArgumentException, IllegalStateException;
     
     /**
      * 
@@ -671,11 +698,15 @@
      * @param dispatcherTypes
      * @param isMatchAfter
      * @param servletNames
+     * @throws IllegalArgumentException If servletNames is null or empty
+     * @throws IllegalStateException    If the context has already been
+     *                                  initialised
      * @since 3.0
      */
     public void addFilterMappingForServletNames(String filterName,
             EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
-            String... servletNames);
+            String... servletNames)
+            throws IllegalArgumentException, IllegalStateException;
     
     /**
      * 
@@ -683,18 +714,24 @@
      * @param dispatcherTypes
      * @param isMatchAfter
      * @param urlPatterns
+4     *
      * @since 3.0
      */
     public void addFilterMappingForUrlPatterns(String filterName,
             EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
-            String... urlPatterns);
+            String... urlPatterns)
+            throws IllegalArgumentException, IllegalStateException;
     
+
     /**
      * 
      * @param sessionCookieConfig
+     * @throws IllegalStateException    If the context has already been
+     *                                  initialised
      * @since 3.0
      */
-    public void setSessionCookieConfig(SessionCookieConfig 
sessionCookieConfig);
+    public void setSessionCookieConfig(SessionCookieConfig sessionCookieConfig)
+            throws IllegalStateException;
     
     /**
      * 
@@ -706,10 +743,17 @@
     /**
      * 
      * @param sessionTrackingModes
+     * @throws IllegalArgumentException If sessionTrackingModes specifies
+     *                                  {...@link SessionTrackingMode.SSL} in
+     *                                  combination with any other
+     *                                  {...@link SessionTrackingMode}
+     * @throws IllegalStateException    If the context has already been
+     *                                  initialised
      * @since 3.0
      */
     public void setSessionTrackingModes(
-            EnumSet<SessionTrackingMode> sessionTrackingModes);
+            EnumSet<SessionTrackingMode> sessionTrackingModes)
+            throws IllegalStateException, IllegalArgumentException;
     
     /**
      * 
@@ -724,6 +768,12 @@
      * @since 3.0
      */
     public EnumSet<SessionTrackingMode> getEffectiveSessionTrackingModes();
+    
+    /**
+     * 
+     * @param path
+     * @return
+     * @since 3.0
+     */
+    public AsyncDispatcher getAsyncDispatcher(String path);
 }
-
-

Modified: tomcat/trunk/java/javax/servlet/ServletRequest.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/ServletRequest.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/ServletRequest.java (original)
+++ tomcat/trunk/java/javax/servlet/ServletRequest.java Fri Apr 17 16:30:56 2009
@@ -604,21 +604,20 @@
     /**
      * 
      * @return
-     * @throws java.lang.IllegalStateException
+     * @throws java.lang.IllegalStateException  If async is not supported for
+     *                                          this request
      * @since 3.0
      */
-    public AsyncContext startAsync() throws java.lang.IllegalStateException;
+    public void startAsync() throws java.lang.IllegalStateException;
     
     /**
      * 
-     * @param servletRequest
-     * @param servletResponse
+     * @param runnable
      * @return
      * @throws java.lang.IllegalStateException
      * @since 3.0
      */
-    public AsyncContext startAsync(ServletRequest servletRequest,
-            ServletResponse servletResponse)
+    public void startAsync(Runnable runnable)
             throws java.lang.IllegalStateException;
     
     /**
@@ -630,6 +629,13 @@
     
     /**
      * 
+     * @throws IllegalStateException    If startAsync was never called
+     * @since 3.0
+     */
+    public void doneAsync() throws IllegalStateException;
+
+    /**
+     * 
      * @return
      * @since 3.0
      */
@@ -640,15 +646,16 @@
      * @return
      * @since 3.0
      */
-    public AsyncContext getAsyncContext();
+    public AsyncDispatcher getAsyncDispatcher();
 
     /**
      * 
-     * @param listener
+     * @param path
+     * @return
      * @since 3.0
      */
-    public void addAsyncListener(AsyncListener listener);
-    
+    public AsyncDispatcher getAsyncDispatcher(String path);
+
     /**
      * 
      * @param listener
@@ -659,11 +666,5 @@
     public void addAsyncListener(AsyncListener listener,
             ServletRequest servletRequest, ServletResponse servletResponse);
     
-    /**
-     * 
-     * @param timeout
-     * @since 3.0
-     */
-    public void setAsyncTimeout(long timeout);
 }
 

Modified: tomcat/trunk/java/javax/servlet/ServletRequestWrapper.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/ServletRequestWrapper.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/ServletRequestWrapper.java (original)
+++ tomcat/trunk/java/javax/servlet/ServletRequestWrapper.java Fri Apr 17 
16:30:56 2009
@@ -417,25 +417,22 @@
      * @throws java.lang.IllegalStateException
      * @since 3.0
      */
-    public AsyncContext startAsync() throws java.lang.IllegalStateException {
-        return request.startAsync();
+    public void startAsync() throws java.lang.IllegalStateException {
+        request.startAsync();
     }
     
     /**
      * The default behavior of this method is to return
-     * startAsync(ServletRequest, ServletResponse) on the wrapped request
-     * object.
+     * startAsync(Runnable) on the wrapped request object.
      * 
-     * @param servletRequest
-     * @param servletResponse
+     * @param runnable
      * @return
      * @throws java.lang.IllegalStateException
      * @since 3.0
      */
-    public AsyncContext startAsync(ServletRequest servletRequest,
-            ServletResponse servletResponse)
+    public void startAsync(Runnable runnable)
             throws java.lang.IllegalStateException {
-        return request.startAsync(servletRequest, servletResponse);
+        request.startAsync(runnable);
     }
     
     /**
@@ -448,7 +445,17 @@
     public boolean isAsyncStarted() {
         return request.isAsyncStarted();
     }
-    
+
+    /**
+     * The default behavior of this method is to return
+     * doneAsync() on the wrapped request object.
+     * @throws java.lang.IllegalStateException
+     * @since 3.0
+     */
+    public void doneAsync() throws IllegalStateException {
+        request.doneAsync();
+    }
+
     /**
      * The default behavior of this method is to return
      * isAsyncSupported() on the wrapped request object.
@@ -462,26 +469,26 @@
     
     /**
      * The default behavior of this method is to return
-     * getAsyncContext() on the wrapped request object.
+     * getAsyncDispatcher() on the wrapped request object.
      * 
      * @return
      * @since 3.0
      */
-    public AsyncContext getAsyncContext() {
-        return request.getAsyncContext();
+    public AsyncDispatcher getAsyncDispatcher() {
+        return request.getAsyncDispatcher();
     }
 
     /**
-     * The default behavior of this method is to call
-     * addAsyncListener(AsyncListener) on the wrapped request object.
+     * The default behavior of this method is to return
+     * getAsyncDispatcher(path) on the wrapped request object.
      * 
-     * @param listener
+     * @return
      * @since 3.0
      */
-    public void addAsyncListener(AsyncListener listener) {
-        request.addAsyncListener(listener);
+    public AsyncDispatcher getAsyncDispatcher(String path) {
+        return request.getAsyncDispatcher(path);
     }
-    
+
     /**
      * The default behavior of this method is to call
      * addAsyncListener(AsyncListener, ServletRequest, ServletResponse) on the
@@ -497,16 +504,5 @@
         request.addAsyncListener(listener, servletRequest, servletResponse);
     }
     
-    /**
-     * The default behavior of this method is to call
-     * startAsync() on the wrapped request object.
-     * 
-     * @param timeout
-     * @since 3.0
-     */
-    public void setAsyncTimeout(long timeout) {
-        request.setAsyncTimeout(timeout);
-    }
-
 }
 

Modified: tomcat/trunk/java/javax/servlet/SessionTrackingMode.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/SessionTrackingMode.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/SessionTrackingMode.java (original)
+++ tomcat/trunk/java/javax/servlet/SessionTrackingMode.java Fri Apr 17 
16:30:56 2009
@@ -22,6 +22,6 @@
  */
 public enum SessionTrackingMode {
     COOKIE,
-    URL,
-    SSL
+    SSL,
+    URL
 }

Modified: tomcat/trunk/java/javax/servlet/http/HttpServlet.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/HttpServlet.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/HttpServlet.java (original)
+++ tomcat/trunk/java/javax/servlet/http/HttpServlet.java Fri Apr 17 16:30:56 
2009
@@ -198,7 +198,8 @@
      *              since midnight, January 1, 1970 GMT, or
      *              -1 if the time is not known
      */
-    protected long getLastModified(HttpServletRequest req) {
+    protected long getLastModified(
+            @SuppressWarnings("unused") HttpServletRequest req) {
         return -1;
     }
 
@@ -472,7 +473,9 @@
      * @exception ServletException  if the request for the
      *                                  OPTIONS cannot be handled
      */
-    protected void doOptions(HttpServletRequest req, HttpServletResponse resp)
+    protected void doOptions(
+            @SuppressWarnings("unused") HttpServletRequest req,
+            HttpServletResponse resp)
         throws ServletException, IOException {
 
         Method[] methods = getAllDeclaredMethods(this.getClass());

Modified: tomcat/trunk/java/org/apache/catalina/connector/Request.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Request.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Fri Apr 17 
16:30:56 2009
@@ -35,7 +35,7 @@
 import java.util.TreeMap;
 
 import javax.security.auth.Subject;
-import javax.servlet.AsyncContext;
+import javax.servlet.AsyncDispatcher;
 import javax.servlet.AsyncListener;
 import javax.servlet.FilterChain;
 import javax.servlet.RequestDispatcher;
@@ -1501,22 +1501,16 @@
     }
 
 
-    public void addAsyncListener(AsyncListener listener,
-            ServletRequest servletRequest, ServletResponse servletResponse) {
-        // TODO SERVLET3
-    }
+    public ServletContext getServletContext() {
+        return context.getServletContext();
+     }
 
-    public void addAsyncListener(AsyncListener listener) {
+    public void startAsync() throws IllegalStateException {
         // TODO SERVLET3
     }
 
-    public AsyncContext getAsyncContext() {
+    public void startAsync(Runnable runnable) throws IllegalStateException {
         // TODO SERVLET3
-        return null;
-    }
-
-    public ServletContext getServletContext() {
-       return context.getServletContext();
     }
 
     public boolean isAsyncStarted() {
@@ -1524,23 +1518,29 @@
         return false;
     }
 
+    public void doneAsync() throws IllegalStateException {
+        // TODO SERVLET3
+    }
+
     public boolean isAsyncSupported() {
         // TODO SERVLET3
         return false;
     }
 
-    public void setAsyncTimeout(long timeout) {
+    public AsyncDispatcher getAsyncDispatcher() {
         // TODO SERVLET3
+        return null;
     }
 
-    public AsyncContext startAsync() throws IllegalStateException {
-        return startAsync(getRequest(),getResponse().getResponse());
+    public AsyncDispatcher getAsyncDispatcher(String path) {
+        // TODO SERVLET3
+        return null;
     }
+    
 
-    public AsyncContext startAsync(ServletRequest servletRequest,
-            ServletResponse servletResponse) throws IllegalStateException {
+    public void addAsyncListener(AsyncListener listener,
+            ServletRequest servletRequest, ServletResponse servletResponse) {
         // TODO SERVLET3
-        return null;
     }
 
     // ---------------------------------------------------- HttpRequest Methods
@@ -2772,5 +2772,5 @@
         }
         return true;
     }
-    
+
 }

Modified: tomcat/trunk/java/org/apache/catalina/connector/RequestFacade.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/RequestFacade.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/RequestFacade.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/connector/RequestFacade.java Fri Apr 
17 16:30:56 2009
@@ -26,7 +26,7 @@
 import java.util.Locale;
 import java.util.Map;
 
-import javax.servlet.AsyncContext;
+import javax.servlet.AsyncDispatcher;
 import javax.servlet.AsyncListener;
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletContext;
@@ -938,21 +938,6 @@
     }
 
 
-    public void addAsyncListener(AsyncListener listener, ServletRequest 
servletRequest, ServletResponse servletResponse) {
-        request.addAsyncListener(listener,servletRequest,servletResponse);
-    }
-
-
-    public void addAsyncListener(AsyncListener listener) {
-        request.addAsyncListener(listener);
-    }
-
-
-    public AsyncContext getAsyncContext() {
-        return request.getAsyncContext();
-    }
-
-
     public ServletContext getServletContext() {
         if (request == null) {
             throw new IllegalStateException(
@@ -963,30 +948,46 @@
     }
 
 
-    public boolean isAsyncStarted() {
-        return request.isAsyncStarted();
+    public void startAsync() throws IllegalStateException {
+        request.startAsync();
     }
 
 
-    public boolean isAsyncSupported() {
+    public void startAsync(Runnable runnable) throws IllegalStateException {
+        request.startAsync(runnable);
+    }
+
+
+    public boolean isAsyncStarted() {
         return request.isAsyncStarted();
     }
 
 
-    public void setAsyncTimeout(long timeout) {
-        request.setAsyncTimeout(timeout);
+    public void doneAsync() throws IllegalStateException {
+        request.doneAsync();
     }
 
+    
+    public boolean isAsyncSupported() {
+        return request.isAsyncStarted();
+    }
 
-    public AsyncContext startAsync() throws IllegalStateException {
-        return request.startAsync();
+    
+    public AsyncDispatcher getAsyncDispatcher() {
+        return request.getAsyncDispatcher();
     }
 
+    
+    public AsyncDispatcher getAsyncDispatcher(String path) {
+        return request.getAsyncDispatcher(path);
+    }
 
-    public AsyncContext startAsync(ServletRequest 
servletRequest,ServletResponse servletResponse) throws IllegalStateException {
-        return request.startAsync(servletRequest, servletResponse);
+    
+    public void addAsyncListener(AsyncListener listener, ServletRequest 
servletRequest, ServletResponse servletResponse) {
+        request.addAsyncListener(listener,servletRequest,servletResponse);
     }
 
+
     public boolean getAllowTrace() {
         return request.getConnector().getAllowTrace();
     }

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java Fri Apr 
17 16:30:56 2009
@@ -34,6 +34,7 @@
 import javax.naming.Binding;
 import javax.naming.NamingException;
 import javax.naming.directory.DirContext;
+import javax.servlet.AsyncDispatcher;
 import javax.servlet.DispatcherType;
 import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
@@ -44,10 +45,8 @@
 import javax.servlet.SessionTrackingMode;
 
 import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.connector.Connector;
 import org.apache.catalina.deploy.ApplicationParameter;
 import org.apache.catalina.deploy.FilterDef;
 import org.apache.catalina.deploy.FilterMap;
@@ -840,8 +839,14 @@
 
 
     public void addFilter(String filterName, String description,
-            String className, Map<String, String> initParameters,
-            boolean isAsyncSupported) {
+            String className, Map<String, String> initParameters)
+            throws IllegalArgumentException, IllegalStateException {
+        
+        if (context.findFilterDef(filterName) != null) {
+            throw new IllegalArgumentException(sm.getString(
+                    "applicationContext.addFilter.iae", filterName,
+                    getContextPath()));
+        }
 
         if (context.initialized) {
             //TODO Spec breaking enhancement to ignore this restriction
@@ -855,17 +860,53 @@
         filterDef.setFilterClass(className);
         filterDef.getParameterMap().putAll(initParameters);
         context.addFilterDef(filterDef);
-        // TODO SERVLET3 - ASync support
+    }
+
+    
+    public void addServlet(String servletName, String description,
+            String className, Map<String, String> initParameters,
+            int loadOnStartup)
+            throws IllegalArgumentException, IllegalStateException {
+        
+        if (context.findFilterDef(servletName) != null) {
+            throw new IllegalArgumentException(sm.getString(
+                    "applicationContext.addServlet.iae", servletName,
+                    getContextPath()));
+        }
+
+        if (context.initialized) {
+            //TODO Spec breaking enhancement to ignore this restriction
+            throw new IllegalStateException(
+                    sm.getString("applicationContext.addServlet.ise",
+                            getContextPath()));
+        }
+        Wrapper wrapper = context.createWrapper();
+        wrapper.setName(servletName);
+        // Description is ignored
+        wrapper.setServletClass(className);
+        for (Map.Entry<String,String> initParam : initParameters.entrySet()) {
+            wrapper.addInitParameter(initParam.getKey(), initParam.getValue());
+        }
+        wrapper.setLoadOnStartup(loadOnStartup);
+        context.addChild(wrapper);
     }
 
 
     public void addFilterMappingForServletNames(String filterName,
             EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
-            String... servletNames) {
+            String... servletNames)
+            throws IllegalArgumentException, IllegalStateException {
+        
+        if (servletNames == null || servletNames.length == 0) {
+            throw new IllegalArgumentException(sm.getString(
+                    "applicationContext.addFilterMapping.iae.servlet"));
+        }
+
         if (context.initialized) {
             //TODO Spec breaking enhancement to ignore this restriction
             throw new IllegalStateException(sm.getString(
-                    "applicationContext.addFilterMapping", getContextPath()));
+                    "applicationContext.addFilterMapping.ise",
+                    getContextPath()));
         }
         FilterMap filterMap = new FilterMap(); 
         for (String servletName : servletNames) {
@@ -885,12 +926,20 @@
 
     public void addFilterMappingForUrlPatterns(String filterName,
             EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
-            String... urlPatterns) {
+            String... urlPatterns)
+            throws IllegalArgumentException, IllegalStateException {
+        
+        if (urlPatterns == null || urlPatterns.length == 0) {
+            throw new IllegalArgumentException(sm.getString(
+                    "applicationContext.addFilterMapping.iae.url",
+                    getContextPath()));
+        }
         
         if (context.initialized) {
             //TODO Spec breaking enhancement to ignore this restriction
             throw new IllegalStateException(sm.getString(
-                    "applicationContext.addFilterMapping", getContextPath()));
+                    "applicationContext.addFilterMapping.ise",
+                    getContextPath()));
         }
         FilterMap filterMap = new FilterMap(); 
         for (String urlPattern : urlPatterns) {
@@ -908,11 +957,17 @@
     }
 
 
-    public void addServletMapping(String servletName, String[] urlPatterns) {
+    public void addServletMapping(String servletName, String[] urlPatterns)
+            throws IllegalArgumentException, IllegalStateException {
+        if (urlPatterns == null || urlPatterns.length == 0) {
+            throw new IllegalArgumentException(sm.getString(
+                    "applicationContext.addServletMapping.iae"));
+        }
+        
         if (context.initialized) {
             //TODO Spec breaking enhancement to ignore this restriction
             throw new IllegalStateException(sm.getString(
-                    "applicationContext.addServletMapping", getContextPath()));
+                    "applicationContext.addServletMapping.ise", 
getContextPath()));
         }
         for (String urlPattern : urlPatterns) {
             boolean jspWildCard = ("*.jsp".equals(urlPattern));
@@ -941,16 +996,7 @@
             defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
         }
 
-        // Context > Host > Engine > Service
-        Connector[] connectors = ((Engine) context.getParent().getParent())
-                .getService().findConnectors();
-        // Need at least one secure connector to use the SSL session ID.
-        for (Connector connector : connectors) {
-            if (Boolean.TRUE.equals(connector.getAttribute("secure"))) {
-                defaultSessionTrackingModes.add(SessionTrackingMode.SSL);
-                break;
-            }
-        }
+        // SSL not enabled by default as it can only used on its own 
     }
 
     /**
@@ -970,17 +1016,25 @@
     }
 
 
-    public void setSessionCookieConfig(SessionCookieConfig 
sessionCookieConfig) {
+    public void setSessionCookieConfig(SessionCookieConfig sessionCookieConfig)
+            throws IllegalArgumentException {
+        
+        if (context.initialized) {
+            //TODO Spec breaking enhancement to ignore this restriction
+            throw new IllegalStateException(sm.getString(
+                    "applicationContext.setSessionCookieConfig.ise",
+                    getContextPath()));
+        }
+
         this.sessionCookieConfig = sessionCookieConfig;
     }
 
 
     /**
      * @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
+     * @throws IllegalArgumentException If SSL is requested in combination with
+     *                                  anything else or if an unsupported
+     *                                  tracking mode is requested
      */
     public void setSessionTrackingModes(
             EnumSet<SessionTrackingMode> sessionTrackingModes) {
@@ -995,16 +1049,29 @@
         for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) {
             if (!defaultSessionTrackingModes.contains(sessionTrackingMode)) {
                 throw new IllegalArgumentException(sm.getString(
-                        "applicationContext.setSessionTracking.iae",
+                        "applicationContext.setSessionTracking.iae.invalid",
                         sessionTrackingMode.toString(), getContextPath()));
             }
         }
-        // TODO SERVLET3 - The SSL test
+
+        // Check SSL has not be configured with anything else
+        if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) {
+            if (sessionTrackingModes.size() > 1) {
+                throw new IllegalArgumentException(sm.getString(
+                        "applicationContext.setSessionTracking.iae.ssl",
+                        getContextPath()));
+            }
+        }
         
         this.sessionTrackingModes = sessionTrackingModes;
     }
 
 
+    public AsyncDispatcher getAsyncDispatcher(String path) {
+        // TODO SERVLET 3
+        return null;
+    }
+    
     // -------------------------------------------------------- Package Methods
     protected StandardContext getContext() {
         return this.context;

Modified: 
tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 
Fri Apr 17 16:30:56 2009
@@ -33,6 +33,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import javax.servlet.AsyncDispatcher;
 import javax.servlet.DispatcherType;
 import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
@@ -388,15 +389,13 @@
 
        
     public void addFilter(String filterName, String description,
-            String className, Map<String, String> initParameters,
-            boolean isAsyncSupported) {
+            String className, Map<String, String> initParameters) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             doPrivileged("addFilter", new Object[]{filterName, description,
-                    className, initParameters,
-                    Boolean.valueOf(isAsyncSupported)});
+                    className, initParameters});
         } else {
             context.addFilter(filterName, description, className,
-                    initParameters, isAsyncSupported);
+                    initParameters);
         }
     }
 
@@ -429,6 +428,19 @@
     }
 
 
+    public void addServlet(String servletName, String description,
+            String className, Map<String, String> initParameters,
+            int loadOnStartup) {
+        if (SecurityUtil.isPackageProtectionEnabled()) {
+            doPrivileged("addServlet", new Object[]{servletName, description,
+                    className, initParameters, 
Integer.valueOf(loadOnStartup)});
+        } else {
+            context.addServlet(servletName, description, className, 
initParameters,
+                    loadOnStartup);
+        }
+    }
+    
+    
     public void addServletMapping(String servletName, String[] urlPatterns) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             doPrivileged("addServletMapping",
@@ -490,6 +502,17 @@
     }
 
 
+    public AsyncDispatcher getAsyncDispatcher(String path) {
+        if (SecurityUtil.isPackageProtectionEnabled()) {
+            return (AsyncDispatcher)
+                doPrivileged("getAsyncDispatcher",
+                        new Object[]{path});
+        } else {
+            return context.getAsyncDispatcher(path);
+        }
+    }
+    
+    
     /**
      * Use reflection to invoke the requested method. Cache the method object 
      * to speed up the process

Modified: tomcat/trunk/java/org/apache/catalina/core/DummyRequest.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/DummyRequest.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/DummyRequest.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/DummyRequest.java Fri Apr 17 
16:30:56 2009
@@ -30,7 +30,7 @@
 import java.util.Locale;
 import java.util.Map;
 
-import javax.servlet.AsyncContext;
+import javax.servlet.AsyncDispatcher;
 import javax.servlet.AsyncListener;
 import javax.servlet.FilterChain;
 import javax.servlet.RequestDispatcher;
@@ -280,15 +280,13 @@
     public int getRemotePort() { return -1; }
     public void addAsyncListener(AsyncListener listener, ServletRequest req,
             ServletResponse res) {}
-    public void addAsyncListener(AsyncListener listener) {}
-    public AsyncContext getAsyncContext() { return null; }
     public ServletContext getServletContext() { return null; }
     public boolean isAsyncStarted() { return false; }
+    public void doneAsync() {}
     public boolean isAsyncSupported() { return false; }
-    public void setAsyncTimeout(long timeout) {}
-    public AsyncContext startAsync() throws IllegalStateException {
-        return null; }
-    public AsyncContext startAsync(ServletRequest req, ServletResponse res)
-            throws IllegalStateException { return null; }
+    public void startAsync() throws IllegalStateException {}
+    public void startAsync(Runnable runnable) throws IllegalStateException {}
+    public AsyncDispatcher getAsyncDispatcher() { return null; }
+    public AsyncDispatcher getAsyncDispatcher(String path) { return null; }
 }
 

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Fri Apr 
17 16:30:56 2009
@@ -13,16 +13,24 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-applicationContext.addFilter.ise=Filters can not be added to context {0} at 
this time. See SRV.4.4.
-applicationContext.addFilterMapping.ise=Filter mappings can not be added to 
context {0} at this time. See SRV.4.4.
-applicationContext.addServletMapping.ise=Servlet mappings can not be added to 
context {0} at this time. See SRV.4.4.
+applicationContext.addFilter.iae=The filter name {0} already exists in context 
{1}
+applicationContext.addFilter.ise=Filters can not be added to context {0} as 
the context has been initialised
+applicationContext.addFilterMapping.iae.servlet=The list of servletNames 
provided was null or empty
+applicationContext.addFilterMapping.iae.url=The list of urlPatterns provided 
was null or empty
+applicationContext.addFilterMapping.ise=Filter mappings can not be added to 
context {0} as the context has been initialised
+applicationContext.addServlet.iae=The servlet name {0} already exists in 
context {1}
+applicationContext.addServlet.ise=Servlets can not be added to context {0} as 
the context has been initialised
+applicationContext.addServletMapping.iae=The list of urlPatterns provided was 
null or empty
+applicationContext.addServletMapping.ise=Servlet mappings can not be added to 
context {0} as the context has been initialised
 applicationContext.attributeEvent=Exception thrown by attributes event listener
 applicationContext.mapping.error=Error during mapping
 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.addSessionCookieConfig.ise=Session Cookie configuration 
cannot be set for context {0} as the context has been initialised
 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.iae.invalid=The session tracking mode 
{0} requested for context {1} is not supported by that context
+applicationContext.setSessionTracking.iae.ssl=The session tracking modes 
requested for context {1} included SSL and at least one other mode. SSL may not 
be configured with other modes.
 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: tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java?rev=766075&r1=766074&r2=766075&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java 
(original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java Fri Apr 
17 16:30:56 2009
@@ -31,6 +31,7 @@
 import java.util.Set;
 import java.util.Vector;
 
+import javax.servlet.AsyncDispatcher;
 import javax.servlet.DispatcherType;
 import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
@@ -443,8 +444,7 @@
 
 
     public void addFilter(String filterName, String description,
-            String className, Map<String, String> initParameters,
-            boolean isAsyncSupported) {
+            String className, Map<String, String> initParameters) {
         // Do nothing
     }
 
@@ -463,6 +463,14 @@
     }
 
 
+    public void addServlet(String servletName, String description,
+            String className, Map<String, String> initParameters,
+            int loadOnStartup) throws IllegalArgumentException,
+            IllegalStateException {
+        // Do nothing
+    }
+
+
     public void addServletMapping(String servletName, String[] urlPatterns) {
         // Do nothing
     }
@@ -493,4 +501,10 @@
         // Do nothing
     }
 
+
+    public AsyncDispatcher getAsyncDispatcher(String path) {
+        // Do nothing
+        return null;
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to