incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r824328 - in /sling/trunk/bundles/commons/classloader: pom.xml src/main/java/org/apache/sling/commons/classloader/impl/ClassLoaderFacade.java
Date Mon, 12 Oct 2009 13:24:36 GMT
Author: cziegeler
Date: Mon Oct 12 13:24:36 2009
New Revision: 824328

URL: http://svn.apache.org/viewvc?rev=824328&view=rev
Log:
SLING-1145 :   Exceptions from dynamic class loader providers should be catched

Modified:
    sling/trunk/bundles/commons/classloader/pom.xml
    sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/ClassLoaderFacade.java

Modified: sling/trunk/bundles/commons/classloader/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/classloader/pom.xml?rev=824328&r1=824327&r2=824328&view=diff
==============================================================================
--- sling/trunk/bundles/commons/classloader/pom.xml (original)
+++ sling/trunk/bundles/commons/classloader/pom.xml Mon Oct 12 13:24:36 2009
@@ -103,5 +103,9 @@
             <groupId>org.jmock</groupId>
             <artifactId>jmock-junit4</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+        </dependency>
     </dependencies>
 </project>

Modified: sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/ClassLoaderFacade.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/ClassLoaderFacade.java?rev=824328&r1=824327&r2=824328&view=diff
==============================================================================
--- sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/ClassLoaderFacade.java
(original)
+++ sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/ClassLoaderFacade.java
Mon Oct 12 13:24:36 2009
@@ -22,6 +22,9 @@
 import java.net.URL;
 import java.util.Enumeration;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 /**
  * The <code>ClassLoaderFacade</code> is a facade
@@ -33,8 +36,15 @@
  */
 public class ClassLoaderFacade extends ClassLoader {
 
+    /** The logger. */
+    private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
+
+    /** Dynamic class loader manager which manages the dynamic class loader providers for
this facade. */
     private final DynamicClassLoaderManagerImpl manager;
 
+    /**
+     * Constructor
+     */
     public ClassLoaderFacade(final DynamicClassLoaderManagerImpl manager) {
         this.manager = manager;
     }
@@ -49,9 +59,13 @@
         final ClassLoader[] loaders = manager.getDynamicClassLoaders();
         for(final ClassLoader cl : loaders) {
             if ( cl != null ) {
-                final URL u = cl.getResource(name);
-                if ( u != null ) {
-                    return u;
+                try {
+                    final URL u = cl.getResource(name);
+                    if ( u != null ) {
+                        return u;
+                    }
+                } catch (Throwable t) {
+                    logger.error("Exception while querying class loader " + cl + " for resource
" + name, t);
                 }
             }
         }
@@ -68,9 +82,13 @@
         final ClassLoader[] loaders = manager.getDynamicClassLoaders();
         for(final ClassLoader cl : loaders) {
             if ( cl != null ) {
-                final Enumeration<URL> e = cl.getResources(name);
-                if ( e != null && e.hasMoreElements() ) {
-                    return e;
+                try {
+                    final Enumeration<URL> e = cl.getResources(name);
+                    if ( e != null && e.hasMoreElements() ) {
+                        return e;
+                    }
+                } catch (Throwable t) {
+                    logger.error("Exception while querying class loader " + cl + " for resources
" + name, t);
                 }
             }
         }
@@ -79,7 +97,7 @@
 
     @Override
     protected synchronized Class<?> loadClass(String name, boolean resolve)
-            throws ClassNotFoundException {
+    throws ClassNotFoundException {
 
         if ( !this.manager.isActive() ) {
             throw new RuntimeException("Dynamic class loader has already been deactivated.");
@@ -90,8 +108,10 @@
                 try {
                     final Class<?> c = cl.loadClass(name);
                     return c;
-                } catch (Exception cnfe) {
+                } catch (ClassNotFoundException cnfe) {
                     // we just ignore this and try the next class loader
+                } catch (Throwable t) {
+                    logger.error("Exception while trying to load class " + name + " from
class loader " + cl, t);
                 }
             }
         }



Mime
View raw message