Author: markt
Date: Tue Apr 12 15:54:46 2016
New Revision: 1738818
URL: http://svn.apache.org/viewvc?rev=1738818&view=rev
Log:
Create a dedicated package to access Servlet 4.0 features.
Ensure the HTTP/2 push example works under a security manager.
Added:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationMapping.java
- copied, changed from r1738650,
tomcat/trunk/java/org/apache/catalina/core/ApplicationMapping.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/GenericFilter.java
- copied, changed from r1738622,
tomcat/trunk/java/javax/servlet/GenericFilter.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/RequestDispatcher.java
(with props)
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/ (with
props)
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpFilter.java
- copied, changed from r1738622,
tomcat/trunk/java/javax/servlet/http/HttpFilter.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
(with props)
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
- copied, changed from r1738622,
tomcat/trunk/java/javax/servlet/http/HttpServletRequestWrapper.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/Mapping.java
- copied, changed from r1738622,
tomcat/trunk/java/javax/servlet/http/Mapping.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/MappingMatch.java
- copied, changed from r1738622,
tomcat/trunk/java/javax/servlet/http/MappingMatch.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/PushBuilder.java
- copied, changed from r1738622,
tomcat/trunk/java/javax/servlet/http/PushBuilder.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/package-info.java
(with props)
tomcat/tc8.5.x/trunk/test/org/apache/catalina/core/TestApplicationMapping.java
- copied, changed from r1738622,
tomcat/trunk/test/org/apache/catalina/core/TestApplicationMapping.java
Modified:
tomcat/tc8.5.x/trunk/conf/catalina.policy
tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/Request.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/RequestFacade.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationContext.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/MappingData.java
tomcat/tc8.5.x/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
tomcat/tc8.5.x/trunk/webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java
Modified: tomcat/tc8.5.x/trunk/conf/catalina.policy
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/conf/catalina.policy?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/conf/catalina.policy (original)
+++ tomcat/tc8.5.x/trunk/conf/catalina.policy Tue Apr 12 15:54:46 2016
@@ -189,6 +189,10 @@ grant {
// Applications using WebSocket need to be able to access these packages
permission java.lang.RuntimePermission
"accessClassInPackage.org.apache.tomcat.websocket";
permission java.lang.RuntimePermission
"accessClassInPackage.org.apache.tomcat.websocket.server";
+
+ // Applications need to access these packages to use the Servlet 4.0
Preview
+ permission java.lang.RuntimePermission
"accessClassInPackage.org.apache.catalina.servlet4preview";
+ permission java.lang.RuntimePermission
"accessClassInPackage.org.apache.catalina.servlet4preview.http";
};
Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/Request.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/Request.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/Request.java
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/Request.java Tue
Apr 12 15:54:46 2016
@@ -74,11 +74,14 @@ import org.apache.catalina.Realm;
import org.apache.catalina.Session;
import org.apache.catalina.TomcatPrincipal;
import org.apache.catalina.Wrapper;
+import org.apache.catalina.core.ApplicationMapping;
import org.apache.catalina.core.ApplicationPart;
import org.apache.catalina.core.ApplicationPushBuilder;
import org.apache.catalina.core.ApplicationSessionCookieConfig;
import org.apache.catalina.core.AsyncContextImpl;
import org.apache.catalina.mapper.MappingData;
+import org.apache.catalina.servlet4preview.http.Mapping;
+import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.catalina.util.ParameterMap;
import org.apache.coyote.ActionCode;
import org.apache.coyote.UpgradeToken;
@@ -116,7 +119,7 @@ import org.ietf.jgss.GSSException;
* @author Remy Maucherat
* @author Craig R. McClanahan
*/
-public class Request implements HttpServletRequest {
+public class Request implements
org.apache.catalina.servlet4preview.http.HttpServletRequest {
private static final Log log = LogFactory.getLog(Request.class);
@@ -481,6 +484,7 @@ public class Request implements HttpServ
}
mappingData.recycle();
+ applicationMapping.recycle();
applicationRequest = null;
if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) {
@@ -619,6 +623,7 @@ public class Request implements HttpServ
* Mapping data.
*/
protected final MappingData mappingData = new MappingData();
+ private final ApplicationMapping applicationMapping = new
ApplicationMapping(mappingData);
/**
* @return mapping data.
@@ -1902,6 +1907,7 @@ public class Request implements HttpServ
*
* @return {@code true} If this request supports server push
*/
+ @Override
public boolean isPushSupported() {
AtomicBoolean result = new AtomicBoolean();
coyoteRequest.action(ActionCode.IS_PUSH_SUPPORTED, result);
@@ -1915,7 +1921,8 @@ public class Request implements HttpServ
*
* @return A builder to use to construct the push request
*/
- public ApplicationPushBuilder getPushBuilder() {
+ @Override
+ public PushBuilder getPushBuilder() {
return new ApplicationPushBuilder(this);
}
@@ -2181,6 +2188,12 @@ public class Request implements HttpServ
}
+ @Override
+ public Mapping getMapping() {
+ return applicationMapping.getMapping();
+ }
+
+
/**
* @return the HTTP request method used in this Request.
*/
Modified:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/RequestFacade.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/RequestFacade.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/RequestFacade.java
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/connector/RequestFacade.java
Tue Apr 12 15:54:46 2016
@@ -34,15 +34,16 @@ import javax.servlet.ServletInputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.http.Part;
import org.apache.catalina.Globals;
-import org.apache.catalina.core.ApplicationPushBuilder;
import org.apache.catalina.security.SecurityUtil;
+import org.apache.catalina.servlet4preview.http.HttpServletRequest;
+import org.apache.catalina.servlet4preview.http.Mapping;
+import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.tomcat.util.res.StringManager;
/**
@@ -1116,12 +1117,37 @@ public class RequestFacade implements Ht
/**
+ * {@inheritDoc}
+ * <p>
+ * Pulled forward from Servlet 4.0. The method signature may be modified,
+ * removed or replaced at any time until Servlet 4.0 becomes final.
+ */
+ @Override
+ public Mapping getMapping() {
+ return request.getMapping();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ * <p>
* Pulled forward from Servlet 4.0. The method signature may be modified,
* removed or replaced at any time until Servlet 4.0 becomes final.
- *
- * @return A builder to use to construct the push request
*/
- public ApplicationPushBuilder getPushBuilder() {
+ @Override
+ public boolean isPushSupported() {
+ return request.isPushSupported();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Pulled forward from Servlet 4.0. The method signature may be modified,
+ * removed or replaced at any time until Servlet 4.0 becomes final.
+ */
+ @Override
+ public PushBuilder getPushBuilder() {
return request.getPushBuilder();
}
}
Modified:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationContext.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationContext.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationContext.java
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationContext.java
Tue Apr 12 15:54:46 2016
@@ -63,6 +63,7 @@ import org.apache.catalina.WebResourceRo
import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.mapper.MappingData;
+import org.apache.catalina.servlet4preview.http.Mapping;
import org.apache.catalina.util.ServerInfo;
import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.buf.CharChunk;
@@ -375,7 +376,7 @@ public class ApplicationContext
if (wrapper == null)
return (null);
- return new ApplicationDispatcher(wrapper, null, null, null, null,
name);
+ return new ApplicationDispatcher(wrapper, null, null, null, null,
null, name);
}
@@ -460,13 +461,14 @@ public class ApplicationContext
Wrapper wrapper = mappingData.wrapper;
String wrapperPath = mappingData.wrapperPath.toString();
String pathInfo = mappingData.pathInfo.toString();
+ Mapping mapping = (new ApplicationMapping(mappingData)).getMapping();
mappingData.recycle();
// Construct a RequestDispatcher to process this request
return new ApplicationDispatcher
(wrapper, uriCC.toString(), wrapperPath, pathInfo,
- queryString, null);
+ queryString, mapping, null);
}
Modified:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
---
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
(original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationDispatcher.java
Tue Apr 12 15:54:46 2016
@@ -44,6 +44,7 @@ import org.apache.catalina.connector.Req
import org.apache.catalina.connector.RequestFacade;
import org.apache.catalina.connector.Response;
import org.apache.catalina.connector.ResponseFacade;
+import org.apache.catalina.servlet4preview.http.Mapping;
import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.res.StringManager;
@@ -199,12 +200,13 @@ final class ApplicationDispatcher implem
* (if any)
* @param queryString Query string parameters included with this request
* (if any)
+ * @param mapping The mapping for this resource (if any)
* @param name Servlet name (if a named dispatcher was created)
* else <code>null</code>
*/
public ApplicationDispatcher
(Wrapper wrapper, String requestURI, String servletPath,
- String pathInfo, String queryString, String name) {
+ String pathInfo, String queryString, Mapping mapping, String name) {
super();
@@ -215,6 +217,7 @@ final class ApplicationDispatcher implem
this.servletPath = servletPath;
this.pathInfo = pathInfo;
this.queryString = queryString;
+ this.mapping = mapping;
this.name = name;
}
@@ -258,6 +261,12 @@ final class ApplicationDispatcher implem
/**
+ * The mapping for this RequestDispatcher.
+ */
+ private final Mapping mapping;
+
+
+ /**
* The StringManager for this package.
*/
private static final StringManager sm =
StringManager.getManager(Constants.Package);
@@ -349,8 +358,7 @@ final class ApplicationDispatcher implem
(ApplicationHttpRequest) wrapRequest(state);
String contextPath = context.getPath();
HttpServletRequest hrequest = state.hrequest;
- if (hrequest.getAttribute(
- RequestDispatcher.FORWARD_REQUEST_URI) == null) {
+ if (hrequest.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI)
== null) {
wrequest.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI,
hrequest.getRequestURI());
wrequest.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH,
@@ -361,6 +369,16 @@ final class ApplicationDispatcher implem
hrequest.getPathInfo());
wrequest.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING,
hrequest.getQueryString());
+ Mapping mapping;
+ if (hrequest instanceof
org.apache.catalina.servlet4preview.http.HttpServletRequest) {
+ mapping =
((org.apache.catalina.servlet4preview.http.HttpServletRequest)
+ hrequest).getMapping();
+ } else {
+ mapping = (new ApplicationMapping(null)).getMapping();
+ }
+ wrequest.setAttribute(
+
org.apache.catalina.servlet4preview.RequestDispatcher.FORWARD_MAPPING,
+ mapping);
}
wrequest.setContextPath(contextPath);
@@ -371,6 +389,7 @@ final class ApplicationDispatcher implem
wrequest.setQueryString(queryString);
wrequest.setQueryParams(queryString);
}
+ wrequest.setMapping(mapping);
processRequest(request,response,state);
}
@@ -560,6 +579,11 @@ final class ApplicationDispatcher implem
queryString);
wrequest.setQueryParams(queryString);
}
+ if (mapping != null) {
+ wrequest.setAttribute(
+
org.apache.catalina.servlet4preview.RequestDispatcher.INCLUDE_MAPPING,
+ mapping);
+ }
wrequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR,
DispatcherType.INCLUDE);
Modified:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
---
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
(original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
Tue Apr 12 15:54:46 2016
@@ -31,13 +31,14 @@ import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpSession;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.Manager;
import org.apache.catalina.Session;
+import org.apache.catalina.servlet4preview.http.Mapping;
+import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.catalina.util.ParameterMap;
import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.MessageBytes;
@@ -59,7 +60,8 @@ import org.apache.tomcat.util.http.Param
* @author Craig R. McClanahan
* @author Remy Maucherat
*/
-class ApplicationHttpRequest extends HttpServletRequestWrapper {
+class ApplicationHttpRequest
+ extends
org.apache.catalina.servlet4preview.http.HttpServletRequestWrapper {
// ------------------------------------------------------- Static Variables
@@ -74,11 +76,13 @@ class ApplicationHttpRequest extends Htt
RequestDispatcher.INCLUDE_SERVLET_PATH,
RequestDispatcher.INCLUDE_PATH_INFO,
RequestDispatcher.INCLUDE_QUERY_STRING,
+ org.apache.catalina.servlet4preview.RequestDispatcher.INCLUDE_MAPPING,
RequestDispatcher.FORWARD_REQUEST_URI,
RequestDispatcher.FORWARD_CONTEXT_PATH,
RequestDispatcher.FORWARD_SERVLET_PATH,
RequestDispatcher.FORWARD_PATH_INFO,
- RequestDispatcher.FORWARD_QUERY_STRING };
+ RequestDispatcher.FORWARD_QUERY_STRING,
+ org.apache.catalina.servlet4preview.RequestDispatcher.FORWARD_MAPPING};
// ----------------------------------------------------------- Constructors
@@ -181,6 +185,12 @@ class ApplicationHttpRequest extends Htt
/**
+ * The mapping for this request.
+ */
+ private Mapping mapping = null;
+
+
+ /**
* The currently active session for this request.
*/
protected Session session = null;
@@ -509,6 +519,12 @@ class ApplicationHttpRequest extends Htt
}
+ @Override
+ public Mapping getMapping() {
+ return mapping;
+ }
+
+
/**
* Return the session associated with this Request, creating one
* if necessary.
@@ -614,7 +630,8 @@ class ApplicationHttpRequest extends Htt
}
- public ApplicationPushBuilder getPushBuilder() {
+ @Override
+ public PushBuilder getPushBuilder() {
return new ApplicationPushBuilder(this);
}
@@ -678,8 +695,7 @@ class ApplicationHttpRequest extends Htt
// Initialize the attributes for this request
dispatcherType =
(DispatcherType)request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
- requestDispatcherPath =
- request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR);
+ requestDispatcherPath =
request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR);
// Initialize the path elements for this request
contextPath = request.getContextPath();
@@ -687,7 +703,11 @@ class ApplicationHttpRequest extends Htt
queryString = request.getQueryString();
requestURI = request.getRequestURI();
servletPath = request.getServletPath();
-
+ if (request instanceof
org.apache.catalina.servlet4preview.http.HttpServletRequest) {
+ mapping =
((org.apache.catalina.servlet4preview.http.HttpServletRequest)
request).getMapping();
+ } else {
+ mapping = (new ApplicationMapping(null)).getMapping();
+ }
}
@@ -745,6 +765,12 @@ class ApplicationHttpRequest extends Htt
this.queryParamString = queryString;
}
+
+ void setMapping(Mapping mapping) {
+ this.mapping = mapping;
+ }
+
+
// ------------------------------------------------------ Protected Methods
/**
Copied:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationMapping.java
(from r1738650,
tomcat/trunk/java/org/apache/catalina/core/ApplicationMapping.java)
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationMapping.java?p2=tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationMapping.java&p1=tomcat/trunk/java/org/apache/catalina/core/ApplicationMapping.java&r1=1738650&r2=1738818&rev=1738818&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationMapping.java
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationMapping.java
Tue Apr 12 15:54:46 2016
@@ -16,10 +16,9 @@
*/
package org.apache.catalina.core;
-import javax.servlet.http.Mapping;
-import javax.servlet.http.MappingMatch;
-
import org.apache.catalina.mapper.MappingData;
+import org.apache.catalina.servlet4preview.http.Mapping;
+import org.apache.catalina.servlet4preview.http.MappingMatch;
public class ApplicationMapping {
@@ -33,37 +32,41 @@ public class ApplicationMapping {
public Mapping getMapping() {
if (mapping == null) {
- String servletName;
- if (mappingData.wrapper == null) {
- servletName = "";
+ if (mappingData == null) {
+ mapping = new MappingImpl("", "", MappingMatch.UNKNOWN, "");
} else {
- servletName = mappingData.wrapper.getName();
- }
- switch (mappingData.matchType) {
- case CONTEXT_ROOT:
- mapping = new MappingImpl("", "", mappingData.matchType,
servletName);
- break;
- case DEFAULT:
- mapping = new MappingImpl("/", "/", mappingData.matchType,
servletName);
- break;
- case EXACT:
- mapping = new
MappingImpl(mappingData.wrapperPath.toString(),
- mappingData.wrapperPath.toString(),
mappingData.matchType, servletName);
- break;
- case EXTENSION:
- String path = mappingData.wrapperPath.toString();
- int extIndex = path.lastIndexOf('.');
- mapping = new MappingImpl(path.substring(0, extIndex),
- "*" + path.substring(extIndex),
mappingData.matchType, servletName);
- break;
- case PATH:
- mapping = new MappingImpl(mappingData.pathInfo.toString(),
- mappingData.wrapperPath.toString() + "/*",
- mappingData.matchType, servletName);
- break;
- case UNKNOWN:
- mapping = new MappingImpl("", "", mappingData.matchType,
servletName);
- break;
+ String servletName;
+ if (mappingData.wrapper == null) {
+ servletName = "";
+ } else {
+ servletName = mappingData.wrapper.getName();
+ }
+ switch (mappingData.matchType) {
+ case CONTEXT_ROOT:
+ mapping = new MappingImpl("", "",
mappingData.matchType, servletName);
+ break;
+ case DEFAULT:
+ mapping = new MappingImpl("/", "/",
mappingData.matchType, servletName);
+ break;
+ case EXACT:
+ mapping = new
MappingImpl(mappingData.wrapperPath.toString(),
+ mappingData.wrapperPath.toString(),
mappingData.matchType, servletName);
+ break;
+ case EXTENSION:
+ String path = mappingData.wrapperPath.toString();
+ int extIndex = path.lastIndexOf('.');
+ mapping = new MappingImpl(path.substring(0, extIndex),
+ "*" + path.substring(extIndex),
mappingData.matchType, servletName);
+ break;
+ case PATH:
+ mapping = new
MappingImpl(mappingData.pathInfo.toString(),
+ mappingData.wrapperPath.toString() + "/*",
+ mappingData.matchType, servletName);
+ break;
+ case UNKNOWN:
+ mapping = new MappingImpl("", "",
mappingData.matchType, servletName);
+ break;
+ }
}
}
Modified:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
---
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java
(original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/core/ApplicationPushBuilder.java
Tue Apr 12 15:54:46 2016
@@ -35,6 +35,7 @@ import javax.servlet.http.HttpSession;
import org.apache.catalina.Context;
import org.apache.catalina.connector.Request;
+import org.apache.catalina.servlet4preview.http.PushBuilder;
import org.apache.catalina.util.SessionConfig;
import org.apache.coyote.ActionCode;
import org.apache.coyote.PushToken;
@@ -44,7 +45,7 @@ import org.apache.tomcat.util.collection
import org.apache.tomcat.util.http.CookieProcessor;
import org.apache.tomcat.util.res.StringManager;
-public class ApplicationPushBuilder {
+public class ApplicationPushBuilder implements PushBuilder {
private static final StringManager sm =
StringManager.getManager(ApplicationPushBuilder.class);
@@ -167,6 +168,7 @@ public class ApplicationPushBuilder {
}
+ @Override
public ApplicationPushBuilder path(String path) {
if (path.startsWith("/")) {
this.path = path;
@@ -183,77 +185,91 @@ public class ApplicationPushBuilder {
}
+ @Override
public String getPath() {
return path;
}
+ @Override
public ApplicationPushBuilder method(String method) {
this.method = method;
return this;
}
+ @Override
public String getMethod() {
return method;
}
+ @Override
public ApplicationPushBuilder etag(String etag) {
this.etag = etag;
return this;
}
+ @Override
public String getEtag() {
return etag;
}
+ @Override
public ApplicationPushBuilder lastModified(String lastModified) {
this.lastModified = lastModified;
return this;
}
+ @Override
public String getLastModified() {
return lastModified;
}
+ @Override
public ApplicationPushBuilder queryString(String queryString) {
this.queryString = queryString;
return this;
}
+ @Override
public String getQueryString() {
return queryString;
}
+ @Override
public ApplicationPushBuilder sessionId(String sessionId) {
this.sessionId = sessionId;
return this;
}
+ @Override
public String getSessionId() {
return sessionId;
}
+ @Override
public ApplicationPushBuilder conditional(boolean conditional) {
this.conditional = conditional;
return this;
}
+ @Override
public boolean isConditional() {
return conditional;
}
+ @Override
public ApplicationPushBuilder addHeader(String name, String value) {
List<String> values = headers.get(name);
if (values == null) {
@@ -266,6 +282,7 @@ public class ApplicationPushBuilder {
}
+ @Override
public ApplicationPushBuilder setHeader(String name, String value) {
List<String> values = headers.get(name);
if (values == null) {
@@ -280,6 +297,7 @@ public class ApplicationPushBuilder {
}
+ @Override
public ApplicationPushBuilder removeHeader(String name) {
headers.remove(name);
@@ -287,11 +305,13 @@ public class ApplicationPushBuilder {
}
+ @Override
public Set<String> getHeaderNames() {
return Collections.unmodifiableSet(headers.keySet());
}
+ @Override
public String getHeader(String name) {
List<String> values = headers.get(name);
if (values == null) {
@@ -302,6 +322,7 @@ public class ApplicationPushBuilder {
}
+ @Override
public boolean push() {
if (path == null) {
throw new
IllegalStateException(sm.getString("pushBuilder.noPath"));
Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java Tue Apr 12
15:54:46 2016
@@ -30,6 +30,7 @@ import org.apache.catalina.Host;
import org.apache.catalina.WebResource;
import org.apache.catalina.WebResourceRoot;
import org.apache.catalina.Wrapper;
+import org.apache.catalina.servlet4preview.http.MappingMatch;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.buf.Ascii;
@@ -992,6 +993,7 @@ public final class Mapper {
(path.getBuffer(), path.getStart(), path.getLength());
mappingData.wrapperPath.setChars
(path.getBuffer(), path.getStart(), path.getLength());
+ mappingData.matchType = MappingMatch.DEFAULT;
}
// Redirection to a folder
char[] buf = path.getBuffer();
@@ -1040,8 +1042,10 @@ public final class Mapper {
mappingData.wrapperPath.setString("");
// This seems wrong but it is what the spec says...
mappingData.contextPath.setString("");
+ mappingData.matchType = MappingMatch.CONTEXT_ROOT;
} else {
mappingData.wrapperPath.setString(wrapper.name);
+ mappingData.matchType = MappingMatch.EXACT;
}
}
}
@@ -1093,6 +1097,7 @@ public final class Mapper {
(path.getBuffer(), path.getOffset(), path.getLength());
mappingData.wrapper = wrappers[pos].object;
mappingData.jspWildCard = wrappers[pos].jspWildCard;
+ mappingData.matchType = MappingMatch.PATH;
}
}
}
@@ -1137,6 +1142,7 @@ public final class Mapper {
mappingData.requestPath.setChars(buf, servletPath, pathEnd
- servletPath);
mappingData.wrapper = wrapper.object;
+ mappingData.matchType = MappingMatch.EXTENSION;
}
path.setOffset(servletPath);
path.setEnd(pathEnd);
Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/MappingData.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/MappingData.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/MappingData.java
(original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/MappingData.java Tue
Apr 12 15:54:46 2016
@@ -20,6 +20,7 @@ package org.apache.catalina.mapper;
import org.apache.catalina.Context;
import org.apache.catalina.Host;
import org.apache.catalina.Wrapper;
+import org.apache.catalina.servlet4preview.http.MappingMatch;
import org.apache.tomcat.util.buf.MessageBytes;
/**
@@ -43,6 +44,9 @@ public class MappingData {
public final MessageBytes redirectPath = MessageBytes.newInstance();
+ // Fields used by ApplicationMapping to implement
javax.servlet.http.Mapping
+ public MappingMatch matchType = MappingMatch.UNKNOWN;
+
public void recycle() {
host = null;
context = null;
@@ -55,5 +59,6 @@ public class MappingData {
wrapperPath.recycle();
pathInfo.recycle();
redirectPath.recycle();
+ matchType = MappingMatch.UNKNOWN;
}
}
Modified:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/security/SecurityClassLoad.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
---
tomcat/tc8.5.x/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
(original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
Tue Apr 12 15:54:46 2016
@@ -166,6 +166,7 @@ public final class SecurityClassLoad {
private static final void loadCoyotePackage(ClassLoader loader)
throws Exception {
final String basePackage = "org.apache.coyote.";
+ loader.loadClass(basePackage + "PushToken");
loader.loadClass(basePackage + "http11.Constants");
// Make sure system property is read at this point
Class<?> clazz = loader.loadClass(basePackage + "Constants");
@@ -277,7 +278,9 @@ public final class SecurityClassLoad {
loader.loadClass(basePackage + "util.buf.StringCache$CharEntry");
loader.loadClass(basePackage + "util.buf.UriUtil");
// collections
- loader.loadClass(basePackage +
"util.collections.CaseInsensitiveKeyMap");
+ Class<?> clazz = loader.loadClass(basePackage +
"util.collections.CaseInsensitiveKeyMap");
+ // Ensure StringManager is configured
+ clazz.newInstance();
loader.loadClass(basePackage +
"util.collections.CaseInsensitiveKeyMap$EntryImpl");
loader.loadClass(basePackage +
"util.collections.CaseInsensitiveKeyMap$EntryIterator");
loader.loadClass(basePackage +
"util.collections.CaseInsensitiveKeyMap$EntrySet");
@@ -286,7 +289,7 @@ public final class SecurityClassLoad {
loader.loadClass(basePackage + "util.http.CookieProcessor");
loader.loadClass(basePackage + "util.http.NamesEnumerator");
// Make sure system property is read at this point
- Class<?> clazz = loader.loadClass(basePackage +
"util.http.FastHttpDateFormat");
+ clazz = loader.loadClass(basePackage + "util.http.FastHttpDateFormat");
clazz.newInstance();
loader.loadClass(basePackage + "util.http.parser.HttpParser");
loader.loadClass(basePackage + "util.http.parser.MediaType");
Copied:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/GenericFilter.java
(from r1738622, tomcat/trunk/java/javax/servlet/GenericFilter.java)
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/GenericFilter.java?p2=tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/GenericFilter.java&p1=tomcat/trunk/java/javax/servlet/GenericFilter.java&r1=1738622&r2=1738818&rev=1738818&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/GenericFilter.java (original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/GenericFilter.java
Tue Apr 12 15:54:46 2016
@@ -14,11 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package javax.servlet;
+package org.apache.catalina.servlet4preview;
import java.io.Serializable;
import java.util.Enumeration;
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
public abstract class GenericFilter implements Filter, FilterConfig,
Serializable {
private static final long serialVersionUID = 1L;
Added:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/RequestDispatcher.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/RequestDispatcher.java?rev=1738818&view=auto
==============================================================================
---
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/RequestDispatcher.java
(added)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/RequestDispatcher.java
Tue Apr 12 15:54:46 2016
@@ -0,0 +1,47 @@
+/*
+ * 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.servlet4preview;
+
+/**
+ * Provides early access to some parts of the proposed Servlet 4.0 API.
+ */
+public interface RequestDispatcher extends javax.servlet.RequestDispatcher {
+
+ /**
+ * The name of the request attribute that should be set by the container
+ * when the {@link #forward(javax.servlet.ServletRequest,
+ * javax.servlet.ServletResponse)} method is called. It provides the
+ * original value of a path-related property of the request. See the
chapter
+ * "Forwarded Request Parameters" in the Servlet Specification for details.
+ *
+ * @since Servlet 4.0
+ */
+ static final String FORWARD_MAPPING = "javax.servlet.forward.mapping";
+
+ /**
+ * The name of the request attribute that should be set by the container
+ * when the {@link #include(javax.servlet.ServletRequest,
+ * javax.servlet.ServletResponse)} method is called on the
+ * {@code RequestDispatcher} obtained by a path and not by a name.
+ * It provides information on the path that was used to obtain the
+ * {@code RequestDispatcher} instance for this include call. See the
chapter
+ * "Included Request Parameters" in the Servlet Specification for details.
+ *
+ * @since Servlet 4.0
+ */
+ static final String INCLUDE_MAPPING = "javax.servlet.include.mapping";
+}
Propchange:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/RequestDispatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/
------------------------------------------------------------------------------
bugtraq:append = false
Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/
------------------------------------------------------------------------------
bugtraq:label = Bugzilla ID (optional)
Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Tue Apr 12 15:54:46 2016
@@ -0,0 +1,2 @@
+(https?\://(bz|issues)\.apache\.org/bugzilla/show_bug.cgi\?id=\d+|BZ\s?\d+)
+(\d+)
Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/
------------------------------------------------------------------------------
bugtraq:message = Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/
------------------------------------------------------------------------------
bugtraq:url = https://bz.apache.org/bugzilla/show_bug.cgi?id=%BUGID%
Copied:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpFilter.java
(from r1738622, tomcat/trunk/java/javax/servlet/http/HttpFilter.java)
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpFilter.java?p2=tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpFilter.java&p1=tomcat/trunk/java/javax/servlet/http/HttpFilter.java&r1=1738622&r2=1738818&rev=1738818&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/HttpFilter.java (original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpFilter.java
Tue Apr 12 15:54:46 2016
@@ -14,15 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package javax.servlet.http;
+package org.apache.catalina.servlet4preview.http;
import java.io.IOException;
import javax.servlet.FilterChain;
-import javax.servlet.GenericFilter;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.catalina.servlet4preview.GenericFilter;
public abstract class HttpFilter extends GenericFilter {
Added:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java?rev=1738818&view=auto
==============================================================================
---
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
(added)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
Tue Apr 12 15:54:46 2016
@@ -0,0 +1,48 @@
+/*
+ * 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.servlet4preview.http;
+
+/**
+ * Provides early access to some parts of the proposed Servlet 4.0 API.
+ */
+public interface HttpServletRequest extends
javax.servlet.http.HttpServletRequest {
+
+ public Mapping getMapping();
+
+ /**
+ * Does the current request allow push requests. This will return {@code
+ * true} only if the underlying protocol supports server push and if pushes
+ * are permitted from the current request.
+ *
+ * @return {@code true} if server push is supported for the current request
+ * otherwise {@code false}
+ */
+ public boolean isPushSupported();
+
+ /**
+ * Obtain a builder for generating push requests. {@link PushBuilder}
+ * documents how this request will be used as the basis for a push request.
+ * Each call to this method will return a new instance, independent of any
+ * previous instance obtained.
+ *
+ * @return A builder that can be used to generate push requests based on
+ * this request.
+ *
+ * @since Servlet 4.0
+ */
+ public PushBuilder getPushBuilder();
+}
Propchange:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
(from r1738622,
tomcat/trunk/java/javax/servlet/http/HttpServletRequestWrapper.java)
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java?p2=tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java&p1=tomcat/trunk/java/javax/servlet/http/HttpServletRequestWrapper.java&r1=1738622&r2=1738818&rev=1738818&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/HttpServletRequestWrapper.java
(original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/HttpServletRequestWrapper.java
Tue Apr 12 15:54:46 2016
@@ -14,26 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package javax.servlet.http;
+package org.apache.catalina.servlet4preview.http;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Enumeration;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequestWrapper;
/**
- * Provides a convenient implementation of the HttpServletRequest interface
that
- * can be subclassed by developers wishing to adapt the request to a Servlet.
- * This class implements the Wrapper or Decorator pattern. Methods default to
- * calling through to the wrapped request object.
- *
- * @see javax.servlet.http.HttpServletRequest
- * @since v 2.3
+ * Provides early access to some parts of the proposed Servlet 4.0 API.
*/
-public class HttpServletRequestWrapper extends ServletRequestWrapper implements
- HttpServletRequest {
+public class HttpServletRequestWrapper extends
javax.servlet.http.HttpServletRequestWrapper
+ implements HttpServletRequest {
/**
* Constructs a request object wrapping the given request.
@@ -43,7 +31,7 @@ public class HttpServletRequestWrapper e
* @throws java.lang.IllegalArgumentException
* if the request is null
*/
- public HttpServletRequestWrapper(HttpServletRequest request) {
+ public HttpServletRequestWrapper(javax.servlet.http.HttpServletRequest
request) {
super(request);
}
@@ -52,348 +40,42 @@ public class HttpServletRequestWrapper e
}
/**
- * The default behavior of this method is to return getAuthType() on the
- * wrapped request object.
- */
- @Override
- public String getAuthType() {
- return this._getHttpServletRequest().getAuthType();
- }
-
- /**
- * The default behavior of this method is to return getCookies() on the
- * wrapped request object.
- */
- @Override
- public Cookie[] getCookies() {
- return this._getHttpServletRequest().getCookies();
- }
-
- /**
- * The default behavior of this method is to return getDateHeader(String
- * name) on the wrapped request object.
- */
- @Override
- public long getDateHeader(String name) {
- return this._getHttpServletRequest().getDateHeader(name);
- }
-
- /**
- * The default behavior of this method is to return getHeader(String name)
- * on the wrapped request object.
- */
- @Override
- public String getHeader(String name) {
- return this._getHttpServletRequest().getHeader(name);
- }
-
- /**
- * The default behavior of this method is to return getHeaders(String name)
- * on the wrapped request object.
- */
- @Override
- public Enumeration<String> getHeaders(String name) {
- return this._getHttpServletRequest().getHeaders(name);
- }
-
- /**
- * The default behavior of this method is to return getHeaderNames() on the
- * wrapped request object.
- */
- @Override
- public Enumeration<String> getHeaderNames() {
- return this._getHttpServletRequest().getHeaderNames();
- }
-
- /**
- * The default behavior of this method is to return getIntHeader(String
- * name) on the wrapped request object.
- */
- @Override
- public int getIntHeader(String name) {
- return this._getHttpServletRequest().getIntHeader(name);
- }
-
- /**
- * The default behavior of this method is to return getMapping() on the
- * wrapped request object.
- */
- @Override
- public Mapping getMapping() {
- return this._getHttpServletRequest().getMapping();
- }
-
- /**
- * The default behavior of this method is to return getMethod() on the
- * wrapped request object.
- */
- @Override
- public String getMethod() {
- return this._getHttpServletRequest().getMethod();
- }
-
- /**
- * The default behavior of this method is to return getPathInfo() on the
- * wrapped request object.
- */
- @Override
- public String getPathInfo() {
- return this._getHttpServletRequest().getPathInfo();
- }
-
- /**
- * The default behavior of this method is to return getPathTranslated() on
- * the wrapped request object.
- */
- @Override
- public String getPathTranslated() {
- return this._getHttpServletRequest().getPathTranslated();
- }
-
- /**
- * The default behavior of this method is to return getContextPath() on the
- * wrapped request object.
- */
- @Override
- public String getContextPath() {
- return this._getHttpServletRequest().getContextPath();
- }
-
- /**
- * The default behavior of this method is to return getQueryString() on the
- * wrapped request object.
- */
- @Override
- public String getQueryString() {
- return this._getHttpServletRequest().getQueryString();
- }
-
- /**
- * The default behavior of this method is to return getRemoteUser() on the
- * wrapped request object.
- */
- @Override
- public String getRemoteUser() {
- return this._getHttpServletRequest().getRemoteUser();
- }
-
- /**
- * The default behavior of this method is to return isUserInRole(String
- * role) on the wrapped request object.
- */
- @Override
- public boolean isUserInRole(String role) {
- return this._getHttpServletRequest().isUserInRole(role);
- }
-
- /**
- * The default behavior of this method is to return getUserPrincipal() on
- * the wrapped request object.
- */
- @Override
- public java.security.Principal getUserPrincipal() {
- return this._getHttpServletRequest().getUserPrincipal();
- }
-
- /**
- * The default behavior of this method is to return getRequestedSessionId()
- * on the wrapped request object.
- */
- @Override
- public String getRequestedSessionId() {
- return this._getHttpServletRequest().getRequestedSessionId();
- }
-
- /**
- * The default behavior of this method is to return getRequestURI() on the
- * wrapped request object.
- */
- @Override
- public String getRequestURI() {
- return this._getHttpServletRequest().getRequestURI();
- }
-
- /**
- * The default behavior of this method is to return getRequestURL() on the
- * wrapped request object.
- */
- @Override
- public StringBuffer getRequestURL() {
- return this._getHttpServletRequest().getRequestURL();
- }
-
- /**
- * The default behavior of this method is to return getServletPath() on the
- * wrapped request object.
- */
- @Override
- public String getServletPath() {
- return this._getHttpServletRequest().getServletPath();
- }
-
- /**
- * The default behavior of this method is to return getSession(boolean
- * create) on the wrapped request object.
- */
- @Override
- public HttpSession getSession(boolean create) {
- return this._getHttpServletRequest().getSession(create);
- }
-
- /**
- * The default behavior of this method is to return getSession() on the
- * wrapped request object.
- */
- @Override
- public HttpSession getSession() {
- return this._getHttpServletRequest().getSession();
- }
-
- /**
- * The default behavior of this method is to call changeSessionId() on the
- * wrapped request object.
- */
- @Override
- public String changeSessionId() {
- return this._getHttpServletRequest().changeSessionId();
- }
-
- /**
- * The default behavior of this method is to return
- * isRequestedSessionIdValid() on the wrapped request object.
- */
- @Override
- public boolean isRequestedSessionIdValid() {
- return this._getHttpServletRequest().isRequestedSessionIdValid();
- }
-
- /**
- * The default behavior of this method is to return
- * isRequestedSessionIdFromCookie() on the wrapped request object.
- */
- @Override
- public boolean isRequestedSessionIdFromCookie() {
- return this._getHttpServletRequest().isRequestedSessionIdFromCookie();
- }
-
- /**
- * The default behavior of this method is to return
- * isRequestedSessionIdFromURL() on the wrapped request object.
- */
- @Override
- public boolean isRequestedSessionIdFromURL() {
- return this._getHttpServletRequest().isRequestedSessionIdFromURL();
- }
-
- /**
- * The default behavior of this method is to return
- * isRequestedSessionIdFromUrl() on the wrapped request object.
- *
- * @deprecated As of Version 3.0 of the Java Servlet API
- */
- @Override
- @Deprecated
- public boolean isRequestedSessionIdFromUrl() {
- return this._getHttpServletRequest().isRequestedSessionIdFromUrl();
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * The default behavior of this method is to return
- * {@link HttpServletRequest#authenticate(HttpServletResponse)}
- * on the wrapped request object.
- *
- * @since Servlet 3.0
- */
- @Override
- public boolean authenticate(HttpServletResponse response)
- throws IOException, ServletException {
- return this._getHttpServletRequest().authenticate(response);
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * The default behavior of this method is to return
- * {@link HttpServletRequest#login(String, String)}
- * on the wrapped request object.
- *
- * @since Servlet 3.0
- */
- @Override
- public void login(String username, String password) throws
ServletException {
- this._getHttpServletRequest().login(username, password);
- }
-
- /**
* {@inheritDoc}
* <p>
* The default behavior of this method is to return
- * {@link HttpServletRequest#logout()}
- * on the wrapped request object.
+ * {@link HttpServletRequest#getMapping()} on the wrapped request object.
*
- * @since Servlet 3.0
- */
- @Override
- public void logout() throws ServletException {
- this._getHttpServletRequest().logout();
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * The default behavior of this method is to return
- * {@link HttpServletRequest#getParts()}
- * on the wrapped request object.
- *
- * @since Servlet 3.0
+ * @since Servlet 4.0
*/
@Override
- public Collection<Part> getParts() throws IOException,
- ServletException {
- return this._getHttpServletRequest().getParts();
+ public Mapping getMapping() {
+ return this._getHttpServletRequest().getMapping();
}
/**
* {@inheritDoc}
* <p>
* The default behavior of this method is to return
- * {@link HttpServletRequest#getPart(String)}
- * on the wrapped request object.
+ * {@link HttpServletRequest#isPushSupported()} on the wrapped request
object.
*
- * @since Servlet 3.0
+ * @since Servlet 4.0
*/
@Override
- public Part getPart(String name) throws IOException,
- ServletException {
- return this._getHttpServletRequest().getPart(name);
+ public boolean isPushSupported() {
+ return this._getHttpServletRequest().isPushSupported();
}
- /**
- * {@inheritDoc}
- * <p>
- * The default behavior of this method is to return
- * {@link HttpServletRequest#upgrade(Class)} on the wrapped request object.
- *
- * @since Servlet 3.1
- */
- @Override
- public <T extends HttpUpgradeHandler> T upgrade(
- Class<T> httpUpgradeHandlerClass) throws IOException,
ServletException {
- return this._getHttpServletRequest().upgrade(httpUpgradeHandlerClass);
- }
/**
* {@inheritDoc}
* <p>
* The default behavior of this method is to return
- * {@link HttpServletRequest#isPushSupported()} on the wrapped request
object.
+ * {@link HttpServletRequest#getPushBuilder()} on the wrapped request
object.
*
* @since Servlet 4.0
*/
@Override
- public boolean isPushSupported() {
- return this._getHttpServletRequest().isPushSupported();
+ public PushBuilder getPushBuilder() {
+ return this._getHttpServletRequest().getPushBuilder();
}
}
Copied:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/Mapping.java
(from r1738622, tomcat/trunk/java/javax/servlet/http/Mapping.java)
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/Mapping.java?p2=tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/Mapping.java&p1=tomcat/trunk/java/javax/servlet/http/Mapping.java&r1=1738622&r2=1738818&rev=1738818&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/Mapping.java (original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/Mapping.java
Tue Apr 12 15:54:46 2016
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package javax.servlet.http;
+package org.apache.catalina.servlet4preview.http;
import javax.servlet.annotation.WebServlet;
Copied:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/MappingMatch.java
(from r1738622, tomcat/trunk/java/javax/servlet/http/MappingMatch.java)
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/MappingMatch.java?p2=tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/MappingMatch.java&p1=tomcat/trunk/java/javax/servlet/http/MappingMatch.java&r1=1738622&r2=1738818&rev=1738818&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/MappingMatch.java (original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/MappingMatch.java
Tue Apr 12 15:54:46 2016
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package javax.servlet.http;
+package org.apache.catalina.servlet4preview.http;
/**
* Represents the ways that a request can be mapped to a servlet
Copied:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/PushBuilder.java
(from r1738622, tomcat/trunk/java/javax/servlet/http/PushBuilder.java)
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/PushBuilder.java?p2=tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/PushBuilder.java&p1=tomcat/trunk/java/javax/servlet/http/PushBuilder.java&r1=1738622&r2=1738818&rev=1738818&view=diff
==============================================================================
--- tomcat/trunk/java/javax/servlet/http/PushBuilder.java (original)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/http/PushBuilder.java
Tue Apr 12 15:54:46 2016
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package javax.servlet.http;
+package org.apache.catalina.servlet4preview.http;
import java.util.Set;
Added:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/package-info.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/package-info.java?rev=1738818&view=auto
==============================================================================
---
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/package-info.java
(added)
+++
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/package-info.java
Tue Apr 12 15:54:46 2016
@@ -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.
+ */
+
+/**
+ * This package provides early access to some of the new features in the
Servlet
+ * 4.0 API. This package exists in Tomcat 8.5 only. The package will not exist
+ * in Tomcat 9 and applications depending on classes in this package will need
+ * to be modified before they will work with Tomcat 9. It is intended that any
+ * such modifications will be limited to replacing
+ * <code>import org.apache.catalina.servlet4preview...<code> with
+ * <code>import javax.servlet...<code> and removing casts.
+ * <p>
+ * This package is not a complete copy of the proposed Servlet 4.0 API. It
+ * contains only a sub-set of those classes that are new or modified in Servlet
+ * 4.0. Users may request the inclusion of additional Servlet 4.0 API changes
in
+ * this package via a Bugzilla enhancement request against Tomcat 8.5.
+ * <p>
+ * The Servlet 4.0 API is a work in progress. The public API of classes in this
+ * package may change in incompatible ways - including classes being renamed or
+ * deleted - between point releases of Tomcat 8.5.
+ */
+package org.apache.catalina.servlet4preview;
Propchange:
tomcat/tc8.5.x/trunk/java/org/apache/catalina/servlet4preview/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied:
tomcat/tc8.5.x/trunk/test/org/apache/catalina/core/TestApplicationMapping.java
(from r1738622,
tomcat/trunk/test/org/apache/catalina/core/TestApplicationMapping.java)
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/test/org/apache/catalina/core/TestApplicationMapping.java?p2=tomcat/tc8.5.x/trunk/test/org/apache/catalina/core/TestApplicationMapping.java&p1=tomcat/trunk/test/org/apache/catalina/core/TestApplicationMapping.java&r1=1738622&r2=1738818&rev=1738818&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestApplicationMapping.java
(original)
+++
tomcat/tc8.5.x/trunk/test/org/apache/catalina/core/TestApplicationMapping.java
Tue Apr 12 15:54:46 2016
@@ -24,12 +24,12 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.Mapping;
import org.junit.Assert;
import org.junit.Test;
import org.apache.catalina.Context;
+import org.apache.catalina.servlet4preview.http.Mapping;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.TomcatBaseTest;
import org.apache.tomcat.util.buf.ByteChunk;
@@ -284,12 +284,14 @@ public class TestApplicationMapping exte
throws ServletException, IOException {
resp.setContentType("text/plain;charset=UTF-8");
PrintWriter pw = resp.getWriter();
- Mapping mapping = req.getMapping();
+ Mapping mapping =
((org.apache.catalina.servlet4preview.http.HttpServletRequest)
+ req).getMapping();
pw.println("MatchValue=[" + mapping.getMatchValue() + "]");
pw.println("Pattern=[" + mapping.getPattern() + "]");
pw.println("MatchType=[" + mapping.getMappingMatch() + "]");
pw.println("ServletName=[" + mapping.getServletName() + "]");
- Mapping includeMapping = (Mapping)
req.getAttribute(RequestDispatcher.INCLUDE_MAPPING);
+ Mapping includeMapping = (Mapping) req.getAttribute(
+
org.apache.catalina.servlet4preview.RequestDispatcher.INCLUDE_MAPPING);
if (includeMapping != null) {
pw.println("IncludeMatchValue=[" +
includeMapping.getMatchValue() + "]");
pw.println("IncludePattern=[" + includeMapping.getPattern() +
"]");
@@ -297,7 +299,8 @@ public class TestApplicationMapping exte
pw.println("IncludeServletName=[" +
includeMapping.getServletName() + "]");
}
- Mapping forwardMapping = (Mapping)
req.getAttribute(RequestDispatcher.FORWARD_MAPPING);
+ Mapping forwardMapping = (Mapping) req.getAttribute(
+
org.apache.catalina.servlet4preview.RequestDispatcher.FORWARD_MAPPING);
if (forwardMapping != null) {
pw.println("ForwardMatchValue=[" +
forwardMapping.getMatchValue() + "]");
pw.println("ForwardPattern=[" + forwardMapping.getPattern() +
"]");
Modified: tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Tue Apr 12 15:54:46 2016
@@ -114,6 +114,11 @@
functions as designed and sessions are swapped out to keep the active
session count below <code>maxActiveSessions</code>. (markt)
</fix>
+ <add>
+ Add the <code>org.apache.catalina.servlet4preview</code> package that
+ can be used to gain early access to Servlet 4.0 features. Note that
this
+ package will <strong>not</strong> be present in Tomcat 9. (markt)
+ </add>
</changelog>
</subsection>
<subsection name="Coyote">
Modified:
tomcat/tc8.5.x/trunk/webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java
URL:
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java?rev=1738818&r1=1738817&r2=1738818&view=diff
==============================================================================
---
tomcat/tc8.5.x/trunk/webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java
(original)
+++
tomcat/tc8.5.x/trunk/webapps/examples/WEB-INF/classes/http2/SimpleImagePush.java
Tue Apr 12 15:54:46 2016
@@ -24,8 +24,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.catalina.connector.RequestFacade;
-import org.apache.catalina.core.ApplicationPushBuilder;
+import org.apache.catalina.servlet4preview.http.PushBuilder;
public class SimpleImagePush extends HttpServlet {
@@ -35,7 +34,8 @@ public class SimpleImagePush extends Htt
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
- ApplicationPushBuilder pb = ((RequestFacade)
req).getPushBuilder().path("servlets/images/code.gif");
+ PushBuilder pb =
((org.apache.catalina.servlet4preview.http.HttpServletRequest)
+ req).getPushBuilder().path("servlets/images/code.gif");
pb.push();
resp.setCharacterEncoding("UTF-8");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]