incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1404952 - in /sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl: FSClassLoaderProvider.java FSDynamicClassLoader.java
Date Fri, 02 Nov 2012 12:38:14 GMT
Author: cziegeler
Date: Fri Nov  2 12:38:13 2012
New Revision: 1404952

URL: http://svn.apache.org/viewvc?rev=1404952&view=rev
Log:
Implement latest class loader writer

Modified:
    sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java
    sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSDynamicClassLoader.java

Modified: sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java?rev=1404952&r1=1404951&r2=1404952&view=diff
==============================================================================
--- sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java
(original)
+++ sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java
Fri Nov  2 12:38:13 2012
@@ -33,7 +33,6 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.commons.classloader.ClassLoaderWriter;
-import org.apache.sling.commons.classloader.DynamicClassLoader;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
 import org.osgi.service.component.ComponentContext;
 
@@ -60,58 +59,13 @@ public class FSClassLoaderProvider
     @Reference
     private DynamicClassLoaderManager dynamicClassLoaderManager;
 
-    private ClassLoader dynamicClassLoader;
-
-    /**
-     * Bind the class load provider.
-     *
-     * @param repositoryClassLoaderProvider the new provider
-     */
-    protected void bindDynamicClassLoaderManager(final DynamicClassLoaderManager rclp) {
-        if ( this.dynamicClassLoader != null ) {
-            this.ungetClassLoader();
-        }
-        this.getClassLoader(rclp);
-    }
-
-    /**
-     * Unbind the class loader provider.
-     * @param repositoryClassLoaderProvider the old provider
-     */
-    protected void unbindDynamicClassLoaderManager(final DynamicClassLoaderManager rclp)
{
-        if ( this.dynamicClassLoaderManager == rclp ) {
-            this.ungetClassLoader();
-        }
-    }
-
-    /**
-     * Get the class loader
-     */
-    private void getClassLoader(final DynamicClassLoaderManager rclp) {
-        this.dynamicClassLoaderManager = rclp;
-        this.dynamicClassLoader = rclp.getDynamicClassLoader();
-    }
-
-    /**
-     * Unget the class loader
-     */
-    private void ungetClassLoader() {
-        this.dynamicClassLoader = null;
-        this.dynamicClassLoaderManager = null;
-    }
     /**
      * @see org.apache.sling.commons.classloader.ClassLoaderWriter#getClassLoader()
      */
     public ClassLoader getClassLoader() {
         synchronized ( this ) {
-            // first check parent
-            boolean recreate = loader == null;
-            if ( (this.dynamicClassLoader instanceof DynamicClassLoader) && !((DynamicClassLoader)this.dynamicClassLoader).isLive())
{
-                this.dynamicClassLoader = this.dynamicClassLoaderManager.getDynamicClassLoader();
-                recreate = true;
-            }
-            if ( recreate || !loader.isLive() ) {
-                loader = new FSDynamicClassLoader(new URL[] {this.rootURL}, this.dynamicClassLoader);
+            if ( loader == null || !loader.isLive() ) {
+                loader = new FSDynamicClassLoader(new URL[] {this.rootURL}, this.dynamicClassLoaderManager.getDynamicClassLoader());
             }
             return this.loader;
         }

Modified: sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSDynamicClassLoader.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSDynamicClassLoader.java?rev=1404952&r1=1404951&r2=1404952&view=diff
==============================================================================
--- sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSDynamicClassLoader.java
(original)
+++ sling/trunk/contrib/commons/fsclassloader/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSDynamicClassLoader.java
Fri Nov  2 12:38:13 2012
@@ -35,15 +35,18 @@ public class FSDynamicClassLoader
     private final Set<String> hit = Collections.synchronizedSet(new HashSet<String>());
     private final Set<String> miss = Collections.synchronizedSet(new HashSet<String>());
 
+    private final DynamicClassLoader parentLoader;
+
     public FSDynamicClassLoader(final URL[] urls, final ClassLoader parent) {
         super(urls, parent);
+        parentLoader = (parent instanceof DynamicClassLoader ? (DynamicClassLoader)parent
: null);
     }
 
     /**
      * @see org.apache.sling.commons.classloader.DynamicClassLoader#isLive()
      */
     public boolean isLive() {
-        return !isDirty;
+        return !isDirty && (parentLoader == null || parentLoader.isLive());
     }
 
     /**



Mime
View raw message