geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r697343 - /geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java
Date Sat, 20 Sep 2008 10:07:57 GMT
Author: jdillon
Date: Sat Sep 20 03:07:57 2008
New Revision: 697343

URL: http://svn.apache.org/viewvc?rev=697343&view=rev
Log:
Set the TCL for command invokations

Modified:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java?rev=697343&r1=697342&r2=697343&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandImpl.java
Sat Sep 20 03:07:57 2008
@@ -31,6 +31,8 @@
 import org.apache.geronimo.gshell.i18n.ResourceBundleMessageSource;
 import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.notification.Notification;
+import org.apache.geronimo.gshell.spring.BeanContainerAware;
+import org.apache.geronimo.gshell.spring.BeanContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
@@ -44,9 +46,18 @@
  */
 public class CommandImpl
     extends CommandSupport
+    implements BeanContainerAware
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    private BeanContainer container;
+
+    public void setBeanContainer(final BeanContainer container) {
+        assert container != null;
+
+        this.container = container;
+    }
+
     @SuppressWarnings({"UnusedDeclaration"})
     @PostConstruct
     private void init() {
@@ -77,6 +88,10 @@
         // Provide logging context for the command execution
         MDC.put("command-id", getId());
 
+        // Set the TCL to the command bean containers realm
+        final ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(container.getClassRealm());
+
         CommandResult result;
 
         try {
@@ -138,6 +153,8 @@
             }
         }
         finally {
+            Thread.currentThread().setContextClassLoader(prevCL);
+
             MDC.remove("command-id");
         }
 



Mime
View raw message