geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: rev 47451 - in geronimo/trunk/modules: client/src/java/org/apache/geronimo/client j2ee/src/java/org/apache/geronimo/j2ee/management/impl naming/src/java/org/apache/geronimo/naming/java
Date Wed, 29 Sep 2004 03:23:37 GMT
Author: dblevins
Date: Tue Sep 28 20:23:36 2004
New Revision: 47451

Modified:
   geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl/J2EEAppClientModuleImpl.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java
Log:
Inject classloader into AppClientModule same as for EJB containers so
incoming requests can be deserialized/serialized under the right
classloader.

AppClientContainer sets classloader in thread for same reasons as well
as for resolving JNDI related classes.



Modified: geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
==============================================================================
--- geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
(original)
+++ geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
Tue Sep 28 20:23:36 2004
@@ -33,11 +33,13 @@
     private final AppClientPlugin jndiContext;
     private final ObjectName appClientModuleName;
     private final Method mainMethod;
+    private final ClassLoader classLoader;
 
     public AppClientContainer(String mainClassName, ObjectName appClientModuleName, AppClientPlugin
jndiContext, ClassLoader classLoader) throws Exception {
         this.mainClassName = mainClassName;
         this.jndiContext = jndiContext;
         this.appClientModuleName = appClientModuleName;
+        this.classLoader = classLoader;
 
         try {
             Class mainClass = classLoader.loadClass(mainClassName);
@@ -59,6 +61,11 @@
 
     public void main(String[] args) throws Exception {
         Throwable throwable = null;
+        Thread thread = Thread.currentThread();
+
+        ClassLoader contextClassLoader = thread.getContextClassLoader();
+        thread.setContextClassLoader(classLoader);
+
         try {
             jndiContext.startClient(appClientModuleName);
 
@@ -71,9 +78,10 @@
             } else if (cause instanceof Error) {
                 throwable = cause;
             }
-            throwable = e;
         } finally {
             jndiContext.stopClient(appClientModuleName);
+
+            thread.setContextClassLoader(contextClassLoader);
 
             if (throwable instanceof Exception) {
                 throw (Exception) throwable;

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl/J2EEAppClientModuleImpl.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl/J2EEAppClientModuleImpl.java
(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl/J2EEAppClientModuleImpl.java
Tue Sep 28 20:23:36 2004
@@ -34,8 +34,9 @@
     private final J2EEServer server;
     private final J2EEApplication application;
     private final Context componentContext;
+    private final ClassLoader classLoader;
 
-    public J2EEAppClientModuleImpl(Context componentContext, String objectName, J2EEServer
server, J2EEApplication application, String deploymentDescriptor) {
+    public J2EEAppClientModuleImpl(Context componentContext, String objectName, J2EEServer
server, J2EEApplication application, String deploymentDescriptor, ClassLoader classLoader)
{
         this.componentContext = componentContext;
         ObjectName myObjectName = JMXUtil.getObjectName(objectName);
         verifyObjectName(myObjectName);
@@ -43,6 +44,7 @@
         this.server = server;
         this.application = application;
         this.deploymentDescriptor = deploymentDescriptor;
+        this.classLoader = classLoader;
     }
 
     /**
@@ -95,6 +97,10 @@
         return componentContext;
     }
 
+    public ClassLoader getClassLoader() {
+        return classLoader;
+    }
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {
@@ -109,13 +115,16 @@
         infoFactory.addAttribute("server", String.class, false);
         infoFactory.addAttribute("application", String.class, false);
         infoFactory.addAttribute("javaVMs", String[].class, false);
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+
 
         infoFactory.setConstructor(new String[]{
             "componentContext",
             "objectName",
             "J2EEServer",
             "J2EEApplication",
-            "deploymentDescriptor"});
+            "deploymentDescriptor",
+            "classLoader"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java
Tue Sep 28 20:23:36 2004
@@ -31,7 +31,7 @@
 public class RootContext extends ReadOnlyContext {
     private static InheritableThreadLocal compContext = new InheritableThreadLocal();
 
-    RootContext(Hashtable env) {
+    public RootContext(Hashtable env) {
         super(env);
     }
 

Mime
View raw message