dblevins    2005/07/05 22:04:03

  Modified:    modules/core/src/java/org/openejb/client
                        LocalInitialContextFactory.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.4       +10 -3     
openejb1/modules/core/src/java/org/openejb/client/LocalInitialContextFactory.java
  
  Index: LocalInitialContextFactory.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/client/LocalInitialContextFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LocalInitialContextFactory.java   16 Jun 2005 22:29:50 -0000      1.3
  +++ LocalInitialContextFactory.java   6 Jul 2005 02:04:03 -0000       1.4
  @@ -95,7 +95,7 @@
       private Loader instantiateLoader(String loaderName) throws Exception {
           Loader loader = null;
           try {
  -            ClassLoader cl = ClasspathUtils.getContextClassLoader();
  +            ClassLoader cl = getContextClassLoader();
               Class loaderClass = Class.forName(loaderName, true, cl);
               loader = (Loader) loaderClass.newInstance();
           } catch (Exception e) {
  @@ -109,7 +109,7 @@
           Context context = null;
           try {
               InitialContextFactory factory = null;
  -            ClassLoader cl = ClasspathUtils.getContextClassLoader();
  +            ClassLoader cl = getContextClassLoader();
               Class ivmFactoryClass = 
Class.forName("org.openejb.core.ivm.naming.InitContextFactory", true, cl);
   
               factory = (InitialContextFactory) ivmFactoryClass.newInstance();
  @@ -122,5 +122,12 @@
           return context;
       }
   
  +    private ClassLoader getContextClassLoader() {
  +        return (ClassLoader) java.security.AccessController.doPrivileged(new 
java.security.PrivilegedAction() {
  +            public Object run() {
  +                return Thread.currentThread().getContextClassLoader();
  +            }
  +        });
  +    }
   }
   
  
  
  

Reply via email to