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 2018/03/23 16:28:28 UTC

[2/4] aries-jax-rs-whiteboard git commit: Add logging

Add logging


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

Branch: refs/heads/master
Commit: 5dfa929a4ecf59ae09c79cb2e914890f7ff7f988
Parents: 04307e8
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Mar 20 16:33:28 2018 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Fri Mar 23 17:20:20 2018 +0100

----------------------------------------------------------------------
 .../activator/CxfJaxrsBundleActivator.java      |  39 +-
 .../internal/AriesJaxrsServiceRuntime.java      | 364 ++++++++++++++++---
 .../jax/rs/whiteboard/internal/Whiteboard.java  | 226 ++++++++++--
 .../rs/whiteboard/internal/utils/LogUtils.java  |  84 +++++
 .../jax/rs/whiteboard/internal/utils/Utils.java |  55 ++-
 5 files changed, 649 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5dfa929a/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 f99cee7..7137e99 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
@@ -43,6 +43,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static java.lang.String.format;
+import static org.apache.aries.jax.rs.whiteboard.internal.utils.LogUtils.ifInfoEnabled;
+import static org.apache.aries.jax.rs.whiteboard.internal.utils.LogUtils.debugTracking;
 import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.canonicalize;
 import static org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.createWhiteboard;
 import static org.apache.aries.osgi.functional.OSGi.all;
@@ -72,8 +74,11 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
         }
 
         OSGi<?> whiteboards =
-            configurations("org.apache.aries.jax.rs.whiteboard").flatMap(
-                configuration -> runWhiteboard(bundleContext, configuration)
+            configurations("org.apache.aries.jax.rs.whiteboard").
+                effects(
+                    debugTracking(_log, () -> "whiteboard configuration")
+                ).flatMap(configuration ->
+                runWhiteboard(bundleContext, configuration)
             );
 
         _whiteboardsResult = whiteboards.run(bundleContext);
@@ -146,7 +151,17 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
                     endpointFilter(configuration::get),
                     __ -> false //never reload
                 ).then(
-                    just(createWhiteboard(bundleContext, configuration))
+                    just(createWhiteboard(bundleContext, configuration)).
+                    effects(
+                        ifInfoEnabled(
+                            _log,
+                            () -> "created whiteboard from configuration: " +
+                                configuration),
+                        ifInfoEnabled(
+                            _log,
+                            () -> "destroyed whiteboard from configuration: " +
+                                configuration)
+                    )
                 .flatMap(
                     whiteboard ->
                         all(
@@ -154,6 +169,12 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
                                 endpoints.effects(
                                     whiteboard::addHttpEndpoints,
                                     whiteboard::removeHttpEndpoints)
+                            ).
+                            effects(
+                                debugTracking(
+                                    _log,
+                                    () -> "endpoint for whiteboard: " +
+                                        whiteboard)
                             ),
                             effects(whiteboard::start, whiteboard::stop)
                         )
@@ -164,7 +185,11 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
     private static OSGi<?> registerClient() {
         return register(
             ClientBuilder.class, new ClientBuilderFactory(),
-            (Map<String, Object>) null);
+            (Map<String, Object>) null).
+            effects(
+                ifInfoEnabled(_log, () -> "Registered ClientBuilder"),
+                ifInfoEnabled(_log, () -> "Unregistered ClientBuilder")
+            );
     }
 
     private static OSGi<?> registerSseEventSourceFactory() {
@@ -180,7 +205,11 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
                     return newBuilder(target).build();
                 }
             },
-            new Hashtable<>());
+            new Hashtable<>()).
+            effects(
+                ifInfoEnabled(_log, () -> "Registered SseEventSourceFactory"),
+                ifInfoEnabled(_log, () -> "Unregistered SseEventSourceFactory")
+            );
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5dfa929a/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 ae8bb08..cb65fb3 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
@@ -22,6 +22,8 @@ import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.generateAp
 import static org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.DEFAULT_NAME;
 import static org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.SUPPORTED_EXTENSION_INTERFACES;
 import static org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.getApplicationBase;
+import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.getServiceId;
+import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
 import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_NAME;
 
 import java.util.ArrayList;
@@ -45,6 +47,7 @@ import org.apache.aries.jax.rs.whiteboard.AriesJaxrsWhiteboardConstants;
 import org.apache.aries.jax.rs.whiteboard.internal.cxf.CxfJaxrsServiceRegistrator;
 import org.apache.aries.jax.rs.whiteboard.internal.utils.PropertyHolder;
 import org.apache.aries.jax.rs.whiteboard.internal.introspection.ClassIntrospector;
+import org.apache.aries.jax.rs.whiteboard.internal.utils.Utils;
 import org.apache.aries.osgi.functional.CachingServiceReference;
 import org.apache.cxf.Bus;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
@@ -68,8 +71,8 @@ import org.slf4j.LoggerFactory;
 public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
 
     private static final long serialVersionUID = 1L;
