felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1659800 - in /felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard: ContextHandler.java ServletContextHelperManager.java WhiteboardHttpService.java
Date Sat, 14 Feb 2015 15:18:34 GMT
Author: cziegeler
Date: Sat Feb 14 15:18:34 2015
New Revision: 1659800

URL: http://svn.apache.org/r1659800
Log:
FELIX-4060 : Implement HTTP Service Update (RFC-189) - correct context and path handling

Modified:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java?rev=1659800&r1=1659799&r2=1659800&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
Sat Feb 14 15:18:34 2015
@@ -183,7 +183,7 @@ public final class ContextHandler implem
                 if ( so != null )
                 {
                     holder = new ContextHolder();
-                    // TODO check for null
+                    // TODO check for null of getService()
                     holder.servletContextHelper = so.getService();
                     holder.servletContext = new PerBundleServletContextImpl(bundle,
                             this.sharedContext,
@@ -194,6 +194,7 @@ public final class ContextHandler implem
                             this.getServletRequestAttributeListener());
                     this.perBundleContextMap.put(key, holder);
                 }
+                // TODO - check null for so
             }
             holder.counter++;
 

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java?rev=1659800&r1=1659799&r2=1659800&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java
Sat Feb 14 15:18:34 2015
@@ -177,8 +177,6 @@ public final class ServletContextHelperM
      */
     private void deactivate(final ContextHandler handler)
     {
-        this.httpService.unregisterContext(handler);
-
         // context listeners last
         final Map<ServiceReference<ServletContextListener>, ServletContextListenerInfo>
listeners = new TreeMap<ServiceReference<ServletContextListener>, ServletContextListenerInfo>();
         final Iterator<Map.Entry<WhiteboardServiceInfo<?>, List<ContextHandler>>>
i = this.servicesMap.entrySet().iterator();
@@ -206,6 +204,9 @@ public final class ServletContextHelperM
             handler.destroyed(info);
         }
         handler.deactivate();
