dblevins    2005/07/05 22:04:03

  Modified:    modules/core/src/java/org/openejb/loader
                        EmbeddingLoader.java TomcatWebappLoader.java
  Log:

  Moved the getContextClassLoader method to the OpenEJB class so ClasspathUtils 
only contains the classpath modifying methods used by the Loaders and other 
code.
  
  Going to kill the ClasspathUtils and make everyone as the loaders directly to 
modify the classpath, rather than sometimes using the loader and then asking 
ClasspathUtils to guess what loader to use.
  
  Part of the fix for OPENEJB-40, OPENEJB-41 and OPENEJB-42.
  
  Revision  Changes    Path
  1.5       +10 -2     
openejb1/modules/core/src/java/org/openejb/loader/EmbeddingLoader.java
  
  Index: EmbeddingLoader.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/loader/EmbeddingLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EmbeddingLoader.java      16 Jun 2005 22:29:51 -0000      1.4
  +++ EmbeddingLoader.java      6 Jul 2005 02:04:03 -0000       1.5
  @@ -67,7 +67,7 @@
       public void load( Hashtable env ) throws Exception{
           if (loaded) return;
   
  -        ClassLoader cl = ClasspathUtils.getContextClassLoader();
  +        ClassLoader cl = getContextClassLoader();
           try{
               cl.loadClass("org.openejb.OpenEJB");
           } catch (Exception e){
  @@ -105,5 +105,13 @@
               throw new Exception( "Could not load OpenEJB libraries. 
Exception: "+
                                    e.getClass().getName()+" "+ e.getMessage());
           }
  +    }
  +
  +    private ClassLoader getContextClassLoader() {
  +        return (ClassLoader) java.security.AccessController.doPrivileged(new 
java.security.PrivilegedAction() {
  +            public Object run() {
  +                return Thread.currentThread().getContextClassLoader();
  +            }
  +        });
       }
   }
  
  
  
  1.3       +16 -4     
openejb1/modules/core/src/java/org/openejb/loader/TomcatWebappLoader.java
  
  Index: TomcatWebappLoader.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/loader/TomcatWebappLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TomcatWebappLoader.java   16 Jun 2005 22:29:51 -0000      1.2
  +++ TomcatWebappLoader.java   6 Jul 2005 02:04:03 -0000       1.3
  @@ -44,7 +44,10 @@
    */
   package org.openejb.loader;
   
  -import java.io.File;
import java.util.Hashtable;

import org.openejb.util.ClasspathUtils;
  +import java.io.File;
  +import java.util.Hashtable;
  +
  +import org.openejb.util.ClasspathUtils;
   
   /**
    * 
  @@ -65,7 +68,7 @@
       public void load( Hashtable env ) throws Exception{
           if (loaded) return;
   
  -        ClassLoader cl = ClasspathUtils.getContextClassLoader();
  +        ClassLoader cl = getContextClassLoader();
           try{
               cl.loadClass("org.openejb.OpenEJB");
           } catch (Exception e){
  @@ -85,7 +88,16 @@
           }
           loaded = true;
       }
  -    
  +
  +    private ClassLoader getContextClassLoader() {
  +        return (ClassLoader) java.security.AccessController.doPrivileged(new 
java.security.PrivilegedAction() {
  +            public Object run() {
  +                return Thread.currentThread().getContextClassLoader();
  +            }
  +        });
  +    }
  +
  +
       // Sets the openejb.home system variable
       private void importOpenEJBLibraries(  Hashtable env ) throws Exception{
           // Sets the openejb.home system variable
  
  
  

Reply via email to