-    private static final Logger _LOGGER = LoggerFactory.getLogger(
-        Whiteboard.class);
+    private static final Logger _log = LoggerFactory.getLogger(
+        AriesJaxrsServiceRuntime.class);
 
     public static String getServiceName(PropertyHolder properties) {
         Object property = properties.get(JAX_RS_NAME);
@@ -94,51 +97,105 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
     }
 
     public void addApplicationEndpoint(
-        String applicationName,
+        CachingServiceReference<CxfJaxrsServiceRegistrator>
+            registratorReference,
         CachingServiceReference<?> endpointImmutableServiceReference,
         Bus bus, Class<?> theClass) {
 
         _applicationEndpoints.compute(
-            applicationName,
+            getServiceName(registratorReference::getProperty),
             merger(
                 new EndpointRuntimeInformation(
                     endpointImmutableServiceReference, bus, theClass)));
+
+        if (_log.isInfoEnabled()) {
+        	_log.info(
+        	    "Resource service {} has been registered into application {}",
+                getServiceId(endpointImmutableServiceReference),
+                registratorReference.getProperty("original.service.id"));
+        }
     }
 
     public void addApplicationExtension(
-        String applicationName,
+        CachingServiceReference<CxfJaxrsServiceRegistrator>
+            registratorReference,
         CachingServiceReference<?> extensionImmutableServiceReference,
         Class<?> theClass) {
 
         _applicationExtensions.compute(
-            applicationName,
+            getServiceName(registratorReference::getProperty),
             merger(
                 new ExtensionRuntimeInformation(
                     extensionImmutableServiceReference, theClass)));
+
+        if (_log.isInfoEnabled()) {
+        	_log.info(
+        	    "Extension {} has been registered to application {}",
+                getServiceId(extensionImmutableServiceReference),
+                registratorReference.getProperty("original.service.id"));
+        }
     }
 
     public void addClashingApplication(
         CachingServiceReference<?> serviceReference) {
 
         _clashingApplications.add(serviceReference);
+
+        String serviceName = getServiceName(serviceReference::getProperty);
+
+        if (_log.isInfoEnabled()) {
+        	_log.info(
+        	    "Application {} clashes with {} for name {}",
+                getServiceId(serviceReference),
+                getServiceId(_servicesForName.get(serviceName)),
+                serviceName);
+        }
     }
 
     public void addClashingExtension(
         CachingServiceReference<?> serviceReference) {
 
         _clashingExtensions.add(serviceReference);
+
+
+        String serviceName = getServiceName(serviceReference::getProperty);
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Extension {} clashes with {} for name {}",
+                getServiceId(serviceReference),
+                getServiceId(_servicesForName.get(serviceName)),
+                serviceName);
+        }
     }
 
     public void addClashingResource(
         CachingServiceReference<?> serviceReference) {
 
         _clashingResources.add(serviceReference);
+
+        String serviceName = getServiceName(serviceReference::getProperty);
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Resource {} clashes with {} for name {}",
+                getServiceId(serviceReference),
+                getServiceId(_servicesForName.get(serviceName)),
+                serviceName);
+        }
     }
 
     public void addContextDependentApplication(
         CachingServiceReference<Application> serviceReference) {
 
         _contextDependentApplications.add(serviceReference);
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Application {} depends on context filter {}",
+                getServiceId(serviceReference),
+                serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT));
+        }
     }
 
     public void addDependentApplication(
@@ -153,7 +210,9 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
         _dependentExtensions.add(cachingServiceReference);
     }
 
-    public void addDependentService(CachingServiceReference<?> serviceReference) {
+    public void addDependentService(
+        CachingServiceReference<?> serviceReference) {
+
         _dependentServices.add(serviceReference);
     }
 
@@ -161,43 +220,78 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
         CachingServiceReference<Application> serviceReference) {
 
         _erroredApplications.add(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Application {} is registered with error",
+                getServiceId(serviceReference));
+        }
     }
 
-    public <T> void addErroredEndpoint(CachingServiceReference<T> serviceReference) {
+    public <T> void addErroredEndpoint(
+        CachingServiceReference<T> serviceReference) {
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Resource {} is registered with error",
+                getServiceId(serviceReference));
+        }
+
         _erroredEndpoints.add(serviceReference);
     }
 
     public void addErroredExtension(
         CachingServiceReference<?> cachingServiceReference) {
 
+        if (_log.isWarnEnabled()) {
+        	_log.warn(
+        	    "Extension {} is registered with error",
+                getServiceId(cachingServiceReference));
+        }
+
         _erroredExtensions.add(cachingServiceReference);
     }
 
     public void addInvalidApplication(
         CachingServiceReference<?> serviceReference) {
 
+        if (_log.isWarnEnabled()) {
+        	_log.warn(
+        	    "Application {} is not valid", getServiceId(serviceReference));
+        }
+
         _invalidApplications.add(serviceReference);
     }
 
     public void addInvalidExtension(
         CachingServiceReference<?> serviceReference) {
 
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Extension {} is not valid", getServiceId(serviceReference));
+        }
+
         _invalidExtensions.add(serviceReference);
     }
 
     public void addInvalidResource(
         CachingServiceReference<?> serviceReference) {
 
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Resource {} is not valid", getServiceId(serviceReference));
+        }
+
         _invalidResources.add(serviceReference);
     }
 
     public boolean addNotGettableApplication(
         CachingServiceReference<Application> serviceReference) {
 
-        if (_LOGGER.isWarnEnabled()) {
-            _LOGGER.warn(
-                "Application from reference " + serviceReference +
-                    " can't be got");
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Application from reference {} can't be got",
+                getServiceId(serviceReference));
         }
 
         return _ungettableApplications.add(serviceReference);
@@ -206,10 +300,10 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
     public <T> boolean addNotGettableEndpoint(
         CachingServiceReference<T> serviceReference) {
 
-        if (_LOGGER.isWarnEnabled()) {
-            _LOGGER.warn(
-                "Resource from reference " + serviceReference +
-                    " can't be got");
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Resource from reference {} can't be got",
+                getServiceId(serviceReference));
         }
 
         return _ungettableEndpoints.add(serviceReference);
@@ -218,17 +312,44 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
     public <T> void addNotGettableExtension(
         CachingServiceReference<T> serviceReference) {
 
-        if (_LOGGER.isWarnEnabled()) {
-            _LOGGER.warn(
-                "Extension from reference " + serviceReference +
-                    " can't be got");
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Extension from reference {} can't be got",
+                getServiceId(serviceReference));
         }
 
         _ungettableExtensions.add(serviceReference);
     }
 
