incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r902807 - in /sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl: Activator.java DynamicClassLoaderManagerFactory.java DynamicClassLoaderManagerImpl.java PackageAdminClassLoader.java
Date Mon, 25 Jan 2010 13:30:59 GMT
Author: cziegeler
Date: Mon Jan 25 13:30:59 2010
New Revision: 902807

URL: http://svn.apache.org/viewvc?rev=902807&view=rev
Log:
SLING-1302 : After a NoClassDefError classes are still not found even if they have been installed
in the meantime

Modified:
    sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java
    sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerFactory.java
    sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerImpl.java
    sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java

Modified: sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java?rev=902807&r1=902806&r2=902807&view=diff
==============================================================================
--- sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java
(original)
+++ sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java
Mon Jan 25 13:30:59 2010
@@ -113,6 +113,12 @@
         if ( needsUpdate ) {
             this.unregisterManagerFactory();
             this.registerManagerFactory();
+        } else {
+            // if a new bundle has been added (=resolved), we should
+            // clear the negative cache (see SLING-1302)
+            if ( event.getType() == BundleEvent.RESOLVED ) {
+                this.service.clearNegativeCaches();
+            }
         }
     }
 }

Modified: sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerFactory.java?rev=902807&r1=902806&r2=902807&view=diff
==============================================================================
--- sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerFactory.java
(original)
+++ sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerFactory.java
Mon Jan 25 13:30:59 2010
@@ -16,8 +16,10 @@
  */
 package org.apache.sling.commons.classloader.impl;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import org.osgi.framework.Bundle;
@@ -40,6 +42,9 @@
 
     private final Set<Long> usedBundles = Collections.synchronizedSet(new HashSet<Long>());
 
+    /** All created managers. */
+    private final List<DynamicClassLoaderManagerImpl> managers = new ArrayList<DynamicClassLoaderManagerImpl>();
+
     /**
      * Create a new service instance
      * @param ctx The bundle context.
@@ -56,7 +61,12 @@
      */
     public Object getService(final Bundle bundle,
                              final ServiceRegistration registration) {
-        return new DynamicClassLoaderManagerImpl(this.context, this.pckAdmin, new BundleProxyClassLoader(bundle),
this);
+        final DynamicClassLoaderManagerImpl manager =  new DynamicClassLoaderManagerImpl(this.context,
+                this.pckAdmin, new BundleProxyClassLoader(bundle), this);
+        synchronized ( managers ) {
+            managers.add(manager);
+        }
+        return manager;
     }
 
     /**
@@ -66,6 +76,9 @@
                              final ServiceRegistration registration,
                              final Object service) {
         if ( service != null ) {
+            synchronized ( managers ) {
+                managers.remove(service);
+            }
             ((DynamicClassLoaderManagerImpl)service).deactivate();
         }
     }
@@ -87,4 +100,15 @@
         final long id = bundle.getBundleId();
         this.usedBundles.add(id);
     }
+
+    /**
+     * Clear the negative caches of all registered managers.
+     */
+    public void clearNegativeCaches() {
+        synchronized ( this.managers ) {
+            for(final DynamicClassLoaderManagerImpl manager : this.managers) {
+                manager.clearNegativeCache();
+            }
+        }
+    }
 }

Modified: sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerImpl.java?rev=902807&r1=902806&r2=902807&view=diff
==============================================================================
--- sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerImpl.java
(original)
+++ sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/DynamicClassLoaderManagerImpl.java
Mon Jan 25 13:30:59 2010
@@ -70,6 +70,13 @@
         this.facade = new ClassLoaderFacade(this);
     }
 
+    /**
+     * Clear the negative cache
+     */
+    public void clearNegativeCache() {
+        this.pckAdminCL.clearNegativeCache();
+    }
+
     private synchronized void updateCache() {
         if ( this.trackingCount < this.getTrackingCount() ) {
             final ServiceReference[] refs = this.getServiceReferences();

Modified: sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java?rev=902807&r1=902806&r2=902807&view=diff
==============================================================================
--- sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
(original)
+++ sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
Mon Jan 25 13:30:59 2010
@@ -61,6 +61,13 @@
     }
 
     /**
+     * Clear the negative cache.
+     */
+    public void clearNegativeCache() {
+        negativeClassCache.clear();
+    }
+
+    /**
      * Find the bundle for a given package.
      * @param pckName The package name.
      * @return The bundle or <code>null</code>



Mime
View raw message