cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: rev 56461 - in cocoon/whiteboard/kernel/sources: runtime/org/apache/cocoon/kernel/deployment startup/org/apache/cocoon/kernel/startup
Date Wed, 03 Nov 2004 03:10:15 GMT
Author: pier
Date: Tue Nov  2 19:10:14 2004
New Revision: 56461

Modified:
   cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
   cocoon/whiteboard/kernel/sources/startup/org/apache/cocoon/kernel/startup/KernelLoader.java
Log:
Reverse loading order of the KernelLoader and log libraries

Modified: cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
==============================================================================
--- cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
(original)
+++ cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
Tue Nov  2 19:10:14 2004
@@ -145,6 +145,9 @@
                 this.logger.log(" - [" + Descriptor.NAMES[descriptor.getType()]
                         + "] " + descriptor.toString());
             }
+            this.logger.log("Shared libraries:");
+            iterator = this.loader.getURLs(this);
+            while (iterator.hasNext()) this.logger.log(" - " + iterator.next());
 
             /* Configure all instances and be done with it */
             Factory.configure(this, instances);

Modified: cocoon/whiteboard/kernel/sources/startup/org/apache/cocoon/kernel/startup/KernelLoader.java
==============================================================================
--- cocoon/whiteboard/kernel/sources/startup/org/apache/cocoon/kernel/startup/KernelLoader.java
(original)
+++ cocoon/whiteboard/kernel/sources/startup/org/apache/cocoon/kernel/startup/KernelLoader.java
Tue Nov  2 19:10:14 2004
@@ -16,6 +16,7 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 /**
@@ -37,6 +38,7 @@
     /** <p>Deny public construction.</p> */
     private KernelLoader(ClassLoader loader, URL libraries[]) {
         super(libraries, loader);
+        for (int x = 0; x < libraries.length; x ++) this.urls.add(libraries[x]);
     }
 
     /**
@@ -91,9 +93,19 @@
      * <p>Add a {@link URL} to the class path handled by this {@link KernelLoader}
      * instance.</p>
      */
+    public Iterator getURLs(StartupKernel kernel) {
+        if (this.kernel != kernel) throw new SecurityException("Invalid instance");
+        return(this.urls.iterator());
+    }
+
+    /**
+     * <p>Add a {@link URL} to the class path handled by this {@link KernelLoader}
+     * instance.</p>
+     */
     public void addURL(StartupKernel kernel, URL url) {
         if (this.kernel != kernel) throw new SecurityException("Invalid instance");
         if ((url == null) || (this.urls.contains(url))) return;
+        this.urls.add(url);
         super.addURL(url);
     }
 
@@ -106,4 +118,50 @@
         if (urls == null) return;
         for (int x = 0; x < urls.length; x ++) this.addURL(kernel, urls[x]);
     }
+
+    /**
+     * <p>Invert the {@link Class} load order of this {@link ClassLoader}.</p>
+     */
+    public synchronized Class loadClass(String name)
+    throws ClassNotFoundException {
+        return this.loadClass(name, false);
+    }
+
+    /**
+     * <p>Invert the {@link Class} load order of this {@link ClassLoader}.</p>
+     */
+    protected synchronized Class loadClass(String name, boolean resolve)
+    throws ClassNotFoundException { 
+        Class clazz = findLoadedClass(name);
+        if (clazz != null) return(clazz);
+        
+        /* Just in case some dummy put the kernel implementation in the path */
+        if ((name.equals("org.apache.cocoon.kernel.Kernel")) ||
+            (name.equals("org.apache.cocoon.kernel.KernelException")) ||
+            (name.startsWith("org.apache.cocoon.kernel.configuration.")) ||
+            (name.startsWith("org.apache.cocoon.kernel.startup"))) {
+            return super.loadClass(name, resolve);
+        }
+
+        try {
+            clazz= this.findClass(name);
+        } catch (ClassNotFoundException e) {
+            clazz = this.getParent().loadClass(name);
+        }
+
+        if (resolve) resolveClass(clazz);
+        return clazz;
+    }
+
+    /**
+     * <p>Invert the resource resolution order of this {@link ClassLoader}.</p>
+     */
+    public synchronized URL getResource(String name) {
+        URL url= null;
+
+        url= this.findResource(name);
+        if (url == null) url= this.getParent().getResource(name);
+
+        return url;
+    }    
 }

Mime
View raw message