Add some debug logging

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@980689 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/Activator.java b/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
index 33e7a60..2eb1821 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
@@ -127,16 +127,26 @@
         String prefixes = (String) bundle.getHeaders().get(
             BUNDLE_RESOURCE_ROOTS);
         if (prefixes != null) {
+            log.debug(
+                "addBundleResourceProvider: Registering resources '{}' for bundle {}/{} as service ",
+                new Object[] { prefixes, bundle.getSymbolicName(),
+                    bundle.getBundleId() });
+
             BundleResourceProvider brp = new BundleResourceProvider(bundle,
                 prefixes);
-            brp.registerService(bundleContext);
+            long id = brp.registerService(bundleContext);
             bundleResourceProviderMap.put(bundle.getBundleId(), brp);
+
+            log.debug("addBundleResourceProvider: Service ID = {}", id);
         }
     }
 
     private void removeBundleResourceProvider(Bundle bundle) {
         BundleResourceProvider brp = bundleResourceProviderMap.remove(bundle.getBundleId());
         if (brp != null) {
+            log.debug(
+                "removeBundleResourceProvider: Unregistering resources for bundle {}/{}",
+                new Object[] { bundle.getSymbolicName(), bundle.getBundleId() });
             brp.unregisterService();
         }
     }
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
index 8f8e1f2..8e2e285 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
@@ -57,10 +57,10 @@
         List<MappedPath> prefixList = new ArrayList<MappedPath>();
 
         final ManifestHeader header = ManifestHeader.parse(rootList);
-        for(final ManifestHeader.Entry entry : header.getEntries()) {
+        for (final ManifestHeader.Entry entry : header.getEntries()) {
             final String resourceRoot = entry.getValue();
             final String pathDirective = entry.getDirectiveValue("path");
-            if ( pathDirective != null ) {
+            if (pathDirective != null) {
                 prefixList.add(new MappedPath(resourceRoot, pathDirective));
             } else {
                 prefixList.add(MappedPath.create(resourceRoot));
@@ -69,7 +69,9 @@
         this.roots = prefixList.toArray(new MappedPath[prefixList.size()]);
     }
 
-    void registerService(BundleContext context) {
+    //---------- Service Registration
+    
+    long registerService(BundleContext context) {
         Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put(Constants.SERVICE_DESCRIPTION,
             "Provider of bundle based resources");
@@ -77,6 +79,8 @@
         props.put(ROOTS, getRoots());
 
         serviceRegistration = context.registerService(SERVICE_NAME, this, props);
+        return (Long) serviceRegistration.getReference().getProperty(
+            Constants.SERVICE_ID);
     }
 
     void unregisterService() {
@@ -84,37 +88,8 @@
             serviceRegistration.unregister();
         }
     }
-
-    //---------- Web Console plugin support
-
-    BundleResourceCache getBundleResourceCache() {
-        return bundle;
-    }
-
-    MappedPath[] getMappedPaths() {
-        return roots;
-    }
-
-    //---------- internal
-
-    /** Returns the root paths */
-    private String[] getRoots() {
-        String[] rootPaths = new String[roots.length];
-        for (int i = 0; i < roots.length; i++) {
-            rootPaths[i] = roots[i].getResourceRoot();
-        }
-        return rootPaths;
-    }
-
-    private MappedPath getMappedPath(String resourcePath) {
-        for (MappedPath mappedPath : roots) {
-            if (mappedPath.isChild(resourcePath)) {
-                return mappedPath;
-            }
-        }
-
-        return null;
-    }
+    
+    // ---------- ResourceProvider interface
 
     public Resource getResource(ResourceResolver resourceResolver,
             HttpServletRequest request, String path) {
@@ -157,4 +132,36 @@
         // be prepared for such a situation
         return Collections.<Resource> emptyList().iterator();
     }
+
+    // ---------- Web Console plugin support
+
+    BundleResourceCache getBundleResourceCache() {
+        return bundle;
+    }
+
+    MappedPath[] getMappedPaths() {
+        return roots;
+    }
+
+    // ---------- internal
+
+    /** Returns the root paths */
+    private String[] getRoots() {
+        String[] rootPaths = new String[roots.length];
+        for (int i = 0; i < roots.length; i++) {
+            rootPaths[i] = roots[i].getResourceRoot();
+        }
+        return rootPaths;
+    }
+
+    private MappedPath getMappedPath(String resourcePath) {
+        for (MappedPath mappedPath : roots) {
+            if (mappedPath.isChild(resourcePath)) {
+                return mappedPath;
+            }
+        }
+
+        return null;
+    }
+
 }