+
+        this.httpService.unregisterContext(handler);
+
     }
 
     /**

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java?rev=1659800&r1=1659799&r2=1659800&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java
Sat Feb 14 15:18:34 2015
@@ -36,6 +36,7 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.handler.FilterHandler;
 import org.apache.felix.http.base.internal.handler.HandlerRegistry;
 import org.apache.felix.http.base.internal.handler.HttpSessionWrapper;
+import org.apache.felix.http.base.internal.handler.PerContextHandlerRegistry;
 import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
 import org.apache.felix.http.base.internal.runtime.ResourceInfo;
@@ -185,8 +186,12 @@ public final class WhiteboardHttpService
                         servletInfo,
                         servlet);
                 try {
-                    this.handlerRegistry.getRegistry(contextHandler.getContextInfo()).addServlet(handler);
-                    contextHandler.addWhiteboardService(servletInfo);
+                    final PerContextHandlerRegistry registry = this.handlerRegistry.getRegistry(contextHandler.getContextInfo());
+                    if (registry != null )
+                    {
+                        registry.addServlet(handler);
+                        contextHandler.addWhiteboardService(servletInfo);
+                    }
                 } catch (final ServletException e) {
                     so.ungetService(servlet);
                     // TODO create failure DTO
@@ -202,13 +207,17 @@ public final class WhiteboardHttpService
      */
     public void unregisterServlet(@Nonnull final ContextHandler contextHandler, @Nonnull
final ServletInfo servletInfo)
     {
-        final Servlet instance = this.handlerRegistry.getRegistry(contextHandler.getContextInfo()).removeServlet(servletInfo,
true);
-        if ( instance != null )
+        final PerContextHandlerRegistry registry = this.handlerRegistry.getRegistry(contextHandler.getContextInfo());
+        if (registry != null )
         {
-            this.bundleContext.getServiceObjects(servletInfo.getServiceReference()).ungetService(instance);
-            contextHandler.ungetServletContext(servletInfo.getServiceReference().getBundle());
-            contextHandler.removeWhiteboardService(servletInfo);
+            final Servlet instance = registry.removeServlet(servletInfo, true);
+            if ( instance != null )
+            {
+                this.bundleContext.getServiceObjects(servletInfo.getServiceReference()).ungetService(instance);
+            }
         }
+        contextHandler.ungetServletContext(servletInfo.getServiceReference().getBundle());
+        contextHandler.removeWhiteboardService(servletInfo);
     }
 
     /**
@@ -228,8 +237,12 @@ public final class WhiteboardHttpService
                     filter,
                     filterInfo);
             try {
-                this.handlerRegistry.getRegistry(contextHandler.getContextInfo()).addFilter(handler);
-                contextHandler.addWhiteboardService(filterInfo);
+                final PerContextHandlerRegistry registry = this.handlerRegistry.getRegistry(contextHandler.getContextInfo());
+                if (registry != null )
+                {
+                    registry.addFilter(handler);
+                    contextHandler.addWhiteboardService(filterInfo);
+                }
             } catch (final ServletException e) {
                 // TODO create failure DTO
             }
@@ -243,13 +256,17 @@ public final class WhiteboardHttpService
      */
     public void unregisterFilter(@Nonnull final ContextHandler contextHandler, @Nonnull final
FilterInfo filterInfo)
     {
-        final Filter instance = this.handlerRegistry.getRegistry(contextHandler.getContextInfo()).removeFilter(filterInfo,
true);
-        if ( instance != null )
+        final PerContextHandlerRegistry registry = this.handlerRegistry.getRegistry(contextHandler.getContextInfo());
+        if (registry != null )
         {
-            this.bundleContext.getServiceObjects(filterInfo.getServiceReference()).ungetService(instance);
-            contextHandler.ungetServletContext(filterInfo.getServiceReference().getBundle());
-            contextHandler.removeWhiteboardService(filterInfo);
+            final Filter instance = registry.removeFilter(filterInfo, true);
+            if ( instance != null )
+            {
+                this.bundleContext.getServiceObjects(filterInfo.getServiceReference()).ungetService(instance);
+            }
         }
+        contextHandler.ungetServletContext(filterInfo.getServiceReference().getBundle());
+        contextHandler.removeWhiteboardService(filterInfo);
     }
 
     /**
@@ -268,8 +285,12 @@ public final class WhiteboardHttpService
                 servletInfo,
                 servlet);
         try {
-            this.handlerRegistry.getRegistry(contextHandler.getContextInfo()).addServlet(handler);
-            contextHandler.addWhiteboardService(resourceInfo);
+            final PerContextHandlerRegistry registry = this.handlerRegistry.getRegistry(contextHandler.getContextInfo());
+            if (registry != null )
+            {
+                registry.addServlet(handler);
+                contextHandler.addWhiteboardService(resourceInfo);
+            }
         } catch (ServletException e) {
             // TODO create failure DTO
         }
@@ -283,8 +304,13 @@ public final class WhiteboardHttpService
     public void unregisterResource(@Nonnull final ContextHandler contextHandler, @Nonnull
final ResourceInfo resourceInfo)
     {
         final ServletInfo servletInfo = new ServletInfo(resourceInfo);
-        this.unregisterServlet(contextHandler, servletInfo);
-        contextHandler.removeWhiteboardService(resourceInfo);
+        final PerContextHandlerRegistry registry = this.handlerRegistry.getRegistry(contextHandler.getContextInfo());
+        if (registry != null )
+        {
+            registry.removeServlet(servletInfo, true);
+        }
+        contextHandler.ungetServletContext(servletInfo.getServiceReference().getBundle());
+        contextHandler.removeWhiteboardService(servletInfo);
     }
 
     public void registerContext(@Nonnull final ContextHandler contextHandler)



Mime
View raw message