Author: remy.maucherat(a)jboss.com
Date: 2009-04-08 21:27:49 -0400 (Wed, 08 Apr 2009)
New Revision: 1000
Added:
trunk/java/javax/servlet/Registration.java
trunk/java/org/apache/catalina/core/ApplicationFilterConfigFacade.java
Removed:
trunk/java/org/apache/catalina/core/StandardFilterFacade.java
Modified:
trunk/ROADMAP.txt
trunk/java/javax/servlet/FilterRegistration.java
trunk/java/javax/servlet/ServletContext.java
trunk/java/javax/servlet/ServletRegistration.java
trunk/java/javax/servlet/ServletRequest.java
trunk/java/javax/servlet/ServletRequestWrapper.java
trunk/java/javax/servlet/http/HttpSession.java
trunk/java/org/apache/catalina/Wrapper.java
trunk/java/org/apache/catalina/core/ApplicationContext.java
trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
trunk/java/org/apache/catalina/core/DummyRequest.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/jasper/servlet/JspCServletContext.java
trunk/java/org/apache/tomcat/InstanceManager.java
Log:
- Update Servlet 3.0 API.
- Redo filter registration impl.
- Add dynamic flag for the registration types.
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/ROADMAP.txt 2009-04-09 01:27:49 UTC (rev 1000)
@@ -2,7 +2,6 @@
Main development:
- Setup standalone TCK environment for testing compliance with the new features
-- Servlet 3.0 async API using event API
- Update digester XML parsing rules for web.xml updates
- web.xml fragments scanning
- Annotation scanning for JBoss Web standalone (likely disabled by default using
conf/web.xml)
Modified: trunk/java/javax/servlet/FilterRegistration.java
===================================================================
--- trunk/java/javax/servlet/FilterRegistration.java 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/java/javax/servlet/FilterRegistration.java 2009-04-09 01:27:49 UTC (rev 1000)
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -37,105 +37,17 @@
package javax.servlet;
import java.util.EnumSet;
-import java.util.Map;
/**
- * Class through which a {@link Filter} (either annotated or declared
- * in the deployment descriptor or added via
- * {@link ServletContext#addFilter(String, String)}) may be further
- * configured.
+ * Interface through which a {@link Filter} may be further configured.
*
- * <p>While all aspects of a Filter added via
- * {@link ServletContext#addFilter(String, String)}) are configurable,
- * the only configurable aspects of an annotated or declared Filter are
- * its initialization parameters and mappings. Initialization parameters
- * may only be added, but not overridden.
- *
* @since 3.0
*/
-public interface FilterRegistration {
+public interface FilterRegistration extends Registration {
/**
- * Sets the description on the filter for which this
- * FilterRegistration was created.
- *
- * <p>A call to this method overrides any previous setting.
- *
- * @param description the description of the filter
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalStateException if the ServletContext from which this
- * FilterRegistration was obtained has already been initialized
- */
- public boolean setDescription(String description);
-
-
- /**
- * Sets the initialization parameter with the given name and value
- * on the filter for which this FilterRegistration was created.
- *
- * @param name the initialization parameter name
- * @param value the initialization parameter value
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalStateException if the ServletContext from which this
- * FilterRegistration was obtained has already been initialized
- * @throws IllegalArgumentException if the given name or value is
- * <tt>null</tt>
- */
- public boolean setInitParameter(String name, String value);
-
-
- /**
- * Sets the given initialization parameters on the filter for which
- * this FilterRegistration was created.
- *
- * <p>The given map of initialization parameters is processed
- * <i>by-value</i>, i.e., for each initialization parameter contained
- * in the map, this method calls {@link #setInitParameter(String,String)}.
- * If that method would return false for any of the
- * initialization parameters in the given map, no updates will be
- * performed, and false will be returned. Likewise, if the map contains
- * an initialization parameter with a <tt>null</tt> name or value, no
- * updates will be performed, and an IllegalArgumentException will be
- * thrown.
- *
- * @param initParameters the initialization parameters
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalStateException if the ServletContext from which this
- * FilterRegistration was obtained has already been initialized
- * @throws IllegalArgumentException if the given map contains an
- * initialization parameter with a <tt>null</tt> name or value
- */
- public boolean setInitParameters(Map<String, String> initParameters);
-
-
- /**
- * Configures the filter for which this FilterRegistration was created
- * as supporting asynchronous operations or not.
- *
- * <p>By default, a filter does not support asynchronous operations.
- *
- * <p>A call to this method overrides any previous setting.
- *
- * @param isAsyncSupported true if the filter supports asynchronous
- * operations, false otherwise
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalStateException if the ServletContext from which this
- * FilterRegistration was obtained has already been initialized
- */
- public boolean setAsyncSupported(boolean isAsyncSupported);
-
-
- /**
* Adds a filter mapping with the given servlet names and dispatcher
- * types for the filter for which this FilterRegistration was created.
+ * types for the Filter represented by this FilterRegistration.
*
* <p>Filter mappings are matched in the order in which they were
* added.
@@ -164,10 +76,9 @@
EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
String... servletNames);
-
/**
* Adds a filter mapping with the given url patterns and dispatcher
- * types for the filter for which this FilterRegistration was created.
+ * types for the Filter represented by this FilterRegistration.
*
* <p>Filter mappings are matched in the order in which they were
* added.
@@ -195,5 +106,13 @@
public boolean addMappingForUrlPatterns(
EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
String... urlPatterns);
+
+ /**
+ * Interface through which a {@link Filter} registered via one of the
+ * <tt>addFilter</tt> methods on {@link ServletContext} may be further
+ * configured.
+ */
+ interface Dynamic extends FilterRegistration, Registration.Dynamic {
+ }
}
Added: trunk/java/javax/servlet/Registration.java
===================================================================
--- trunk/java/javax/servlet/Registration.java (rev 0)
+++ trunk/java/javax/servlet/Registration.java 2009-04-09 01:27:49 UTC (rev 1000)
@@ -0,0 +1,132 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License").
You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at
https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package javax.servlet;
+
+import java.util.Map;
+
+/**
+ * Interface through which a {@link Servlet} or {@link Filter} may be
+ * further configured.
+ *
+ * @since 3.0
+ */
+public interface Registration {
+
+ /**
+ * Sets the initialization parameter with the given name and value
+ * on the Servlet or Filter that is represented by this Registration.
+ *
+ * @param name the initialization parameter name
+ * @param value the initialization parameter value
+ *
+ * @return true if the update was successful, i.e., an initialization
+ * parameter with the given name did not already exist for the Servlet
+ * or Filter represented by this Registration, and false otherwise
+ *
+ * @throws IllegalStateException if the ServletContext from which this
+ * Registration was obtained has already been initialized
+ * @throws IllegalArgumentException if the given name or value is
+ * <tt>null</tt>
+ */
+ public boolean setInitParameter(String name, String value);
+
+ /**
+ * Sets the given initialization parameters on the Servlet or Filter
+ * that is represented by this Registration.
+ *
+ * <p>The given map of initialization parameters is processed
+ * <i>by-value</i>, i.e., for each initialization parameter contained
+ * in the map, this method calls {@link #setInitParameter(String,String)}.
+ * If that method would return false for any of the
+ * initialization parameters in the given map, no updates will be
+ * performed, and false will be returned. Likewise, if the map contains
+ * an initialization parameter with a <tt>null</tt> name or value, no
+ * updates will be performed, and an IllegalArgumentException will be
+ * thrown.
+ *
+ * @param initParameters the initialization parameters
+ *
+ * @return true if the update was successful, false otherwise
+ *
+ * @throws IllegalStateException if the ServletContext from which this
+ * Registration was obtained has already been initialized
+ * @throws IllegalArgumentException if the given map contains an
+ * initialization parameter with a <tt>null</tt> name or value
+ */
+ public boolean setInitParameters(Map<String, String> initParameters);
+
+ /**
+ * Interface through which a {@link Servlet} or {@link Filter} registered
+ * via one of the <tt>addServlet</tt> or <tt>addFilter</tt>
methods,
+ * respectively, on {@link ServletContext} may be further configured.
+ */
+ interface Dynamic extends Registration {
+
+ /**
+ * Sets the description on the Servlet or Filter represented by
+ * this dynamic Registration.
+ *
+ * <p>A call to this method overrides any previous setting.
+ *
+ * @param description the description of the servlet
+ *
+ * @throws IllegalStateException if the ServletContext from which
+ * this dynamic Registration was obtained has already been initialized
+ */
+ public void setDescription(String description);
+
+ /**
+ * Configures the Servlet or Filter represented by this dynamic
+ * Registration as supporting asynchronous operations or not.
+ *
+ * <p>By default, servlet and filters do not support asynchronous
+ * operations.
+ *
+ * <p>A call to this method overrides any previous setting.
+ *
+ * @param isAsyncSupported true if the Servlet or Filter represented
+ * by this dynamic Registration supports asynchronous operations,
+ * false otherwise
+ *
+ * @throws IllegalStateException if the ServletContext from which
+ * this dynamic Registration was obtained has already been
+ * initialized
+ */
+ public void setAsyncSupported(boolean isAsyncSupported);
+ }
+}
+
Modified: trunk/java/javax/servlet/ServletContext.java
===================================================================
--- trunk/java/javax/servlet/ServletContext.java 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/java/javax/servlet/ServletContext.java 2009-04-09 01:27:49 UTC (rev 1000)
@@ -663,8 +663,8 @@
*
* @since 3.0
*/
- public ServletRegistration addServlet(String servletName,
- String className);
+ public ServletRegistration.Dynamic addServlet(
+ String servletName, String className);
/*
@@ -690,8 +690,8 @@
*
* @since 3.0
*/
- public ServletRegistration addServlet(String servletName,
- Servlet servlet);
+ public ServletRegistration.Dynamic addServlet(
+ String servletName, Servlet servlet);
/*
@@ -713,7 +713,7 @@
*
* @since 3.0
*/
- public ServletRegistration addServlet(String servletName,
+ public ServletRegistration.Dynamic addServlet(String servletName,
Class <? extends Servlet> servletClass);
@@ -774,7 +774,8 @@
*
* @since 3.0
*/
- public FilterRegistration addFilter(String filterName, String className);
+ public FilterRegistration.Dynamic addFilter(
+ String filterName, String className);
/*
@@ -798,7 +799,8 @@
*
* @since 3.0
*/
- public FilterRegistration addFilter(String filterName, Filter filter);
+ public FilterRegistration.Dynamic addFilter(
+ String filterName, Filter filter);
/**
@@ -820,7 +822,7 @@
*
* @since 3.0
*/
- public FilterRegistration addFilter(String filterName,
+ public FilterRegistration.Dynamic addFilter(String filterName,
Class <? extends Filter> filterClass);
Modified: trunk/java/javax/servlet/ServletRegistration.java
===================================================================
--- trunk/java/javax/servlet/ServletRegistration.java 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/java/javax/servlet/ServletRegistration.java 2009-04-09 01:27:49 UTC (rev 1000)
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
@@ -36,144 +36,63 @@
package javax.servlet;
-import java.util.Map;
-
/**
- * Class through which a {@link Servlet} (either annotated or declared
- * in the deployment descriptor or added via
- * {@link ServletContext#addServlet(String, String)}) may be further
- * configured.
+ * Interface through which a {@link Servlet} may be further configured.
*
- * <p>While all aspects of a Servlet added via
- * {@link ServletContext#addServlet(String, String)}) are configurable,
- * the only configurable aspects of an annotated or declared Servlet are
- * its initialization parameters and mappings. Initialization parameters
- * may only be added, but not overridden.
- *
* @since 3.0
*/
-public interface ServletRegistration {
+public interface ServletRegistration extends Registration {
/**
- * Sets the description on the servlet for which this ServletRegistration
- * was created.
+ * Adds a servlet mapping with the given URL patterns for the Servlet
+ * represented by this ServletRegistration.
*
- * <p>A call to this method overrides any previous setting.
+ * @param urlPatterns the URL patterns of the servlet mapping
*
- * @param description the description of the servlet
- *
* @return true if the update was successful, false otherwise
*
+ * @throws IllegalArgumentException if <tt>urlPatterns</tt> is null
+ * or empty
* @throws IllegalStateException if the ServletContext from which this
* ServletRegistration was obtained has already been initialized
*/
- public boolean setDescription(String description);
+ public boolean addMapping(String... urlPatterns);
-
/**
- * Sets the initialization parameter with the given name and value
- * on the servlet for which this ServletRegistration was created.
- *
- * @param name the initialization parameter name
- * @param value the initialization parameter value
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalStateException if the ServletContext from which this
- * ServletRegistration was obtained has already been initialized
- * @throws IllegalArgumentException if the given name or value is
- * <tt>null</tt>
- */
- public boolean setInitParameter(String name, String value);
-
-
- /**
- * Sets the given initialization parameters on the servlet for which
- * this ServletRegistration was created.
- *
- * <p>The given map of initialization parameters is processed
- * <i>by-value</i>, i.e., for each initialization parameter contained
- * in the map, this method calls {@link #setInitParameter(String,String)}.
- * If that method would return false for any of the
- * initialization parameters in the given map, no updates will be
- * performed, and false will be returned. Likewise, if the map contains
- * an initialization parameter with a <tt>null</tt> name or value, no
- * updates will be performed, and an IllegalArgumentException will be
- * thrown.
- *
- * @param initParameters the initialization parameters
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalStateException if the ServletContext from which this
- * ServletRegistration was obtained has already been initialized
- * @throws IllegalArgumentException if the given map contains an
- * initialization parameter with a <tt>null</tt> name or value
- */
- public boolean setInitParameters(Map<String, String> initParameters);
-
-
- /**
- * Sets the <code>loadOnStartup</code> priority on the servlet for which
- * this ServletRegistration was created.
- *
- * <p>A <tt>loadOnStartup</tt> value of greater than or equal to
zero
- * indicates to the container the initialization priority of the
- * servlet. In this case, the container must instantiate and initialize
- * the servlet during the initialization phase of this servlet context,
- * that is, after it has invoked all of the ServletContextListeners
- * configured for this servlet context at their
- * {@link ServletContextListener#contextInitialized} method.
- *
- * <p>If <tt>loadOnStartup</tt> is a negative integer, the
container
- * is free to instantiate and initialize the servlet lazily.
- *
- * <p>The default value for <tt>loadOnStartup</tt> is
<code>-1</code>.
- *
- * <p>A call to this method overrides any previous setting.
- *
- * @param loadOnStartup the initialization priority of the servlet
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalStateException if the ServletContext from which this
- * ServletRegistration was obtained has already been initialized
+ * Interface through which a {@link Servlet} registered via one of the
+ * <tt>addServlet</tt> methods on {@link ServletContext} may be further
+ * configured.
*/
- public boolean setLoadOnStartup(int loadOnStartup);
+ interface Dynamic extends ServletRegistration, Registration.Dynamic {
+ /**
+ * Sets the <code>loadOnStartup</code> priority on the Servlet
+ * represented by this dynamic ServletRegistration.
+ *
+ * <p>A <tt>loadOnStartup</tt> value of greater than or equal
to
+ * zero indicates to the container the initialization priority of
+ * the Servlet. In this case, the container must instantiate and
+ * initialize the Servlet during the initialization phase of the
+ * ServletContext, that is, after it has invoked all of the
+ * ServletContextListener objects configured for the ServletContext
+ * at their {@link ServletContextListener#contextInitialized}
+ * method.
+ *
+ * <p>If <tt>loadOnStartup</tt> is a negative integer, the
container
+ * is free to instantiate and initialize the Servlet lazily.
+ *
+ * <p>The default value for <tt>loadOnStartup</tt> is
<code>-1</code>.
+ *
+ * <p>A call to this method overrides any previous setting.
+ *
+ * @param loadOnStartup the initialization priority of the Servlet
+ *
+ * @throws IllegalStateException if the ServletContext from which
+ * this dynamic ServletRegistration was obtained has already been
+ * initialized
+ */
+ public void setLoadOnStartup(int loadOnStartup);
+ }
- /**
- * Configures the servlet for which this ServletRegistration was
- * created as supporting asynchronous operations or not.
- *
- * <p>By default, a servlet does not support asynchronous operations.
- *
- * <p>A call to this method overrides any previous setting.
- *
- * @param isAsyncSupported true if the servlet supports asynchronous
- * operations, false otherwise
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalStateException if the ServletContext from which this
- * ServletRegistration was obtained has already been initialized
- */
- public boolean setAsyncSupported(boolean isAsyncSupported);
-
-
- /**
- * Adds a servlet mapping with the given URL patterns for the servlet
- * for which this ServletRegistration was created.
- *
- * @param urlPatterns the URL patterns of the servlet mapping
- *
- * @return true if the update was successful, false otherwise
- *
- * @throws IllegalArgumentException if <tt>urlPatterns</tt> is null
- * or empty
- * @throws IllegalStateException if the ServletContext from which this
- * ServletRegistration was obtained has already been initialized
- */
- public boolean addMapping(String... urlPatterns);
}
Modified: trunk/java/javax/servlet/ServletRequest.java
===================================================================
--- trunk/java/javax/servlet/ServletRequest.java 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/java/javax/servlet/ServletRequest.java 2009-04-09 01:27:49 UTC (rev 1000)
@@ -613,8 +613,8 @@
/**
* Puts this request into asynchronous mode, and initializes its
* {@link AsyncContext} with the original (unwrapped) ServletRequest
- * and ServletResponse objects and the timeout derived according
- * to the rules laid out in {@link #setAsyncTimeout}.
+ * and ServletResponse objects and the timeout as returned by
+ * {@link #getAsyncTimeout}.
*
* <p>This will delay committal of the associated response until
* {@link AsyncContext#complete} is called on the returned
@@ -659,8 +659,7 @@
/**
* Puts this request into asynchronous mode, and initializes its
* {@link AsyncContext} with the given request and response objects
- * and the timeout derived according to the rules laid out in
- * {@link #setAsyncTimeout}.
+ * and the timeout as returned by {@link #getAsyncTimeout}.
*
* <p>The ServletRequest and ServletResponse parameters must be either
* the same objects as were passed to the calling servlet's service
@@ -844,10 +843,11 @@
* started on this request by a call to {@link #startAsync} or
* {@link #startAsync(ServletRequest, ServletResponse)}.
*
- * <p>By default, the timeout specified via the
- * <code>async-timeout</code> deployment descriptor element or the
- * <code>asyncTimeout</code> annotation of the servlet or filter that
- * started the asynchronous operation will be used.
+ * <p>By default, the container's default timeout for asynchronous
+ * operations, which is available via a call to
+ * {@link #getAsyncTimeout}, will be used.
+ * A timeout value of 0 or less indicates that the asynchronous
+ * operations will never time out.
*
* <p>If neither {@link AsyncContext#complete} nor
* {@link AsyncContext#dispatch} is called within the
@@ -878,6 +878,26 @@
/**
+ * Gets the timeout (in milliseconds) for any asynchronous operations
+ * initiated on this request by a call to {@link #startAsync} or
+ * {@link #startAsync(ServletRequest, ServletResponse)}.
+ *
+ * <p>This method returns the container's default timeout for
+ * asynchronous operations, or the timeout value passed to the most
+ * recent invocation of {@link #setAsyncTimeout}.
+ *
+ * <p>A timeout value of 0 or less indicates that the asynchronous
+ * operation will never time out.
+ *
+ * @return the timeout in milliseconds for any asynchronous
+ * operations started on this request
+ *
+ * @since 3.0
+ */
+ public long getAsyncTimeout();
+
+
+ /**
* Gets the dispatcher type of this request.
*
* <p>The dispatcher type of a request is used by the container
Modified: trunk/java/javax/servlet/ServletRequestWrapper.java
===================================================================
--- trunk/java/javax/servlet/ServletRequestWrapper.java 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/java/javax/servlet/ServletRequestWrapper.java 2009-04-09 01:27:49 UTC (rev
1000)
@@ -544,11 +544,10 @@
/**
* Sets the timeout (in milliseconds) for any asynchronous operations
- * started on the wrapped request by a call to {@link #startAsync} or
- * {@link #startAsync(ServletRequest, ServletResponse)}.
+ * initiated on the wrapped request.
*
* @param timeout the timeout in milliseconds for any asynchronous
- * operations started on the wrapped request
+ * operations initiated on the wrapped request
*
* @throws IllegalStateException if called after {@link #startAsync},
* unless within the scope of a dispatch resulting from an
@@ -564,6 +563,22 @@
/**
+ * Gets the timeout (in milliseconds) for any asynchronous operations
+ * initiated on the wrapped request.
+ *
+ * @return the timeout in milliseconds for any asynchronous
+ * operations initiated on the wrapped request
+ *
+ * @see ServletRequest#getAsyncTimeout
+ *
+ * @since 3.0
+ */
+ public long getAsyncTimeout() {
+ return request.getAsyncTimeout();
+ }
+
+
+ /**
* Checks (recursively) if this ServletRequestWrapper wraps the given
* {@link ServletRequest} instance.
*
Modified: trunk/java/javax/servlet/http/HttpSession.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSession.java 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/java/javax/servlet/http/HttpSession.java 2009-04-09 01:27:49 UTC (rev 1000)
@@ -106,14 +106,10 @@
*
* @see HttpSessionBindingListener
* @see HttpSessionContext
- *
*/
public interface HttpSession {
-
-
-
/**
*
* Returns the time when this session was created, measured
@@ -126,16 +122,11 @@
*
* @exception IllegalStateException if this method is called on an
* invalidated session
- *
*/
-
public long getCreationTime();
-
-
-
+
/**
- *
* Returns a string containing the unique identifier assigned
* to this session. The identifier is assigned
* by the servlet container and is implementation dependent.
@@ -143,17 +134,15 @@
* @return a string specifying the identifier
* assigned to this session
*/
-
public String getId();
-
-
/**
*
* Returns the last time the client sent a request associated with
* this session, as the number of milliseconds since midnight
- * January 1, 1970 GMT, and marked by the time the container received the request.
+ * January 1, 1970 GMT, and marked by the time the container received the
+ * request.
*
* <p>Actions that your application takes, such as getting or setting
* a value associated with the session, do not affect the access
@@ -167,77 +156,63 @@
*
* @exception IllegalStateException if this method is called on an
* invalidated session
- *
*/
-
public long getLastAccessedTime();
/**
- * Returns the ServletContext to which this session belongs.
- *
- * @return The ServletContext object for the web application
- * @since 2.3
- */
-
+ * Returns the ServletContext to which this session belongs.
+ *
+ * @return The ServletContext object for the web application
+ * @since 2.3
+ */
public ServletContext getServletContext();
/**
- *
* Specifies the time, in seconds, between client requests before the
- * servlet container will invalidate this session. A negative time
- * indicates the session should never timeout.
+ * servlet container will invalidate this session.
*
+ * <p>An <tt>interval</tt> value of zero or less indicates that
the
+ * session should never timeout.
+ *
* @param interval An integer specifying the number
* of seconds
- *
- */
-
+ */
public void setMaxInactiveInterval(int interval);
-
-
- /**
- * Returns the maximum time interval, in seconds, that
- * the servlet container will keep this session open between
- * client accesses. After this interval, the servlet container
- * will invalidate the session. The maximum time interval can be set
- * with the <code>setMaxInactiveInterval</code> method.
- * A negative time indicates the session should never timeout.
- *
- *
- * @return an integer specifying the number of
- * seconds this session remains open
- * between client requests
- *
- * @see #setMaxInactiveInterval
- *
- *
- */
-
+ /**
+ * Returns the maximum time interval, in seconds, that
+ * the servlet container will keep this session open between
+ * client accesses. After this interval, the servlet container
+ * will invalidate the session. The maximum time interval can be set
+ * with the <code>setMaxInactiveInterval</code> method.
+ *
+ * <p>A return value of zero or less indicates that the
+ * session will never timeout.
+ *
+ * @return an integer specifying the number of
+ * seconds this session remains open
+ * between client requests
+ *
+ * @see #setMaxInactiveInterval
+ */
public int getMaxInactiveInterval();
-
-
- /**
- *
- * @deprecated As of Version 2.1, this method is
- * deprecated and has no replacement.
- * It will be removed in a future
- * version of the Java Servlet API.
- *
- */
-
+ /**
+ *
+ * @deprecated As of Version 2.1, this method is
+ * deprecated and has no replacement.
+ * It will be removed in a future
+ * version of the Java Servlet API.
+ *
+ */
public HttpSessionContext getSessionContext();
-
-
-
+
/**
- *
* Returns the object bound with the specified name in this session, or
* <code>null</code> if no object is bound under the name.
*
@@ -247,16 +222,11 @@
*
* @exception IllegalStateException if this method is called on an
* invalidated session
- *
*/
-
public Object getAttribute(String name);
-
-
/**
- *
* @deprecated As of Version 2.2, this method is
* replaced by {@link #getAttribute}.
*
@@ -266,16 +236,11 @@
*
* @exception IllegalStateException if this method is called on an
* invalidated session
- *
*/
-
public Object getValue(String name);
-
-
-
+
/**
- *
* Returns an <code>Enumeration</code> of <code>String</code>
objects
* containing the names of all the objects bound to this session.
*
@@ -286,16 +251,11 @@
*
* @exception IllegalStateException if this method is called on an
* invalidated session
- *
- */
-
+ */
public Enumeration<String> getAttributeNames();
-
-
/**
- *
* @deprecated As of Version 2.2, this method is
* replaced by {@link #getAttributeNames}
*
@@ -306,13 +266,9 @@
*
* @exception IllegalStateException if this method is called on an
* invalidated session
- *
*/
-
public String[] getValueNames();
-
-
/**
* Binds an object to this session, using the name specified.
@@ -341,17 +297,11 @@
*
* @exception IllegalStateException if this method is called on an
* invalidated session
- *
*/
-
public void setAttribute(String name, Object value);
-
-
-
/**
- *
* @deprecated As of Version 2.2, this method is
* replaced by {@link #setAttribute}
*
@@ -362,17 +312,11 @@
*
* @exception IllegalStateException if this method is called on an
* invalidated session
- *
*/
-
public void putValue(String name, Object value);
-
-
-
/**
- *
* Removes the object bound with the specified name from
* this session. If the session does not have an object
* bound with the specified name, this method does nothing.
@@ -383,8 +327,6 @@
* <code>HttpSessionBindingListener.valueUnbound</code>. The container
* then notifies any <code>HttpSessionAttributeListener</code>s in the
web
* application.
- *
- *
*
* @param name the name of the object to
* remove from this session
@@ -392,15 +334,10 @@
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
-
public void removeAttribute(String name);
-
-
-
/**
- *
* @deprecated As of Version 2.2, this method is
* replaced by {@link #removeAttribute}
*
@@ -410,29 +347,20 @@
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
-
public void removeValue(String name);
-
-
/**
- *
* Invalidates this session then unbinds any objects bound
* to it.
*
* @exception IllegalStateException if this method is called on an
* already invalidated session
- *
*/
-
public void invalidate();
-
-
/**
- *
* Returns <code>true</code> if the client does not yet know about the
* session or if the client chooses not to join the session. For
* example, if the server used only cookie-based sessions, and
@@ -445,7 +373,6 @@
*
* @exception IllegalStateException if this method is called on an
* already invalidated session
- *
*/
public boolean isNew();
Modified: trunk/java/org/apache/catalina/Wrapper.java
===================================================================
--- trunk/java/org/apache/catalina/Wrapper.java 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/java/org/apache/catalina/Wrapper.java 2009-04-09 01:27:49 UTC (rev 1000)
@@ -104,6 +104,21 @@
/**
+ * Get the flag that indicates if the wrapper was added programmatically.
+ * The flag value defaults to false.
+ */
+ public boolean isDynamic();
+
+
+ /**
+ * Set a flag that indicates if the wrapper was added programmatically.
+ *
+ * @param value New async supported value
+ */
+ public void setDynamic(boolean dynamic);
+
+
+ /**
* Return the InstanceSupport object for this Wrapper instance.
*/
public InstanceSupport getInstanceSupport();
@@ -265,6 +280,13 @@
/**
+ * Set the associated servlet instance. This will only do something
+ * meaningful for non STM servlets.
+ */
+ public void setServlet(Servlet servlet);
+
+
+ /**
* Return the value for the specified initialization parameter name,
* if any; otherwise return <code>null</code>.
*
Modified: trunk/java/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-04-08 21:24:35 UTC
(rev 999)
+++ trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-04-09 01:27:49 UTC
(rev 1000)
@@ -1,18 +1,46 @@
/*
- * 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
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*
- *
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.
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.
*/
@@ -808,37 +836,93 @@
}
- public FilterRegistration addFilter(String filterName, String className)
+ public FilterRegistration.Dynamic addFilter(String filterName, String className)
throws IllegalArgumentException, IllegalStateException {
if (context.isInitialized()) {
- throw new
IllegalStateException(sm.getString("applicationContext.addFilter.ise",
+ throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
FilterDef filterDef = new FilterDef();
filterDef.setFilterName(filterName);
filterDef.setFilterClass(className);
- context.addFilterDef(filterDef);
- return new StandardFilterFacade(context, filterDef);
+ ApplicationFilterConfig filterConfig = new ApplicationFilterConfig(context,
filterDef);
+ filterConfig.setDynamic(true);
+ context.addApplicationFilterConfig(filterConfig);
+ return (FilterRegistration.Dynamic) filterConfig.getFacade();
}
- public ServletRegistration addServlet(String servletName, String className)
+ public FilterRegistration.Dynamic addFilter(String filterName, Filter filter) {
+ if (context.isInitialized()) {
+ throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
+ getContextPath()));
+ }
+ FilterDef filterDef = new FilterDef();
+ filterDef.setFilterName(filterName);
+ filterDef.setFilterClass(filter.getClass().getName());
+ ApplicationFilterConfig filterConfig = new ApplicationFilterConfig(context,
filterDef);
+ filterConfig.setDynamic(true);
+ filterConfig.setFilter(filter);
+ context.addApplicationFilterConfig(filterConfig);
+ return (FilterRegistration.Dynamic) filterConfig.getFacade();
+ }
+
+
+ public FilterRegistration.Dynamic addFilter(String filterName,
+ Class<? extends Filter> filterClass) {
+ return addFilter(filterName, filterClass.getName());
+ }
+
+
+ public ServletRegistration.Dynamic addServlet(String servletName, String className)
throws IllegalArgumentException, IllegalStateException {
+ if (context.isInitialized()) {
+ throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
+ getContextPath()));
+ }
Wrapper wrapper = context.createWrapper();
+ wrapper.setDynamic(true);
wrapper.setName(servletName);
wrapper.setServletClass(className);
context.addChild(wrapper);
- return wrapper.getFacade();
+ return (ServletRegistration.Dynamic) wrapper.getFacade();
}
+ public ServletRegistration.Dynamic addServlet(String servletName,
+ Class<? extends Servlet> clazz) throws IllegalArgumentException,
+ IllegalStateException {
+ return addServlet(servletName, clazz.getName());
+ }
+
+
+ public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) {
+ if (context.isInitialized()) {
+ throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
+ getContextPath()));
+ }
+ Wrapper wrapper = context.createWrapper();
+ wrapper.setDynamic(true);
+ wrapper.setName(servletName);
+ wrapper.setServletClass(servlet.getClass().getName());
+ wrapper.setServlet(servlet);
+ context.addChild(wrapper);
+ return (ServletRegistration.Dynamic) wrapper.getFacade();
+ }
+
+
public FilterRegistration findFilterRegistration(String filterName) {
- FilterDef filterDef = context.findFilterDef(filterName);
- if (filterDef == null) {
- return null;
- } else {
- return new StandardFilterFacade(context, filterDef);
+ ApplicationFilterConfig filterConfig =
context.findApplicationFilterConfig(filterName);
+ if (filterConfig == null) {
+ FilterDef filterDef = context.findFilterDef(filterName);
+ if (filterDef == null) {
+ return null;
+ } else {
+ filterConfig = new ApplicationFilterConfig(context, filterDef);
+ context.addApplicationFilterConfig(filterConfig);
+ }
}
+ return filterConfig.getFacade();
}
@@ -877,61 +961,36 @@
return context.getSessionCookie();
}
-/* FIXME gone ?
- public void setSessionCookieConfig(SessionCookieConfig sessionCookieConfig) {
- SessionCookie sessionCookie = new SessionCookie();
- sessionCookie.setComment(sessionCookieConfig.getComment());
- sessionCookie.setDomain(sessionCookieConfig.getDomain());
- sessionCookie.setHttpOnly(sessionCookieConfig.isHttpOnly());
- sessionCookie.setSecure(sessionCookieConfig.isSecure());
- context.setSessionCookie(sessionCookie);
- }*/
-
- public ServletRegistration addServlet(String servletName,
- Class<? extends Servlet> clazz) throws IllegalArgumentException,
- IllegalStateException {
- return addServlet(servletName, clazz.getName());
- }
-
-
- public FilterRegistration addFilter(String filterName, Filter filter) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
- public FilterRegistration addFilter(String filterName,
- Class<? extends Filter> filterClass) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
- public ServletRegistration addServlet(String servletName, Servlet servlet) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
public <T extends Filter> T createFilter(Class<T> c)
throws ServletException {
- // TODO Auto-generated method stub
- return null;
+ try {
+ return (T) context.getInstanceManager().newInstance(c);
+ } catch (Throwable e) {
+ throw new ServletException
+ (sm.getString("applicationContext.create"), e);
+ }
}
public <T extends Servlet> T createServlet(Class<T> c)
throws ServletException {
- // TODO Auto-generated method stub
- return null;
+ try {
+ return (T) context.getInstanceManager().newInstance(c);
+ } catch (Throwable e) {
+ throw new ServletException
+ (sm.getString("applicationContext.create"), e);
+ }
}
public boolean setInitParameter(String name, String value) {
- context.addParameter(name, value);
- // FIXME: return value ?
- return false;
+ try {
+ context.addParameter(name, value);
+ return true;
+ } catch (IllegalStateException e) {
+ return false;
+ }
}
Modified: trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 2009-04-08 21:24:35
UTC (rev 999)
+++ trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 2009-04-09 01:27:49
UTC (rev 1000)
@@ -1,18 +1,46 @@
/*
- * 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
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*
- *
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.
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.
*/
@@ -373,10 +401,10 @@
}
- public FilterRegistration addFilter(String filterName, String className)
+ public FilterRegistration.Dynamic addFilter(String filterName, String className)
throws IllegalArgumentException, IllegalStateException {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (FilterRegistration) doPrivileged("addFilter",
+ return (FilterRegistration.Dynamic) doPrivileged("addFilter",
new Object[]{filterName, className});
} else {
return context.addFilter(filterName, className);
@@ -384,9 +412,9 @@
}
- public FilterRegistration addFilter(String filterName, Filter filter) {
+ public FilterRegistration.Dynamic addFilter(String filterName, Filter filter) {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (FilterRegistration) doPrivileged("addFilter",
+ return (FilterRegistration.Dynamic) doPrivileged("addFilter",
new Object[]{filterName, filter});
} else {
return context.addFilter(filterName, filter);
@@ -394,10 +422,10 @@
}
- public FilterRegistration addFilter(String filterName,
+ public FilterRegistration.Dynamic addFilter(String filterName,
Class<? extends Filter> filterClass) {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (FilterRegistration) doPrivileged("addFilter",
+ return (FilterRegistration.Dynamic) doPrivileged("addFilter",
new Object[]{filterName, filterClass});
} else {
return context.addFilter(filterName, filterClass);
@@ -405,10 +433,10 @@
}
- public ServletRegistration addServlet(String servletName, String className)
+ public ServletRegistration.Dynamic addServlet(String servletName, String className)
throws IllegalArgumentException, IllegalStateException {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (ServletRegistration) doPrivileged("addServlet",
+ return (ServletRegistration.Dynamic) doPrivileged("addServlet",
new Object[]{servletName, className});
} else {
return context.addServlet(servletName, className);
@@ -416,11 +444,11 @@
}
- public ServletRegistration addServlet(String servletName,
+ public ServletRegistration.Dynamic addServlet(String servletName,
Class<? extends Servlet> clazz) throws IllegalArgumentException,
IllegalStateException {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (ServletRegistration) doPrivileged("addServlet",
+ return (ServletRegistration.Dynamic) doPrivileged("addServlet",
new Object[]{servletName, clazz});
} else {
return context.addServlet(servletName, clazz);
@@ -428,9 +456,9 @@
}
- public ServletRegistration addServlet(String servletName, Servlet servlet) {
+ public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (ServletRegistration) doPrivileged("addServlet",
+ return (ServletRegistration.Dynamic) doPrivileged("addServlet",
new Object[]{servletName, servlet});
} else {
return context.addServlet(servletName, servlet);
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-04-08 21:24:35
UTC (rev 999)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-04-09 01:27:49
UTC (rev 1000)
@@ -1,18 +1,46 @@
/*
- * 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
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*
- *
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.
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.
*/
@@ -22,19 +50,24 @@
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.EnumSet;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import javax.naming.NamingException;
+import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
+import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.deploy.FilterDef;
+import org.apache.catalina.deploy.FilterMap;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.StringManager;
@@ -67,28 +100,10 @@
* @param context The context with which we are associated
* @param filterDef Filter definition for which a FilterConfig is to be
* constructed
- *
- * @exception ClassCastException if the specified class does not implement
- * the <code>javax.servlet.Filter</code> interface
- * @exception ClassNotFoundException if the filter class cannot be found
- * @exception IllegalAccessException if the filter class cannot be
- * publicly instantiated
- * @exception InstantiationException if an exception occurs while
- * instantiating the filter object
- * @exception ServletException if thrown by the filter's init() method
- * @throws NamingException
- * @throws InvocationTargetException
*/
- public ApplicationFilterConfig(Context context, FilterDef filterDef)
- throws ClassCastException, ClassNotFoundException,
- IllegalAccessException, InstantiationException,
- ServletException, InvocationTargetException, NamingException {
-
- super();
-
+ public ApplicationFilterConfig(Context context, FilterDef filterDef) {
this.context = context;
- setFilterDef(filterDef);
-
+ this.filterDef = filterDef;
}
@@ -96,18 +111,37 @@
/**
+ * The facade associated with this wrapper.
+ */
+ protected ApplicationFilterConfigFacade facade =
+ new ApplicationFilterConfigFacade(this);
+
+
+ /**
* The Context with which we are associated.
*/
private Context context = null;
/**
+ * Dynamic flag.
+ */
+ protected boolean dynamic = false;
+
+
+ /**
* The application Filter we are configured for.
*/
private transient Filter filter = null;
/**
+ * The application Filter we are configured for.
+ */
+ private transient Filter filterInstance = null;
+
+
+ /**
* The <code>FilterDef</code> that defines our associated Filter.
*/
private FilterDef filterDef = null;
@@ -175,6 +209,28 @@
/**
+ * Get the facade FilterRegistration.
+ */
+ public FilterRegistration getFacade() {
+ return facade;
+ }
+
+
+ public boolean isDynamic() {
+ return dynamic;
+ }
+
+
+ public void setDynamic(boolean dynamic) {
+ this.dynamic = dynamic;
+ if (dynamic) {
+ // Change the facade (normally, this happens when the Wrapper is created)
+ facade = new ApplicationFilterConfigFacade.Dynamic(this);
+ }
+ }
+
+
+ /**
* Return a String representation of this object.
*/
public String toString() {
@@ -190,6 +246,80 @@
}
+ public boolean addMappingForServletNames(EnumSet<DispatcherType>
dispatcherTypes,
+ boolean isMatchAfter, String... servletNames) {
+ if (context.isInitialized()) {
+ throw new
IllegalStateException(sm.getString("filterRegistration.addFilterMapping.ise",
context.getPath()));
+ }
+ FilterMap filterMap = new FilterMap();
+ for (String servletName : servletNames) {
+ filterMap.addServletName(servletName);
+ }
+ filterMap.setFilterName(filterDef.getFilterName());
+ for (DispatcherType dispatcherType: dispatcherTypes) {
+ filterMap.setDispatcher(dispatcherType.name());
+ }
+ if (isMatchAfter) {
+ context.addFilterMap(filterMap);
+ } else {
+ context.addFilterMapBefore(filterMap);
+ }
+ return true;
+ }
+
+
+ public boolean addMappingForUrlPatterns(
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... urlPatterns) {
+ if (context.isInitialized()) {
+ throw new
IllegalStateException(sm.getString("filterRegistration.addFilterMapping.ise",
context.getPath()));
+ }
+ FilterMap filterMap = new FilterMap();
+ for (String urlPattern : urlPatterns) {
+ filterMap.addURLPattern(urlPattern);
+ }
+ filterMap.setFilterName(filterDef.getFilterName());
+ for (DispatcherType dispatcherType: dispatcherTypes) {
+ filterMap.setDispatcher(dispatcherType.name());
+ }
+ if (isMatchAfter) {
+ context.addFilterMap(filterMap);
+ } else {
+ context.addFilterMapBefore(filterMap);
+ }
+ return true;
+ }
+
+
+ public void setAsyncSupported(boolean asyncSupported) {
+ filterDef.setAsyncSupported(asyncSupported);
+ context.addFilterDef(filterDef);
+ }
+
+
+ public void setDescription(String description) {
+ filterDef.setDescription(description);
+ context.addFilterDef(filterDef);
+ }
+
+
+ public boolean setInitParameter(String name, String value) {
+ filterDef.addInitParameter(name, value);
+ context.addFilterDef(filterDef);
+ return true;
+ }
+
+
+ public boolean setInitParameters(Map<String, String> initParameters) {
+ Iterator<String> parameterNames = initParameters.keySet().iterator();
+ while (parameterNames.hasNext()) {
+ String parameterName = parameterNames.next();
+ filterDef.addInitParameter(parameterName,
initParameters.get(parameterName));
+ }
+ return true;
+ }
+
+
// -------------------------------------------------------- Package Methods
@@ -216,8 +346,13 @@
return (this.filter);
// Identify the class loader we will be using
- String filterClass = filterDef.getFilterClass();
- this.filter = (Filter) getInstanceManager().newInstance(filterClass);
+ if (filterInstance == null) {
+ String filterClass = filterDef.getFilterClass();
+ this.filter = (Filter) getInstanceManager().newInstance(filterClass);
+ } else {
+ this.filter = filterInstance;
+ filterInstance = null;
+ }
if (context instanceof StandardContext &&
context.getSwallowOutput()) {
@@ -238,6 +373,14 @@
}
+
+ /**
+ * Set the filter instance programmatically.
+ */
+ public void setFilter(Filter filter) {
+ filterInstance = filter;
+ }
+
/**
* Return the filter definition we are configured for.
@@ -279,65 +422,9 @@
}
- /**
- * Set the filter definition we are configured for. This has the side
- * effect of instantiating an instance of the corresponding filter class.
- *
- * @param filterDef The new filter definition
- *
- * @exception ClassCastException if the specified class does not implement
- * the <code>javax.servlet.Filter</code> interface
- * @exception ClassNotFoundException if the filter class cannot be found
- * @exception IllegalAccessException if the filter class cannot be
- * publicly instantiated
- * @exception InstantiationException if an exception occurs while
- * instantiating the filter object
- * @exception ServletException if thrown by the filter's init() method
- * @throws NamingException
- * @throws InvocationTargetException
- */
- void setFilterDef(FilterDef filterDef)
- throws ClassCastException, ClassNotFoundException,
- IllegalAccessException, InstantiationException,
- ServletException, InvocationTargetException, NamingException {
+ // -------------------------------------------------------- Private Methods
- this.filterDef = filterDef;
- if (filterDef == null) {
- // Release any previously allocated filter instance
- if (this.filter != null){
- if( Globals.IS_SECURITY_ENABLED) {
- try{
- SecurityUtil.doAsPrivilege("destroy", filter);
- } catch(java.lang.Exception ex){
-
context.getLogger().error("ApplicationFilterConfig.doAsPrivilege", ex);
- }
- SecurityUtil.remove(filter);
- } else {
- filter.destroy();
- }
- if (!context.getIgnoreAnnotations()) {
- try {
- ((StandardContext)
context).getInstanceManager().destroyInstance(this.filter);
- } catch (Exception e) {
-
context.getLogger().error("ApplicationFilterConfig.preDestroy", e);
- }
- }
- }
- this.filter = null;
-
- } else {
-
- // Allocate a new filter instance
- Filter filter = getFilter();
-
- }
-
- }
-
-
- // -------------------------------------------------------- Private Methods
-
private InstanceManager getInstanceManager() {
if (instanceManager == null) {
if (context instanceof StandardContext) {
Added: trunk/java/org/apache/catalina/core/ApplicationFilterConfigFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterConfigFacade.java
(rev 0)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterConfigFacade.java 2009-04-09
01:27:49 UTC (rev 1000)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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 org.apache.catalina.core;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.NamingException;
+import javax.servlet.DispatcherType;
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.FilterRegistration;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Globals;
+import org.apache.catalina.deploy.FilterDef;
+import org.apache.catalina.security.SecurityUtil;
+import org.apache.catalina.util.Enumerator;
+import org.apache.catalina.util.StringManager;
+import org.apache.tomcat.InstanceManager;
+import org.apache.tomcat.util.log.SystemLogHandler;
+
+
+/**
+ * Facade for AppalicationFilterConfig.
+ *
+ * @author Remy Maucherat
+ * @version $Revision: 992 $ $Date: 2009-04-08 01:09:34 +0200 (Wed, 08 Apr 2009) $
+ */
+
+public class ApplicationFilterConfigFacade implements FilterConfig, FilterRegistration {
+
+
+ protected static StringManager sm =
+ StringManager.getManager(Constants.Package);
+
+ public static class Dynamic extends ApplicationFilterConfigFacade
+ implements FilterRegistration.Dynamic {
+
+ public Dynamic(ApplicationFilterConfig config) {
+ super(config);
+ }
+
+ }
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ public ApplicationFilterConfigFacade(ApplicationFilterConfig config) {
+ this.config = config;
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The Context with which we are associated.
+ */
+ private ApplicationFilterConfig config = null;
+
+
+ // --------------------------------------------------- FilterConfig Methods
+
+
+ /**
+ * Return the name of the filter we are configuring.
+ */
+ public String getFilterName() {
+
+ return config.getFilterName();
+
+ }
+
+
+ /**
+ * Return a <code>String</code> containing the value of the named
+ * initialization parameter, or <code>null</code> if the parameter
+ * does not exist.
+ *
+ * @param name Name of the requested initialization parameter
+ */
+ public String getInitParameter(String name) {
+
+ return config.getInitParameter(name);
+
+ }
+
+
+ /**
+ * Return an <code>Enumeration</code> of the names of the initialization
+ * parameters for this Filter.
+ */
+ public Enumeration getInitParameterNames() {
+
+ return config.getInitParameterNames();
+
+ }
+
+
+ /**
+ * Return the ServletContext of our associated web application.
+ */
+ public ServletContext getServletContext() {
+
+ return config.getServletContext();
+
+ }
+
+
+ public boolean addMappingForServletNames(
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... servletNames) {
+ return config.addMappingForServletNames(dispatcherTypes, isMatchAfter,
servletNames);
+ }
+
+
+ public boolean addMappingForUrlPatterns(
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... urlPatterns) {
+ return config.addMappingForUrlPatterns(dispatcherTypes, isMatchAfter,
urlPatterns);
+ }
+
+
+ public boolean setInitParameter(String name, String value) {
+ return config.setInitParameter(name, value);
+ }
+
+
+ public boolean setInitParameters(Map<String, String> initParameters) {
+ return config.setInitParameters(initParameters);
+ }
+
+
+ public void setAsyncSupported(boolean isAsyncSupported) {
+ config.setAsyncSupported(isAsyncSupported);
+ }
+
+ public void setDescription(String description) {
+ config.setDescription(description);
+ }
+
+}
Modified: trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
===================================================================
--- trunk/java/org/apache/catalina/core/DefaultInstanceManager.java 2009-04-08 21:24:35
UTC (rev 999)
+++ trunk/java/org/apache/catalina/core/DefaultInstanceManager.java 2009-04-09 01:27:49
UTC (rev 1000)
@@ -123,6 +123,10 @@
return newInstance(clazz.newInstance(), clazz);
}
+ public Object newInstance(Class<?> c) throws IllegalAccessException,
InvocationTargetException, NamingException, InstantiationException {
+ return newInstance(c.newInstance(), c);
+ }
+
public void newInstance(Object o)
throws IllegalAccessException, InvocationTargetException, NamingException {
newInstance(o, o.getClass());
Modified: trunk/java/org/apache/catalina/core/DummyRequest.java
===================================================================
--- trunk/java/org/apache/catalina/core/DummyRequest.java 2009-04-08 21:24:35 UTC (rev
999)
+++ trunk/java/org/apache/catalina/core/DummyRequest.java 2009-04-09 01:27:49 UTC (rev
1000)
@@ -288,6 +288,7 @@
ServletException { return false; }
public void login(String username, String password) throws ServletException {}
public void logout() throws ServletException {}
+ public long getAsyncTimeout() { return 0; }
}
Modified: trunk/java/org/apache/catalina/core/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-04-08 21:24:35 UTC
(rev 999)
+++ trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-04-09 01:27:49 UTC
(rev 1000)
@@ -13,8 +13,9 @@
# 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.alreadyInitialized=Context {0} is already initialized.
applicationContext.attributeEvent=Exception thrown by attributes event listener
+applicationContext.create=Error creating instance
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
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-04-08 21:24:35 UTC (rev
999)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-04-09 01:27:49 UTC (rev
1000)
@@ -2297,6 +2297,19 @@
*
* @param filterDef The filter definition to be added
*/
+ public void addApplicationFilterConfig(ApplicationFilterConfig filterConfig) {
+
+ filterConfigs.put(filterConfig.getFilterName(), filterConfig);
+ fireContainerEvent("addApplicationFilterConfig", filterConfig);
+
+ }
+
+
+ /**
+ * Add a filter definition to this Context.
+ *
+ * @param filterDef The filter definition to be added
+ */
public void addFilterDef(FilterDef filterDef) {
synchronized (filterDefs) {
@@ -2789,6 +2802,16 @@
/**
+ * Return the application filter for the given name.
+ */
+ public ApplicationFilterConfig findApplicationFilterConfig(String name) {
+
+ return (ApplicationFilterConfig) filterConfigs.get(name);
+
+ }
+
+
+ /**
* Return the set of application listener class names configured
* for this application.
*/
@@ -3884,7 +3907,18 @@
// Instantiate and record a FilterConfig for each defined filter
boolean ok = true;
synchronized (filterConfigs) {
- filterConfigs.clear();
+ Iterator filterConfigsIterator = filterConfigs.values().iterator();
+ while (filterConfigsIterator.hasNext()) {
+ ApplicationFilterConfig filterConfig =
+ (ApplicationFilterConfig) filterConfigsIterator.next();
+ try {
+ filterConfig.getFilter();
+ } catch (Throwable t) {
+ getLogger().error
+ (sm.getString("standardContext.filterStart", name),
t);
+ ok = false;
+ }
+ }
Iterator names = filterDefs.keySet().iterator();
while (names.hasNext()) {
String name = (String) names.next();
@@ -3894,6 +3928,7 @@
try {
filterConfig = new ApplicationFilterConfig
(this, (FilterDef) filterDefs.get(name));
+ filterConfig.getFilter();
filterConfigs.put(name, filterConfig);
} catch (Throwable t) {
getLogger().error
Deleted: trunk/java/org/apache/catalina/core/StandardFilterFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardFilterFacade.java 2009-04-08 21:24:35 UTC
(rev 999)
+++ trunk/java/org/apache/catalina/core/StandardFilterFacade.java 2009-04-09 01:27:49 UTC
(rev 1000)
@@ -1,164 +0,0 @@
-/*
- * 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 org.apache.catalina.core;
-
-
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.servlet.DispatcherType;
-import javax.servlet.FilterRegistration;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.deploy.FilterDef;
-import org.apache.catalina.deploy.FilterMap;
-import org.apache.catalina.util.StringManager;
-
-
-/**
- * Facade for the <b>FilterDef</b> object, with a hook to the Context to
- * store them automatically. The name of the class is not accurate, since
- * there is no StandardFilter, but for consistency with StandardWrapper.
- *
- * @author Remy Maucharat
- * @version $Revision: 947 $ $Date: 2009-03-10 05:02:22 +0100 (Tue, 10 Mar 2009) $
- */
-
-public final class StandardFilterFacade
- implements FilterRegistration {
-
-
- /**
- * The string manager for this package.
- */
- private static final StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Create a new facade around a FilterDef.
- */
- public StandardFilterFacade(Context context, FilterDef filterDef) {
-
- super();
- this.context = context;
- this.filterDef = filterDef;
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Associated context.
- */
- private Context context = null;
-
-
- /**
- * Wrapped filter def (facade).
- */
- private FilterDef filterDef = null;
-
-
- // --------------------------------------------- FilterRegistration Methods
-
-
- public boolean addMappingForServletNames(EnumSet<DispatcherType>
dispatcherTypes,
- boolean isMatchAfter, String... servletNames) {
- if (context.isInitialized()) {
- throw new
IllegalStateException(sm.getString("filterRegistration.addFilterMapping.ise",
context.getPath()));
- }
- FilterMap filterMap = new FilterMap();
- for (String servletName : servletNames) {
- filterMap.addServletName(servletName);
- }
- filterMap.setFilterName(filterDef.getFilterName());
- for (DispatcherType dispatcherType: dispatcherTypes) {
- filterMap.setDispatcher(dispatcherType.name());
- }
- if (isMatchAfter) {
- context.addFilterMap(filterMap);
- } else {
- context.addFilterMapBefore(filterMap);
- }
- return true;
- }
-
-
- public boolean addMappingForUrlPatterns(
- EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
- String... urlPatterns) {
- if (context.isInitialized()) {
- throw new
IllegalStateException(sm.getString("filterRegistration.addFilterMapping.ise",
context.getPath()));
- }
- FilterMap filterMap = new FilterMap();
- for (String urlPattern : urlPatterns) {
- filterMap.addURLPattern(urlPattern);
- }
- filterMap.setFilterName(filterDef.getFilterName());
- for (DispatcherType dispatcherType: dispatcherTypes) {
- filterMap.setDispatcher(dispatcherType.name());
- }
- if (isMatchAfter) {
- context.addFilterMap(filterMap);
- } else {
- context.addFilterMapBefore(filterMap);
- }
- return true;
- }
-
-
- public boolean setAsyncSupported(boolean asyncSupported) {
- filterDef.setAsyncSupported(asyncSupported);
- context.addFilterDef(filterDef);
- return true;
- }
-
-
- public boolean setDescription(String description) {
- filterDef.setDescription(description);
- context.addFilterDef(filterDef);
- return true;
- }
-
-
- public boolean setInitParameter(String name, String value) {
- filterDef.addInitParameter(name, value);
- context.addFilterDef(filterDef);
- return true;
- }
-
-
- public boolean setInitParameters(Map<String, String> initParameters) {
- Iterator<String> parameterNames = initParameters.keySet().iterator();
- while (parameterNames.hasNext()) {
- String parameterName = parameterNames.next();
- filterDef.addInitParameter(parameterName,
initParameters.get(parameterName));
- }
- return true;
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-04-08 21:24:35 UTC (rev
999)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-04-09 01:27:49 UTC (rev
1000)
@@ -105,6 +105,12 @@
/**
+ * Dynamic flag.
+ */
+ protected boolean dynamic = false;
+
+
+ /**
* 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
@@ -150,6 +156,12 @@
/**
+ * The (single) initialized instance of this servlet.
+ */
+ protected Servlet servletInstance = null;
+
+
+ /**
* The support object for our instance listeners.
*/
protected InstanceSupport instanceSupport = new InstanceSupport(this);
@@ -320,6 +332,20 @@
}
+ public boolean isDynamic() {
+ return dynamic;
+ }
+
+
+ public void setDynamic(boolean dynamic) {
+ this.dynamic = dynamic;
+ if (dynamic) {
+ // Change the facade (normally, this happens when the Wrapper is created)
+ facade = new StandardWrapperFacade.Dynamic(this);
+ }
+ }
+
+
/**
* 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
@@ -803,6 +829,14 @@
/**
+ * Set the associated servlet instance.
+ */
+ public void setServlet(Servlet servlet) {
+ servletInstance = servlet;
+ }
+
+
+ /**
* Allocate an initialized instance of this Servlet that is ready to have
* its <code>service()</code> method called. If the servlet class does
* not implement <code>SingleThreadModel</code>, the (only) initialized
@@ -1060,26 +1094,31 @@
(sm.getString("standardWrapper.notClass", getName()));
}
- InstanceManager instanceManager =
((StandardContext)getParent()).getInstanceManager();
- try {
- servlet = (Servlet) instanceManager.newInstance(actualClass);
- } catch (ClassCastException e) {
- unavailable(null);
- // Restore the context ClassLoader
- throw new ServletException
+ if (servletInstance == null) {
+ InstanceManager instanceManager =
((StandardContext)getParent()).getInstanceManager();
+ try {
+ servlet = (Servlet) instanceManager.newInstance(actualClass);
+ } catch (ClassCastException e) {
+ unavailable(null);
+ // Restore the context ClassLoader
+ throw new ServletException
(sm.getString("standardWrapper.notServlet", actualClass),
e);
- } catch (Throwable e) {
- unavailable(null);
+ } catch (Throwable e) {
+ unavailable(null);
- // Added extra log statement for Bugzilla 36630:
- //
http://issues.apache.org/bugzilla/show_bug.cgi?id=36630
- if(log.isDebugEnabled()) {
- log.debug(sm.getString("standardWrapper.instantiate",
actualClass), e);
- }
+ // Added extra log statement for Bugzilla 36630:
+ //
http://issues.apache.org/bugzilla/show_bug.cgi?id=36630
+ if(log.isDebugEnabled()) {
+ log.debug(sm.getString("standardWrapper.instantiate",
actualClass), e);
+ }
- // Restore the context ClassLoader
- throw new ServletException
+ // Restore the context ClassLoader
+ throw new ServletException
(sm.getString("standardWrapper.instantiate", actualClass),
e);
+ }
+ } else {
+ servlet = servletInstance;
+ servletInstance = null;
}
// Special handling for ContainerServlet instances
Modified: trunk/java/org/apache/catalina/core/StandardWrapperFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperFacade.java 2009-04-08 21:24:35 UTC
(rev 999)
+++ trunk/java/org/apache/catalina/core/StandardWrapperFacade.java 2009-04-09 01:27:49 UTC
(rev 1000)
@@ -1,18 +1,46 @@
/*
- * 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
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*
- *
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.
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.
*/
@@ -38,7 +66,7 @@
* @version $Revision$ $Date$
*/
-public final class StandardWrapperFacade
+public class StandardWrapperFacade
implements ServletRegistration, ServletConfig {
@@ -49,6 +77,16 @@
StringManager.getManager(Constants.Package);
+ public static class Dynamic extends StandardWrapperFacade
+ implements ServletRegistration.Dynamic {
+
+ public Dynamic(StandardWrapper wrapper) {
+ super(wrapper);
+ }
+
+ }
+
+
// ----------------------------------------------------------- Constructors
@@ -120,15 +158,13 @@
}
- public boolean setAsyncSupported(boolean asyncSupported) {
+ public void setAsyncSupported(boolean asyncSupported) {
wrapper.setAsyncSupported(asyncSupported);
- return true;
}
- public boolean setDescription(String description) {
+ public void setDescription(String description) {
wrapper.setDescription(description);
- return true;
}
@@ -148,9 +184,8 @@
}
- public boolean setLoadOnStartup(int loadOnStartup) {
+ public void setLoadOnStartup(int loadOnStartup) {
wrapper.setLoadOnStartup(loadOnStartup);
- return true;
}
Modified: trunk/java/org/apache/jasper/servlet/JspCServletContext.java
===================================================================
--- trunk/java/org/apache/jasper/servlet/JspCServletContext.java 2009-04-08 21:24:35 UTC
(rev 999)
+++ trunk/java/org/apache/jasper/servlet/JspCServletContext.java 2009-04-09 01:27:49 UTC
(rev 1000)
@@ -443,19 +443,19 @@
}
- public FilterRegistration addFilter(String filterName, String className)
+ public FilterRegistration.Dynamic addFilter(String filterName, String className)
throws IllegalArgumentException, IllegalStateException {
return null;
}
- public ServletRegistration addServlet(String servletName, String className)
+ public ServletRegistration.Dynamic addServlet(String servletName, String className)
throws IllegalArgumentException, IllegalStateException {
return null;
}
- public ServletRegistration addServlet(String servletName,
+ public ServletRegistration.Dynamic addServlet(String servletName,
Class<? extends Servlet> clazz) throws IllegalArgumentException,
IllegalStateException {
return null;
@@ -492,29 +492,18 @@
}
- public void setSessionCookieConfig(SessionCookieConfig sessionCookieConfig) {
- // Do nothing
- }
-
-
- public void setSessionTrackingModes(
- EnumSet<SessionTrackingMode> sessionTrackingModes) {
- // Do nothing
- }
-
-
- public FilterRegistration addFilter(String filterName, Filter filter) {
+ public FilterRegistration.Dynamic addFilter(String filterName, Filter filter) {
return null;
}
- public FilterRegistration addFilter(String filterName,
+ public FilterRegistration.Dynamic addFilter(String filterName,
Class<? extends Filter> filterClass) {
return null;
}
- public ServletRegistration addServlet(String servletName, Servlet servlet) {
+ public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) {
return null;
}
Modified: trunk/java/org/apache/tomcat/InstanceManager.java
===================================================================
--- trunk/java/org/apache/tomcat/InstanceManager.java 2009-04-08 21:24:35 UTC (rev 999)
+++ trunk/java/org/apache/tomcat/InstanceManager.java 2009-04-09 01:27:49 UTC (rev 1000)
@@ -37,6 +37,10 @@
throws IllegalAccessException, InvocationTargetException, NamingException,
InstantiationException, ClassNotFoundException;
+ public Object newInstance(Class<?> c)
+ throws IllegalAccessException, InvocationTargetException, NamingException,
+ InstantiationException;
+
public void newInstance(Object o)
throws IllegalAccessException, InvocationTargetException, NamingException;