You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2017/08/25 15:25:43 UTC

[2/8] aries-jax-rs-whiteboard git commit: Refactor to include default application in DTOs

Refactor to include default application in DTOs


Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/7c1fce86
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/7c1fce86
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/7c1fce86

Branch: refs/heads/master
Commit: 7c1fce8609ff45ef80e12b3dcac3ddc38cd284e9
Parents: 216070b
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Aug 22 18:16:58 2017 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Aug 22 18:16:58 2017 +0200

----------------------------------------------------------------------
 jax-rs.itests/src/main/java/test/JaxrsTest.java | 64 +++++++--------
 .../internal/AriesJaxRSServiceRuntime.java      | 34 ++++----
 .../internal/CXFJaxRsServiceRegistrator.java    | 20 -----
 .../aries/jax/rs/whiteboard/internal/Utils.java | 12 +++
 .../jax/rs/whiteboard/internal/Whiteboard.java  | 83 +++++++++++---------
 5 files changed, 104 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c1fce86/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index ecf817a..f089eb6 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -69,14 +69,14 @@ public class JaxrsTest extends TestHelper {
         try {
             JaxRSServiceRuntime runtime = getJaxRSServiceRuntime();
 
-            assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+            assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
 
             assertNotNull(runtime);
 
             serviceRegistration = registerApplication(
                 new TestApplication());
 
-            assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+            assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length);
 
             Client client = createClient();
 
@@ -239,12 +239,12 @@ public class JaxrsTest extends TestHelper {
         ServiceRegistration<?> serviceRegistration2;
 
         try {
-            assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+            assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
             assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
             serviceRegistration = registerApplication(new TestApplication());
 
-            assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+            assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length);
             assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
             Response response = webTarget.request().get();
@@ -256,7 +256,7 @@ public class JaxrsTest extends TestHelper {
             serviceRegistration2 = registerApplication(
                 new TestApplicationConflict(), "service.ranking", 1);
 
-            assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+            assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length);
             assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
             response = webTarget.request().get();
@@ -271,7 +271,7 @@ public class JaxrsTest extends TestHelper {
 
             serviceRegistration2.unregister();
 
-            assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+            assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length);
             assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
             response = webTarget.request().get();
@@ -392,7 +392,7 @@ public class JaxrsTest extends TestHelper {
         JaxRSServiceRuntime runtime = getJaxRSServiceRuntime();
 
         Runnable testCase = () -> {
-            assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+            int applications = runtime.getRuntimeDTO().applicationDTOs.length;
 
             assertEquals(404, webTarget.request().get().getStatus());
 
@@ -408,7 +408,9 @@ public class JaxrsTest extends TestHelper {
                         get().
                         readEntity(String.class));
 
-                assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+                assertEquals(
+                    applications + 1,
+                    runtime.getRuntimeDTO().applicationDTOs.length);
             }
             finally {
                 if (serviceRegistration != null) {
@@ -481,13 +483,13 @@ public class JaxrsTest extends TestHelper {
 
         JaxRSServiceRuntime runtime = getJaxRSServiceRuntime();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         ServiceRegistration<Application> serviceRegistration =
             registerApplication(new TestApplication());
 
-        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         assertEquals(
@@ -497,7 +499,7 @@ public class JaxrsTest extends TestHelper {
         ServiceRegistration<Application> ungettableServiceRegistration =
             registerUngettableApplication("service.ranking", 1);
 
-        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         assertEquals(
@@ -510,14 +512,14 @@ public class JaxrsTest extends TestHelper {
 
         serviceRegistration.unregister();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         assertEquals(404, webTarget.request().get().getStatus());
 
         ungettableServiceRegistration.unregister();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
     }
 
@@ -533,13 +535,13 @@ public class JaxrsTest extends TestHelper {
 
         JaxRSServiceRuntime runtime = getJaxRSServiceRuntime();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         ServiceRegistration<Application> serviceRegistration =
             registerApplication(new TestApplication());
 
-        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         assertEquals(
@@ -549,7 +551,7 @@ public class JaxrsTest extends TestHelper {
         ServiceRegistration<Application> ungettableServiceRegistration =
             registerUngettableApplication("service.ranking", -1);
 
-        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         assertEquals(
@@ -562,14 +564,14 @@ public class JaxrsTest extends TestHelper {
 
         serviceRegistration.unregister();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         assertEquals(404, webTarget.request().get().getStatus());
 
         ungettableServiceRegistration.unregister();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
     }
 
@@ -577,13 +579,13 @@ public class JaxrsTest extends TestHelper {
     public void testNotGettableApplication() throws InterruptedException {
         JaxRSServiceRuntime runtime = getJaxRSServiceRuntime();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         ServiceRegistration<Application> serviceRegistration =
             registerUngettableApplication();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length);
 
         assertEquals(
@@ -592,21 +594,25 @@ public class JaxrsTest extends TestHelper {
 
         serviceRegistration.unregister();
 
-        assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length);
+        assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length);
         assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length);
     }
 
     @Test
-    public void testStandaloneEndPoint() {
+    public void testStandaloneEndPoint() throws InterruptedException {
         Client client = createClient();
 
         WebTarget webTarget = client.
             target("http://localhost:8080").
             path("test");
 
+        JaxRSServiceRuntime runtime = getJaxRSServiceRuntime();
+
         ServiceRegistration<?> serviceRegistration = null;
 
         try {
+            runtime.getRuntimeDTO();
+
             serviceRegistration = registerAddon(new TestAddon());
 
             Response response = webTarget.request().get();
@@ -964,20 +970,6 @@ public class JaxrsTest extends TestHelper {
             Object.class, testFilter, properties);
     }
 
-    /*private ServiceRegistration<?> registerFilter(Object... keyValues) {
-
-        TestFilter testFilter = new TestFilter();
-
-        Dictionary<String, Object> properties = new Hashtable<>();
-
-        for (int i = 0; i < keyValues.length; i = i + 2) {
-            properties.put(keyValues[i].toString(), keyValues[i + 1]);
-        }
-
-        return bundleContext.registerService(
-            Object.class, testFilter, properties);
-    }*/
-
     private ServiceRegistration<Application> registerUngettableApplication(
         Object... keyValues) {
 

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c1fce86/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
index 140e82e..da6de71 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java
@@ -31,18 +31,20 @@ import org.osgi.service.jaxrs.runtime.dto.RuntimeDTO;
 import org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants;
 
 import javax.ws.rs.core.Application;
+import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Stream;
 
+import static org.apache.aries.jax.rs.whiteboard.internal.Utils.getProperties;
 import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_NAME;
 
 public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
 
     private static final long serialVersionUID = 1L;
 
-    private ConcurrentHashMap<String, ServiceReference<Application>>
+    private ConcurrentHashMap<String, Map<String, Object>>
         _applications = new ConcurrentHashMap<>();
 
     private ConcurrentHashMap<String, Set<ServiceReference<?>>>
@@ -96,13 +98,13 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
         _ungettableExtensions.remove(serviceReference);
     }
 
-    public ServiceReference<Application> setApplicationForPath(
-        String path, ServiceReference<Application> serviceReference) {
+    public Map<String, Object> setApplicationForPath(
+        String path, Map<String, Object> properties) {
 
-        return _applications.put(path, serviceReference);
+        return _applications.put(path, properties);
     }
 
-    public ServiceReference<Application> unsetApplicationForPath(String path) {
+    public Map<String, Object> unsetApplicationForPath(String path) {
         return _applications.remove(path);
     }
 
@@ -268,14 +270,13 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
     }
 
     private ApplicationDTO buildApplicationDTO(
-        ServiceReference<Application> serviceReference) {
+        Map<String, Object> properties) {
 
         ApplicationDTO applicationDTO = new ApplicationDTO(){};
 
-        applicationDTO.name = getApplicationName(serviceReference);
-        applicationDTO.base = Whiteboard.getApplicationBase(serviceReference);
-        applicationDTO.serviceId = (Long)serviceReference.getProperty(
-            "service.id");
+        applicationDTO.name = getApplicationName(properties);
+        applicationDTO.base = Whiteboard.getApplicationBase(properties);
+        applicationDTO.serviceId = (Long)properties.get("service.id");
 
         applicationDTO.resourceDTOs = getApplicationEndpointsStream(
             applicationDTO.name).toArray(
@@ -351,7 +352,7 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
             JaxRSWhiteboardConstants.JAX_RS_NAME);
 
         failedApplicationDTO.name = nameProperty == null ?
-            generateApplicationName(serviceReference) :
+            generateApplicationName(getProperties(serviceReference)) :
             nameProperty.toString();
 
         failedApplicationDTO.failureReason = reason;
@@ -359,23 +360,22 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
         return failedApplicationDTO;
     }
 
-    public static String getApplicationName(
-        ServiceReference<?> serviceReference) {
+    public static String getApplicationName(Map<String, Object> properties) {
 
-        Object property = serviceReference.getProperty(JAX_RS_NAME);
+        Object property = properties.get(JAX_RS_NAME);
 
         if (property == null) {
-            return generateApplicationName(serviceReference);
+            return generateApplicationName(properties);
         }
 
         return property.toString();
     }
 
     public static String generateApplicationName(
-        ServiceReference<?> serviceReference) {
+        Map<String, Object> properties) {
 
         return ".jax-rs-application-" +
-            serviceReference.getProperty("service.id").toString();
+            properties.get("service.id").toString();
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c1fce86/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
index a43abba..50d51a7 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
@@ -19,8 +19,6 @@ package org.apache.aries.jax.rs.whiteboard.internal;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.ws.rs.core.Application;
 
@@ -35,7 +33,6 @@ import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.provider.json.JSONProvider;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
-import org.osgi.framework.ServiceReference;
 
 public class CXFJaxRsServiceRegistrator {
 
@@ -46,8 +43,6 @@ public class CXFJaxRsServiceRegistrator {
     private Server _server;
     private final Collection<ResourceProvider> _services = new ArrayList<>();
 
-    private static final String CXF_ENDPOINT_ADDRESS = "CXF_ENDPOINT_ADDRESS";
-
     public CXFJaxRsServiceRegistrator(Bus bus, Application application) {
         _bus = bus;
         _application = application;
@@ -55,21 +50,6 @@ public class CXFJaxRsServiceRegistrator {
         rewire();
     }
 
-    public static Map<String, Object> getProperties(
-        ServiceReference<?> sref, String addressKey) {
-
-        String[] propertyKeys = sref.getPropertyKeys();
-        Map<String, Object> properties = new HashMap<>(propertyKeys.length);
-
-        for (String key : propertyKeys) {
-            properties.put(key, sref.getProperty(key));
-        }
-
-        properties.put(
-            CXF_ENDPOINT_ADDRESS, sref.getProperty(addressKey).toString());
-        return properties;
-    }
-
     public void add(ResourceProvider resourceProvider) {
         if (_closed) {
             return;

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c1fce86/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
index 0a343bf..2506be3 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
@@ -28,6 +28,7 @@ import org.osgi.service.jaxrs.runtime.dto.FailedApplicationDTO;
 
 import javax.ws.rs.core.Application;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.NavigableSet;
 import java.util.SortedSet;
@@ -47,6 +48,17 @@ import static org.apache.aries.osgi.functional.OSGi.register;
  */
 public class Utils {
 
+    public static Map<String, Object> getProperties(ServiceReference<?> sref) {
+        String[] propertyKeys = sref.getPropertyKeys();
+        Map<String, Object> properties = new HashMap<>(propertyKeys.length);
+
+        for (String key : propertyKeys) {
+            properties.put(key, sref.getProperty(key));
+        }
+
+        return properties;
+    }
+
     public static <T> OSGi<T> service(ServiceReference<T> serviceReference) {
         return
             bundleContext().flatMap(bundleContext ->

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c1fce86/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
index cb2c078..aaf6220 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
@@ -44,7 +44,9 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Function;
 
 import static java.lang.String.format;
+import static org.apache.aries.jax.rs.whiteboard.internal.AriesJaxRSServiceRuntime.getApplicationName;
 import static org.apache.aries.jax.rs.whiteboard.internal.Utils.deployRegistrator;
+import static org.apache.aries.jax.rs.whiteboard.internal.Utils.getProperties;
 import static org.apache.aries.jax.rs.whiteboard.internal.Utils.highestPer;
 import static org.apache.aries.jax.rs.whiteboard.internal.Utils.onlyGettables;
 import static org.apache.aries.jax.rs.whiteboard.internal.Utils.safeRegisterEndpoint;
@@ -75,7 +77,8 @@ import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_
  */
 public class Whiteboard {
 
-    public static final Function<ServiceTuple<Application>, String> APPLICATION_BASE = ((Function<ServiceTuple<Application>, ServiceReference<Application>>) ServiceTuple::getServiceReference).andThen(Whiteboard::getApplicationBase);
+    public static final Function<ServiceTuple<Application>, String> APPLICATION_BASE = ((Function<ServiceTuple<Application>, ServiceReference<Application>>) ServiceTuple::getServiceReference).andThen(Utils::getProperties).andThen(Whiteboard::getApplicationBase);
+    public static final String DEFAULT_NAME = ".default";
 
     public static OSGi<Void> createWhiteboard(Dictionary<String, ?> configuration) {
         AriesJaxRSServiceRuntime runtime = new AriesJaxRSServiceRuntime();
@@ -84,15 +87,15 @@ public class Whiteboard {
 
         return
             bundleContext().flatMap(bundleContext ->
-            registerJaxRSServiceRuntime(runtime, bundleContext, configurationMap).flatMap(runtimeResgistration ->
-            createDefaultJaxRsServiceRegistrator(configurationMap).flatMap(defaultServiceRegistrator ->
-            just(new ServiceRegistrationChangeCounter(runtimeResgistration)).flatMap(counter ->
-            just(runtimeResgistration.getReference()).flatMap(runtimeRegistration ->
+            registerJaxRSServiceRuntime(runtime, bundleContext, configurationMap).flatMap(runtimeRegistration ->
+            createDefaultJaxRsServiceRegistrator(configurationMap, runtime).flatMap(defaultServiceRegistrator ->
+            just(new ServiceRegistrationChangeCounter(runtimeRegistration)).flatMap(counter ->
+            just(runtimeRegistration.getReference()).flatMap(runtimeReference ->
                 all(
-                    countChanges(whiteboardApplications(runtimeRegistration, runtime, Maps.from(configuration)), counter),
-                    countChanges(whiteBoardApplicationSingletons(runtimeRegistration, runtime), counter),
-                    countChanges(whiteboardExtensions(runtimeRegistration, defaultServiceRegistrator, runtime), counter),
-                    countChanges(whiteboardSingletons(runtimeRegistration, defaultServiceRegistrator, runtime), counter)
+                    countChanges(whiteboardApplications(runtimeReference, runtime, Maps.from(configuration)), counter),
+                    countChanges(whiteBoardApplicationSingletons(runtimeReference, runtime), counter),
+                    countChanges(whiteboardExtensions(runtimeReference, defaultServiceRegistrator, runtime), counter),
+                    countChanges(whiteboardSingletons(runtimeReference, defaultServiceRegistrator, runtime), counter)
             ))))));
     }
 
@@ -147,18 +150,22 @@ public class Whiteboard {
     }
 
     private static OSGi<CXFJaxRsServiceRegistrator>
-        createDefaultJaxRsServiceRegistrator(Map<String, ?> configuration) {
+        createDefaultJaxRsServiceRegistrator(
+            Map<String, ?> configuration, AriesJaxRSServiceRuntime runtime) {
 
         Map<String, Object> properties = new HashMap<>(configuration);
         properties.put(JAX_RS_NAME, ".default");
+        properties.put(JAX_RS_APPLICATION_BASE, "/");
+        properties.put("service.id", (long)-1);
 
         return
             bundleContext().flatMap(bundleContext ->
             just(createBus(bundleContext, configuration)).flatMap(bus ->
-            registerCXFServletService(bus, "", configuration).then(
-            just(
-                new CXFJaxRsServiceRegistrator(bus, new DefaultApplication()))
-            )));
+            registerCXFServletService(bus, "", configuration).foreach(
+                __ -> runtime.setApplicationForPath("/", properties),
+                __ -> runtime.unsetApplicationForPath("/")).then(
+            just(new CXFJaxRsServiceRegistrator(bus, new DefaultApplication()))
+        )));
     }
 
     private static String getApplicationFilter() {
@@ -237,7 +244,7 @@ public class Whiteboard {
                 CXFJaxRsServiceRegistrator.class, applicationFilter).
                 flatMap(registratorReference ->
             just(
-                AriesJaxRSServiceRuntime.getApplicationName(registratorReference)).
+                getApplicationName(getProperties(registratorReference))).
                 flatMap(applicationName ->
             waitForExtensionDependencies(ref,
                 service(registratorReference).flatMap(registrator ->
@@ -267,12 +274,13 @@ public class Whiteboard {
                 bundleContext -> highestRankedPerPath.flatMap(
                     ref -> deployApplication(configuration, bundleContext, ref)
                 ).map(
-                    ServiceTuple::getServiceReference).
-                foreach(
-                    sr -> runtime.setApplicationForPath(
-                            getApplicationBase(sr), sr),
-                    sr -> runtime.unsetApplicationForPath(
-                        getApplicationBase(sr))
+                    ServiceTuple::getServiceReference
+                ).map(
+                    Utils::getProperties
+                ).foreach(
+                    p -> runtime.setApplicationForPath(
+                        getApplicationBase(p), p),
+                    p -> runtime.unsetApplicationForPath(getApplicationBase(p))
                 )
             );
     }
@@ -286,20 +294,18 @@ public class Whiteboard {
         ServiceReference<Application> serviceReference =
             tuple.getServiceReference();
 
-        Map<String, Object> properties =
-            CXFJaxRsServiceRegistrator.getProperties(
-                serviceReference, JAX_RS_APPLICATION_BASE);
+        Map<String, Object> properties = getProperties(serviceReference);
 
         properties.computeIfAbsent(
             JAX_RS_NAME,
             (__) -> AriesJaxRSServiceRuntime.generateApplicationName(
-                tuple.getServiceReference()));
+                properties));
 
         return
             all(
                 deployRegistrator(bus, tuple.getService(), properties),
                 registerCXFServletService(
-                    bus, getApplicationBase(serviceReference), properties)).
+                    bus, getApplicationBase(properties), properties)).
             then(
                 just(tuple)
             );
@@ -310,10 +316,8 @@ public class Whiteboard {
             ServiceReference<?> jaxRsRuntimeServiceReference) {
 
         return
-            serviceReferences(
-                Application.class, getApplicationFilter()).
-            filter(
-                new TargetFilter<>(jaxRsRuntimeServiceReference));
+            serviceReferences(Application.class, getApplicationFilter()).
+            filter(new TargetFilter<>(jaxRsRuntimeServiceReference));
     }
 
     private static OSGi<?> whiteboardExtensions(
@@ -327,7 +331,10 @@ public class Whiteboard {
                 flatMap(ref ->
             waitForExtensionDependencies(ref,
                 safeRegisterExtension(
-                    ref, ".default", defaultServiceRegistrator, runtime)
+                    ref, DEFAULT_NAME, defaultServiceRegistrator, runtime)
+            ).foreach(
+                __ -> runtime.addApplicationExtension(DEFAULT_NAME, ref),
+                __ -> runtime.removeApplicationExtension(DEFAULT_NAME, ref)
             )
         );
     }
@@ -340,11 +347,15 @@ public class Whiteboard {
         return
             serviceReferences(getSingletonsFilter()).
                 filter(new TargetFilter<>(jaxRsRuntimeServiceReference)).
-                flatMap(serviceReference ->
-            waitForExtensionDependencies(serviceReference,
+                flatMap(ref ->
+            waitForExtensionDependencies(
+                ref,
                 safeRegisterEndpoint(
-                    serviceReference, ".default", defaultServiceRegistrator,
+                    ref, DEFAULT_NAME, defaultServiceRegistrator,
                     runtime)
+            ).foreach(
+                __ -> runtime.addApplicationEndpoint(DEFAULT_NAME, ref),
+                __ -> runtime.removeApplicationExtension(DEFAULT_NAME, ref)
             )
         );
     }
@@ -428,9 +439,9 @@ public class Whiteboard {
     }
 
     public static String getApplicationBase(
-        ServiceReference<Application> serviceReference) {
+        Map<String, Object> properties) {
 
-        return serviceReference.getProperty(JAX_RS_APPLICATION_BASE).toString();
+        return properties.get(JAX_RS_APPLICATION_BASE).toString();
     }