+    public void addServiceForName(CachingServiceReference<?> serviceReference) {
+        _servicesForName.put(
+            getServiceName(serviceReference::getProperty), serviceReference);
+
+        if (_log.isInfoEnabled()) {
+        	_log.info(
+        	    "Registered service {} for name {}",
+                getServiceId(serviceReference),
+                getServiceName(serviceReference::getProperty));
+        }
+    }
+
     public boolean addShadowedApplication(
-        CachingServiceReference<Application> serviceReference) {
+        CachingServiceReference<Application> serviceReference,
+        String actualBasePath) {
+
+        if (_log.isInfoEnabled()) {
+            ApplicationRuntimeInformation applicationRuntimeInformation =
+                _applications.get(actualBasePath);
+
+            if (applicationRuntimeInformation != null) {
+                _log.info(
+                    "Application reference {} is shadowed by {}",
+                    getServiceId(serviceReference),
+                    getServiceId(
+                        applicationRuntimeInformation._cachingServiceReference)
+                );
+            }
+        }
 
         return _shadowedApplications.add(serviceReference);
     }
@@ -299,10 +420,30 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
         return runtimeDTO;
     }
 
-    private Stream<FailedApplicationDTO> contextDependentApplicationsDTOStream() {
+    public void removedServiceForName(
+        CachingServiceReference<?> serviceReference) {
+
+        _servicesForName.remove(getServiceName(serviceReference::getProperty));
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Unregistered service {} for name {}",
+                getServiceId(serviceReference),
+                getServiceName(serviceReference::getProperty));
+        }
+    }
+
+    private ConcurrentHashMap<String, CachingServiceReference<?>>
+        _servicesForName = new ConcurrentHashMap<>();
+
+    private Stream<FailedApplicationDTO>
+        contextDependentApplicationsDTOStream() {
+
         return _contextDependentApplications.stream().map(
             sr -> buildFailedApplicationDTO(
-                AriesJaxrsWhiteboardConstants.FAILURE_REASON_REQUIRED_CONTEXT_UNAVAILABLE, sr)
+                AriesJaxrsWhiteboardConstants.
+                    FAILURE_REASON_REQUIRED_CONTEXT_UNAVAILABLE,
+                sr)
         );
     }
 
@@ -319,49 +460,95 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
     }
 
     public void removeApplicationEndpoint(
-        String applicationName,
+        CachingServiceReference<CxfJaxrsServiceRegistrator>
+            registratorReference,
         CachingServiceReference<?> cachingServiceReference) {
 
         _applicationEndpoints.compute(
-            applicationName,
+            getServiceName(registratorReference::getProperty),
             remover(
                 new EndpointRuntimeInformation(
                 cachingServiceReference, null, null)));
+
+        if (_log.isInfoEnabled()) {
+        	_log.info(
+        	    "Endpoint {} has been removed from application {}",
+                getServiceId(cachingServiceReference),
+                registratorReference.getProperty("original.service.id"));
+        }
     }
 
     public void removeApplicationExtension(
-        String applicationName,
+        CachingServiceReference<CxfJaxrsServiceRegistrator>
+            registratorReference,
         CachingServiceReference<?> extensionImmutableServiceReference) {
 
         _applicationExtensions.computeIfPresent(
-            applicationName,
+            getServiceName(registratorReference::getProperty),
             remover(
                 new ExtensionRuntimeInformation(
                 extensionImmutableServiceReference, null)));
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Extension {} has been removed from application {}",
+                getServiceId(extensionImmutableServiceReference),
+                registratorReference.getProperty("original.service.id"));
+        }
     }
 
     public void removeClashingApplication(
         CachingServiceReference<?> serviceReference) {
 
         _clashingApplications.remove(serviceReference);
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Application {} no longer clashes for name {}",
+                getServiceId(serviceReference),
+                getServiceName(serviceReference::getProperty));
+        }
     }
 
     public void removeClashingExtension(
         CachingServiceReference<?> serviceReference) {
 
         _clashingExtensions.remove(serviceReference);
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Extension {} no longer clashes for name {}",
+                getServiceId(serviceReference),
+                getServiceName(serviceReference::getProperty));
+        }
     }
 
     public void removeClashingResource(
         CachingServiceReference<?> serviceReference) {
 
         _clashingResources.remove(serviceReference);
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Resource {} no longer clashes for name {}",
+                getServiceId(serviceReference),
+                getServiceName(serviceReference::getProperty));
+        }
+
     }
 
     public void removeContextDependentApplication(
         CachingServiceReference<Application> serviceReference) {
 
         _contextDependentApplications.remove(serviceReference);
+
+        if (_log.isInfoEnabled()) {
+            _log.info(
+                "Application {} no longer depends on context filter {}",
+                getServiceId(serviceReference),
+                serviceReference.getProperty(HTTP_WHITEBOARD_CONTEXT_SELECT));
+        }
+
     }
 
     public void removeDependentApplication(
@@ -376,7 +563,9 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
         _dependentExtensions.remove(cachingServiceReference);
     }
 
-    public void removeDependentService(CachingServiceReference<?> serviceReference) {
+    public void removeDependentService(
+        CachingServiceReference<?> serviceReference) {
+
         _dependentServices.remove(serviceReference);
     }
 
@@ -384,63 +573,120 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
         CachingServiceReference<Application> serviceReference) {
 
         _erroredApplications.remove(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Errored application {} is gone",
+                getServiceId(serviceReference));
+        }
     }
 
