incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r980689 - in /sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl: Activator.java BundleResourceProvider.java
Date Fri, 30 Jul 2010 09:05:46 GMT
Author: fmeschbe
Date: Fri Jul 30 09:05:46 2010
New Revision: 980689

URL: http://svn.apache.org/viewvc?rev=980689&view=rev
Log:
Add some debug logging

Modified:
    sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
    sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java

Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java?rev=980689&r1=980688&r2=980689&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
(original)
+++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
Fri Jul 30 09:05:46 2010
@@ -127,16 +127,26 @@ public class Activator implements Bundle
         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();
         }
     }

Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java?rev=980689&r1=980688&r2=980689&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
(original)
+++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
Fri Jul 30 09:05:46 2010
@@ -57,10 +57,10 @@ public class BundleResourceProvider impl
         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 @@ public class BundleResourceProvider impl
         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 @@ public class BundleResourceProvider impl
         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 @@ public class BundleResourceProvider impl
             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 @@ public class BundleResourceProvider impl
         // 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;
+    }
+
 }



Mime
View raw message