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/02/24 16:41:52 UTC

[05/12] aries-jax-rs-whiteboard git commit: Moved to component dsl

Moved to component dsl


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/0e87e50b
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/0e87e50b
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/0e87e50b

Branch: refs/heads/master
Commit: 0e87e50be72f2e05da9be8df34be6065fa76ec1f
Parents: e1300b9
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Feb 15 11:30:45 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500

----------------------------------------------------------------------
 jax-rs.whiteboard/bnd.bnd                       |   1 +
 jax-rs.whiteboard/pom.xml                       |   5 +
 .../activator/CXFJaxRsBundleActivator.java      | 167 +++++++++++++++----
 .../AddonsServiceTrackerCustomizer.java         |  84 ----------
 .../ApplicationServiceTrackerCustomizer.java    |  66 --------
 ...AndInterceptorsServiceTrackerCustomizer.java | 121 --------------
 .../SingletonServiceTrackerCustomizer.java      |  78 ---------
 .../internal/TrackedJaxRsRegistrator.java       |  45 -----
 8 files changed, 138 insertions(+), 429 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/bnd.bnd
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/bnd.bnd b/jax-rs.whiteboard/bnd.bnd
index 1f7dc5a..f37aab4 100644
--- a/jax-rs.whiteboard/bnd.bnd
+++ b/jax-rs.whiteboard/bnd.bnd
@@ -51,6 +51,7 @@ Import-Package:\
     org.apache.cxf.jaxrs.ext.*
 
 -includeresource:\
+	lib/component-dsl.jar=component-dsl-*.jar;lib:=true,\
     lib/cxf-core.jar=cxf-core-*.jar;lib:=true,\
     lib/cxf-rt-databinding-jaxb.jar=cxf-rt-databinding-jaxb-*.jar;lib:=true,\
     lib/cxf-rt-frontend-jaxrs.jar=cxf-rt-frontend-jaxrs-*.jar;lib:=true,\

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/pom.xml b/jax-rs.whiteboard/pom.xml
index 493f7b2..132eb32 100644
--- a/jax-rs.whiteboard/pom.xml
+++ b/jax-rs.whiteboard/pom.xml
@@ -102,5 +102,10 @@
             <artifactId>slf4j-api</artifactId>
             <version>1.7.2</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.aries.component-dsl</groupId>
+            <artifactId>component-dsl</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index a871418..45fbf04 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -21,9 +21,9 @@ import javax.servlet.Servlet;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.ext.RuntimeDelegate;
 
-import org.apache.aries.jax.rs.whiteboard.internal.ApplicationServiceTrackerCustomizer;
-import org.apache.aries.jax.rs.whiteboard.internal.FiltersAndInterceptorsServiceTrackerCustomizer;
-import org.apache.aries.jax.rs.whiteboard.internal.SingletonServiceTrackerCustomizer;
+import org.apache.aries.jax.rs.whiteboard.internal.CXFJaxRsServiceRegistrator;
+import org.apache.aries.osgi.functional.OSGi;
+import org.apache.aries.osgi.functional.OSGiResult;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.CXFBusFactory;
@@ -31,15 +31,21 @@ import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.wiring.BundleWiring;
-import org.osgi.util.tracker.ServiceTracker;
 
+import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Hashtable;
-
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.aries.osgi.functional.OSGi.bundleContext;
+import static org.apache.aries.osgi.functional.OSGi.just;
+import static org.apache.aries.osgi.functional.OSGi.onClose;
+import static org.apache.aries.osgi.functional.OSGi.register;
+import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
 import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME;
 import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
 import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME;