-    public <T> void removeErroredEndpoint(CachingServiceReference<T> serviceReference) {
+    public <T> void removeErroredEndpoint(
+        CachingServiceReference<T> serviceReference) {
+
         _erroredEndpoints.remove(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Errored resource {} is gone", getServiceId(serviceReference));
+        }
     }
 
     public void removeErroredExtension(
-        CachingServiceReference<?> cachingServiceReference) {
+        CachingServiceReference<?> serviceReference) {
+
+        _erroredExtensions.remove(serviceReference);
 
-        _erroredExtensions.remove(cachingServiceReference);
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Errored extension {} is gone", getServiceId(serviceReference));
+        }
     }
 
     public void removeInvalidApplication(
         CachingServiceReference<?> serviceReference) {
 
         _invalidApplications.remove(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Invalid application {} is gone",
+                getServiceId(serviceReference));
+        }
     }
 
     public void removeInvalidExtension(
         CachingServiceReference<?> serviceReference) {
 
         _invalidExtensions.remove(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Invalid extension {} is gone", getServiceId(serviceReference));
+        }
     }
 
     public void removeInvalidResource(
         CachingServiceReference<?> serviceReference) {
 
         _invalidResources.remove(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Invalid resource {} is gone", getServiceId(serviceReference));
+        }
     }
 
-    public boolean removeNotGettableApplication(
+    public void removeNotGettableApplication(
         CachingServiceReference<Application> serviceReference) {
 
-        return _ungettableApplications.remove(serviceReference);
+        _ungettableApplications.remove(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Ungettable application reference {} is gone",
+                getServiceId(serviceReference));
+        }
     }
 
-    public <T> boolean removeNotGettableEndpoint(
+    public <T> void removeNotGettableEndpoint(
         CachingServiceReference<T> serviceReference) {
 
-        return _ungettableEndpoints.remove(serviceReference);
+        _ungettableEndpoints.remove(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Ungettable resource reference {} is gone",
+                getServiceId(serviceReference));
+        }
     }
 
     public <T> void removeNotGettableExtension(
         CachingServiceReference<T> serviceReference) {
 
         _ungettableExtensions.remove(serviceReference);
+
+        if (_log.isWarnEnabled()) {
+            _log.warn(
+                "Ungettable extension reference {} is gone",
+                getServiceId(serviceReference));
+        }
     }
 
     public boolean removeShadowedApplication(
         CachingServiceReference<Application> serviceReference) {
 
+        if (_log.isDebugEnabled()) {
+        	_log.debug(
+        	    "Application {} is no longer shadowed",
+                getServiceId(serviceReference));
+        }
+
         return _shadowedApplications.remove(serviceReference);
     }
 
     public ApplicationRuntimeInformation setApplicationForPath(
-        String path,
-        CachingServiceReference<Application> serviceReference,
+        String path, CachingServiceReference<Application> serviceReference,
         CxfJaxrsServiceRegistrator cxfJaxRsServiceRegistrator) {
 
         ApplicationRuntimeInformation ari = new ApplicationRuntimeInformation(
@@ -453,9 +699,21 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
                     getServiceName(
                         ari._cachingServiceReference::getProperty))) {
 
+                    if (_log.isInfoEnabled()) {
+                    	_log.info(
+                    	    "Setting application {} as default",
+                            getServiceId(serviceReference));
+                    }
+
                     _defaultApplicationProperties = ari;
                 }
 
+                if (_log.isInfoEnabled()) {
+                	_log.info(
+                	    "Registering application {} for path {}",
+                        getServiceId(serviceReference), path);
+                }
+
                 return ari;
             });
     }
@@ -481,15 +739,16 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
         new CopyOnWriteArrayList<>();
     private Set<CachingServiceReference<Application>>
         _contextDependentApplications = ConcurrentHashMap.newKeySet();
-    private volatile ApplicationRuntimeInformation _defaultApplicationProperties;
+    private volatile ApplicationRuntimeInformation
+        _defaultApplicationProperties;
     private Set<CachingServiceReference<Application>> _dependentApplications =
         ConcurrentHashMap.newKeySet();
     private Set<CachingServiceReference<?>> _dependentExtensions =
         ConcurrentHashMap.newKeySet();
     private Set<CachingServiceReference<?>> _dependentServices =
         ConcurrentHashMap.newKeySet();
-    private Collection<CachingServiceReference<Application>> _erroredApplications =
-        new CopyOnWriteArrayList<>();
+    private Collection<CachingServiceReference<Application>>
+        _erroredApplications = new CopyOnWriteArrayList<>();
     private Collection<CachingServiceReference<?>> _erroredEndpoints =
         new CopyOnWriteArrayList<>();
     private Collection<CachingServiceReference<?>> _erroredExtensions =
@@ -500,8 +759,8 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
         new CopyOnWriteArrayList<>();
     private Collection<CachingServiceReference<?>> _invalidResources =
         new CopyOnWriteArrayList<>();
-    private Collection<CachingServiceReference<Application>> _shadowedApplications =
-        new CopyOnWriteArrayList<>();
+    private Collection<CachingServiceReference<Application>>
+        _shadowedApplications = new CopyOnWriteArrayList<>();
     private Collection<CachingServiceReference<Application>>
         _ungettableApplications = new CopyOnWriteArrayList<>();
     private Collection<CachingServiceReference<?>> _ungettableEndpoints =
@@ -647,17 +906,21 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
             );
     }
 
