psmith      2004/06/16 17:17:15

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
  Log:
  * Only remove the SecurityManager if the Preferences says its ok to do so
  
  * TEMPORARILY switch the TCCL on Chainsaw startup so that JoranConfigurator has 
access to the ClassLoader
  that can access the JMS/DB/whatever jars/resources that are required.  Hoping this 
is ok for now, until a
  better stategy can be thought of.
  
  Revision  Changes    Path
  1.99      +21 -3     logging-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java
  
  Index: LogUI.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- LogUI.java        14 Jun 2004 22:56:33 -0000      1.98
  +++ LogUI.java        17 Jun 2004 00:17:15 -0000      1.99
  @@ -258,9 +258,12 @@
     public static void createChainsawGUI(
       ApplicationPreferenceModel model, Action newShutdownAction) {
       
  +    if(model.isOkToRemoveSecurityManager()) {
  +        MessageCenter.getInstance().addMessage("User has authorised removal of Java 
Security Manager via preferences");
  +     System.setSecurityManager(null);
  +    }
  +    LogLog.info("SecurityManager is now: " + System.getSecurityManager());
       
  -    ClassLoader classLoader = PluginClassLoaderFactory.create(new 
File(SettingsManager.getInstance().getSettingsDirectory() + File.separator + 
"plugins"));
  -    Thread.currentThread().setContextClassLoader(classLoader);
       
       LogUI logUI = new LogUI();
   
  @@ -273,17 +276,32 @@
       logUI.handler.addEventBatchListener(logUI.new NewTabEventBatchReceiver());
       
       
  +    /**
  +     * TODO until we work out how JoranConfigurator might be able to have
  +     * configurable class loader, if at all.  For now we temporarily replace the
  +     * TCCL so that Plugins that need access to resources in 
  +     * the Plugins directory can find them (this is particularly
  +     * important for the Web start version of Chainsaw
  +     */ 
  +    ClassLoader classLoader = 
PluginClassLoaderFactory.getInstance().getClassLoader();
  +    ClassLoader previousTCCL = Thread.currentThread().getContextClassLoader();
  +    
       String config = model.getConfigurationURL();
       if(config!=null && (!(config.trim().equals("")))) {
           config = config.trim();
           LogLog.info("Using '" + config + "' for auto-configuration");
           try {
  +          // we temporarily swap the TCCL so that plugins can find resources
  +          Thread.currentThread().setContextClassLoader(classLoader);
             JoranConfigurator jc = new JoranConfigurator();
             jc.doConfigure(new URL(config), LogManager.getLoggerRepository());
             jc.logErrors();
           } catch (MalformedURLException e) {
             LogLog.error("Failed to use the auto-configuration file", e);
  -        }   
  +        }finally{
  +            // now switch it back...
  +            Thread.currentThread().setContextClassLoader(previousTCCL);
  +        }
       }else {
           LogLog.info("No auto-configuration file found within the 
ApplicationPreferenceModel");
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to