@@ -48,9 +54,26 @@ import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHIT
 public class CXFJaxRsBundleActivator implements BundleActivator {
 
     private BundleContext _bundleContext;
-    private ServiceTracker<Application, ?> _applicationTracker;
-    private ServiceTracker<Object, ?> _singletonsServiceTracker;
-    private ServiceTracker<Object, ?> _filtersAndInterceptorsServiceTracker;
+    private OSGiResult<?> _applicationsResult;
+    private OSGiResult<?> _singletonsResult;
+    private OSGiResult<?> _filtersResult;
+
+    private static <T> OSGi<T> service(ServiceReference<T> serviceReference) {
+        return
+            bundleContext().flatMap(bundleContext ->
+            onClose(() -> bundleContext.ungetService(serviceReference)).then(
+            just(bundleContext.getService(serviceReference))
+        ));
+    }
+
+    private static OSGi<?> cxfRegistrator(
+        Bus bus, Application application, Map<String, Object> props) {
+
+        return
+            just(new CXFJaxRsServiceRegistrator(bus, application, props)).flatMap(registrator ->
+            onClose(registrator::close).then(
+            register(CXFJaxRsServiceRegistrator.class, registrator, props)));
+    }
 
     @Override
     public void start(BundleContext bundleContext) throws Exception {
@@ -62,20 +85,58 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
             CXFBusFactory.class.getName()).createBus();
         registerCXFServletService(bus);
 
-        _applicationTracker = new ServiceTracker<>(
-            bundleContext, getApplicationFilter(),
-            new ApplicationServiceTrackerCustomizer(bundleContext, bus));
-        _applicationTracker.open();
-
-        _singletonsServiceTracker = new ServiceTracker<>(
-            bundleContext, getSingletonsFilter(),
-            new SingletonServiceTrackerCustomizer(bundleContext, bus));
-        _singletonsServiceTracker.open();
-
-        _filtersAndInterceptorsServiceTracker = new ServiceTracker<>(
-            bundleContext, getFiltersFilter(),
-            new FiltersAndInterceptorsServiceTrackerCustomizer(bundleContext));
-        _filtersAndInterceptorsServiceTracker.open();
+        OSGi<?> applications =
+            serviceReferences(Application.class, getApplicationFilter()).
+                flatMap(ref ->
+            just(
+                CXFJaxRsServiceRegistrator.getProperties(
+                    ref, "osgi.jaxrs.application.base")).
+                flatMap(properties ->
+            service(ref).flatMap(application ->
+            cxfRegistrator(bus, application, properties)
+        )));
+
+        _applicationsResult = applications.run(bundleContext);
+
+        OSGi<?> singletons =
+            serviceReferences(getSingletonsFilter()).
+                flatMap(serviceReference ->
+            just(
+                CXFJaxRsServiceRegistrator.getProperties(
+                    serviceReference, "osgi.jaxrs.resource.base")).
+                flatMap(properties ->
+            service(serviceReference).flatMap(service ->
+            cxfRegistrator(bus,
+                new Application() {
+                    @Override
+                        public Set<Object> getSingletons() {
+                            return Collections.singleton(service);
+                        }
+                },
+                properties)
+        )));
+
+        _singletonsResult = singletons.run(bundleContext);
+
+        OSGi<?> filters =
+            serviceReferences(getFiltersFilter()).flatMap(ref ->
+            just(
+                ref.getProperty("osgi.jaxrs.filter.base").toString()).
+                flatMap(filterBase ->
+            serviceReferences(
+                CXFJaxRsServiceRegistrator.class, "(CXF_ENDPOINT_ADDRESS=*)").
+                filter(regref ->
+                    regref.
+                        getProperty("CXF_ENDPOINT_ADDRESS").
+                        toString().
+                        startsWith(filterBase)).
+                flatMap(regref ->
+            service(regref).flatMap(registrator ->
+            service(ref).flatMap(service ->
+            safeRegisterEndpoint(ref, registrator, service)
+        )))));
+
+        _filtersResult = filters.run(bundleContext);
     }
 
     /**
@@ -96,6 +157,44 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
         }
     }
 
+    private OSGi<?> safeRegisterEndpoint(
+        ServiceReference<?> ref, CXFJaxRsServiceRegistrator registrator,
+        Object service) {
+
+        return
+            onClose(() -> unregisterEndpoint(registrator, service)).then(
+            registerEndpoint(ref, registrator, service));
+    }
+
+    private OSGi<?> registerEndpoint(
+        ServiceReference<?> ref,
+        CXFJaxRsServiceRegistrator registrator, Object service) {
+
+        Thread thread = Thread.currentThread();
+
+        ClassLoader contextClassLoader = thread.getContextClassLoader();
+
+        ClassLoader classLoader = ref.getBundle().adapt(BundleWiring.class).
+            getClassLoader();
+
+        try {
+            thread.setContextClassLoader(classLoader);
+
+            registrator.add(service);
+        }
+        finally {
+            thread.setContextClassLoader(contextClassLoader);
+        }
+
+        return just(service);
+    }
+
+    private void unregisterEndpoint(
+        CXFJaxRsServiceRegistrator registrator, Object service) {
+
+        registrator.remove(service);
+    }
+
     private ServiceRegistration<Servlet> registerCXFServletService(Bus bus) {
         Dictionary<String, Object> properties = new Hashtable<>();
         properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT,
@@ -114,25 +213,23 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
         return cxfNonSpringServlet;
     }
 
-    private Filter getFiltersFilter() throws InvalidSyntaxException {
-        return _bundleContext.createFilter("(osgi.jaxrs.filter.base=*)");
+    private String getFiltersFilter() {
+        return "(osgi.jaxrs.filter.base=*)";
     }
 
-    private Filter getApplicationFilter() throws InvalidSyntaxException {
-        return _bundleContext.createFilter(
-            "(&(objectClass=" + Application.class.getName() + ")" +
-                "(osgi.jaxrs.application.base=*))");
+    private String getApplicationFilter() {
+        return "(osgi.jaxrs.application.base=*)";
     }
 
-    private Filter getSingletonsFilter() throws InvalidSyntaxException {
-        return _bundleContext.createFilter("(osgi.jaxrs.resource.base=*)");
+    private String getSingletonsFilter() {
+        return "(osgi.jaxrs.resource.base=*)";
     }
     
     @Override
     public void stop(BundleContext context) throws Exception {
-        _applicationTracker.close();
-        _filtersAndInterceptorsServiceTracker.close();
-        _singletonsServiceTracker.close();
+        _applicationsResult.close();
+        _filtersResult.close();
+        _singletonsResult.close();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AddonsServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AddonsServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AddonsServiceTrackerCustomizer.java
deleted file mode 100644
index 9db1aea..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AddonsServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.aries.jax.rs.whiteboard.internal;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class AddonsServiceTrackerCustomizer
-    implements
-        ServiceTrackerCustomizer<CXFJaxRsServiceRegistrator, CXFJaxRsServiceRegistrator> {
-
-    private final BundleContext _bundleContext;
-    private final ClassLoader _classLoader;
-    private final Object _service;
-
-    public AddonsServiceTrackerCustomizer(
-        BundleContext bundleContext, ClassLoader classLoader,
-        Object service) {
-
-        _bundleContext = bundleContext;
-        _classLoader = classLoader;
-        _service = service;
-    }
-
-    @Override
-    public CXFJaxRsServiceRegistrator addingService(ServiceReference<CXFJaxRsServiceRegistrator> reference) {
-        CXFJaxRsServiceRegistrator registrator = _bundleContext.getService(reference);
-        try {
-            runInClassLoader(_classLoader, () -> registrator.add(_service));
-            return registrator;
-        }
-        catch (Exception e) {
-            _bundleContext.ungetService(reference);
-            throw e;
-        }
-    }
-
-    @Override
-    public void modifiedService(
-        ServiceReference<CXFJaxRsServiceRegistrator> reference,
-        CXFJaxRsServiceRegistrator cxfJaxRsServiceRegistrator) {
-
-        removedService(reference, cxfJaxRsServiceRegistrator);
-        addingService(reference);
-    }
-
-    @Override
-    public void removedService(
-        ServiceReference<CXFJaxRsServiceRegistrator> reference,
-        CXFJaxRsServiceRegistrator cxfJaxRsServiceRegistrator) {
-
-        cxfJaxRsServiceRegistrator.remove(_service);
-        _bundleContext.ungetService(reference);
-    }
-    
-    private void runInClassLoader(ClassLoader cl, Runnable runable) {
-        Thread thread = Thread.currentThread();
-        ClassLoader contextClassLoader = thread.getContextClassLoader();
-        try {
-            thread.setContextClassLoader(_classLoader);
-            runable.run();
-        }
-        finally {
-            thread.setContextClassLoader(contextClassLoader);
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationServiceTrackerCustomizer.java
deleted file mode 100644
index ccf2165..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.aries.jax.rs.whiteboard.internal;
-
-import java.util.Map;
-
-import javax.ws.rs.core.Application;
-
-import org.apache.cxf.Bus;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class ApplicationServiceTrackerCustomizer
-    implements ServiceTrackerCustomizer<Application, TrackedJaxRsRegistrator> {
-
-    private BundleContext _bundleContext;
-    private Bus _bus;
-
-    public ApplicationServiceTrackerCustomizer(BundleContext bundleContext, Bus bus) {
-        _bundleContext = bundleContext;
-        _bus = bus;
-    }
-
-    @Override
-    public TrackedJaxRsRegistrator addingService(ServiceReference<Application> serviceReference) {
-        Application application = _bundleContext.getService(serviceReference);
-        try {
-            Map<String, Object> props = CXFJaxRsServiceRegistrator
-                .getProperties(serviceReference, "osgi.jaxrs.application.base");
-            CXFJaxRsServiceRegistrator registrator = new CXFJaxRsServiceRegistrator(_bus, application, props);
-            return new TrackedJaxRsRegistrator(registrator, _bundleContext, props);
-        }
-        catch (Throwable e) {
-            _bundleContext.ungetService(serviceReference);
-            throw e;
-        }
-    }
-
-    @Override
-    public void modifiedService(ServiceReference<Application> serviceReference, TrackedJaxRsRegistrator tracked) {
-        removedService(serviceReference, tracked);
-        addingService(serviceReference);
-    }
-
-    @Override
-    public void removedService(ServiceReference<Application> reference, TrackedJaxRsRegistrator tracked) {
-        _bundleContext.ungetService(reference);
-        tracked.close();
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/FiltersAndInterceptorsServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/FiltersAndInterceptorsServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/FiltersAndInterceptorsServiceTrackerCustomizer.java
deleted file mode 100644
index 9e516b8..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/FiltersAndInterceptorsServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.aries.jax.rs.whiteboard.internal;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class FiltersAndInterceptorsServiceTrackerCustomizer
-    implements ServiceTrackerCustomizer<Object, ServiceTracker<?, ?>> {
-
-    private BundleContext _bundleContext;
-
-    public FiltersAndInterceptorsServiceTrackerCustomizer(
-        BundleContext bundleContext) {
-
-        _bundleContext = bundleContext;
-    }
-
-    @Override
-    public ServiceTracker<?, ?> addingService(final ServiceReference<Object> reference) {
-        final String filterBase =
-            reference.getProperty("osgi.jaxrs.filter.base").toString();
-
-        final Object service = _bundleContext.getService(reference);
-
-        ServiceTracker<CXFJaxRsServiceRegistrator, CXFJaxRsServiceRegistrator> serviceTracker = new ServiceTracker<>(
-            _bundleContext, CXFJaxRsServiceRegistrator.class,
-            new ServiceTrackerCustomizer
-                <CXFJaxRsServiceRegistrator, CXFJaxRsServiceRegistrator>() {
-
-                @Override
-                public CXFJaxRsServiceRegistrator addingService(
-                    ServiceReference<CXFJaxRsServiceRegistrator> cxfReference) {
-
-                    Object resourceBaseObject =
-                        cxfReference.getProperty("CXF_ENDPOINT_ADDRESS");
-
-                    if (resourceBaseObject == null) {
-                        return null;
-                    }
-
-                    String resourceBase = resourceBaseObject.toString();
-
-                    if (resourceBase.startsWith(filterBase)) {
-                        CXFJaxRsServiceRegistrator serviceRegistrator =
-                            _bundleContext.getService(cxfReference);
-                        try {
-                            serviceRegistrator.add(service);
-
-                            return serviceRegistrator;
-                        }
-                        finally {
-                            _bundleContext.ungetService(reference);
-                        }
-                    }
-
-                    return null;
-                }
-
-                @Override
-                public void modifiedService(
-                    ServiceReference<CXFJaxRsServiceRegistrator> reference,
-                    CXFJaxRsServiceRegistrator serviceRegistrator) {
-
-                    removedService(reference, serviceRegistrator);
-                    addingService(reference);
-                }
-
-                @Override
-                public void removedService(
-                    ServiceReference<CXFJaxRsServiceRegistrator> reference,
-                    CXFJaxRsServiceRegistrator serviceRegistrator) {
-
-                    try {
-                        serviceRegistrator.remove(service);
-                    }
-                    finally {
-                        _bundleContext.ungetService(reference);
-                    }
-                }
-            });
-
-        serviceTracker.open();
-
-        return serviceTracker;
-    }
-
-    @Override
-    public void modifiedService(
-        ServiceReference<Object> reference, ServiceTracker<?, ?> serviceTracker) {
-
-        removedService(reference, serviceTracker);
-        addingService(reference);
-    }
-
-    @Override
-    public void removedService(
-        ServiceReference<Object> reference, ServiceTracker<?, ?> serviceTracker) {
-
-        _bundleContext.ungetService(reference);
-
-        serviceTracker.close();
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/SingletonServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/SingletonServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/SingletonServiceTrackerCustomizer.java
deleted file mode 100644
index 2d1264d..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/SingletonServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.aries.jax.rs.whiteboard.internal;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ws.rs.core.Application;
-
-import org.apache.cxf.Bus;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class SingletonServiceTrackerCustomizer
-    implements ServiceTrackerCustomizer<Object, TrackedJaxRsRegistrator> {
-
-    private BundleContext _bundleContext;
-    private Bus _bus;
-
-    public SingletonServiceTrackerCustomizer(BundleContext bundleContext, Bus bus) {
-        _bundleContext = bundleContext;
-        _bus = bus;
-    }
-
-    @Override
-    public TrackedJaxRsRegistrator addingService(
-        ServiceReference<Object> serviceReference) {
-
-        final Object service = _bundleContext.getService(serviceReference);
-        Application application = new Application() {
-            @Override
-            public Set<Object> getSingletons() {
-                return Collections.singleton(service);
-            }
-        };
-        try {
-            Map<String, Object> properties = CXFJaxRsServiceRegistrator
-                .getProperties(serviceReference, "osgi.jaxrs.resource.base");
-            CXFJaxRsServiceRegistrator cxfJaxRsServiceRegistrator = 
-                new CXFJaxRsServiceRegistrator(_bus, application, properties);
-            return new TrackedJaxRsRegistrator(cxfJaxRsServiceRegistrator, _bundleContext, properties);
-        }
-        catch (Exception e) {
-            _bundleContext.ungetService(serviceReference);
-            throw e;
-        }
-    }
-
-    @Override
-    public void modifiedService(ServiceReference<Object> serviceReference, TrackedJaxRsRegistrator tracked) {
-        removedService(serviceReference, tracked);
-        addingService(serviceReference);
-    }
-
-    @Override
-    public void removedService(ServiceReference<Object> reference, TrackedJaxRsRegistrator tracked) {
-        _bundleContext.ungetService(reference);
-        tracked.close();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/TrackedJaxRsRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/TrackedJaxRsRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/TrackedJaxRsRegistrator.java
deleted file mode 100644
index 90ed68e..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/TrackedJaxRsRegistrator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.aries.jax.rs.whiteboard.internal;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public class TrackedJaxRsRegistrator {
-    private final CXFJaxRsServiceRegistrator _registrator;
-    private final ServiceRegistration<?> _sreg;
-
-    public TrackedJaxRsRegistrator(CXFJaxRsServiceRegistrator cxfJaxRsServiceRegistrator, 
-                                   BundleContext bundleContext, 
-                                   Map<String, Object> properties) {
-        _registrator = cxfJaxRsServiceRegistrator;
-        _sreg = bundleContext.
-            registerService(CXFJaxRsServiceRegistrator.class, 
-                            cxfJaxRsServiceRegistrator,
-                            new Hashtable<>(properties));
-    }
-
-
-
-    public void close() {
-        _registrator.close();
-        _sreg.unregister();
-    }
-}
\ No newline at end of file