-    private Stream<FailedExtensionDTO> applicationDependentExtensionsDTOStream() {
+    private Stream<FailedExtensionDTO>
+        applicationDependentExtensionsDTOStream() {
+
         return _applicationDependentExtensions.stream().map(
             sr -> buildFailedExtensionDTO(
-                DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE, sr)
+                DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE,
+                sr)
         );
     }
 
     private Stream<FailedResourceDTO> applicationDependentResourcesDTOStream() {
         return _applicationDependentResources.stream().map(
             sr -> buildFailedResourceDTO(
-                DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE, sr)
+                DTOConstants.FAILURE_REASON_REQUIRED_APPLICATION_UNAVAILABLE,
+                sr)
         );
     }
 
@@ -851,10 +1114,9 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
                 endpointRuntimeInformations.stream() :
                 Stream.empty();
 
-        return
-            applicationEndpointStream.map(
-                sr -> populateResourceDTO(new ResourceDTO(), sr)
-            );
+        return applicationEndpointStream.map(
+            sr -> populateResourceDTO(new ResourceDTO(), sr)
+        );
     }
 
     private Stream<ExtensionDTO> getApplicationExtensionsStream(String name) {
@@ -900,7 +1162,9 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
         );
     }
 
-    private Stream<FailedApplicationDTO> unreferenciableApplicationsDTOStream() {
+    private Stream<FailedApplicationDTO>
+        unreferenciableApplicationsDTOStream() {
+
         return _ungettableApplications.stream().
             map(
                 sr -> buildFailedApplicationDTO(

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5dfa929a/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 5abaf33..dc0003d 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
@@ -39,6 +39,8 @@ import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.service.http.context.ServletContextHelper;
 import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.servlet.Servlet;
 import javax.ws.rs.container.ContainerRequestFilter;
@@ -71,13 +73,18 @@ import java.util.stream.Stream;
 import static java.lang.String.format;
 import static java.util.stream.Collectors.toMap;
 import static org.apache.aries.jax.rs.whiteboard.internal.AriesJaxrsServiceRuntime.getServiceName;
+import static org.apache.aries.jax.rs.whiteboard.internal.utils.LogUtils.ifDebugEnabled;
+import static org.apache.aries.jax.rs.whiteboard.internal.utils.LogUtils.ifErrorEnabled;
+import static org.apache.aries.jax.rs.whiteboard.internal.utils.LogUtils.ifInfoEnabled;
 import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.canonicalize;
 import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.generateApplicationName;
 import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.getProperties;
+import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.getServiceId;
 import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.highestPer;
 import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.onlyGettables;
 import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.service;
 import static org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.updateProperty;
+import static org.apache.aries.osgi.functional.OSGi.NOOP;
 import static org.apache.aries.osgi.functional.OSGi.all;
 import static org.apache.aries.osgi.functional.OSGi.changeContext;
 import static org.apache.aries.osgi.functional.OSGi.effects;
@@ -127,8 +134,12 @@ public class Whiteboard {
                 org.apache.cxf.feature.Feature.class,
                 org.apache.cxf.jaxrs.ext.ContextProvider.class)
             .collect(toMap(Class::getName, Function.identity())));
+
     static final String DEFAULT_NAME = ".default";
 
+    private static final Logger _log = LoggerFactory.getLogger(
+        Whiteboard.class);
+
     private final AriesJaxrsServiceRuntime _runtime;
     private final Map<String, ?> _configurationMap;
     private final BundleContext _bundleContext;
@@ -245,7 +256,12 @@ public class Whiteboard {
                 ),
                 this::registerShadowedService,
                 this::unregisterShadowedService
-            ).distribute(
+            ).
+            effects(
+                _runtime::addServiceForName,
+                _runtime::removedServiceForName
+            ).
+            distribute(
                 p -> ignore(applications((OSGi)p.filter(this::isApplication))),
                 p -> ignore(applicationResources(p.filter(this::isResource))),
                 p -> ignore(applicationExtensions(p.filter(this::isExtension)))
@@ -298,7 +314,12 @@ public class Whiteboard {
             OSGi<CachingServiceReference<T>> error = effects(
                 () -> onAddingInvalid.accept(serviceReference),
                 () -> onRemovingInvalid.accept(serviceReference)
-            ).then(
+            ).
+            effects(
+                ifDebugEnabled(_log, () -> "Invalid service {}"),
+                ifDebugEnabled(_log, () -> "Invalid service {} is gone")
+            ).
+            then(
                 nothing()
             );
 
@@ -308,18 +329,36 @@ public class Whiteboard {
                 !propertyObject.toString().equals(JAX_RS_DEFAULT_APPLICATION) &&
                 propertyObject.toString().startsWith(".")) {
 
+                if (_log.isWarnEnabled()) {
+                    _log.warn(
+                        "Invalid property {} in service {}",
+                        JAX_RS_DEFAULT_APPLICATION, serviceReference);
+                }
+
                 return error;
             }
 
             if (!testFilters(
                 serviceReference.getProperty(JAX_RS_APPLICATION_SELECT))) {
 
+                if (_log.isWarnEnabled()) {
+                    _log.warn(
+                        "Invalid value for property {} in service {}",
+                        JAX_RS_APPLICATION_SELECT, serviceReference);
+                }
+
                 return error;
             }
 
             if (!testFilters(
                 serviceReference.getProperty(JAX_RS_EXTENSION_SELECT))) {
 
+                if (_log.isWarnEnabled()) {
+                    _log.warn(
+                        "Invalid value for property {} in service {}",
+                        JAX_RS_EXTENSION_SELECT, serviceReference);
+                }
+
                 return error;
             }
 
@@ -411,7 +450,7 @@ public class Whiteboard {
                 arwc -> just(arwc.getActualBasePath()),
                 applicationsWithContext,
                 t -> _runtime.addShadowedApplication(
-                    t.getApplicationReference()),
+                    t.getApplicationReference(), t.getActualBasePath()),
                 t -> _runtime.removeShadowedApplication(
                     t.getApplicationReference())
         );
@@ -420,7 +459,7 @@ public class Whiteboard {
             onlyGettables(
                 just(application.getApplicationReference()),
                 _runtime::addNotGettableApplication,
-                _runtime::removeNotGettableApplication).
+                _runtime::removeNotGettableApplication, _log).
             recoverWith(
                 (t, e) ->
                     just(t).map(
@@ -481,11 +520,23 @@ public class Whiteboard {
             }
         }
 
+        if (_log.isDebugEnabled()) {
+            _log.debug(
+                "Creating CXF Bus with extensions {} and properties {}",
+                extensions, properties);
+        }
+
         ExtensionManagerBus bus = new ExtensionManagerBus(
             cxfExtensions, properties, wiring.getClassLoader());
 
         bus.initialize();
 
+        if (_log.isDebugEnabled()) {
+            _log.debug(
+                "Created CXF Bus with extensions {} and properties {}",
+                extensions, properties);
+        }
+
         return bus;
     }
 
@@ -569,7 +620,7 @@ public class Whiteboard {
                 ).filter(
                     new TargetFilter<>(_runtimeReference)
                 ),
-                __ -> {}, __ -> {});
+                __ -> {}, __ -> {}, _log);
 
         return accumulateInMap(
             cxfExtensionsForApplication,
@@ -700,13 +751,24 @@ public class Whiteboard {
                 onlyGettables(
                     just(serviceReference),
                     _runtime::addNotGettableEndpoint,
-                    _runtime::removeNotGettableEndpoint
+                    _runtime::removeNotGettableEndpoint,
+                    _log
                 )
             ).recoverWith((t, e) ->
                 just(serviceReference).
                 effects(
                     _runtime::addErroredEndpoint,
                     _runtime::removeErroredEndpoint).
+                effects(
+                    ifErrorEnabled(
+                        _log,
+                        () -> "ServiceReference {} for endpoint produced " +
+                            "error: {}",
+                        e),
+                    ifErrorEnabled(
+                        _log,
+                        () -> "Errored ServiceReference {} for endpoint left")
+                ).
                 then(nothing())
             ).flatMap(st ->
                 just(st.getServiceObjects()).
@@ -714,14 +776,35 @@ public class Whiteboard {
                         Utils::getResourceProvider
                 ).effects(
                     rp -> _runtime.addApplicationEndpoint(
-                        applicationName, st.getCachingServiceReference(),
+                        registratorReference, st.getCachingServiceReference(),
                         registrator.getBus(), st.getService().getClass()),
                     rp -> _runtime.removeApplicationEndpoint(
-                        applicationName, st.getCachingServiceReference())
+                        registratorReference, st.getCachingServiceReference())
                 ).effects(
                     registrator::add,
                     registrator::remove
-            )));
+                ).effects(
+                    ifDebugEnabled(
+                        _log,
+                        () -> "Registered endpoint " +
+                            st.getCachingServiceReference().
+                                getServiceReference() + " into application " +
+                                getServiceName(
+                                    registratorReference.
+                                        getServiceReference()::getProperty)
+                    ),
+                    ifDebugEnabled(
+                        _log,
+                        () -> "Unregistered endpoint " +
+                            st.getCachingServiceReference().
+                                getServiceReference() + " from application " +
+                                getServiceName(
+                                    registratorReference.
+                                        getServiceReference()::getProperty)
+                    )
+
+                )
+            ));
     }
 
     private OSGi<?> safeRegisterExtension(
@@ -741,7 +824,8 @@ public class Whiteboard {
                     onlyGettables(
                         just(serviceReference),
                         _runtime::addNotGettableExtension,
-                        _runtime::removeNotGettableExtension
+                        _runtime::removeNotGettableExtension,
+                        _log
                     )
                 ).recoverWith(
                 (t, e) ->
@@ -750,17 +834,52 @@ public class Whiteboard {
                         _runtime::addErroredExtension,
                         _runtime::removeErroredExtension
                     ).
+                    effects(
+                        ifErrorEnabled(
+                            _log,
+                            () -> "ServiceReference {} for extension " +
+                                "produced error: {}",
+                            e),
+                        ifErrorEnabled(
+                            _log,
+                            () -> "Errored ServiceReference {} for extension " +
+                                "left")
+                    ).
                     then(nothing())
             ).effects(
                 registrator::addProvider,
                 registrator::removeProvider
             ).effects(
                 t -> _runtime.addApplicationExtension(
-                    applicationName, serviceReference,
+                    registratorReference, serviceReference,
                     t.getService().getClass()),
                 __ -> _runtime.removeApplicationExtension(
-                    applicationName, serviceReference)
-            ).then(
+                    registratorReference, serviceReference)
+            ).
+            effects(
+                ifDebugEnabled(
+                    _log,
+                    () ->
+                        "Registered extension " +
+                            serviceReference.getServiceReference() +
+                                " into application " +
+                            getServiceName(
+                                registratorReference.
+                                    getServiceReference()::getProperty)
+                ),
+                ifDebugEnabled(
+                    _log,
+                    () ->
+                        "Unregistered extension  " +
+                            serviceReference.getServiceReference() +
+                            " from application " +
+                            getServiceName(
+                                registratorReference.
+                                    getServiceReference()::getProperty)
+                )
+
+            ).
+            then(
             register(
                 ApplicationExtensionRegistration.class,
                 () -> new ApplicationExtensionRegistration(){},
@@ -803,13 +922,19 @@ public class Whiteboard {
             }
 
             for (String extensionDependency : extensionDependencies) {
-                extensionDependency = String.format(
+                if  (_log.isDebugEnabled()) {
+                    _log.debug(
+                        "Application {} has a dependency on {}",
+                        reference, extensionDependency);
+                }
+
+                String finalExtensionDependency = String.format(
                     "(&(!(objectClass=%s))%s)",
                     ApplicationExtensionRegistration.class.getName(),
                     extensionDependency);
 
                 program =
-                    once(serviceReferences(extensionDependency)).
+                    once(serviceReferences(finalExtensionDependency)).
                         flatMap(
                             sr -> {
                                 Object applicationSelectProperty =
@@ -838,11 +963,23 @@ public class Whiteboard {
                                 return nothing();
                             }
                         ).effects(
-                        __ -> {},
-                        __ -> _runtime.addDependentApplication(
-                            reference)
-                    ).
-                        then(program);
+                                __ -> {},
+                                __ -> _runtime.addDependentApplication(
+                                    reference)
+                        ).
+                        effects(
+                            ifInfoEnabled(
+                                _log,
+                                () -> "Application "+ getServiceId(reference) +
+                                    " dependency " + extensionDependency +
+                                        " has been fullfiled"),
+                            ifInfoEnabled(
+                                _log,
+                                () -> "Application "+ getServiceId(reference) +
+                                    " dependency " + extensionDependency +
+                                        " has gone")
+                        ).
+                    then(program);
             }
 
             program = program.effects(
@@ -855,7 +992,7 @@ public class Whiteboard {
     }
 
     private OSGi<?> waitForExtensionDependencies(
-        CachingServiceReference<?> serviceReference,
+        CachingServiceReference<?> reference,
         CachingServiceReference<CxfJaxrsServiceRegistrator>
             applicationRegistratorReference,
         Consumer<CachingServiceReference<?>> onAddingDependent,
@@ -865,38 +1002,45 @@ public class Whiteboard {
             applicationRegistratorReference::getProperty);
 
         String[] extensionDependencies = canonicalize(
-            serviceReference.getProperty(JAX_RS_EXTENSION_SELECT));
+            reference.getProperty(JAX_RS_EXTENSION_SELECT));
 
-        OSGi<CachingServiceReference<?>> program = just(serviceReference);
+        OSGi<CachingServiceReference<?>> program = just(reference);
 
         if (extensionDependencies.length > 0) {
-            onAddingDependent.accept(serviceReference);
+            onAddingDependent.accept(reference);
         }
         else {
             return program;
         }
 
         for (String extensionDependency : extensionDependencies) {
+            if  (_log.isDebugEnabled()) {
+                _log.debug(
+                    "Extension {} has a dependency on {}",
+                    reference, extensionDependency);
+            }
+
             try {
-                extensionDependency = extensionDependency.replace(
+                String finalExtensionDependency = extensionDependency.replace(
                     "(objectClass=", "(original.objectClass=");
 
                 Filter extensionFilter = _bundleContext.createFilter(
-                    extensionDependency);
+                    finalExtensionDependency);
 
                 if (
                     extensionFilter.match(_runtimeReference) ||
                     extensionFilter.match(
-                        applicationRegistratorReference.getServiceReference())) {
-
+                        applicationRegistratorReference.getServiceReference()))
+                {
                     continue;
                 }
 
                 program =
-                    once(serviceReferences(ApplicationExtensionRegistration.class).
+                    once(serviceReferences(
+                        ApplicationExtensionRegistration.class).
                         filter(
                             sr -> sr.getProperty("original.application.name").
-                                    equals(applicationName)
+                                equals(applicationName)
                         ).map(
                             CachingServiceReference::getServiceReference
                         ).filter(
@@ -904,9 +1048,21 @@ public class Whiteboard {
                         )
                     ).effects(
                         __ -> {},
-                        __ -> onAddingDependent.accept(serviceReference)
+                        __ -> onAddingDependent.accept(reference)
                     ).
-                    then(program);
+                    effects(
+                        ifInfoEnabled(
+                            _log,
+                            () -> "Extension " + getServiceId(reference) +
+                                " dependency " + extensionDependency +
+                                    " has been fullfiled"),
+                        ifInfoEnabled(
+                            _log,
+                            () -> "Extension " + getServiceId(reference) +
+                                " dependency " + extensionDependency +
+                                    " has gone")
+                    ).
+                then(program);
             }
             catch (InvalidSyntaxException e) {
 
@@ -914,11 +1070,11 @@ public class Whiteboard {
         }
 
         program = onClose(
-            () -> onRemovingDependent.accept(serviceReference)).
+            () -> onRemovingDependent.accept(reference)).
             then(program);
 
         program = program.effects(
-            __ -> onRemovingDependent.accept(serviceReference),
+            __ -> onRemovingDependent.accept(reference),
             __ -> {}
         );
 
@@ -1024,7 +1180,7 @@ public class Whiteboard {
 
         Supplier<Map<String, ?>> contextPropertiesSup;
 
-        OSGi<?> program = just(0);
+        OSGi<?> program = effects(NOOP, NOOP);
 
         if (contextReference == null) {
             contextPropertiesSup = () -> {

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5dfa929a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/LogUtils.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/LogUtils.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/LogUtils.java
new file mode 100644
index 0000000..d0ffe48
--- /dev/null
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/LogUtils.java
@@ -0,0 +1,84 @@
+/*
+ * 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.utils;
+
+import org.apache.aries.osgi.functional.Effect;
+import org.slf4j.Logger;
+
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+public class LogUtils {
+
+    public static Effect<Object> debugTracking(
+        Logger log, Supplier<String> type) {
+
+        return new Effect<>(
+            o -> {
+                if (log.isDebugEnabled()) {
+                    log.debug("adding new {}: {}", type.get(), o);
+                }
+            },
+            o -> {
+                if (log.isDebugEnabled()) {
+                    log.debug("removed new {}: {}", type.get(), o);
+                }
+            }
+        );
+    }
+
+    public static Consumer<Object> ifDebugEnabled(
+        Logger log, Supplier<String> message) {
+
+        return o -> {
+            if (log.isDebugEnabled()) {
+                log.debug(message.get(), o);
+            }
+        };
+    }
+
+    public static Consumer<Object> ifInfoEnabled(
+        Logger log, Supplier<String> message) {
+
+        return o -> {
+            if (log.isInfoEnabled()) {
+                log.info(message.get(), o);
+            }
+        };
+    }
+
+    public static Consumer<Object> ifErrorEnabled(
+        Logger log, Supplier<String> message) {
+
+        return o -> {
+            if (log.isErrorEnabled()) {
+                log.error(message.get(), o);
+            }
+        };
+    }
+
+    public static Consumer<Object> ifErrorEnabled(
+        Logger log, Supplier<String> message, Throwable t) {
+
+        return o -> {
+            if (log.isErrorEnabled()) {
+                log.error(message.get(), o, t);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5dfa929a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/Utils.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/Utils.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/Utils.java
index e15ed83..9ea25bf 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/Utils.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/utils/Utils.java
@@ -22,6 +22,7 @@ import org.apache.aries.osgi.functional.OSGi;
 import org.osgi.framework.ServiceObjects;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
 
 import java.util.Collection;
 import java.util.Comparator;
@@ -32,6 +33,7 @@ import java.util.Map;
 import java.util.function.Consumer;
 import java.util.function.Function;
 
+import static org.apache.aries.jax.rs.whiteboard.internal.utils.LogUtils.ifDebugEnabled;
 import static org.apache.aries.osgi.functional.OSGi.bundleContext;
 import static org.apache.aries.osgi.functional.OSGi.effects;
 import static org.apache.aries.osgi.functional.OSGi.just;
@@ -81,22 +83,14 @@ public class Utils {
         return properties;
     }
 
-    public static int getRanking(
+    public static long getServiceId(
         CachingServiceReference<?> cachingServiceReference) {
 
-        Object property = cachingServiceReference.getProperty(
-            "service.ranking");
-
-        if (property == null) {
-            return 0;
-        }
+        return (long)cachingServiceReference.getProperty("service.id");
+    }
 
-        if (property instanceof Number) {
-            return ((Number)property).intValue();
-        }
-        else {
-            return 0;
-        }
+    public static long getServiceId(ServiceReference<?> serviceReference) {
+        return (long)serviceReference.getProperty("service.id");
     }
 
     public static <T> ServiceReferenceResourceProvider getResourceProvider(
@@ -129,14 +123,15 @@ public class Utils {
     public static <T> OSGi<ServiceTuple<T>> onlyGettables(
         OSGi<CachingServiceReference<T>> program,
         Consumer<CachingServiceReference<T>> whenAddedNotGettable,
-        Consumer<CachingServiceReference<T>> whenLeavingNotGettable) {
+        Consumer<CachingServiceReference<T>> whenLeavingNotGettable,
+        Logger log) {
 
         return bundleContext().flatMap(bundleContext ->
             program.recoverWith(
                 (serviceReference, e) ->
                     notGettableResult(
                         whenAddedNotGettable, whenLeavingNotGettable,
-                        serviceReference)
+                        serviceReference, log)
             ).flatMap(serviceReference -> {
                 ServiceObjects<T> serviceObjects =
                     bundleContext.getServiceObjects(
@@ -146,25 +141,37 @@ public class Utils {
                 if (service == null) {
                     return notGettableResult(
                         whenAddedNotGettable, whenLeavingNotGettable,
-                        serviceReference);
+                        serviceReference, log);
                 }
 
                 return
                     just(new ServiceTuple<>(
                             serviceReference, serviceObjects, service)).
-                    effects(__ -> {}, ServiceTuple::dispose);
+                    effects(__ -> {}, ServiceTuple::dispose).
+                    effects(
+                        ifDebugEnabled(
+                            log,
+                            () -> "Obtained instance from " + serviceReference),
+                        ifDebugEnabled(
+                            log,
+                            () -> "Released instance from " + serviceReference)
+                    );
             }));
     }
 
     private static <T, S> OSGi<S> notGettableResult(
         Consumer<CachingServiceReference<T>> whenAddedNotGettable,
         Consumer<CachingServiceReference<T>> whenLeavingNotGettable,
-        CachingServiceReference<T> immutable) {
+        CachingServiceReference<T> immutable, Logger log) {
 
         return effects(
             () -> whenAddedNotGettable.accept(immutable),
             () -> whenLeavingNotGettable.accept(immutable)
-        ).then(
+        ).effects(
+            ifDebugEnabled(log, () -> "Tracked not gettable reference {}"),
+            ifDebugEnabled(log, () -> "Untracked not gettable reference {}")
+        ).
+        then(
             nothing()
         );
     }
@@ -182,16 +189,6 @@ public class Utils {
         ));
     }
 
-    public static <T> OSGi<ServiceObjects<T>> serviceObjects(
-        CachingServiceReference<T> immutableServiceReference) {
-
-        return
-            bundleContext().flatMap(bundleContext ->
-            just(bundleContext.getServiceObjects(
-                immutableServiceReference.getServiceReference()))
-        );
-    }
-
     public static void updateProperty(
         ServiceRegistration<?> serviceRegistration, String key, Object value) {