incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r644882 - in /incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal: JcrResourceResolverFactoryImpl.java helper/bundle/
Date Fri, 04 Apr 2008 20:26:02 GMT
Author: fmeschbe
Date: Fri Apr  4 13:26:00 2008
New Revision: 644882

URL: http://svn.apache.org/viewvc?rev=644882&view=rev
Log:
SLING-356 Remove BundleResourceProvider from jcr/Resource bundle and remove
support for BundleResourceProvider in the JcrResourceResolverFactoryImpl

Removed:
    incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/bundle/
Modified:
    incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java

Modified: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java?rev=644882&r1=644881&r2=644882&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
(original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
Fri Apr  4 13:26:00 2008
@@ -18,11 +18,8 @@
  */
 package org.apache.sling.jcr.resource.internal;
 
-import static org.apache.sling.jcr.resource.JcrResourceConstants.BUNDLE_RESOURCE_ROOTS;
-
 import java.util.ArrayList;
 import java.util.Dictionary;
-import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.LinkedList;
 import java.util.List;
@@ -39,11 +36,9 @@
 import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
 import org.apache.sling.jcr.resource.internal.helper.Mapping;
 import org.apache.sling.jcr.resource.internal.helper.ResourceProviderEntry;
-import org.apache.sling.jcr.resource.internal.helper.bundle.BundleResourceProvider;
 import org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderEntry;
 import org.apache.sling.osgi.commons.OsgiUtil;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentContext;
@@ -75,7 +70,7 @@
  *                cardinality="0..n" policy="dynamic"
  */
 public class JcrResourceResolverFactoryImpl implements
-        JcrResourceResolverFactory, BundleListener {
+        JcrResourceResolverFactory {
 
     /**
      * @scr.property value="true" type="Boolean"
@@ -156,8 +151,6 @@
 
     private ResourceProviderEntry rootProviderEntry;
 
-    private Map<Long, BundleResourceProvider> bundleResourceProviderMap = new HashMap<Long,
BundleResourceProvider>();
-
     public JcrResourceResolverFactoryImpl() {
         this.rootProviderEntry = new ResourceProviderEntry("/", null, null);
     }
@@ -174,36 +167,6 @@
         return new JcrResourceResolver(sessionRoot, this);
     }
 
-    // ---------- BundleListener -----------------------------------------------
-
-    /**
-     * Loads and unloads any components provided by the bundle whose state
-     * changed. If the bundle has been started, the components are loaded. If
-     * the bundle is about to stop, the components are unloaded.
-     *
-     * @param event The <code>BundleEvent</code> representing the bundle state
-     *            change.
-     */
-    public void bundleChanged(BundleEvent event) {
-
-        //
-        // NOTE:
-        // This is synchronous - take care to not block the system !!
-        //
-
-        switch (event.getType()) {
-            case BundleEvent.STARTED:
-                // register resource provider for the started bundle
-                addBundleResourceProvider(event.getBundle());
-                break;
-
-            case BundleEvent.STOPPED:
-                // remove resource provider after the bundle has stopped
-                removeBundleResourceProvider(event.getBundle());
-                break;
-        }
-    }
-
     // ---------- EventAdmin Event Dispatching ---------------------------------
 
     /**
@@ -281,41 +244,6 @@
         return searchPath;
     }
 
-    // ---------- Bundle provided resources -----------------------------------
-
-    private void addBundleResourceProvider(Bundle bundle) {
-        String prefixes = (String) bundle.getHeaders().get(
-            BUNDLE_RESOURCE_ROOTS);
-        if (prefixes != null) {
-            BundleResourceProvider brp = new BundleResourceProvider(bundle,
-                prefixes);
-            String[] rootPaths = brp.getRoots();
-            for (String rootPath : rootPaths) {
-                try {
-                    rootProviderEntry.addResourceProvider(rootPath, brp);
-                } catch (IllegalStateException ise) {
-                    log.error(
-                        "addBundleResourceProvider: A ResourceProvider for {} is already
registered",
-                        rootPath);
-                }
-            }
-            bundleResourceProviderMap.put(bundle.getBundleId(), brp);
-        }
-    }
-
-    private void removeBundleResourceProvider(Bundle bundle) {
-        BundleResourceProvider brp = bundleResourceProviderMap.get(bundle.getBundleId());
-        if (brp != null) {
-            String[] rootPaths = brp.getRoots();
-            for (String rootPath : rootPaths) {
-                // TODO: Do not remove this path, if another resource
-                // owns it. This may be the case if adding the provider
-                // yielded an IllegalStateException
-                rootProviderEntry.removeResourceProvider(rootPath);
-            }
-        }
-    }
-
     // ---------- SCR Integration ---------------------------------------------
 
     /** Activates this component, called by SCR before registering as a service */
@@ -323,21 +251,6 @@
         this.componentContext = componentContext;
         this.serviceReference = componentContext.getServiceReference();
 
-        componentContext.getBundleContext().addBundleListener(this);
-
-        try {
-            Bundle[] bundles = componentContext.getBundleContext().getBundles();
-            for (Bundle bundle : bundles) {
-                if (bundle.getState() == Bundle.ACTIVE) {
-                    // add bundle resource provider for active bundles
-                    addBundleResourceProvider(bundle);
-                }
-            }
-        } catch (Throwable t) {
-            log.error("activate: Problem while loading initial content and"
-                + " registering mappings for existing bundles", t);
-        }
-
         Dictionary<?, ?> properties = componentContext.getProperties();
 
         BidiMap virtuals = new TreeBidiMap();
@@ -394,8 +307,6 @@
 
     /** Deativates this component, called by SCR to take out of service */
     protected void deactivate(ComponentContext componentContext) {
-        componentContext.getBundleContext().removeBundleListener(this);
-
         this.componentContext = null;
     }
 



Mime
View raw message