[jboss-svn-commits] JBL Code SVN: r23392 - labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/lifecycle.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Oct 9 09:46:26 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-10-09 09:46:26 -0400 (Thu, 09 Oct 2008)
New Revision: 23392

Modified:
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/lifecycle/LifecycleController.java
Log:
Use context class loader: JBESB-2104

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/lifecycle/LifecycleController.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/lifecycle/LifecycleController.java	2008-10-09 13:02:53 UTC (rev 23391)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/lifecycle/LifecycleController.java	2008-10-09 13:46:26 UTC (rev 23392)
@@ -60,6 +60,7 @@
 	private ManagedLifecycleAdapter m_lifecycle;
 	private String m_startTime;
 	private final ObjectName listObjectName ;
+	private final ClassLoader tccl ;
 	
 	private static final Logger logger = Logger.getLogger(LifecycleController.class);
 	
@@ -79,6 +80,7 @@
 		m_lifecycle = f_lifecycle;
 		m_startTime = "";
 		listObjectName = getObjectName() ;
+		tccl = Thread.currentThread().getContextClassLoader() ;
 	}
 
 	/**
@@ -267,24 +269,30 @@
      * an exception.
      */
 	public Object invoke(String method, Object[] arg1, String[] arg2) throws ReflectionException {
-		if (method.equalsIgnoreCase(START_ACTION)) {
-			try {
-				start();
-			} catch (ManagedLifecycleException e) {
-				logger.error("", e);
-				return "Error invoking " + method + ": " + e.toString();
+		final ClassLoader current = Thread.currentThread().getContextClassLoader() ;
+		Thread.currentThread().setContextClassLoader(tccl) ;
+		try {
+			if (method.equalsIgnoreCase(START_ACTION)) {
+				try {
+					start();
+				} catch (ManagedLifecycleException e) {
+					logger.error("", e);
+					return "Error invoking " + method + ": " + e.toString();
+				}
+				return "Invoking the " + method + " on the lifecycle.";
+			} else if (method.equalsIgnoreCase(STOP_ACTION)) {
+				try {
+					stop();
+				} catch (ManagedLifecycleException e) {
+					logger.error("", e);
+					return "Error invoking " + method + ": " + e.toString();
+				}
+				return "Invoking the " + method + " on the lifecycle.";
+			} else {
+				throw new ReflectionException(new NoSuchMethodException(method));
 			}
-			return "Invoking the " + method + " on the lifecycle.";
-		} else if (method.equalsIgnoreCase(STOP_ACTION)) {
-			try {
-				stop();
-			} catch (ManagedLifecycleException e) {
-				logger.error("", e);
-				return "Error invoking " + method + ": " + e.toString();
-			}
-			return "Invoking the " + method + " on the lifecycle.";
-		} else {
-			throw new ReflectionException(new NoSuchMethodException(method));
+		} finally {
+			Thread.currentThread().setContextClassLoader(current) ;
 		}
 	}
 




More information about the jboss-svn-commits mailing list