From 09a9e27a3dbcfcc6c3b27e6a7d3c9bd814397f83 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 20 Oct 2009 13:41:59 +0000 Subject: [PATCH] Update spec classes for latest Servlet 3.0 API as of 2009-10-15. Update internals so Tomcat builds with the updated spec. Lots if stubbed impl marked with TODO. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@827435 13f79535-47bb-0310-9956-ffa450edef68 --- java/javax/servlet/AsyncContext.java | 12 +- java/javax/servlet/AsyncEvent.java | 36 +++++- java/javax/servlet/AsyncListener.java | 1 + java/javax/servlet/DispatcherType.java | 1 - java/javax/servlet/FilterRegistration.java | 14 ++- java/javax/servlet/HttpConstraintElement.java | 92 ++++++++++++++ .../javax/servlet/HttpMethodConstraintElement.java | 50 ++++++++ java/javax/servlet/LocalStrings.properties | 3 + java/javax/servlet/MultipartConfigElement.java | 72 +++++++++++ java/javax/servlet/Registration.java | 42 +++++-- .../javax/servlet/ServletContainerInitializer.java | 13 +- java/javax/servlet/ServletContext.java | 123 ++++++++++++++++++- java/javax/servlet/ServletOutputStream.java | 4 +- java/javax/servlet/ServletRegistration.java | 12 +- java/javax/servlet/ServletRequest.java | 38 ------ java/javax/servlet/ServletRequestWrapper.java | 47 ------- java/javax/servlet/ServletSecurityElement.java | 131 ++++++++++++++++++++ java/javax/servlet/annotation/HandlesTypes.java | 1 - java/javax/servlet/annotation/HttpConstraint.java | 36 ++++++ .../servlet/annotation/HttpMethodConstraint.java | 37 ++++++ java/javax/servlet/annotation/MultipartConfig.java | 5 +- java/javax/servlet/annotation/ServletSecurity.java | 45 +++++++ java/javax/servlet/annotation/WebFilter.java | 1 - java/javax/servlet/annotation/WebInitParam.java | 1 - java/javax/servlet/annotation/WebListener.java | 3 +- java/javax/servlet/annotation/WebServlet.java | 1 - .../servlet/descriptor/JspConfigDescriptor.java | 28 +++++ .../descriptor/JspPropertyGroupDescriptor.java | 38 ++++++ .../javax/servlet/descriptor/TaglibDescriptor.java | 26 ++++ java/javax/servlet/http/HttpServletRequest.java | 7 +- .../servlet/http/HttpServletRequestWrapper.java | 3 +- java/javax/servlet/http/HttpServletResponse.java | 5 +- .../servlet/http/HttpServletResponseWrapper.java | 5 +- java/javax/servlet/http/Part.java | 5 +- java/org/apache/catalina/connector/Request.java | 42 +------ .../apache/catalina/connector/RequestFacade.java | 21 +--- java/org/apache/catalina/connector/Response.java | 5 +- .../apache/catalina/connector/ResponseFacade.java | 5 +- .../apache/catalina/core/ApplicationContext.java | 81 ++++++++++++- .../catalina/core/ApplicationContextFacade.java | 135 ++++++++++++++++++++- .../org/apache/catalina/core/AsyncContextImpl.java | 30 ++++- java/org/apache/catalina/core/DummyRequest.java | 9 +- java/org/apache/catalina/core/DummyResponse.java | 5 +- .../apache/jasper/servlet/JspCServletContext.java | 74 ++++++++++- webapps/examples/WEB-INF/classes/async/Async0.java | 2 +- webapps/examples/WEB-INF/classes/async/Async1.java | 2 +- webapps/examples/WEB-INF/classes/async/Async2.java | 2 +- webapps/examples/WEB-INF/classes/async/Async3.java | 2 +- 48 files changed, 1130 insertions(+), 223 deletions(-) create mode 100644 java/javax/servlet/HttpConstraintElement.java create mode 100644 java/javax/servlet/HttpMethodConstraintElement.java create mode 100644 java/javax/servlet/MultipartConfigElement.java create mode 100644 java/javax/servlet/ServletSecurityElement.java create mode 100644 java/javax/servlet/annotation/HttpConstraint.java create mode 100644 java/javax/servlet/annotation/HttpMethodConstraint.java create mode 100644 java/javax/servlet/annotation/ServletSecurity.java create mode 100644 java/javax/servlet/descriptor/JspConfigDescriptor.java create mode 100644 java/javax/servlet/descriptor/JspPropertyGroupDescriptor.java create mode 100644 java/javax/servlet/descriptor/TaglibDescriptor.java diff --git a/java/javax/servlet/AsyncContext.java b/java/javax/servlet/AsyncContext.java index f54361254..66dec458d 100644 --- a/java/javax/servlet/AsyncContext.java +++ b/java/javax/servlet/AsyncContext.java @@ -64,7 +64,15 @@ public interface AsyncContext { void start(Runnable run); - public long getAsyncTimeout(); + void addListener(AsyncListener listener); - public void setAsyncTimeout(long timeout); + void addListener(AsyncListener listener, ServletRequest request, + ServletResponse response); + + T createListener(Class clazz) + throws ServletException; + + long getTimeout(); + + void setTimeout(long timeout); } diff --git a/java/javax/servlet/AsyncEvent.java b/java/javax/servlet/AsyncEvent.java index 6ba2f0c74..cde734747 100644 --- a/java/javax/servlet/AsyncEvent.java +++ b/java/javax/servlet/AsyncEvent.java @@ -18,23 +18,51 @@ package javax.servlet; /** * @since Servlet 3.0 - * $Id$ * TODO SERVLET3 - Add comments */ public class AsyncEvent { + private AsyncContext context; private ServletRequest request; private ServletResponse response; + private Throwable throwable; - public AsyncEvent(ServletRequest request, ServletResponse response) { + public AsyncEvent(AsyncContext context) { + this.context = context; + } + + public AsyncEvent(AsyncContext context, ServletRequest request, + ServletResponse response) { + this.context = context; + this.request = request; + this.response = response; + } + + public AsyncEvent(AsyncContext context, Throwable throwable) { + this.context = context; + this.throwable = throwable; + } + + public AsyncEvent(AsyncContext context, ServletRequest request, + ServletResponse response, Throwable throwable) { + this.context = context; this.request = request; this.response = response; + this.throwable = throwable; } - public ServletRequest getRequest() { + public AsyncContext getAsyncContext() { + return context; + } + + public ServletRequest getSuppliedRequest() { return request; } - public ServletResponse getResponse() { + public ServletResponse getSuppliedResponse() { return response; } + + public Throwable getThrowable() { + return throwable; + } } diff --git a/java/javax/servlet/AsyncListener.java b/java/javax/servlet/AsyncListener.java index 01dd54b8a..78a379191 100644 --- a/java/javax/servlet/AsyncListener.java +++ b/java/javax/servlet/AsyncListener.java @@ -28,4 +28,5 @@ public interface AsyncListener extends EventListener { void onComplete(AsyncEvent event) throws IOException; void onTimeout(AsyncEvent event) throws IOException; void onError(AsyncEvent event) throws IOException; + void onStartAsync(AsyncEvent event) throws IOException; } diff --git a/java/javax/servlet/DispatcherType.java b/java/javax/servlet/DispatcherType.java index d68acb2e7..67e560305 100644 --- a/java/javax/servlet/DispatcherType.java +++ b/java/javax/servlet/DispatcherType.java @@ -18,7 +18,6 @@ package javax.servlet; /** * @since Servlet 3.0 - * $Id$ */ public enum DispatcherType { FORWARD, diff --git a/java/javax/servlet/FilterRegistration.java b/java/javax/servlet/FilterRegistration.java index 59967a0d9..3f54f9572 100644 --- a/java/javax/servlet/FilterRegistration.java +++ b/java/javax/servlet/FilterRegistration.java @@ -16,11 +16,11 @@ */ package javax.servlet; +import java.util.Collection; import java.util.EnumSet; /** * @since Servlet 3.0 - * $Id$ * TODO SERVLET3 - Add comments */ public interface FilterRegistration extends Registration { @@ -36,6 +36,11 @@ public interface FilterRegistration extends Registration { public void addMappingForServletNames( EnumSet dispatcherTypes, boolean isMatchAfter, String... servletNames); + /** + * + * @return + */ + public Collection getServletNameMappings(); /** * @@ -49,7 +54,14 @@ public interface FilterRegistration extends Registration { EnumSet dispatcherTypes, boolean isMatchAfter, String... urlPatterns); + /** + * + * @return + */ + public Collection getUrlPatternMappings(); + public static interface Dynamic extends FilterRegistration, Registration.Dynamic { + // No additional methods } } diff --git a/java/javax/servlet/HttpConstraintElement.java b/java/javax/servlet/HttpConstraintElement.java new file mode 100644 index 000000000..cb9ae8e98 --- /dev/null +++ b/java/javax/servlet/HttpConstraintElement.java @@ -0,0 +1,92 @@ +/* +* 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; + +import java.util.ResourceBundle; + +import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; +import javax.servlet.annotation.ServletSecurity.TransportGuarantee; + +/** + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +public class HttpConstraintElement { + + private static final String LSTRING_FILE = "javax.servlet.LocalStrings"; + protected static final ResourceBundle lStrings = + ResourceBundle.getBundle(LSTRING_FILE); + + private EmptyRoleSemantic emptyRoleSemantic = EmptyRoleSemantic.PERMIT; + private TransportGuarantee transportGuarantee = TransportGuarantee.NONE; + private String[] rolesAllowed = new String[0]; + + /** + * Default constraint is permit with no transport guarantee. + */ + public HttpConstraintElement() { + // Default constructor + } + + /** + * Convenience constructor for {@link EmptyRoleSemantic.DENY}. + * + */ + public HttpConstraintElement(EmptyRoleSemantic emptyRoleSemantic) { + this.emptyRoleSemantic = emptyRoleSemantic; + } + + /** + * Convenience constructor to specify transport guarantee and/or roles. + */ + public HttpConstraintElement(TransportGuarantee transportGuarantee, + String... rolesAllowed) { + this.transportGuarantee = transportGuarantee; + this.rolesAllowed = rolesAllowed; + } + + /** + * + * @param emptyRoleSemantic + * @param transportGuarantee + * @param rolesAllowed + * @throws IllegalArgumentException if roles are specified when DENY is used + */ + public HttpConstraintElement(EmptyRoleSemantic emptyRoleSemantic, + TransportGuarantee transportGuarantee, String... rolesAllowed) { + if (rolesAllowed != null && rolesAllowed.length > 0 && + EmptyRoleSemantic.DENY.equals(emptyRoleSemantic)) { + throw new IllegalArgumentException(lStrings.getString( + "httpConstraintElement.invalidRolesDeny")); + } + this.emptyRoleSemantic = emptyRoleSemantic; + this.transportGuarantee = transportGuarantee; + this.rolesAllowed = rolesAllowed; + } + + public EmptyRoleSemantic getEmptyRoleSemantic() { + return emptyRoleSemantic; + } + + public TransportGuarantee getTransportGuarantee() { + return transportGuarantee; + } + + public String[] getRolesAllowed() { + return rolesAllowed; + } +} \ No newline at end of file diff --git a/java/javax/servlet/HttpMethodConstraintElement.java b/java/javax/servlet/HttpMethodConstraintElement.java new file mode 100644 index 000000000..025a5d617 --- /dev/null +++ b/java/javax/servlet/HttpMethodConstraintElement.java @@ -0,0 +1,50 @@ +/* +* 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 Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +public class HttpMethodConstraintElement extends HttpConstraintElement { + + private String methodName; + + public HttpMethodConstraintElement(String methodName) { + if (methodName == null || methodName.length() == 0) { + throw new IllegalArgumentException(lStrings.getString( + "httpMethodConstraintElement.invalidMethod")); + } + this.methodName = methodName; + } + + public HttpMethodConstraintElement(String methodName, + HttpConstraintElement constraint) { + super(constraint.getEmptyRoleSemantic(), + constraint.getTransportGuarantee(), + constraint.getRolesAllowed()); + if (methodName == null || methodName.length() == 0) { + throw new IllegalArgumentException(lStrings.getString( + "httpMethodConstraintElement.invalidMethod")); + } + this.methodName = methodName; + } + + public String getMethodName() { + return methodName; + } +} \ No newline at end of file diff --git a/java/javax/servlet/LocalStrings.properties b/java/javax/servlet/LocalStrings.properties index 49fb28710..0f60d51e8 100644 --- a/java/javax/servlet/LocalStrings.properties +++ b/java/javax/servlet/LocalStrings.properties @@ -19,3 +19,6 @@ err.not_iso8859_1=Not an ISO 8859-1 character: {0} value.true=true value.false=false + +httpConstraintElement.invalidRolesDeny=Roles may not be specified when using DENY +httpMethodConstraintElement.invalidMethod=Invalid HTTP method \ No newline at end of file diff --git a/java/javax/servlet/MultipartConfigElement.java b/java/javax/servlet/MultipartConfigElement.java new file mode 100644 index 000000000..fb6934ca5 --- /dev/null +++ b/java/javax/servlet/MultipartConfigElement.java @@ -0,0 +1,72 @@ +/* +* 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; + +import javax.servlet.annotation.MultipartConfig; + +/** + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +public class MultipartConfigElement { + + private String location = ""; + private long maxFileSize = -1; + private long maxRequestSize = -1; + private int fileSizeThreshold = 0; + + public MultipartConfigElement(String location) { + // Keep empty string default if location is null + if (location != null) { + this.location = location; + } + } + + public MultipartConfigElement(String location, long maxFileSize, + long maxRequestSize, int fileSizeThreshold) { + // Keep empty string default if location is null + if (location != null) { + this.location = location; + } + this.maxFileSize = maxFileSize; + this.maxRequestSize = maxRequestSize; + this.fileSizeThreshold = fileSizeThreshold; + } + + public MultipartConfigElement(MultipartConfig annotation) { + location = annotation.location(); + maxFileSize = annotation.maxFileSize(); + maxRequestSize = annotation.maxRequestSize(); + fileSizeThreshold = annotation.fileSizeThreshold(); + } + + public String getLocation() { + return location; + } + + public long getMaxFileSize() { + return maxFileSize; + } + + public long getMaxRequestSize() { + return maxRequestSize; + } + + public int getFileSizeThreshold() { + return fileSizeThreshold; + } +} \ No newline at end of file diff --git a/java/javax/servlet/Registration.java b/java/javax/servlet/Registration.java index f45594d5a..fe09cc577 100644 --- a/java/javax/servlet/Registration.java +++ b/java/javax/servlet/Registration.java @@ -26,18 +26,40 @@ import java.util.Set; */ public interface Registration { - public boolean setInitParameter(String name, String value) - throws IllegalArgumentException, IllegalStateException; + public String getName(); + + public String getClassName(); - public Set setInitParameters(Map initParameters) - throws IllegalArgumentException, IllegalStateException; + /** + * + * @param name + * @param value + * @return + * @throws IllegalArgumentException + * @throws IllegalStateException + */ + public boolean setInitParameter(String name, String value); - public interface Dynamic { - - public void setDescription(String description) - throws IllegalStateException; + public String getInitParameter(String name); + + /** + * + * @param initParameters + * @return + * @throws IllegalArgumentException + * @throws IllegalStateException + */ + public Set setInitParameters(Map initParameters); + + public Map getInitParameters(); + + public interface Dynamic extends Registration { - public void setAsyncSupported(boolean isAsyncSupported) - throws IllegalStateException; + /** + * + * @param isAsyncSupported + * @throws IllegalStateException + */ + public void setAsyncSupported(boolean isAsyncSupported); } } diff --git a/java/javax/servlet/ServletContainerInitializer.java b/java/javax/servlet/ServletContainerInitializer.java index 6c8d45803..c16ed8e7d 100644 --- a/java/javax/servlet/ServletContainerInitializer.java +++ b/java/javax/servlet/ServletContainerInitializer.java @@ -16,12 +16,21 @@ */ package javax.servlet; +import java.util.Set; + /** * @since Servlet 3.0 * $Id$ * TODO SERVLET3 - Add comments */ public interface ServletContainerInitializer { - public void onStartup(java.util.Set> c, - ServletContext ctx); + + /** + * + * @param c + * @param ctx + * @throws ServletException + */ + public void onStartup(Set> c, ServletContext ctx) + throws ServletException; } diff --git a/java/javax/servlet/ServletContext.java b/java/javax/servlet/ServletContext.java index 6a6d6e473..25eb16290 100644 --- a/java/javax/servlet/ServletContext.java +++ b/java/javax/servlet/ServletContext.java @@ -21,8 +21,12 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.EnumSet; import java.util.Enumeration; +import java.util.EventListener; +import java.util.Map; import java.util.Set; +import javax.servlet.descriptor.JspConfigDescriptor; + /** * * Defines a set of methods that a servlet uses to communicate with its @@ -56,6 +60,12 @@ import java.util.Set; public interface ServletContext { public static final String TEMPDIR = "javax.servlet.context.tempdir"; + + /** + * @since Servlet 3.0 + */ + public static final String ORDERED_LIBS = + "javax.servlet.context.orderedLibs"; /** * Returns a ServletContext object that @@ -114,7 +124,23 @@ public interface ServletContext { public int getMinorVersion(); + /** + * + * @return + * @throws UnsupportedOperationException + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public int getEffectiveMajorVersion(); + /** + * + * @return + * @throws UnsupportedOperationException + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public int getEffectiveMinorVersion(); /** * Returns the MIME type of the specified file, or null if @@ -532,6 +558,7 @@ public interface ServletContext { * @param value * @return * @throws IllegalStateException + * @throws UnsupportedOperationException * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ @@ -710,10 +737,21 @@ public interface ServletContext { * * @param servletName * @return + * @throws UnsupportedOperationException + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public ServletRegistration getServletRegistration(String servletName); + + + /** + * + * @return + * @throws UnsupportedOperationException * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public ServletRegistration findServletRegistration(String servletName); + public Map getServletRegistrations(); /** @@ -774,15 +812,25 @@ public interface ServletContext { * * @param filterName * @return + * @throws UnsupportedOperationException * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public FilterRegistration findFilterRegistration(String filterName); + public FilterRegistration getFilterRegistration(String filterName); + /** + * + * @return + * @throws UnsupportedOperationException + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public Map getFilterRegistrations(); /** * * @return + * @throws UnsupportedOperationException * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ @@ -797,6 +845,7 @@ public interface ServletContext { * {@link SessionTrackingMode} * @throws IllegalStateException If the context has already been * initialised + * @throws UnsupportedOperationException * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ @@ -810,14 +859,80 @@ public interface ServletContext { * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public EnumSet getDefaultSessionTrackingModes(); + public Set getDefaultSessionTrackingModes(); + + /** + * + * @return + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public Set getEffectiveSessionTrackingModes(); + + /** + * + * @param listenerClass + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public void addListener(Class listenerClass); + + /** + * + * @param className + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public void addListener(String className); + + /** + * + * @param + * @param t + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public void addListener(T t); + + /** + * + * @param + * @param c + * @return + * @throws ServletException + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public T createListener(Class c) + throws ServletException; + + /** + * + * @param roleNames + * @throws UnsupportedOperationException + * @throws IllegalArgumentException + * @throws IllegalStateException + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public void declareRoles(String... roleNames); /** * * @return + * @throws UnsupportedOperationException + * @throws SecurityException * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public EnumSet getEffectiveSessionTrackingModes(); + public ClassLoader getClassLoader(); + /** + * + * @return + * @throws UnsupportedOperationException + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ + public JspConfigDescriptor getJspConfigDescriptor(); } diff --git a/java/javax/servlet/ServletOutputStream.java b/java/javax/servlet/ServletOutputStream.java index 82785b365..6d8fb18c2 100644 --- a/java/javax/servlet/ServletOutputStream.java +++ b/java/javax/servlet/ServletOutputStream.java @@ -43,8 +43,8 @@ import java.util.ResourceBundle; public abstract class ServletOutputStream extends OutputStream { private static final String LSTRING_FILE = "javax.servlet.LocalStrings"; - private static ResourceBundle lStrings = - ResourceBundle.getBundle(LSTRING_FILE); + private static final ResourceBundle lStrings = + ResourceBundle.getBundle(LSTRING_FILE); diff --git a/java/javax/servlet/ServletRegistration.java b/java/javax/servlet/ServletRegistration.java index 3248ba45a..3d2fee35e 100644 --- a/java/javax/servlet/ServletRegistration.java +++ b/java/javax/servlet/ServletRegistration.java @@ -16,6 +16,7 @@ */ package javax.servlet; +import java.util.Collection; import java.util.Set; /** @@ -33,10 +34,17 @@ public interface ServletRegistration extends Registration { * @throws IllegalStateException if the associated ServletContext has * already been initialised */ - public Set addMapping(String... urlPatterns); + public Set addMapping(String... urlPatterns); + + public Collection getMappings(); + + public String getRunAsRole(); public static interface Dynamic extends ServletRegistration, Registration.Dynamic { - + public void setLoadOnStartup(int loadOnStartup); + public void setMultipartConfig(MultipartConfigElement multipartConfig); + public void setRunAsRole(String roleName); + public Set setServletSecurity(ServletSecurityElement constraint); } } diff --git a/java/javax/servlet/ServletRequest.java b/java/javax/servlet/ServletRequest.java index 8d6873b8d..70932f280 100644 --- a/java/javax/servlet/ServletRequest.java +++ b/java/javax/servlet/ServletRequest.java @@ -651,44 +651,6 @@ public interface ServletRequest { /** * - * @param listener - * @since Servlet 3.0 - * TODO SERVLET3 - Add comments - */ - public void addAsyncListener(AsyncListener listener); - - /** - * - * @param listener - * @param servletRequest - * @param servletResponse - * @since Servlet 3.0 - * TODO SERVLET3 - Add comments - */ - public void addAsyncListener(AsyncListener listener, - ServletRequest servletRequest, ServletResponse servletResponse); - - /** - * - * @param timeout - * @throws java.lang.IllegalStateException - * @since Servlet 3.0 - * TODO SERVLET3 - Add comments - */ - public void setAsyncTimeout(long timeout); - - - /** - * - * @return - * @since Servlet 3.0 - * TODO SERVLET3 - Add comments - */ - public long getAsyncTimeout(); - - - /** - * * @return * @since Servlet 3.0 * TODO SERVLET3 - Add comments diff --git a/java/javax/servlet/ServletRequestWrapper.java b/java/javax/servlet/ServletRequestWrapper.java index 755a9655d..a6c2b78dd 100644 --- a/java/javax/servlet/ServletRequestWrapper.java +++ b/java/javax/servlet/ServletRequestWrapper.java @@ -471,53 +471,6 @@ public class ServletRequestWrapper implements ServletRequest { } /** - * The default behavior of this method is to call - * addAsyncListener(AsyncListener) on the wrapped request object. - * - * @param listener - * @since Servlet 3.0 - */ - public void addAsyncListener(AsyncListener listener) { - request.addAsyncListener(listener); - } - - /** - * The default behavior of this method is to call - * addAsyncListener(AsyncListener, ServletRequest, ServletResponse) on the - * wrapped request object. - * - * @param listener - * @param servletRequest - * @param servletResponse - * @since Servlet 3.0 - */ - public void addAsyncListener(AsyncListener listener, - ServletRequest servletRequest, ServletResponse servletResponse) { - request.addAsyncListener(listener, servletRequest, servletResponse); - } - - /** - * The default behavior of this method is to call - * setAsyncTimeout(long) on the wrapped request object. - * - * @param listener - * @since Servlet 3.0 - */ - public void setAsyncTimeout(long timeout) { - request.setAsyncTimeout(timeout); - } - - /** - * The default behavior of this method is to call - * getAsyncTimeout() on the wrapped request object. - * - * @since Servlet 3.0 - */ - public long getAsyncTimeout() { - return request.getAsyncTimeout(); - } - - /** * * @param wrapped * @since Servlet 3.0 diff --git a/java/javax/servlet/ServletSecurityElement.java b/java/javax/servlet/ServletSecurityElement.java new file mode 100644 index 000000000..0335825c9 --- /dev/null +++ b/java/javax/servlet/ServletSecurityElement.java @@ -0,0 +1,131 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.annotation.HttpMethodConstraint; +import javax.servlet.annotation.ServletSecurity; + +/** + * + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +public class ServletSecurityElement extends HttpConstraintElement { + + private Map methodConstraints = + new HashMap(); + + /** + * Use default HttpConstraint. + */ + public ServletSecurityElement() { + super(); + } + + + /** + * Use specific constraints for specified methods and default + * HttpConstraintElement for all other methods. + * @param httpMethodConstraints + * @throws IllegalArgumentException if a method name is specified more than + * once + */ + public ServletSecurityElement( + Collection httpMethodConstraints) { + super(); + addHttpMethodConstraints(httpMethodConstraints); + } + + /** + * Use specified HttpConstraintElement. + * @param httpConstraintElement + */ + public ServletSecurityElement(HttpConstraintElement httpConstraintElement) { + this (httpConstraintElement, null); + } + + /** + * Use specified HttpConstraintElement as default and specific constraints + * for specified methods. + * @param httpConstraintElement + * @param httpMethodConstraints + * @throws IllegalArgumentException if a method name is specified more than + */ + public ServletSecurityElement(HttpConstraintElement httpConstraintElement, + Collection httpMethodConstraints) { + super(httpConstraintElement.getEmptyRoleSemantic(), + httpConstraintElement.getTransportGuarantee(), + httpConstraintElement.getRolesAllowed()); + addHttpMethodConstraints(httpMethodConstraints); + } + + /** + * Create from an annotation. + * @param annotation + * @throws IllegalArgumentException if a method name is specified more than + */ + public ServletSecurityElement(ServletSecurity annotation) { + this(new HttpConstraintElement(annotation.value().value(), + annotation.value().transportGuarantee(), + annotation.value().rolesAllowed())); + + List l = + new ArrayList(); + HttpMethodConstraint[] constraints = annotation.httpMethodConstraints(); + if (constraints != null) { + for (int i = 0; i < constraints.length; i++) { + HttpMethodConstraintElement e = + new HttpMethodConstraintElement(constraints[i].value(), + new HttpConstraintElement( + constraints[i].emptyRoleSemantic(), + constraints[i].transportGuarantee(), + constraints[i].rolesAllowed())); + l.add(e); + } + } + addHttpMethodConstraints(l); + } + + public Collection getHttpMethodConstraints() { + return methodConstraints.values(); + } + + public Collection getMethodNames() { + return methodConstraints.keySet(); + } + + private void addHttpMethodConstraints( + Collection httpMethodConstraints) { + if (httpMethodConstraints == null) { + return; + } + for (HttpMethodConstraintElement constraint : httpMethodConstraints) { + String method = constraint.getMethodName(); + if (methodConstraints.containsKey(method)) { + throw new IllegalArgumentException( + "Duplicate method name: " + method); + } + methodConstraints.put(method, constraint); + } + } +} diff --git a/java/javax/servlet/annotation/HandlesTypes.java b/java/javax/servlet/annotation/HandlesTypes.java index 82ec9f663..d32c71e75 100644 --- a/java/javax/servlet/annotation/HandlesTypes.java +++ b/java/javax/servlet/annotation/HandlesTypes.java @@ -24,7 +24,6 @@ import java.lang.annotation.Target; /** * @since Servlet 3.0 - * $Id$ * TODO SERVLET3 - Add comments */ @Target({ElementType.TYPE}) diff --git a/java/javax/servlet/annotation/HttpConstraint.java b/java/javax/servlet/annotation/HttpConstraint.java new file mode 100644 index 000000000..39045074e --- /dev/null +++ b/java/javax/servlet/annotation/HttpConstraint.java @@ -0,0 +1,36 @@ +/* + * 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.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; +import javax.servlet.annotation.ServletSecurity.TransportGuarantee; + +/** + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface HttpConstraint { + EmptyRoleSemantic value() default EmptyRoleSemantic.PERMIT; + TransportGuarantee transportGuarantee() default TransportGuarantee.NONE; + String[] rolesAllowed() default {}; +} diff --git a/java/javax/servlet/annotation/HttpMethodConstraint.java b/java/javax/servlet/annotation/HttpMethodConstraint.java new file mode 100644 index 000000000..58b49eb27 --- /dev/null +++ b/java/javax/servlet/annotation/HttpMethodConstraint.java @@ -0,0 +1,37 @@ +/* + * 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.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic; +import javax.servlet.annotation.ServletSecurity.TransportGuarantee; + +/** + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface HttpMethodConstraint { + String value(); + EmptyRoleSemantic emptyRoleSemantic() default EmptyRoleSemantic.PERMIT; + TransportGuarantee transportGuarantee() default TransportGuarantee.NONE; + String[] rolesAllowed() default {}; +} diff --git a/java/javax/servlet/annotation/MultipartConfig.java b/java/javax/servlet/annotation/MultipartConfig.java index 9bdeab5e6..fe2ee1736 100644 --- a/java/javax/servlet/annotation/MultipartConfig.java +++ b/java/javax/servlet/annotation/MultipartConfig.java @@ -24,7 +24,6 @@ import java.lang.annotation.Target; /** * @since Servlet 3.0 - * $Id$ * TODO SERVLET3 - Add comments */ @Target({ElementType.TYPE}) @@ -32,7 +31,7 @@ import java.lang.annotation.Target; @Documented public @interface MultipartConfig { String location() default ""; - long maxFileSize() default 0L; - long maxRequestSize() default 0L; + long maxFileSize() default -1L; + long maxRequestSize() default -1L; int fileSizeThreshold() default 0; } diff --git a/java/javax/servlet/annotation/ServletSecurity.java b/java/javax/servlet/annotation/ServletSecurity.java new file mode 100644 index 000000000..b66b656e9 --- /dev/null +++ b/java/javax/servlet/annotation/ServletSecurity.java @@ -0,0 +1,45 @@ +/* + * 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.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +@Inherited +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ServletSecurity { + enum EmptyRoleSemantic { + PERMIT, + DENY + } + enum TransportGuarantee { + NONE, + CONFIDENTIAL + } + HttpConstraint value() default @HttpConstraint; + HttpMethodConstraint[] httpMethodConstraints() default {}; +} diff --git a/java/javax/servlet/annotation/WebFilter.java b/java/javax/servlet/annotation/WebFilter.java index a3946a467..bc066252d 100644 --- a/java/javax/servlet/annotation/WebFilter.java +++ b/java/javax/servlet/annotation/WebFilter.java @@ -26,7 +26,6 @@ import javax.servlet.DispatcherType; /** * @since Servlet 3.0 - * $Id$ * TODO SERVLET3 - Add comments */ @Target({ElementType.TYPE}) diff --git a/java/javax/servlet/annotation/WebInitParam.java b/java/javax/servlet/annotation/WebInitParam.java index b77ac4667..9a2315a5c 100644 --- a/java/javax/servlet/annotation/WebInitParam.java +++ b/java/javax/servlet/annotation/WebInitParam.java @@ -24,7 +24,6 @@ import java.lang.annotation.Documented; /** * @since Servlet 3.0 - * $Id$ * TODO SERVLET3 - Add comments */ @Target({ElementType.TYPE}) diff --git a/java/javax/servlet/annotation/WebListener.java b/java/javax/servlet/annotation/WebListener.java index 5f7168fec..0463bd6c6 100644 --- a/java/javax/servlet/annotation/WebListener.java +++ b/java/javax/servlet/annotation/WebListener.java @@ -24,12 +24,11 @@ import java.lang.annotation.Documented; /** * @since Servlet 3.0 - * $Id$ * TODO SERVLET3 - Add comments */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface WebListener { - String description() default ""; + String value() default ""; } diff --git a/java/javax/servlet/annotation/WebServlet.java b/java/javax/servlet/annotation/WebServlet.java index 3f3b3867e..4150314c2 100644 --- a/java/javax/servlet/annotation/WebServlet.java +++ b/java/javax/servlet/annotation/WebServlet.java @@ -24,7 +24,6 @@ import java.lang.annotation.Documented; /** * @since Servlet 3.0 - * $Id$ * TODO SERVLET3 - Add comments */ @Target({ElementType.TYPE}) diff --git a/java/javax/servlet/descriptor/JspConfigDescriptor.java b/java/javax/servlet/descriptor/JspConfigDescriptor.java new file mode 100644 index 000000000..8296d44ae --- /dev/null +++ b/java/javax/servlet/descriptor/JspConfigDescriptor.java @@ -0,0 +1,28 @@ +/* + * 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.descriptor; + +import java.util.Collection; + +/** + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +public interface JspConfigDescriptor { + public Collection getTaglibs(); + public Collection getJspPropertyGroups(); +} diff --git a/java/javax/servlet/descriptor/JspPropertyGroupDescriptor.java b/java/javax/servlet/descriptor/JspPropertyGroupDescriptor.java new file mode 100644 index 000000000..25c71a928 --- /dev/null +++ b/java/javax/servlet/descriptor/JspPropertyGroupDescriptor.java @@ -0,0 +1,38 @@ +/* + * 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.descriptor; + +import java.util.Collection; + +/** + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +public interface JspPropertyGroupDescriptor { + public Collection getUrlPatterns(); + public String getElIgnored(); + public String getPageEncoding(); + public String getScriptingInvalid(); + public String getIsXml(); + public Collection getIncludePreludes(); + public Collection getIncludeCodas(); + public String getDeferredSyntaxAllowedAsLiteral(); + public String getTrimDirectiveWhitespaces(); + public String getDefaultContentType(); + public String getBuffer(); + public String getErrorOnUndeclaredNamespace(); +} diff --git a/java/javax/servlet/descriptor/TaglibDescriptor.java b/java/javax/servlet/descriptor/TaglibDescriptor.java new file mode 100644 index 000000000..208640b88 --- /dev/null +++ b/java/javax/servlet/descriptor/TaglibDescriptor.java @@ -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.descriptor; + +/** + * @since Servlet 3.0 + * TODO SERVLET3 - Add comments + */ +public interface TaglibDescriptor { + public String getTaglidURI(); + public String getTaglibLocation(); +} diff --git a/java/javax/servlet/http/HttpServletRequest.java b/java/javax/servlet/http/HttpServletRequest.java index 6f7f1cd80..194f85a5e 100644 --- a/java/javax/servlet/http/HttpServletRequest.java +++ b/java/javax/servlet/http/HttpServletRequest.java @@ -21,6 +21,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import java.io.IOException; +import java.util.Collection; import java.util.Enumeration; /** @@ -681,7 +682,7 @@ public interface HttpServletRequest extends ServletRequest { * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public void login(java.lang.String username, String password) + public void login(String username, String password) throws ServletException; @@ -700,7 +701,7 @@ public interface HttpServletRequest extends ServletRequest { * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public Iterable getParts(); + public Collection getParts() throws IOException, ServletException; /** @@ -711,5 +712,5 @@ public interface HttpServletRequest extends ServletRequest { * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public Part getPart(java.lang.String name); + public Part getPart(String name); } diff --git a/java/javax/servlet/http/HttpServletRequestWrapper.java b/java/javax/servlet/http/HttpServletRequestWrapper.java index 8d466d7fd..98921de81 100644 --- a/java/javax/servlet/http/HttpServletRequestWrapper.java +++ b/java/javax/servlet/http/HttpServletRequestWrapper.java @@ -20,6 +20,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequestWrapper; import java.io.IOException; +import java.util.Collection; import java.util.Enumeration; /** @@ -292,7 +293,7 @@ public class HttpServletRequestWrapper extends ServletRequestWrapper implements * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public Iterable getParts() { + public Collection getParts() throws IOException, ServletException { return this._getHttpServletRequest().getParts(); } diff --git a/java/javax/servlet/http/HttpServletResponse.java b/java/javax/servlet/http/HttpServletResponse.java index 0a9bf62f2..9a14dc222 100644 --- a/java/javax/servlet/http/HttpServletResponse.java +++ b/java/javax/servlet/http/HttpServletResponse.java @@ -17,6 +17,7 @@ package javax.servlet.http; import java.io.IOException; +import java.util.Collection; import javax.servlet.ServletResponse; @@ -348,7 +349,7 @@ public interface HttpServletResponse extends ServletResponse { * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public Iterable getHeaders(String name); + public Collection getHeaders(String name); /** @@ -357,7 +358,7 @@ public interface HttpServletResponse extends ServletResponse { * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public Iterable getHeaderNames(); + public Collection getHeaderNames(); /* diff --git a/java/javax/servlet/http/HttpServletResponseWrapper.java b/java/javax/servlet/http/HttpServletResponseWrapper.java index f003e4bb5..285f5612c 100644 --- a/java/javax/servlet/http/HttpServletResponseWrapper.java +++ b/java/javax/servlet/http/HttpServletResponseWrapper.java @@ -17,6 +17,7 @@ package javax.servlet.http; import java.io.IOException; +import java.util.Collection; import javax.servlet.ServletResponseWrapper; @@ -218,7 +219,7 @@ public class HttpServletResponseWrapper extends ServletResponseWrapper implement * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public Iterable getHeaders(String name) { + public Collection getHeaders(String name) { return this._getHttpServletResponse().getHeaders(name); } @@ -226,7 +227,7 @@ public class HttpServletResponseWrapper extends ServletResponseWrapper implement * @since Servlet 3.0 * TODO SERVLET3 - Add comments */ - public Iterable getHeaderNames() { + public Collection getHeaderNames() { return this._getHttpServletResponse().getHeaderNames(); } diff --git a/java/javax/servlet/http/Part.java b/java/javax/servlet/http/Part.java index 7f9ca5074..087e62163 100644 --- a/java/javax/servlet/http/Part.java +++ b/java/javax/servlet/http/Part.java @@ -18,6 +18,7 @@ package javax.servlet.http; import java.io.IOException; import java.io.InputStream; +import java.util.Collection; /** * @since Servlet 3.0 @@ -31,6 +32,6 @@ public interface Part { public void write(String fileName) throws IOException; public void delete() throws IOException; public String getHeader(String name); - public Iterable getHeaders(String name); - public Iterable getHeaderNames(); + public Collection getHeaders(String name); + public Collection getHeaderNames(); } diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java index a43f9ef69..42e0fe319 100644 --- a/java/org/apache/catalina/connector/Request.java +++ b/java/org/apache/catalina/connector/Request.java @@ -26,6 +26,7 @@ import java.io.UnsupportedEncodingException; import java.security.Principal; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; @@ -36,7 +37,6 @@ import java.util.TreeMap; import javax.security.auth.Subject; import javax.servlet.AsyncContext; -import javax.servlet.AsyncListener; import javax.servlet.DispatcherType; import javax.servlet.FilterChain; import javax.servlet.RequestDispatcher; @@ -391,11 +391,6 @@ public class Request */ protected volatile AsyncContextImpl asyncContext = null; - /** - * async timeout - */ - protected long asyncTimeout = 0; - protected Boolean asyncSupported = null; @@ -1501,37 +1496,6 @@ public class Request return this.asyncContext; } - public void addAsyncListener(AsyncListener listener) { - // TODO SERVLET3 - async - if (isAsyncSupported() && isAsyncStarted()) { - this.asyncContext.addAsyncListener(listener); - } else { - throw new IllegalStateException("Async [Supported:"+isAsyncSupported()+"; Started:"+isAsyncStarted()+"]"); - } - } - - public void addAsyncListener(AsyncListener listener, ServletRequest servletRequest, ServletResponse servletResponse) { - // TODO SERVLET3 - async - if (isAsyncSupported() && isAsyncStarted()) { - this.asyncContext.addAsyncListener(listener,servletRequest,servletResponse); - } else { - throw new IllegalStateException("Async [Supported:"+isAsyncSupported()+"; Started:"+isAsyncStarted()+"]"); - } - } - - public void setAsyncTimeout(long timeout) { - // TODO SERVLET3 - async - if (this.asyncTimeout!=timeout) { - this.asyncTimeout = timeout; - coyoteRequest.action(ActionCode.ACTION_ASYNC_SETTIMEOUT,new Long(timeout)); - } - } - - public long getAsyncTimeout() { - // TODO SERVLET3 - async - return asyncTimeout; - } - public DispatcherType getDispatcherType() { // TODO SERVLET3 - dispatcher if (internalDispatcherType==null) { @@ -2311,8 +2275,8 @@ public class Request // TODO Servlet 3 - authentication } - public Iterable getParts() { - // TODO Servlet 3 - authentication + public Collection getParts() { + // TODO Servlet 3 - file upload return null; } diff --git a/java/org/apache/catalina/connector/RequestFacade.java b/java/org/apache/catalina/connector/RequestFacade.java index c82f37127..a79b7e364 100644 --- a/java/org/apache/catalina/connector/RequestFacade.java +++ b/java/org/apache/catalina/connector/RequestFacade.java @@ -22,12 +22,12 @@ import java.io.BufferedReader; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Collection; import java.util.Enumeration; import java.util.Locale; import java.util.Map; import javax.servlet.AsyncContext; -import javax.servlet.AsyncListener; import javax.servlet.DispatcherType; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; @@ -973,27 +973,10 @@ public class RequestFacade implements HttpServletRequest { } - public void addAsyncListener(AsyncListener listener) { - request.addAsyncListener(listener); - } - - - public void addAsyncListener(AsyncListener listener, ServletRequest servletRequest, ServletResponse servletResponse) { - request.addAsyncListener(listener,servletRequest,servletResponse); - } - public AsyncContext getAsyncContext() { return request.getAsyncContext(); } - public long getAsyncTimeout() { - return request.getAsyncTimeout(); - } - - public void setAsyncTimeout(long timeout) { - request.setAsyncTimeout(timeout); - } - public DispatcherType getDispatcherType() { return request.getDispatcherType(); } @@ -1011,7 +994,7 @@ public class RequestFacade implements HttpServletRequest { request.logout(); } - public Iterable getParts() { + public Collection getParts() { return request.getParts(); } diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java index e0c26a235..9db6febf5 100644 --- a/java/org/apache/catalina/connector/Response.java +++ b/java/org/apache/catalina/connector/Response.java @@ -29,6 +29,7 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.Enumeration; import java.util.List; import java.util.Locale; @@ -876,7 +877,7 @@ public class Response /** * Return an Iterable of all the header names set for this response. */ - public Iterable getHeaderNames() { + public Collection getHeaderNames() { MimeHeaders headers = coyoteResponse.getMimeHeaders(); int n = headers.size(); @@ -895,7 +896,7 @@ public class Response * * @param name Header name to look up */ - public Iterable getHeaders(String name) { + public Collection getHeaders(String name) { Enumeration enumeration = coyoteResponse.getMimeHeaders().values(name); diff --git a/java/org/apache/catalina/connector/ResponseFacade.java b/java/org/apache/catalina/connector/ResponseFacade.java index e687612f7..9c26b15bf 100644 --- a/java/org/apache/catalina/connector/ResponseFacade.java +++ b/java/org/apache/catalina/connector/ResponseFacade.java @@ -24,6 +24,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.util.Collection; import java.util.Locale; import javax.servlet.ServletOutputStream; @@ -561,11 +562,11 @@ public class ResponseFacade return response.getHeader(name); } - public Iterable getHeaderNames() { + public Collection getHeaderNames() { return response.getHeaderNames(); } - public Iterable getHeaders(String name) { + public Collection getHeaders(String name) { return response.getHeaders(name); } } diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java index ed9d13103..240762ebe 100644 --- a/java/org/apache/catalina/core/ApplicationContext.java +++ b/java/org/apache/catalina/core/ApplicationContext.java @@ -26,6 +26,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.EnumSet; import java.util.Enumeration; +import java.util.EventListener; import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -45,6 +46,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRegistration; import javax.servlet.SessionCookieConfig; import javax.servlet.SessionTrackingMode; +import javax.servlet.descriptor.JspConfigDescriptor; import org.apache.catalina.Context; import org.apache.catalina.Engine; @@ -897,7 +899,7 @@ public class ApplicationContext } - public FilterRegistration findFilterRegistration(String filterName) { + public FilterRegistration getFilterRegistration(String filterName) { // TODO Servlet 3.0 return null; } @@ -967,7 +969,7 @@ public class ApplicationContext } - public ServletRegistration findServletRegistration(String servletName) { + public ServletRegistration getServletRegistration(String servletName) { // TODO Servlet 3.0 return null; } @@ -1062,12 +1064,87 @@ public class ApplicationContext } + @Override public boolean setInitParameter(String name, String value) { // TODO Servlet 3 return false; } + @Override + public void addListener(Class listenerClass) { + // TODO Servlet 3 + } + + + @Override + public void addListener(String className) { + // TODO Servlet 3 + } + + + @Override + public void addListener(T t) { + // TODO Servlet 3 + } + + + @Override + public T createListener(Class c) + throws ServletException { + // TODO Servlet 3 + return null; + } + + + @Override + public void declareRoles(String... roleNames) { + // TODO Servlet 3 + } + + + @Override + public ClassLoader getClassLoader() { + // TODO Servlet 3 + return null; + } + + + @Override + public int getEffectiveMajorVersion() { + // TODO Servlet 3 + return 0; + } + + + @Override + public int getEffectiveMinorVersion() { + // TODO Servlet 3 + return 0; + } + + + @Override + public Map getFilterRegistrations() { + // TODO Servlet 3 + return null; + } + + + @Override + public JspConfigDescriptor getJspConfigDescriptor() { + // TODO Servlet 3 + return null; + } + + + @Override + public Map getServletRegistrations() { + // TODO Servlet 3 + return null; + } + + // -------------------------------------------------------- Package Methods protected StandardContext getContext() { return this.context; diff --git a/java/org/apache/catalina/core/ApplicationContextFacade.java b/java/org/apache/catalina/core/ApplicationContextFacade.java index a9d57ed25..92f843def 100644 --- a/java/org/apache/catalina/core/ApplicationContextFacade.java +++ b/java/org/apache/catalina/core/ApplicationContextFacade.java @@ -29,7 +29,9 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.EnumSet; import java.util.Enumeration; +import java.util.EventListener; import java.util.HashMap; +import java.util.Map; import java.util.Set; import javax.servlet.Filter; @@ -41,6 +43,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRegistration; import javax.servlet.SessionCookieConfig; import javax.servlet.SessionTrackingMode; +import javax.servlet.descriptor.JspConfigDescriptor; import org.apache.catalina.Globals; import org.apache.catalina.security.SecurityUtil; @@ -432,12 +435,12 @@ public final class ApplicationContextFacade } - public FilterRegistration findFilterRegistration(String filterName) { + public FilterRegistration getFilterRegistration(String filterName) { if (SecurityUtil.isPackageProtectionEnabled()) { return (FilterRegistration) doPrivileged( "findFilterRegistration", new Object[]{filterName}); } else { - return context.findFilterRegistration(filterName); + return context.getFilterRegistration(filterName); } } @@ -486,12 +489,12 @@ public final class ApplicationContextFacade } - public ServletRegistration findServletRegistration(String servletName) { + public ServletRegistration getServletRegistration(String servletName) { if (SecurityUtil.isPackageProtectionEnabled()) { return (ServletRegistration) doPrivileged( "findServletRegistration", new Object[]{servletName}); } else { - return context.findServletRegistration(servletName); + return context.getServletRegistration(servletName); } } @@ -545,8 +548,127 @@ public final class ApplicationContextFacade return context.setInitParameter(name, value); } } - - + + + @Override + public void addListener(Class listenerClass) { + if (SecurityUtil.isPackageProtectionEnabled()) { + doPrivileged("addListener", + new Object[]{listenerClass}); + } else { + context.addListener(listenerClass); + } + } + + + @Override + public void addListener(String className) { + if (SecurityUtil.isPackageProtectionEnabled()) { + doPrivileged("addListener", + new Object[]{className}); + } else { + context.addListener(className); + } + } + + + @Override + public void addListener(T t) { + if (SecurityUtil.isPackageProtectionEnabled()) { + doPrivileged("addListener", + new Object[]{t}); + } else { + context.addListener(t); + } + } + + + @Override + public T createListener(Class c) + throws ServletException { + if (SecurityUtil.isPackageProtectionEnabled()) { + return (T) doPrivileged("createListener", new Object[]{c}); + } else { + return context.createListener(c); + } + } + + + @Override + public void declareRoles(String... roleNames) { + if (SecurityUtil.isPackageProtectionEnabled()) { + doPrivileged("declareRoles", + new Object[]{roleNames}); + } else { + context.declareRoles(roleNames); + } + } + + + @Override + public ClassLoader getClassLoader() { + if (SecurityUtil.isPackageProtectionEnabled()) { + return (ClassLoader) doPrivileged("getClassLoader", null); + } else { + return context.getClassLoader(); + } + } + + + @Override + public int getEffectiveMajorVersion() { + if (SecurityUtil.isPackageProtectionEnabled()) { + return ((Integer) doPrivileged("getEffectiveMajorVersion", + null)).intValue(); + } else { + return context.getEffectiveMajorVersion(); + } + } + + + @Override + public int getEffectiveMinorVersion() { + if (SecurityUtil.isPackageProtectionEnabled()) { + return ((Integer) doPrivileged("getEffectiveMinorVersion", + null)).intValue(); + } else { + return context.getEffectiveMinorVersion(); + } + } + + + @Override + public Map getFilterRegistrations() { + if (SecurityUtil.isPackageProtectionEnabled()) { + return (Map) doPrivileged( + "getFilterRegistrations", null); + } else { + return context.getFilterRegistrations(); + } + } + + + @Override + public JspConfigDescriptor getJspConfigDescriptor() { + if (SecurityUtil.isPackageProtectionEnabled()) { + return (JspConfigDescriptor) doPrivileged("getJspConfigDescriptor", + null); + } else { + return context.getJspConfigDescriptor(); + } + } + + + @Override + public Map getServletRegistrations() { + if (SecurityUtil.isPackageProtectionEnabled()) { + return (Map) doPrivileged( + "getServletRegistrations", null); + } else { + return context.getServletRegistrations(); + } + } + /** * Use reflection to invoke the requested method. Cache the method object * to speed up the process @@ -669,4 +791,5 @@ public final class ApplicationContextFacade throw realException; } + } diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java b/java/org/apache/catalina/core/AsyncContextImpl.java index e7dcfe9bf..aab357ce0 100644 --- a/java/org/apache/catalina/core/AsyncContextImpl.java +++ b/java/org/apache/catalina/core/AsyncContextImpl.java @@ -194,18 +194,36 @@ public class AsyncContextImpl implements AsyncContext { } } - public void addAsyncListener(AsyncListener listener) { + @Override + public void addListener(AsyncListener listener) { AsyncListenerWrapper wrapper = new AsyncListenerWrapper(); wrapper.setListener(listener); listeners.add(wrapper); } - public void addAsyncListener(AsyncListener listener, ServletRequest servletRequest, ServletResponse servletResponse) { + @Override + public void addListener(AsyncListener listener, ServletRequest servletRequest, + ServletResponse servletResponse) { AsyncListenerWrapper wrapper = new AsyncListenerWrapper(); wrapper.setListener(listener); listeners.add(wrapper); } - + + @Override + public T createListener(Class clazz) + throws ServletException { + T listener = null; + try { + listener = clazz.newInstance(); + } catch (InstantiationException e) { + ServletException se = new ServletException(e); + throw se; + } catch (IllegalAccessException e) { + ServletException se = new ServletException(e); + throw se; + } + return listener; + } public void recycle() { servletRequest = null; @@ -341,11 +359,11 @@ public class AsyncContextImpl implements AsyncContext { state.set(st); } - public long getAsyncTimeout() { + public long getTimeout() { return timeout; } - public void setAsyncTimeout(long timeout) { + public void setTimeout(long timeout) { this.timeout = timeout; request.getCoyoteRequest().action(ActionCode.ACTION_ASYNC_SETTIMEOUT,new Long(timeout)); } @@ -361,7 +379,7 @@ public class AsyncContextImpl implements AsyncContext { public void init(ServletRequest request, ServletResponse response) { this.servletRequest = request; this.servletResponse = response; - event = new AsyncEvent(request,response); + event = new AsyncEvent(this, request, response); } } diff --git a/java/org/apache/catalina/core/DummyRequest.java b/java/org/apache/catalina/core/DummyRequest.java index ebc511395..3c32ec47c 100644 --- a/java/org/apache/catalina/core/DummyRequest.java +++ b/java/org/apache/catalina/core/DummyRequest.java @@ -25,13 +25,13 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.Socket; import java.security.Principal; +import java.util.Collection; import java.util.Enumeration; import java.util.Iterator; import java.util.Locale; import java.util.Map; import javax.servlet.AsyncContext; -import javax.servlet.AsyncListener; import javax.servlet.DispatcherType; import javax.servlet.FilterChain; import javax.servlet.RequestDispatcher; @@ -282,8 +282,6 @@ public class DummyRequest public String getLocalName() { return null; } public int getLocalPort() { return -1; } public int getRemotePort() { return -1; } - public void addAsyncListener(AsyncListener listener, ServletRequest req, - ServletResponse res) {} public ServletContext getServletContext() { return null; } public boolean isAsyncStarted() { return false; } public boolean isAsyncSupported() { return false; } @@ -291,17 +289,14 @@ public class DummyRequest return null; } public Part getPart(String name) { return null; } - public Iterable getParts() { return null; } + public Collection getParts() { return null; } public boolean authenticate(HttpServletResponse response) throws IOException, ServletException { return false; } public void login(String username, String password) throws ServletException {} public void logout() throws ServletException {} - public void addAsyncListener(AsyncListener listener) {} public AsyncContext getAsyncContext() { return null; } - public long getAsyncTimeout() { return 0; } public DispatcherType getDispatcherType() { return null; } - public void setAsyncTimeout(long timeout) {} public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) { return null; } } diff --git a/java/org/apache/catalina/core/DummyResponse.java b/java/org/apache/catalina/core/DummyResponse.java index f871b6af7..0d3d62013 100644 --- a/java/org/apache/catalina/core/DummyResponse.java +++ b/java/org/apache/catalina/core/DummyResponse.java @@ -22,6 +22,7 @@ package org.apache.catalina.core; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; +import java.util.Collection; import java.util.Locale; import javax.servlet.ServletOutputStream; @@ -101,7 +102,7 @@ public class DummyResponse public Cookie[] getCookies() { return null; } public String getHeader(String name) { return null; } - public Iterable getHeaderNames() { return null; } + public Collection getHeaderNames() { return null; } public String[] getHeaderValues(@SuppressWarnings("unused") String name) { return null; } @@ -130,5 +131,5 @@ public class DummyResponse public void setStatus(int status) {} /** @deprecated */ public void setStatus(int status, String message) {} - public Iterable getHeaders(String name) { return null; } + public Collection getHeaders(String name) { return null; } } diff --git a/java/org/apache/jasper/servlet/JspCServletContext.java b/java/org/apache/jasper/servlet/JspCServletContext.java index 998536ba2..2c85115c2 100644 --- a/java/org/apache/jasper/servlet/JspCServletContext.java +++ b/java/org/apache/jasper/servlet/JspCServletContext.java @@ -25,8 +25,10 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.EnumSet; import java.util.Enumeration; +import java.util.EventListener; import java.util.HashSet; import java.util.Hashtable; +import java.util.Map; import java.util.Set; import java.util.Vector; @@ -40,6 +42,7 @@ import javax.servlet.ServletRegistration; import javax.servlet.SessionCookieConfig; import javax.servlet.SessionTrackingMode; import javax.servlet.FilterRegistration.Dynamic; +import javax.servlet.descriptor.JspConfigDescriptor; /** @@ -512,12 +515,12 @@ public class JspCServletContext implements ServletContext { } - public FilterRegistration findFilterRegistration(String filterName) { + public FilterRegistration getFilterRegistration(String filterName) { return null; } - public ServletRegistration findServletRegistration(String servletName) { + public ServletRegistration getServletRegistration(String servletName) { return null; } @@ -526,4 +529,71 @@ public class JspCServletContext implements ServletContext { return false; } + + @Override + public void addListener(Class listenerClass) { + // NOOP + } + + + @Override + public void addListener(String className) { + // NOOP + } + + + @Override + public void addListener(T t) { + // NOOP + } + + + @Override + public T createListener(Class c) + throws ServletException { + return null; + } + + + @Override + public void declareRoles(String... roleNames) { + // NOOP + } + + + @Override + public ClassLoader getClassLoader() { + return null; + } + + + @Override + public int getEffectiveMajorVersion() { + return 3; + } + + + @Override + public int getEffectiveMinorVersion() { + return 0; + } + + + @Override + public Map getFilterRegistrations() { + return null; + } + + + @Override + public JspConfigDescriptor getJspConfigDescriptor() { + return null; + } + + + @Override + public Map getServletRegistrations() { + return null; + } + } diff --git a/webapps/examples/WEB-INF/classes/async/Async0.java b/webapps/examples/WEB-INF/classes/async/Async0.java index 6929141f4..9ad05b5d0 100644 --- a/webapps/examples/WEB-INF/classes/async/Async0.java +++ b/webapps/examples/WEB-INF/classes/async/Async0.java @@ -42,7 +42,7 @@ public class Async0 extends HttpServlet { } else { resp.setContentType("text/plain"); final AsyncContext actx = req.startAsync(); - actx.setAsyncTimeout(Long.MAX_VALUE); + actx.setTimeout(Long.MAX_VALUE); Runnable run = new Runnable() { public void run() { try { diff --git a/webapps/examples/WEB-INF/classes/async/Async1.java b/webapps/examples/WEB-INF/classes/async/Async1.java index 497bfb26b..b8fbc4029 100644 --- a/webapps/examples/WEB-INF/classes/async/Async1.java +++ b/webapps/examples/WEB-INF/classes/async/Async1.java @@ -35,7 +35,7 @@ public class Async1 extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final AsyncContext actx = req.startAsync(); - actx.setAsyncTimeout(30*1000); + actx.setTimeout(30*1000); Runnable run = new Runnable() { public void run() { try { diff --git a/webapps/examples/WEB-INF/classes/async/Async2.java b/webapps/examples/WEB-INF/classes/async/Async2.java index 0ef07ad9c..874fe4262 100644 --- a/webapps/examples/WEB-INF/classes/async/Async2.java +++ b/webapps/examples/WEB-INF/classes/async/Async2.java @@ -35,7 +35,7 @@ public class Async2 extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final AsyncContext actx = req.startAsync(); - actx.setAsyncTimeout(30*1000); + actx.setTimeout(30*1000); Runnable run = new Runnable() { public void run() { try { diff --git a/webapps/examples/WEB-INF/classes/async/Async3.java b/webapps/examples/WEB-INF/classes/async/Async3.java index 1d4a7e117..c4a85963f 100644 --- a/webapps/examples/WEB-INF/classes/async/Async3.java +++ b/webapps/examples/WEB-INF/classes/async/Async3.java @@ -35,7 +35,7 @@ public class Async3 extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final AsyncContext actx = req.startAsync(); - actx.setAsyncTimeout(30*1000); + actx.setTimeout(30*1000); actx.dispatch("/jsp/async/async3.jsp"); actx.complete(); } -- 2.11.0