commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patri...@apache.org
Subject cvs commit: jakarta-commons-sandbox/daemon/src/java LauncherBootstrap.java
Date Wed, 10 Jul 2002 17:35:03 GMT
patrickl    2002/07/10 10:35:02

  Modified:    daemon/src/java LauncherBootstrap.java
  Log:
  Set context class loader just ot be safe
  
  Revision  Changes    Path
  1.2       +17 -3     jakarta-commons-sandbox/daemon/src/java/LauncherBootstrap.java
  
  Index: LauncherBootstrap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/LauncherBootstrap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LauncherBootstrap.java	10 Jul 2002 05:27:52 -0000	1.1
  +++ LauncherBootstrap.java	10 Jul 2002 17:35:02 -0000	1.2
  @@ -117,9 +117,20 @@
               URL launcherJar = LauncherBootstrap.class.getResource("/" + JAR_FILE_NAME);
               if (launcherJar == null)
                   throw new FileNotFoundException(JAR_FILE_NAME);
  - 
  -            // Try to laod the main class
  -            URLClassLoader loader = new URLClassLoader(new URL[]{launcherJar});
  +
  +            // Cache the current class loader 
  +            ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
  +
  +            URLClassLoader loader = null;
  +            if (oldLoader != null)
  +                loader = new URLClassLoader(new URL[]{launcherJar}, oldLoader);
  +            else
  +                loader = new URLClassLoader(new URL[]{launcherJar});
  +
  +            // Set the current class loader
  +            Thread.currentThread().setContextClassLoader(loader);
  +
  +            // Try to load the main class
               Class mainClass = loader.loadClass(MAIN_CLASS_NAME);
   
               // Try to invoke its main method
  @@ -135,6 +146,9 @@
               t.printStackTrace();
               System.exit(1);
           }
  +
  +        // Always exit cleanly
  +        System.exit(0);
   
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message