felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1670917 - in /felix/trunk/http/base/src: main/java/org/apache/felix/http/base/internal/whiteboard/ test/java/org/apache/felix/http/base/internal/runtime/dto/
Date Thu, 02 Apr 2015 14:28:01 GMT
Author: cziegeler
Date: Thu Apr  2 14:28:00 2015
New Revision: 1670917

URL: http://svn.apache.org/r1670917
Log:
FELIX-4060 : Implement HTTP Service Update (RFC-189) - remove intermediate listener registry

Removed:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ListenerRegistry.java
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/PerContextEventListener.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.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=1670917&r1=1670916&r2=1670917&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
Thu Apr  2 14:28:00 2015
@@ -47,11 +47,10 @@ public final class ContextHandler implem
 
     public ContextHandler(final ServletContextHelperInfo info,
             final ServletContext webContext,
-            final PerContextEventListener eventListener,
             final Bundle bundle)
     {
         this.info = info;
-        this.eventListener = eventListener;
+        this.eventListener = new PerContextEventListener(bundle, this);
         this.bundle = bundle;
         this.sharedContext = new SharedServletContextImpl(webContext,
                 info.getName(),
@@ -147,4 +146,8 @@ public final class ContextHandler implem
         public ExtServletContext servletContext;
         public ServletContextHelper servletContextHelper;
     }
+
+    public PerContextEventListener getListenerRegistry() {
+        return this.eventListener;
+    }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/PerContextEventListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/PerContextEventListener.java?rev=1670917&r1=1670916&r2=1670917&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/PerContextEventListener.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/PerContextEventListener.java
Thu Apr  2 14:28:00 2015
@@ -78,13 +78,15 @@ public final class PerContextEventListen
 
     private final Bundle bundle;
 
-    PerContextEventListener(final Bundle bundle)
+    private final ContextHandler contextHandler;
+
+    PerContextEventListener(final Bundle bundle, final ContextHandler contextHandler)
     {
         this.bundle = bundle;
+        this.contextHandler = contextHandler;
     }
 
-    void initialized(@Nonnull final ServletContextListenerInfo listenerInfo,
-            @Nonnull ContextHandler contextHandler)
+    void initialized(@Nonnull final ServletContextListenerInfo listenerInfo)
     {
         final ServletContextListener listener = listenerInfo.getService(bundle);
         if (listener != null)
@@ -99,8 +101,7 @@ public final class PerContextEventListen
         }
     }
 
-    void destroyed(@Nonnull final ServletContextListenerInfo listenerInfo,
-            @Nonnull ContextHandler contextHandler)
+    void destroyed(@Nonnull final ServletContextListenerInfo listenerInfo)
     {
         final ServiceReference<ServletContextListener> listenerRef = listenerInfo
                 .getServiceReference();

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java?rev=1670917&r1=1670916&r2=1670917&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
Thu Apr  2 14:28:00 2015
@@ -104,8 +104,6 @@ public final class WhiteboardManager
 
     private final WhiteboardHttpService httpService;
 
-    private final ListenerRegistry listenerRegistry;
-
     private final Map<AbstractInfo<?>, Integer> serviceFailures = new ConcurrentSkipListMap<AbstractInfo<?>,
Integer>();
 
     private volatile ServletContext webContext;
@@ -131,7 +129,6 @@ public final class WhiteboardManager
         this.bundleContext = bundleContext;
         this.httpServiceFactory = httpServiceFactory;
         this.httpService = new WhiteboardHttpService(this.bundleContext, registry);
-        this.listenerRegistry = new ListenerRegistry(bundleContext.getBundle());
         this.serviceRuntime = new HttpServiceRuntimeImpl(registry, this);
     }
 
@@ -288,7 +285,7 @@ public final class WhiteboardManager
         // context listeners first
         for(final ServletContextListenerInfo info : listeners.values())
         {
-            this.listenerRegistry.initialized(info, handler);
+            handler.getListenerRegistry().initialized(info);
         }
         // now register services
         for(final WhiteboardServiceInfo<?> info : services)
