cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: rev 56541 - cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment
Date Thu, 04 Nov 2004 00:46:08 GMT
Author: pier
Date: Wed Nov  3 16:46:08 2004
New Revision: 56541

Modified:
   cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
   cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Wiring.java
Log:
Set context classloader when switching from one block to another (helps resolutions of commons-logging,
servlet-based stuff, ...)


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
Wed Nov  3 16:46:08 2004
@@ -14,6 +14,7 @@
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -146,8 +147,8 @@
                         + "] " + descriptor.toString());
             }
             this.logger.log("Shared libraries:");
-            iterator = this.loader.getURLs(this);
-            while (iterator.hasNext()) this.logger.log(" - " + iterator.next());
+            URL urls[] = this.loader.getURLs();
+            for (int x = 0; x < urls.length; x ++) this.logger.log(" - " + urls[x]);
 
             /* Configure all instances and be done with it */
             Factory.configure(this, instances);

Modified: cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Wiring.java
==============================================================================
--- cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Wiring.java
(original)
+++ cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Wiring.java
Wed Nov  3 16:46:08 2004
@@ -27,12 +27,15 @@
 
     /** <p>The instance of the proxied object.</p> */
     private Object instance = null;
+    /** <p>The instance of the proxied object.</p> */
+    private ClassLoader context = null;
 
     /**
      * <p>Create a new {@link Wiring} instance.</p>
      */
     public Wiring(Object instance) {
         if (instance == null) throw new NullPointerException("Null proxy instance");
+        this.context = instance.getClass().getClassLoader();
         this.instance = instance;
     }
 
@@ -41,12 +44,18 @@
      */
     public Object invoke(Object proxy, Method method, Object[] parameters)
     throws Throwable {
+        Thread thread = Thread.currentThread();
+        ClassLoader previous = thread.getContextClassLoader();
+        thread.setContextClassLoader(this.context);
+
         try {
             return(method.invoke(this.instance, parameters));
         } catch (InvocationTargetException e) {
             Throwable cause = e.getCause();
             if (cause != null) throw cause;
             throw e;
+        } finally {
+            thread.setContextClassLoader(previous);
         }
     }
 }

Mime
View raw message