felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1656500 - in /felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal: dispatch/Dispatcher.java dispatch/RequestDispatcherProvider.java dispatch/ServletContextWrapper.java handler/PerContextHandlerRegistry.java
Date Mon, 02 Feb 2015 15:52:22 GMT
Author: cziegeler
Date: Mon Feb  2 15:52:22 2015
New Revision: 1656500

URL: http://svn.apache.org/r1656500
Log:
FELIX-4060 : Implement HTTP Service Update (RFC-189)

Modified:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/RequestDispatcherProvider.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletContextWrapper.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PerContextHandlerRegistry.java

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java?rev=1656500&r1=1656499&r2=1656500&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
Mon Feb  2 15:52:22 2015
@@ -87,7 +87,7 @@ public final class Dispatcher implements
 
             try
             {
-                ServletRequestWrapper req = new ServletRequestWrapper((HttpServletRequest)
request, this.handler.getContext(), this.requestInfo, DispatcherType.FORWARD);
+                ServletRequestWrapper req = new ServletRequestWrapper((HttpServletRequest)
request, this.handler.getContext(), this.requestInfo, DispatcherType.FORWARD, this.handler.getContextServiceId());
                 Dispatcher.this.forward(this.handler, req, (HttpServletResponse) response);
             }
             finally
@@ -105,7 +105,7 @@ public final class Dispatcher implements
         @Override
         public void include(ServletRequest request, ServletResponse response) throws ServletException,
IOException
         {
-            ServletRequestWrapper req = new ServletRequestWrapper((HttpServletRequest) request,
this.handler.getContext(), this.requestInfo, DispatcherType.INCLUDE);
+            ServletRequestWrapper req = new ServletRequestWrapper((HttpServletRequest) request,
this.handler.getContext(), this.requestInfo, DispatcherType.INCLUDE, this.handler.getContextServiceId());
             Dispatcher.this.include(this.handler, req, (HttpServletResponse) response);
         }
     }
@@ -201,7 +201,7 @@ public final class Dispatcher implements
 
                                 final FilterHandler[] filterHandlers = handlerRegistry.getFilterHandlers(errorHandler,
DispatcherType.ERROR, request.getRequestURI());
 
-                                invokeChain(filterHandlers, errorHandler, new ServletRequestWrapper(request,
errorHandler.getContext(), requestInfo), this);
+                                invokeChain(filterHandlers, errorHandler, new ServletRequestWrapper(request,
errorHandler.getContext(), requestInfo, this.serviceId), this);
 
                                 invokeSuper = false;
                             }
@@ -234,19 +234,22 @@ public final class Dispatcher implements
         private final DispatcherType type;
         private final RequestInfo requestInfo;
         private final ExtServletContext servletContext;
+        private final Long contextId;
 
-        public ServletRequestWrapper(HttpServletRequest req, ExtServletContext servletContext,
RequestInfo requestInfo)
+        public ServletRequestWrapper(HttpServletRequest req, ExtServletContext servletContext,
RequestInfo requestInfo, final Long contextId)
         {
-            this(req, servletContext, requestInfo, null /* type */);
+            this(req, servletContext, requestInfo, null /* type */, contextId);
         }
 
-        public ServletRequestWrapper(HttpServletRequest req, ExtServletContext servletContext,
RequestInfo requestInfo, DispatcherType type)
+        public ServletRequestWrapper(HttpServletRequest req, ExtServletContext servletContext,
RequestInfo requestInfo,
+                DispatcherType type, final Long contextId)
         {
             super(req);
 
             this.servletContext = servletContext;
             this.requestInfo = requestInfo;
             this.type = type;
+            this.contextId = contextId;
         }
 
         @Override