@@ -324,7 +321,7 @@ public final class WhiteboardManager
         }
         for(final ServletContextListenerInfo info : listeners.values())
         {
-            this.listenerRegistry.destroyed(info, handler);
+            handler.getListenerRegistry().destroyed(info);
         }
         handler.deactivate();
 
@@ -343,10 +340,8 @@ public final class WhiteboardManager
             {
                 synchronized ( this.contextMap )
                 {
-                    PerContextEventListener contextEventListener = listenerRegistry.addContext(info);
-                    ContextHandler handler = new ContextHandler(info,
+                    final ContextHandler handler = new ContextHandler(info,
                             this.webContext,
-                            contextEventListener,
                             this.bundleContext.getBundle());
 
                     List<ContextHandler> handlerList = this.contextMap.get(info.getName());
@@ -429,7 +424,6 @@ public final class WhiteboardManager
                             this.activate(newHead);
                             removeFailure(newHead.getContextInfo(), FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
                         }
-                        listenerRegistry.removeContext(info);
                     }
                 }
             }
@@ -540,27 +534,27 @@ public final class WhiteboardManager
 
             else if ( info instanceof ServletContextAttributeListenerInfo )
             {
-                this.listenerRegistry.addListener((ServletContextAttributeListenerInfo) info,
handler);
+                handler.getListenerRegistry().addListener((ServletContextAttributeListenerInfo)
info);
             }
             else if ( info instanceof HttpSessionListenerInfo )
             {
-                this.listenerRegistry.addListener((HttpSessionListenerInfo) info, handler);
+                handler.getListenerRegistry().addListener((HttpSessionListenerInfo) info);
             }
             else if ( info instanceof HttpSessionAttributeListenerInfo )
             {
-                this.listenerRegistry.addListener((HttpSessionAttributeListenerInfo) info,
handler);
+                handler.getListenerRegistry().addListener((HttpSessionAttributeListenerInfo)
info);
             }
             else if ( info instanceof HttpSessionIdListenerInfo )
             {
-                this.listenerRegistry.addListener((HttpSessionIdListenerInfo) info, handler);
+                handler.getListenerRegistry().addListener((HttpSessionIdListenerInfo) info);
             }
             else if ( info instanceof ServletRequestListenerInfo )
             {
-                this.listenerRegistry.addListener((ServletRequestListenerInfo) info, handler);
+                handler.getListenerRegistry().addListener((ServletRequestListenerInfo) info);
             }
             else if ( info instanceof ServletRequestAttributeListenerInfo )
             {
-                this.listenerRegistry.addListener((ServletRequestAttributeListenerInfo) info,
handler);
+                handler.getListenerRegistry().addListener((ServletRequestAttributeListenerInfo)
info);
             }
         }
         catch (final RegistrationFailureException e)
@@ -599,27 +593,27 @@ public final class WhiteboardManager
 
             else if ( info instanceof ServletContextAttributeListenerInfo )
             {
-                this.listenerRegistry.removeListener((ServletContextAttributeListenerInfo)
info, handler);
+                handler.getListenerRegistry().removeListener((ServletContextAttributeListenerInfo)
info);
             }
             else if ( info instanceof HttpSessionListenerInfo )
             {
-                this.listenerRegistry.removeListener((HttpSessionListenerInfo) info, handler);
+                handler.getListenerRegistry().removeListener((HttpSessionListenerInfo) info);
             }
             else if ( info instanceof HttpSessionAttributeListenerInfo )
             {
-                this.listenerRegistry.removeListener((HttpSessionAttributeListenerInfo) info,
handler);
+                handler.getListenerRegistry().removeListener((HttpSessionAttributeListenerInfo)
info);
             }
             else if ( info instanceof HttpSessionIdListenerInfo )
             {
-                this.listenerRegistry.removeListener((HttpSessionIdListenerInfo) info, handler);
+                handler.getListenerRegistry().removeListener((HttpSessionIdListenerInfo)
info);
             }
             else if ( info instanceof ServletRequestListenerInfo )
             {
-                this.listenerRegistry.removeListener((ServletRequestListenerInfo) info, handler);
+                handler.getListenerRegistry().removeListener((ServletRequestListenerInfo)
info);
             }
             else if ( info instanceof ServletRequestAttributeListenerInfo )
             {
-                this.listenerRegistry.removeListener((ServletRequestAttributeListenerInfo)
info, handler);
+                handler.getListenerRegistry().removeListener((ServletRequestAttributeListenerInfo)
info);
             }
         }
         catch (final RegistrationFailureException e)
