Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Auge2015-08-12 18:48:26 +0000
committerRaymond Auge2015-08-12 18:48:26 +0000
commit14b77e49a4a25351725b3dad145f24c2b2cb141b (patch)
tree2976a89b708486533496979342c250433b0df9c5 /bundles/org.eclipse.equinox.http.servlet
parent9768ce0f3ebc232ec78118b986350cc589681022 (diff)
downloadrt.equinox.bundles-14b77e49a4a25351725b3dad145f24c2b2cb141b.tar.gz
rt.equinox.bundles-14b77e49a4a25351725b3dad145f24c2b2cb141b.tar.xz
rt.equinox.bundles-14b77e49a4a25351725b3dad145f24c2b2cb141b.zip
Bug 467859 - [http whiteboard] request/response wrappers are not visible ...
... during later request processing Signed-off-by: Raymond Auge <raymond.auge@liferay.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.http.servlet')
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java141
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java88
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java64
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java20
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestBuilder.java185
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/NamedDispatcherAdaptor.java80
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java10
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java46
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java63
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java41
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Const.java3
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java31
12 files changed, 385 insertions, 387 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
index eb429ed9..fb3b5651 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
@@ -23,7 +23,7 @@ import javax.servlet.http.*;
import org.eclipse.equinox.http.servlet.context.ContextPathCustomizer;
import org.eclipse.equinox.http.servlet.internal.context.*;
import org.eclipse.equinox.http.servlet.internal.error.*;
-import org.eclipse.equinox.http.servlet.internal.servlet.*;
+import org.eclipse.equinox.http.servlet.internal.servlet.Match;
import org.eclipse.equinox.http.servlet.internal.util.*;
import org.osgi.framework.*;
import org.osgi.framework.dto.ServiceReferenceDTO;
@@ -162,7 +162,7 @@ public class HttpServiceRuntimeImpl
requestInfoDTO.path = path;
try {
- doDispatch(null, null, path, requestInfoDTO);
+ getDispatchTargets(path, requestInfoDTO);
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -196,12 +196,36 @@ public class HttpServiceRuntimeImpl
contextPathCustomizerHolder = null;
}
- public boolean doDispatch(
- HttpServletRequest request, HttpServletResponse response,
- String path)
- throws ServletException, IOException {
+ public DispatchTargets getDispatchTargets(
+ String path, RequestInfoDTO requestInfoDTO) {
+
+ // perfect match
+ DispatchTargets dispatchTargets = getDispatchTargets(
+ path, null, Match.EXACT, requestInfoDTO);
+
+ if (dispatchTargets == null) {
+ // extension match
+ String extension = Path.findExtension(path);
+
+ dispatchTargets = getDispatchTargets(
+ path, extension, Match.EXTENSION,
+ requestInfoDTO);
+ }
- return doDispatch(request, response, path, null);
+ if (dispatchTargets == null) {
+ // regex match
+ dispatchTargets = getDispatchTargets(
+ path, null, Match.REGEX, requestInfoDTO);
+ }
+
+ if (dispatchTargets == null) {
+ // handle '/' aliases
+ dispatchTargets = getDispatchTargets(
+ path, null, Match.DEFAULT_SERVLET,
+ requestInfoDTO);
+ }
+
+ return dispatchTargets;
}
public Set<Object> getRegisteredObjects() {
@@ -332,104 +356,23 @@ public class HttpServiceRuntimeImpl
return legacyIdGenerator.getAndIncrement();
}
- private boolean doDispatch(
- HttpServletRequest request, HttpServletResponse response,
- String path, RequestInfoDTO requestInfoDTO)
- throws ServletException, IOException {
-
- // perfect match
- if (doDispatch(
- request, response, path, null, Match.EXACT, requestInfoDTO)) {
-
- return true;
- }
-
- String extensionAlias = findExtensionAlias(path);
-
- // extension match
- if (doDispatch(
- request, response, path, extensionAlias, Match.EXTENSION,
- requestInfoDTO)) {
-
- return true;
- }
-
- // regex match
- if (doDispatch(
- request, response, path, null, Match.REGEX, requestInfoDTO)) {
-
- return true;
- }
-
- // handle '/' aliases
- if (doDispatch(
- request, response, path, null, Match.DEFAULT_SERVLET,
- requestInfoDTO)) {
-
- return true;
- }
-
- return false;
- }
-
- private boolean doDispatch(
- HttpServletRequest request, HttpServletResponse response,
- String requestURI, String extension, Match match,
- RequestInfoDTO requestInfoDTO)
- throws ServletException, IOException {
+ public boolean doDispatch(
+ HttpServletRequest request, HttpServletResponse response, String path)
+ throws IOException, ServletException {
- DispatchTargets dispatchTargets = getDispatchTargets(
- request, requestURI, extension, match, requestInfoDTO);
+ DispatchTargets dispatchTargets = getDispatchTargets(path, null);
- if ((dispatchTargets == null) || (requestInfoDTO != null)) {
+ if (dispatchTargets == null) {
return false;
}
- ContextController contextController =
- dispatchTargets.getContextController();
- DispatcherType dispatcherType = DispatcherType.REQUEST;
-
- if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null) {
- request.setAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH, contextController.getContextPath());
- request.setAttribute(RequestDispatcher.INCLUDE_PATH_INFO, dispatchTargets.getPathInfo());
- request.setAttribute(RequestDispatcher.INCLUDE_QUERY_STRING, request.getQueryString());
- request.setAttribute(RequestDispatcher.INCLUDE_REQUEST_URI, requestURI);
- request.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, dispatchTargets.getServletPath());
-
- dispatcherType = DispatcherType.INCLUDE;
- }
- else if (request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI) != null) {
- dispatcherType = DispatcherType.FORWARD;
- }
-
- HttpServletRequest wrappedRequest = new HttpServletRequestBuilder(
- request, dispatchTargets).build();
- HttpServletResponseWrapper wrapperResponse =
- new HttpServletResponseWrapperImpl(response);
-
- ResponseStateHandler responseStateHandler = new ResponseStateHandler(
- wrappedRequest, wrapperResponse, dispatchTargets, dispatcherType);
-
- responseStateHandler.processRequest();
-
- return true;
- }
-
- private String findExtensionAlias(String alias) {
- String lastSegment = alias.substring(alias.lastIndexOf('/') + 1);
-
- int dot = lastSegment.lastIndexOf('.');
-
- if (dot == -1) {
- return null;
- }
-
- return lastSegment.substring(dot + 1);
+ return dispatchTargets.doDispatch(
+ request, response, path, request.getDispatcherType());
}
private DispatchTargets getDispatchTargets(
- HttpServletRequest request, String requestURI, String extension,
- Match match, RequestInfoDTO requestInfoDTO) {
+ String requestURI, String extension, Match match,
+ RequestInfoDTO requestInfoDTO) {
Collection<ContextController> contextControllers = getContextControllers(
requestURI);
@@ -457,7 +400,7 @@ public class HttpServiceRuntimeImpl
for (ContextController contextController : contextControllers) {
DispatchTargets dispatchTargets =
contextController.getDispatchTargets(
- request, null, requestURI, servletPath, pathInfo,
+ null, requestURI, servletPath, pathInfo,
extension, match, requestInfoDTO);
if (dispatchTargets != null) {
@@ -465,7 +408,7 @@ public class HttpServiceRuntimeImpl
}
}
- if ((match == Match.EXACT) || (extension != null)) {
+ if (match == Match.EXACT) {
break;
}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java
index 874203e7..d11198bb 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java
@@ -594,13 +594,86 @@ public class ContextController {
}
public DispatchTargets getDispatchTargets(
- HttpServletRequest request, String servletName, String requestURI,
- String servletPath, String pathInfo, String extension, Match match,
+ String path, RequestInfoDTO requestInfoDTO) {
+
+ // perfect match
+ DispatchTargets dispatchTargets = getDispatchTargets(
+ path, null, Match.EXACT, requestInfoDTO);
+
+ if (dispatchTargets == null) {
+ // extension match
+ String extension = Path.findExtension(path);
+
+ dispatchTargets = getDispatchTargets(
+ path, extension, Match.EXTENSION,
+ requestInfoDTO);
+ }
+
+ if (dispatchTargets == null) {
+ // regex match
+ dispatchTargets = getDispatchTargets(
+ path, null, Match.REGEX, requestInfoDTO);
+ }
+
+ if (dispatchTargets == null) {
+ // handle '/' aliases
+ dispatchTargets = getDispatchTargets(
+ path, null, Match.DEFAULT_SERVLET,
+ requestInfoDTO);
+ }
+
+ return dispatchTargets;
+ }
+
+ private DispatchTargets getDispatchTargets(
+ String path, String extension, Match match,
RequestInfoDTO requestInfoDTO) {
- checkShutdown();
+ int pos = path.lastIndexOf('/');
+
+ String servletPath = path;
+ String pathInfo = null;
+
+ if (match == Match.DEFAULT_SERVLET) {
+ pathInfo = servletPath;
+ servletPath = Const.SLASH;
+ }
+
+ do {
+ DispatchTargets dispatchTargets = getDispatchTargets(
+ null, path, servletPath, pathInfo,
+ extension, match, requestInfoDTO);
+
+ if (dispatchTargets != null) {
+ return dispatchTargets;
+ }
- getProxyContext().initializeServletPath(request);
+ if (match == Match.EXACT) {
+ break;
+ }
+
+ if (pos > -1) {
+ String newServletPath = path.substring(0, pos);
+ pathInfo = path.substring(pos);
+ servletPath = newServletPath;
+ pos = servletPath.lastIndexOf('/');
+
+ continue;
+ }
+
+ break;
+ }
+ while (true);
+
+ return null;
+ }
+
+ public DispatchTargets getDispatchTargets(
+ String servletName, String requestURI, String servletPath,
+ String pathInfo, String extension, Match match,
+ RequestInfoDTO requestInfoDTO) {
+
+ checkShutdown();
EndpointRegistration<?> endpointRegistration = null;
String pattern = null;
@@ -619,7 +692,10 @@ public class ContextController {
return null;
}
- endpointRegistration.addReference();
+ if (match == Match.EXTENSION) {
+ servletPath = servletPath + pathInfo;
+ pathInfo = null;
+ }
addEnpointRegistrationsToRequestInfo(
endpointRegistration, requestInfoDTO);
@@ -662,8 +738,6 @@ public class ContextController {
!matchingFilterRegistrations.contains(filterRegistration)) {
matchingFilterRegistrations.add(filterRegistration);
-
- filterRegistration.addReference();
}
}
}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java
index 2a2519c9..79956aca 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/DispatchTargets.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Raymond Augé and others.
+ * Copyright (c) 2014, 2015 Raymond Augé and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,10 +11,15 @@
package org.eclipse.equinox.http.servlet.internal.context;
+import java.io.IOException;
import java.util.Collections;
import java.util.List;
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration;
import org.eclipse.equinox.http.servlet.internal.registration.FilterRegistration;
+import org.eclipse.equinox.http.servlet.internal.servlet.*;
/**
* @author Raymond Augé
@@ -45,6 +50,63 @@ public class DispatchTargets {
this.pathInfo = pathInfo;
}
+ public boolean doDispatch(
+ HttpServletRequest request, HttpServletResponse response,
+ String requestURI, DispatcherType dispatcherType)
+ throws ServletException, IOException {
+
+ if (dispatcherType == DispatcherType.INCLUDE) {
+ request.setAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH, contextController.getContextPath());
+ request.setAttribute(RequestDispatcher.INCLUDE_PATH_INFO, getPathInfo());
+ request.setAttribute(RequestDispatcher.INCLUDE_QUERY_STRING, request.getQueryString());
+ request.setAttribute(RequestDispatcher.INCLUDE_REQUEST_URI, requestURI);
+ request.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, getServletPath());
+ }
+ else if (dispatcherType == DispatcherType.FORWARD) {
+ response.resetBuffer();
+
+ request.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH, request.getContextPath());
+ request.setAttribute(RequestDispatcher.FORWARD_PATH_INFO, request.getPathInfo());
+ request.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING, request.getQueryString());
+ request.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI, request.getRequestURI());
+ request.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH, request.getServletPath());
+ }
+
+ HttpServletRequestBuilder httpRuntimeRequest = HttpServletRequestBuilder.findHttpRuntimeRequest(request);
+ boolean pushedState = false;
+
+ try {
+ if (httpRuntimeRequest == null) {
+ httpRuntimeRequest = new HttpServletRequestBuilder(request, this, dispatcherType);
+ request = httpRuntimeRequest;
+ response = new HttpServletResponseWrapperImpl(response);
+ }
+ else {
+ httpRuntimeRequest.push(this);
+ pushedState = true;
+ }
+
+ ResponseStateHandler responseStateHandler = new ResponseStateHandler(
+ request, response, this, dispatcherType);
+
+ responseStateHandler.processRequest();
+
+ if ((dispatcherType == DispatcherType.FORWARD) &&
+ !response.isCommitted()) {
+
+ response.flushBuffer();
+ response.getWriter().close();
+ }
+
+ return true;
+ }
+ finally {
+ if (pushedState) {
+ httpRuntimeRequest.pop();
+ }
+ }
+ }
+
public ContextController getContextController() {
return contextController;
}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java
index 7da78842..94143788 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Raymond Augé and others.
+ * Copyright (c) 2014, 2015 Raymond Augé and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@
package org.eclipse.equinox.http.servlet.internal.registration;
import org.eclipse.equinox.http.servlet.internal.servlet.Match;
+import org.eclipse.equinox.http.servlet.internal.util.Const;
import org.osgi.dto.DTO;
/**
@@ -33,7 +34,7 @@ public abstract class MatchableRegistration<T, D extends DTO>
int cpl = pattern.length() - 2;
- if (pattern.endsWith("/*") && servletPath.regionMatches(0, pattern, 0, cpl)) { //$NON-NLS-1$
+ if (pattern.endsWith(Const.SLASH_STAR) && servletPath.regionMatches(0, pattern, 0, cpl)) {
if ((pattern.length() > 2) && !pattern.startsWith(servletPath)) {
return false;
}
@@ -55,7 +56,7 @@ public abstract class MatchableRegistration<T, D extends DTO>
return pattern.equals(servletPath);
}
- if (pattern.indexOf("/*.") == 0) { //$NON-NLS-1$
+ if (pattern.indexOf(Const.SLASH_STAR_DOT) == 0) {
pattern = pattern.substring(1);
}
@@ -71,8 +72,17 @@ public abstract class MatchableRegistration<T, D extends DTO>
}
}
- if ((match == Match.EXTENSION) && (pattern.indexOf("*.") == 0)) { //$NON-NLS-1$
- return pattern.substring(2).equals(extension);
+ if (match == Match.EXTENSION) {
+ int index = pattern.lastIndexOf(Const.STAR_DOT);
+ String patterPrefix = Const.BLANK;
+
+ if (index > 0) {
+ patterPrefix = pattern.substring(0, index - 1);
+ }
+
+ if ((index != -1) && (servletPath.equals(patterPrefix))) {
+ return pattern.endsWith(Const.DOT + extension);
+ }
}
return false;
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestBuilder.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestBuilder.java
index e1c75cc0..4edc2eb0 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestBuilder.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/HttpServletRequestBuilder.java
@@ -12,114 +12,46 @@
*******************************************************************************/
package org.eclipse.equinox.http.servlet.internal.servlet;
-import java.lang.reflect.*;
-import java.util.*;
+import java.util.List;
+import java.util.Stack;
import javax.servlet.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
+import javax.servlet.http.*;
+import org.eclipse.equinox.http.servlet.internal.context.ContextController;
import org.eclipse.equinox.http.servlet.internal.context.DispatchTargets;
-import org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration;
import org.eclipse.equinox.http.servlet.internal.util.Const;
import org.eclipse.equinox.http.servlet.internal.util.EventListeners;
import org.osgi.service.http.HttpContext;
-public class HttpServletRequestBuilder {
+public class HttpServletRequestBuilder extends HttpServletRequestWrapper {
- static interface RequestGetter {
- HttpServletRequest getOriginalRequest();
- }
-
- private DispatchTargets dispatchTargets;
- private EndpointRegistration<?> servletRegistration;
+ private Stack<DispatchTargets> dispatchTargets = new Stack<DispatchTargets>();
private final HttpServletRequest request;
- private HttpServletRequest requestProxy;
- private boolean isRequestDispatcherInclude;
+ private final DispatcherType dispatcherType;
static final String INCLUDE_REQUEST_URI_ATTRIBUTE = "javax.servlet.include.request_uri"; //$NON-NLS-1$
static final String INCLUDE_CONTEXT_PATH_ATTRIBUTE = "javax.servlet.include.context_path"; //$NON-NLS-1$
static final String INCLUDE_SERVLET_PATH_ATTRIBUTE = "javax.servlet.include.servlet_path"; //$NON-NLS-1$
static final String INCLUDE_PATH_INFO_ATTRIBUTE = "javax.servlet.include.path_info"; //$NON-NLS-1$
- private final ThreadLocal<HttpServletRequest> requestTL = new ThreadLocal<HttpServletRequest>();
-
- private final static Map<Method, Method> requestToHandlerMethods;
-
- static {
- requestToHandlerMethods = createContextToHandlerMethods();
- }
-
- private static Map<Method, Method> createContextToHandlerMethods() {
- Map<Method, Method> methods = new HashMap<Method, Method>();
- Method[] handlerMethods =
- HttpServletRequestBuilder.class.getDeclaredMethods();
+ public static HttpServletRequestBuilder findHttpRuntimeRequest(
+ HttpServletRequest request) {
- for (int i = 0; i < handlerMethods.length; i++) {
- Method handlerMethod = handlerMethods[i];
- String name = handlerMethod.getName();
- Class<?>[] parameterTypes = handlerMethod.getParameterTypes();
-
- try {
- Method method = HttpServletRequest.class.getMethod(
- name, parameterTypes);
- methods.put(method, handlerMethod);
- }
- catch (NoSuchMethodException e) {
- // do nothing
+ while (request instanceof HttpServletRequestWrapper) {
+ if (request instanceof HttpServletRequestBuilder) {
+ return (HttpServletRequestBuilder)request;
}
+
+ request = (HttpServletRequest)((HttpServletRequestWrapper)request).getRequest();
}
- return methods;
+ return null;
}
- public HttpServletRequestBuilder(HttpServletRequest request, DispatchTargets dispatchTargets) {
+ public HttpServletRequestBuilder(HttpServletRequest request, DispatchTargets dispatchTargets, DispatcherType dispatcherType) {
+ super(request);
this.request = request;
- this.dispatchTargets = dispatchTargets;
- this.servletRegistration = dispatchTargets.getServletRegistration();
-
- isRequestDispatcherInclude = request.getAttribute(HttpServletRequestBuilder.INCLUDE_REQUEST_URI_ATTRIBUTE) != null;
-
- this.requestProxy = (HttpServletRequest)Proxy.newProxyInstance(
- getClass().getClassLoader(),
- new Class[] {HttpServletRequest.class, RequestGetter.class},
- new InvocationHandler() {
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
-
- if (method.getName().equals("getOriginalRequest")) {
- return getOriginalRequest();
- }
-
- return HttpServletRequestBuilder.this.invoke(proxy, method, args);
- }
-
- }
- );
- }
-
- public HttpServletRequest build() {
- return requestProxy;
- }
-
-
- Object invoke(Object proxy, Method method, Object[] args) throws Throwable{
- requestTL.set((HttpServletRequest)proxy);
-
- try {
- Method m = requestToHandlerMethods.get(method);
- try {
- if (m != null) {
- return m.invoke(this, args);
- }
- return method.invoke(request, args);
- } catch (InvocationTargetException e) {
- throw e.getCause();
- }
- }
- finally {
- requestTL.remove();
- }
+ this.dispatchTargets.push(dispatchTargets);
+ this.dispatcherType = dispatcherType;
}
public String getAuthType() {
@@ -139,33 +71,37 @@ public class HttpServletRequestBuilder {
}
public String getPathInfo() {
- if (isRequestDispatcherInclude)
+ if (dispatcherType == DispatcherType.INCLUDE)
return request.getPathInfo();
- return dispatchTargets.getPathInfo();
+ return dispatchTargets.peek().getPathInfo();
+ }
+
+ public DispatcherType getDispatcherType() {
+ return dispatcherType;
}
public ServletContext getServletContext() {
- return servletRegistration.getServletContext();
+ return dispatchTargets.peek().getServletRegistration().getServletContext();
}
public String getServletPath() {
- if (isRequestDispatcherInclude)
+ if (dispatcherType == DispatcherType.INCLUDE)
return request.getServletPath();
- if (dispatchTargets.getServletPath().equals(Const.SLASH)) {
+ if (dispatchTargets.peek().getServletPath().equals(Const.SLASH)) {
return Const.BLANK;
}
- return dispatchTargets.getServletPath();
+ return dispatchTargets.peek().getServletPath();
}
public String getContextPath() {
- return dispatchTargets.getContextController().getFullContextPath();
+ return dispatchTargets.peek().getContextController().getFullContextPath();
}
public Object getAttribute(String attributeName) {
- String servletPath = dispatchTargets.getServletPath();
- if (isRequestDispatcherInclude) {
+ String servletPath = dispatchTargets.peek().getServletPath();
+ if (dispatcherType == DispatcherType.INCLUDE) {
if (attributeName.equals(HttpServletRequestBuilder.INCLUDE_CONTEXT_PATH_ATTRIBUTE)) {
String contextPath = (String) request.getAttribute(HttpServletRequestBuilder.INCLUDE_CONTEXT_PATH_ATTRIBUTE);
if (contextPath == null || contextPath.equals(Const.SLASH))
@@ -177,6 +113,10 @@ public class HttpServletRequestBuilder {
return contextPath + includeServletPath;
} else if (attributeName.equals(HttpServletRequestBuilder.INCLUDE_SERVLET_PATH_ATTRIBUTE)) {
+ String attributeServletPath = (String) request.getAttribute(HttpServletRequestBuilder.INCLUDE_SERVLET_PATH_ATTRIBUTE);
+ if (attributeServletPath != null) {
+ return attributeServletPath;
+ }
if (servletPath.equals(Const.SLASH)) {
return Const.BLANK;
}
@@ -206,23 +146,36 @@ public class HttpServletRequestBuilder {
}
public RequestDispatcher getRequestDispatcher(String path) {
- if (!path.startsWith(getContextPath())) {
- path = getContextPath().substring(
- request.getContextPath().length()).concat(path);
+ ContextController contextController =
+ this.dispatchTargets.peek().getContextController();
+
+ // support relative paths
+ if (!path.startsWith(Const.SLASH)) {
+ path = this.dispatchTargets.peek().getServletPath() + Const.SLASH + path;
}
+ // if the path starts with the full context path strip it
+ else if (path.startsWith(contextController.getFullContextPath())) {
+ path = path.substring(contextController.getFullContextPath().length());
+ }
+
+ DispatchTargets requestedDispatchTargets = contextController.getDispatchTargets(path, null);
- return new RequestDispatcherAdaptor(request.getRequestDispatcher(path));
+ if (requestedDispatchTargets == null) {
+ return null;
+ }
+
+ return new RequestDispatcherAdaptor(requestedDispatchTargets, path);
}
public static String getDispatchPathInfo(HttpServletRequest req) {
- if (req.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE) != null)
+ if (req.getDispatcherType() == DispatcherType.INCLUDE)
return (String) req.getAttribute(INCLUDE_PATH_INFO_ATTRIBUTE);
return req.getPathInfo();
}
public static String getDispatchServletPath(HttpServletRequest req) {
- if (req.getAttribute(INCLUDE_REQUEST_URI_ATTRIBUTE) != null) {
+ if (req.getDispatcherType() == DispatcherType.INCLUDE) {
String servletPath = (String) req.getAttribute(INCLUDE_SERVLET_PATH_ATTRIBUTE);
return (servletPath == null) ? Const.BLANK : servletPath;
}
@@ -232,8 +185,8 @@ public class HttpServletRequestBuilder {
public HttpSession getSession() {
HttpSession session = request.getSession();
if (session != null) {
- return dispatchTargets.getContextController().getSessionAdaptor(
- session, servletRegistration.getT().getServletConfig().getServletContext());
+ return dispatchTargets.peek().getContextController().getSessionAdaptor(
+ session, dispatchTargets.peek().getServletRegistration().getT().getServletConfig().getServletContext());
}
return null;
@@ -242,17 +195,25 @@ public class HttpServletRequestBuilder {
public HttpSession getSession(boolean create) {
HttpSession session = request.getSession(create);
if (session != null) {
- return dispatchTargets.getContextController().getSessionAdaptor(
- session, servletRegistration.getT().getServletConfig().getServletContext());
+ return dispatchTargets.peek().getContextController().getSessionAdaptor(
+ session, dispatchTargets.peek().getServletRegistration().getT().getServletConfig().getServletContext());
}
return null;
}
+ public synchronized void pop() {
+ this.dispatchTargets.pop();
+ }
+
+ public synchronized void push(DispatchTargets dispatchTargets) {
+ this.dispatchTargets.push(dispatchTargets);
+ }
+
public void removeAttribute(String name) {
request.removeAttribute(name);
- EventListeners eventListeners = dispatchTargets.getContextController().getEventListeners();
+ EventListeners eventListeners = dispatchTargets.peek().getContextController().getEventListeners();
List<ServletRequestAttributeListener> listeners = eventListeners.get(
ServletRequestAttributeListener.class);
@@ -263,7 +224,7 @@ public class HttpServletRequestBuilder {
ServletRequestAttributeEvent servletRequestAttributeEvent =
new ServletRequestAttributeEvent(
- servletRegistration.getServletContext(), requestProxy, name, null);
+ dispatchTargets.peek().getServletRegistration().getServletContext(), this, name, null);
for (ServletRequestAttributeListener servletRequestAttributeListener : listeners) {
servletRequestAttributeListener.attributeRemoved(
@@ -275,7 +236,7 @@ public class HttpServletRequestBuilder {
boolean added = (request.getAttribute(name) == null);
request.setAttribute(name, value);
- EventListeners eventListeners = dispatchTargets.getContextController().getEventListeners();
+ EventListeners eventListeners = dispatchTargets.peek().getContextController().getEventListeners();
List<ServletRequestAttributeListener> listeners = eventListeners.get(
ServletRequestAttributeListener.class);
@@ -286,7 +247,7 @@ public class HttpServletRequestBuilder {
ServletRequestAttributeEvent servletRequestAttributeEvent =
new ServletRequestAttributeEvent(
- servletRegistration.getServletContext(), requestProxy, name, value);
+ dispatchTargets.peek().getServletRegistration().getServletContext(), this, name, value);
for (ServletRequestAttributeListener servletRequestAttributeListener : listeners) {
if (added) {
@@ -300,8 +261,4 @@ public class HttpServletRequestBuilder {
}
}
- HttpServletRequest getOriginalRequest() {
- return request;
- }
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/NamedDispatcherAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/NamedDispatcherAdaptor.java
deleted file mode 100644
index 12e1c1be..00000000
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/NamedDispatcherAdaptor.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2014 Cognos Incorporated, IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cognos Incorporated - initial API and implementation
- * IBM Corporation - bug fixes and enhancements
- * Raymond Augé <raymond.auge@liferay.com> - Bug 436698
- *******************************************************************************/
-package org.eclipse.equinox.http.servlet.internal.servlet;
-
-import java.io.IOException;
-import javax.servlet.*;
-import javax.servlet.http.*;
-import org.eclipse.equinox.http.servlet.internal.context.DispatchTargets;
-
-//This class unwraps the request so it can be processed by the underlying servlet container.
-public class NamedDispatcherAdaptor implements RequestDispatcher {
-
- private final DispatchTargets dispatchTargets;
-
- public NamedDispatcherAdaptor(DispatchTargets dispatchTargets) {
- this.dispatchTargets = dispatchTargets;
- }
-
- public void forward(ServletRequest req, ServletResponse resp)
- throws IOException, ServletException {
-
- if (req instanceof HttpServletRequestBuilder.RequestGetter)
- req = ((HttpServletRequestBuilder.RequestGetter) req).getOriginalRequest();
-
- doDispatch((HttpServletRequest)req, (HttpServletResponse)resp);
- }
-
- public void include(ServletRequest req, ServletResponse resp)
- throws IOException, ServletException {
-
- if (req instanceof HttpServletRequestBuilder.RequestGetter)
- req = ((HttpServletRequestBuilder.RequestGetter) req).getOriginalRequest();
-
- doDispatch((HttpServletRequest)req, (HttpServletResponse)resp);
- }
-
- private void doDispatch(
- HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
-
- DispatcherType dispatcherType = DispatcherType.REQUEST;
-
- if (request.getAttribute("javax.servlet.include.request_uri") != null) {
- request.setAttribute(
- "javax.servlet.include.request_uri", request.getRequestURI());
- request.setAttribute(
- "javax.servlet.include.context_path",
- dispatchTargets.getContextController().getContextPath());
- request.setAttribute(
- "javax.servlet.include.servlet_path",
- dispatchTargets.getServletPath());
- request.setAttribute(
- "javax.servlet.include.path_info",
- dispatchTargets.getPathInfo());
-
- dispatcherType = DispatcherType.INCLUDE;
- }
-
- HttpServletRequest wrappedRequest = new HttpServletRequestBuilder(
- request, dispatchTargets).build();
- HttpServletResponseWrapper wrapperResponse =
- new HttpServletResponseWrapperImpl(response);
-
- ResponseStateHandler responseStateHandler = new ResponseStateHandler(
- wrappedRequest, wrapperResponse, dispatchTargets, dispatcherType);
-
- responseStateHandler.processRequest();
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
index a21a0402..1e9ff409 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
@@ -67,7 +67,7 @@ public class ProxyServlet extends HttpServlet {
alias = Const.SLASH;
}
- if (processAlias(request, response, alias)) {
+ if (httpServiceRuntimeImpl.doDispatch(request, response, alias)) {
return;
}
@@ -83,12 +83,4 @@ public class ProxyServlet extends HttpServlet {
}
}
- private boolean processAlias(
- HttpServletRequest request, HttpServletResponse response,
- String alias)
- throws ServletException, IOException {
-
- return httpServiceRuntimeImpl.doDispatch(request, response, alias);
- }
-
}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java
index 6e1e9f4c..bc034226 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/RequestDispatcherAdaptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2014 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2015 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,39 +14,37 @@ package org.eclipse.equinox.http.servlet.internal.servlet;
import java.io.IOException;
import javax.servlet.*;
-import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.eclipse.equinox.http.servlet.internal.context.DispatchTargets;
//This class unwraps the request so it can be processed by the underlying servlet container.
public class RequestDispatcherAdaptor implements RequestDispatcher {
- private RequestDispatcher requestDispatcher;
+ private final DispatchTargets dispatchTargets;
+ private final String path;
- public RequestDispatcherAdaptor(RequestDispatcher requestDispatcher) {
- this.requestDispatcher = requestDispatcher;
- }
-
- public void forward(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
- while (true) {
- if (req instanceof HttpServletRequestBuilder.RequestGetter) {
- req = ((HttpServletRequestBuilder.RequestGetter) req).getOriginalRequest();
- break;
- }
+ public RequestDispatcherAdaptor(
+ DispatchTargets dispatchTargets, String path) {
- if (req instanceof HttpServletRequestWrapper) {
- req = ((HttpServletRequestWrapper)req).getRequest();
- continue;
- }
+ this.dispatchTargets = dispatchTargets;
+ this.path = path;
+ }
- break;
- }
+ public void forward(ServletRequest request, ServletResponse response)
+ throws IOException, ServletException {
- requestDispatcher.forward(req, resp);
+ dispatchTargets.doDispatch(
+ (HttpServletRequest)request, (HttpServletResponse)response,
+ path, DispatcherType.FORWARD);
}
- public void include(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
- if (req instanceof HttpServletRequestBuilder.RequestGetter)
- req = ((HttpServletRequestBuilder.RequestGetter) req).getOriginalRequest();
+ public void include(ServletRequest request, ServletResponse response)
+ throws IOException, ServletException {
- requestDispatcher.include(req, resp);
+ dispatchTargets.doDispatch(
+ (HttpServletRequest)request, (HttpServletResponse)response,
+ path, DispatcherType.INCLUDE);
}
+
}
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java
index f607a242..f4cbe2e8 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java
@@ -12,14 +12,14 @@
package org.eclipse.equinox.http.servlet.internal.servlet;
import java.io.IOException;
-import java.util.*;
+import java.util.Collections;
+import java.util.List;
import javax.servlet.*;
import javax.servlet.http.*;
import org.eclipse.equinox.http.servlet.internal.context.ContextController;
import org.eclipse.equinox.http.servlet.internal.context.DispatchTargets;
import org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration;
import org.eclipse.equinox.http.servlet.internal.registration.FilterRegistration;
-import org.eclipse.equinox.http.servlet.internal.util.EventListeners;
/**
* @author Raymond Augé
@@ -37,20 +37,20 @@ public class ResponseStateHandler {
}
public void processRequest() throws IOException, ServletException {
- ContextController contextController = dispatchTargets.getContextController();
- EventListeners eventListeners = contextController.getEventListeners();
- List<ServletRequestListener> servletRequestListeners = Collections.emptyList();
- EndpointRegistration<?> registration = dispatchTargets.getServletRegistration();
- List<FilterRegistration> matchingFilterRegistrations = dispatchTargets.getMatchingFilterRegistrations();
+ List<ServletRequestListener> servletRequestListeners = getServletRequestListener();
+ EndpointRegistration<?> endpoint = dispatchTargets.getServletRegistration();
+ List<FilterRegistration> filters = dispatchTargets.getMatchingFilterRegistrations();
- ServletRequestEvent servletRequestEvent = null;
+ endpoint.addReference();
- if (dispatcherType == DispatcherType.REQUEST) {
- servletRequestListeners = eventListeners.get(ServletRequestListener.class);
+ for (FilterRegistration filterRegistration : filters) {
+ filterRegistration.addReference();
+ }
- if (!servletRequestListeners.isEmpty()) {
- servletRequestEvent = new ServletRequestEvent(registration.getServletContext(), request);
- }
+ ServletRequestEvent servletRequestEvent = null;
+
+ if ((dispatcherType == DispatcherType.REQUEST) && !servletRequestListeners.isEmpty()) {
+ servletRequestEvent = new ServletRequestEvent(endpoint.getServletContext(), request);
}
try {
@@ -58,15 +58,15 @@ public class ResponseStateHandler {
servletRequestListener.requestInitialized(servletRequestEvent);
}
- if (registration.getServletContextHelper().handleSecurity(request, response)) {
- if (matchingFilterRegistrations.isEmpty()) {
- registration.service(request, response);
+ if (endpoint.getServletContextHelper().handleSecurity(request, response)) {
+ if (filters.isEmpty()) {
+ endpoint.service(request, response);
}
else {
- Collections.sort(matchingFilterRegistrations);
+ Collections.sort(filters);
FilterChain chain = new FilterChainImpl(
- matchingFilterRegistrations, registration, dispatcherType);
+ filters, endpoint, dispatcherType);
chain.doFilter(request, response);
}
@@ -87,19 +87,18 @@ public class ResponseStateHandler {
}
}
finally {
- registration.removeReference();
-
- for (Iterator<FilterRegistration> it =
- matchingFilterRegistrations.iterator(); it.hasNext();) {
+ endpoint.removeReference();
- FilterRegistration filterRegistration = it.next();
+ for (FilterRegistration filterRegistration : filters) {
filterRegistration.removeReference();
}
- handleErrors();
+ if (dispatcherType == DispatcherType.REQUEST) {
+ handleErrors();
- for (ServletRequestListener servletRequestListener : servletRequestListeners) {
- servletRequestListener.requestDestroyed(servletRequestEvent);
+ for (ServletRequestListener servletRequestListener : servletRequestListeners) {
+ servletRequestListener.requestDestroyed(servletRequestEvent);
+ }
}
}
}
@@ -108,11 +107,11 @@ public class ResponseStateHandler {
this.exception = exception;
}
- private void handleErrors() throws IOException, ServletException {
- if (dispatcherType != DispatcherType.REQUEST) {
- return;
- }
+ private List<ServletRequestListener> getServletRequestListener() {
+ return dispatchTargets.getContextController().getEventListeners().get(ServletRequestListener.class);
+ }
+ private void handleErrors() throws IOException, ServletException {
if (exception != null) {
handleException();
}
@@ -158,7 +157,7 @@ public class ResponseStateHandler {
String className = clazz.getName();
DispatchTargets errorDispatchTargets = contextController.getDispatchTargets(
- null, className, null, null, null, null, Match.EXACT, null);
+ className, null, null, null, null, Match.EXACT, null);
if (errorDispatchTargets == null) {
throwException(exception);
@@ -235,7 +234,7 @@ public class ResponseStateHandler {
ContextController contextController = dispatchTargets.getContextController();
DispatchTargets errorDispatchTargets = contextController.getDispatchTargets(
- null, String.valueOf(status), null, null, null, null, Match.EXACT, null);
+ String.valueOf(status), null, null, null, null, Match.EXACT, null);
if (errorDispatchTargets == null) {
wrappedResponse.sendError(status, wrapperImpl.getMessage());
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java
index 3430a2ba..cb1366f5 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java
@@ -139,13 +139,13 @@ public class ServletContextAdaptor {
public RequestDispatcher getNamedDispatcher(String servletName) {
DispatchTargets dispatchTargets = contextController.getDispatchTargets(
- null, servletName, null, null, null, null, Match.EXACT, null);
+ servletName, null, null, null, null, Match.EXACT, null);
if (dispatchTargets == null) {
return null;
}
- return new NamedDispatcherAdaptor(dispatchTargets);
+ return new RequestDispatcherAdaptor(dispatchTargets, servletName);
}
public String getRealPath(final String path) {
@@ -166,13 +166,22 @@ public class ServletContextAdaptor {
}
public RequestDispatcher getRequestDispatcher(String path) {
- if (!path.startsWith(getContextPath())) {
- path = getContextPath().substring(
- servletContext.getContextPath().length()).concat(path);
+ // no relative paths supported, must begin with '/'
+ if (!path.startsWith(Const.SLASH)) {
+ return null;
+ }
+ // if the path starts with the full context path strip it
+ if (path.startsWith(contextController.getFullContextPath())) {
+ path = path.substring(contextController.getFullContextPath().length());
+ }
+
+ DispatchTargets dispatchTargets = contextController.getDispatchTargets(path, null);
+
+ if (dispatchTargets == null) {
+ return null;
}
- return new RequestDispatcherAdaptor(
- servletContext.getRequestDispatcher(path));
+ return new RequestDispatcherAdaptor(dispatchTargets, path);
}
public URL getResource(final String name) {
@@ -287,17 +296,17 @@ public class ServletContextAdaptor {
public void createFilter(Class<?> arg1) {
throw new UnsupportedOperationException();
- }
+ }
public void createServlet(Class<?> arg1) {
throw new UnsupportedOperationException();
- }
- public void createListener(Class<?> arg1) {
- throw new UnsupportedOperationException();
- }
-
- public void declareRoles(String... arg1) {
- throw new UnsupportedOperationException();
- }
+ }
+ public void createListener(Class<?> arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void declareRoles(String... arg1) {
+ throw new UnsupportedOperationException();
+ }
public void setAttribute(String attributeName, Object attributeValue) {
if (attributeValue == null) {
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Const.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Const.java
index 69f549e6..0db8bfc0 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Const.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Const.java
@@ -18,6 +18,7 @@ public class Const {
public static final String BLANK = ""; //$NON-NLS-1$
public static final String CLOSE_PAREN = ")"; //$NON-NLS-1$
+ public static final String DOT = "."; //$NON-NLS-1$
public static final String[] EMPTY_ARRAY = new String[0];
public static final String EQUAL = "="; //$NON-NLS-1$
public static final String FILTER_NAME = "filter-name"; //$NON-NLS-1$
@@ -28,6 +29,8 @@ public class Const {
public static final String SERVLET_NAME = "servlet-name"; //$NON-NLS-1$
public static final String SLASH = "/"; //$NON-NLS-1$
public static final String SLASH_STAR = "/*"; //$NON-NLS-1$
+ public static final String SLASH_STAR_DOT = "/*."; //$NON-NLS-1$
+ public static final String STAR_DOT = "*."; //$NON-NLS-1$
public static final String EQUINOX_LEGACY_TCCL_PROP = "equinox.legacy.tccl"; //$NON-NLS-1$
public static final String EQUINOX_LEGACY_CONTEXT_SELECT = "equinox.context.select"; //$NON-NLS-1$
public static final String EQUINOX_LEGACY_CONTEXT_HELPER = "equinox.legacy.context.helper"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java
new file mode 100644
index 00000000..53b0e962
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/Path.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Raymond Augé.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raymond Augé <raymond.auge@liferay.com> - Bug 467859
+ ******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal.util;
+
+/**
+ * @author Raymond Augé
+ */
+public class Path {
+
+ public static String findExtension(String path) {
+ String lastSegment = path.substring(path.lastIndexOf('/') + 1);
+
+ int dot = lastSegment.lastIndexOf('.');
+
+ if (dot == -1) {
+ return null;
+ }
+
+ return lastSegment.substring(dot + 1);
+ }
+
+} \ No newline at end of file

Back to the top