geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r330353 - /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
Date Wed, 02 Nov 2005 20:35:26 GMT
Author: dain
Date: Wed Nov  2 12:35:24 2005
New Revision: 330353

URL: http://svn.apache.org/viewcvs?rev=330353&view=rev
Log:
GERONIMO-1129 set TTCL around GBean lifecycle methods

Modified:
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java?rev=330353&r1=330352&r2=330353&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
Wed Nov  2 12:35:24 2005
@@ -853,6 +853,8 @@
             startTime = System.currentTimeMillis();
         }
 
+        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(classLoader);
         Object instance = null;
         try {
             GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
@@ -958,6 +960,8 @@
             } else {
                 throw new Error(t);
             }
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldCL);
         }
     }
 
@@ -1045,20 +1049,26 @@
         }
 
         // we notify the bean before removing our reference so the bean can be called back
while stopping
-        if (instance instanceof GBeanLifecycle) {
-            if (stop) {
-                try {
-                    ((GBeanLifecycle) instance).doStop();
-                } catch (Throwable ignored) {
-                    log.error("Problem in doStop of " + objectName, ignored);
-                }
-            } else {
-                try {
-                    ((GBeanLifecycle) instance).doFail();
-                } catch (Throwable ignored) {
-                    log.error("Problem in doFail of " + objectName, ignored);
+        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(classLoader);
+        try {
+            if (instance instanceof GBeanLifecycle) {
+                if (stop) {
+                    try {
+                        ((GBeanLifecycle) instance).doStop();
+                    } catch (Throwable ignored) {
+                        log.error("Problem in doStop of " + objectName, ignored);
+                    }
+                } else {
+                    try {
+                        ((GBeanLifecycle) instance).doFail();
+                    } catch (Throwable ignored) {
+                        log.error("Problem in doFail of " + objectName, ignored);
+                    }
                 }
             }
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldCL);
         }
 
         // bean has been notified... drop our reference



Mime
View raw message