You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2009/05/04 09:48:20 UTC

svn commit: r771225 - in /incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal: JcrResourceResolverFactoryImpl.java JcrResourceResolverPlugin.java JcrResourceResolverWebConsolePlugin.java

Author: fmeschbe
Date: Mon May  4 07:48:20 2009
New Revision: 771225

URL: http://svn.apache.org/viewvc?rev=771225&view=rev
Log:
* Rename JcrResourceResolverPlugin to JcrResourceResolverWebConsolePlugin to
  make sure the name indicates what this class is really all about
* Add more logging to resource provider bindung and unbinding

Added:
    incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java   (contents, props changed)
      - copied, changed from r762273, incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverPlugin.java
Removed:
    incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverPlugin.java
Modified:
    incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java

Modified: incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java?rev=771225&r1=771224&r2=771225&view=diff
==============================================================================
--- incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java (original)
+++ incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java Mon May  4 07:48:20 2009
@@ -404,7 +404,7 @@
         if (useNewResourceResolver) {
             try {
                 mapEntries = new MapEntries(this, getRepository());
-                plugin = new JcrResourceResolverPlugin(componentContext.getBundleContext(), this);
+                plugin = new JcrResourceResolverWebConsolePlugin(componentContext.getBundleContext(), this);
             } catch (Exception e) {
                 log.error(
                     "activate: Cannot access repository, failed setting up Mapping Support",
@@ -413,7 +413,7 @@
         }
     }
 
-    private JcrResourceResolverPlugin plugin;
+    private JcrResourceResolverWebConsolePlugin plugin;
 
     /** Deativates this component, called by SCR to take out of service */
     protected void deactivate(ComponentContext componentContext) {
@@ -490,12 +490,20 @@
     }
 
     protected void bindResourceProvider(ServiceReference reference) {
+        
+        String serviceName = getServiceName(reference);
+        
         if (componentContext == null) {
 
+            log.debug("bindResourceProvider: Delaying {}", serviceName);
+
             // delay binding resource providers if called before activation
             delayedResourceProviders.add(reference);
 
         } else {
+            
+            log.debug("bindResourceProvider: Binding {}", serviceName);
+            
             String[] roots = OsgiUtil.toStringArray(reference.getProperty(ResourceProvider.ROOTS));
             if (roots != null && roots.length > 0) {
 
@@ -515,6 +523,9 @@
                         try {
                             rootProviderEntry.addResourceProvider(root,
                                 provider);
+
+                            log.debug("bindResourceProvider: {}={} ({})",
+                                new Object[] { root, provider, serviceName });
                         } catch (ResourceProviderEntryException rpee) {
                             log.error(
                                 "bindResourceProvider: Cannot register ResourceProvider {} for {}: ResourceProvider {} is already registered",
@@ -524,10 +535,17 @@
                     }
                 }
             }
+            
+            log.debug("bindResourceProvider: Bound {}", serviceName);
         }
     }
 
     protected void unbindResourceProvider(ServiceReference reference) {
+
+        String serviceName = getServiceName(reference);
+        
+        log.debug("unbindResourceProvider: Unbinding {}", serviceName);
+
         String[] roots = OsgiUtil.toStringArray(reference.getProperty(ResourceProvider.ROOTS));
         if (roots != null && roots.length > 0) {
 
@@ -545,9 +563,14 @@
                     // owns it. This may be the case if adding the provider
                     // yielded an ResourceProviderEntryException
                     rootProviderEntry.removeResourceProvider(root);
+                    
+                    log.debug("unbindResourceProvider: root={} ({})", root,
+                        serviceName);
                 }
             }
         }
+        
+        log.debug("unbindResourceProvider: Unbound {}", serviceName);
     }
 
     protected void bindJcrResourceTypeProvider(ServiceReference reference) {
@@ -595,4 +618,18 @@
             this.provider = p;
         }
     }
+    
+    private String getServiceName(ServiceReference reference) {
+        if (log.isDebugEnabled()) {
+            StringBuilder snBuilder = new StringBuilder(64);
+            snBuilder.append('{');
+            snBuilder.append(reference.toString());
+            snBuilder.append('/');
+            snBuilder.append(reference.getProperty(Constants.SERVICE_ID));
+            snBuilder.append('}');
+            return snBuilder.toString();
+        }
+
+        return null;
+    }
 }

Copied: incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java (from r762273, incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverPlugin.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java?p2=incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java&p1=incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverPlugin.java&r1=762273&r2=771225&rev=771225&view=diff
==============================================================================
--- incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverPlugin.java (original)
+++ incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java Mon May  4 07:48:20 2009
@@ -1,16 +1,20 @@
 /*
- * $Url: $
- * $Id: $
+ * 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
  *
- * Copyright 1997-2005 Day Management AG
- * Barfuesserplatz 6, 4001 Basel, Switzerland
- * All Rights Reserved.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- * This software is the confidential and proprietary information of
- * Day Management AG, ("Confidential Information"). You shall not
- * disclose such Confidential Information and shall use it only in
- * accordance with the terms of the license agreement you entered into
- * with Day.
+ * 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.sling.jcr.resource.internal;
 
@@ -38,19 +42,21 @@
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
 
-public class JcrResourceResolverPlugin extends AbstractWebConsolePlugin {
+public class JcrResourceResolverWebConsolePlugin extends AbstractWebConsolePlugin {
 
+    private static final long serialVersionUID = 0;
+    
     private static final String ATTR_TEST = "plugin.test";
 
     private static final String ATTR_SUBMIT = "plugin.submit";
 
     private static final String ATTR_RESULT = "plugin.result";
 
-    private final JcrResourceResolverFactoryImpl resolverFactory;
+    private final transient JcrResourceResolverFactoryImpl resolverFactory;
 
     private ServiceRegistration service;
 
-    JcrResourceResolverPlugin(BundleContext context,
+    JcrResourceResolverWebConsolePlugin(BundleContext context,
             JcrResourceResolverFactoryImpl resolverFactory) {
         this.resolverFactory = resolverFactory;
 

Propchange: incubator/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java
------------------------------------------------------------------------------
    svn:mergeinfo =