@@ -697,7 +691,7 @@ public final class WhiteboardManager
     {
         Collection<ServletContextHelperRuntime> contextRuntimes = new TreeSet<ServletContextHelperRuntime>(ServletContextHelperRuntime.COMPARATOR);
         List<ContextRuntime> handlerRuntimes;
-        Map<Long, Collection<ServiceReference<?>>> listenerRuntimes;
+        final Map<Long, Collection<ServiceReference<?>>> listenerRuntimes
= new HashMap<Long, Collection<ServiceReference<?>>>();
         FailureRuntime.Builder failureRuntime = FailureRuntime.builder();
         synchronized ( this.contextMap )
         {
@@ -705,11 +699,14 @@ public final class WhiteboardManager
             {
                 if ( !contextHandlerList.isEmpty() )
                 {
-                    contextRuntimes.add(contextHandlerList.get(0));
+                    final ContextHandler handler = contextHandlerList.get(0);
+                    contextRuntimes.add(handler);
+
+                    final long serviceId = handler.getContextInfo().getServiceId();
+                    listenerRuntimes.put(serviceId, handler.getListenerRegistry().getRuntime());
                 }
             }
             handlerRuntimes = registry.getRuntime(failureRuntime);
-            listenerRuntimes = listenerRegistry.getContextRuntimes();
             failureRuntime.add(serviceFailures);
         }
         return new RegistryRuntime(contextRuntimes, handlerRuntimes, listenerRuntimes, failureRuntime.build());

Modified: felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java?rev=1670917&r1=1670916&r2=1670917&view=diff
==============================================================================
--- felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java
(original)
+++ felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java
Thu Apr  2 14:28:00 2015
@@ -63,7 +63,6 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.apache.felix.http.base.internal.whiteboard.ContextHandler;
-import org.apache.felix.http.base.internal.whiteboard.ListenerRegistry;
 import org.apache.felix.http.base.internal.whiteboard.PerContextEventListener;
 import org.junit.Before;
 import org.junit.Rule;
@@ -138,14 +137,12 @@ public class RuntimeDTOBuilderTest
 
     private RegistryRuntime registry;
     private Map<String, Object> runtimeAttributes;
-	private ListenerRegistry listenerRegistry;
 
     @Before
     public void setUp()
     {
         registry = null;
         runtimeAttributes = RUNTIME_ATTRIBUTES;
-        listenerRegistry = new ListenerRegistry(bundle);
     }
 
     public ServletContextHelperRuntime setupContext(ServletContext context, String name,
long serviceId)
@@ -163,8 +160,8 @@ public class RuntimeDTOBuilderTest
         Map<String, String> initParameters = createInitParameterMap();
         ServletContextHelperInfo contextInfo = createContextInfo(0, serviceId, name, path,
initParameters);
 
-        PerContextEventListener eventListener = listenerRegistry.addContext(contextInfo);
-        ServletContextHelperRuntime contextHandler = new ContextHandler(contextInfo, context,
eventListener, bundle);
+        ContextHandler contextHandler = new ContextHandler(contextInfo, context, bundle);
+        PerContextEventListener eventListener = contextHandler.getListenerRegistry();
 
         ServletContext sharedContext = contextHandler.getSharedContext();
         sharedContext.setAttribute("intAttr", 1);



Mime
View raw message