@@ -385,6 +388,10 @@ public final class Dispatcher implements
         @Override
         public RequestDispatcher getRequestDispatcher(String path)
         {
+            if ( this.contextId == null )
+            {
+                return null;
+            }
             // See section 9.1 of Servlet 3.0 specification...
             if (path == null)
             {
@@ -396,7 +403,7 @@ public final class Dispatcher implements
             {
                 path = concat(getServletPath(), path);
             }
-            return Dispatcher.this.getRequestDispatcher(path);
+            return Dispatcher.this.getRequestDispatcher(this.contextId, path);
         }
 
         @Override
@@ -413,7 +420,7 @@ public final class Dispatcher implements
         @Override
         public ServletContext getServletContext()
         {
-            return new ServletContextWrapper(this.servletContext, Dispatcher.this);
+            return new ServletContextWrapper(this.contextId, this.servletContext, Dispatcher.this);
         }
 
         @Override
@@ -548,7 +555,7 @@ public final class Dispatcher implements
 
         try
         {
-            final HttpServletRequest wrappedRequest = new ServletRequestWrapper(req, servletContext,
requestInfo);
+            final HttpServletRequest wrappedRequest = new ServletRequestWrapper(req, servletContext,
requestInfo, servletHandler.getContextServiceId());
             final FilterHandler[] filterHandlers = this.handlerRegistry.getFilterHandlers(servletHandler,
req.getDispatcherType(), requestURI);
             invokeChain(filterHandlers, servletHandler, wrappedRequest, wrappedResponse);
         }
@@ -566,14 +573,14 @@ public final class Dispatcher implements
     }
 
     @Override
-    public RequestDispatcher getNamedDispatcher(String name)
+    public RequestDispatcher getNamedDispatcher(final long contextId, final String name)
     {
         ServletHandler handler = this.handlerRegistry.getServletHandlerByName(name);
         return handler != null ? new RequestDispatcherImpl(handler, null) : null;
     }
 
     @Override
-    public RequestDispatcher getRequestDispatcher(String path)
+    public RequestDispatcher getRequestDispatcher(final long contextId, String path)
     {
         // See section 9.1 of Servlet 3.x specification...
         if (path == null || (!path.startsWith("/") && !"".equals(path)))

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/RequestDispatcherProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/RequestDispatcherProvider.java?rev=1656500&r1=1656499&r2=1656500&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/RequestDispatcherProvider.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/RequestDispatcherProvider.java
Mon Feb  2 15:52:22 2015
@@ -30,10 +30,10 @@ public interface RequestDispatcherProvid
     /**
      * @see ServletContext#getNamedDispatcher(String)
      */
-    RequestDispatcher getNamedDispatcher(String name);
+    RequestDispatcher getNamedDispatcher(long contextId, String name);
 
     /**
      * @see ServletContext#getRequestDispatcher(String)
      */
-    RequestDispatcher getRequestDispatcher(String path);
+    RequestDispatcher getRequestDispatcher(long contextId, String path);
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletContextWrapper.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletContextWrapper.java?rev=1656500&r1=1656499&r2=1656500&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletContextWrapper.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletContextWrapper.java
Mon Feb  2 15:52:22 2015
@@ -31,14 +31,17 @@ class ServletContextWrapper extends Serv
 {
     private final RequestDispatcherProvider provider;
 
+    private final long contextId;
+
     /**
      * Creates a new {@link ServletContextWrapper} instance.
      */
-    public ServletContextWrapper(ExtServletContext delegate, RequestDispatcherProvider provider)
+    public ServletContextWrapper(long contextId, ExtServletContext delegate, RequestDispatcherProvider
provider)
     {
         super(delegate);
 
         this.provider = provider;
+        this.contextId = contextId;
     }
 
     @Override
@@ -49,7 +52,7 @@ class ServletContextWrapper extends Serv
             return null;
         }
 
-        RequestDispatcher dispatcher = this.provider.getNamedDispatcher(name);
+        RequestDispatcher dispatcher = this.provider.getNamedDispatcher(contextId, name);
         return dispatcher != null ? dispatcher : super.getNamedDispatcher(name);
     }
 
@@ -62,7 +65,7 @@ class ServletContextWrapper extends Serv
             return null;
         }
 
-        RequestDispatcher dispatcher = this.provider.getRequestDispatcher(path);
+        RequestDispatcher dispatcher = this.provider.getRequestDispatcher(contextId, path);
         return dispatcher != null ? dispatcher : super.getRequestDispatcher(path);
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PerContextHandlerRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PerContextHandlerRegistry.java?rev=1656500&r1=1656499&r2=1656500&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PerContextHandlerRegistry.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PerContextHandlerRegistry.java
Mon Feb  2 15:52:22 2015
@@ -201,7 +201,6 @@ public final class PerContextHandlerRegi
 
     public ServletHandler getServletHander(String requestURI)
     {
-        // TODO - take servlet context helper ranking and prefix into account (FELIX-4778)
         return this.servletMapping.getBestMatch(requestURI);
     }
 



Mime
View raw message