commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/logging/src/java/org/apache/commons/logging/impl SimpleLog.java
Date Sat, 15 Jun 2002 20:54:48 GMT
craigmcc    2002/06/15 13:54:48

  Modified:    logging/src/java/org/apache/commons/logging/impl
                        SimpleLog.java
  Log:
  Make SimpleLog check for its "simplelog.properties" resource in the thread
  context class loader, if present, while using the same trick LogFactory
  does to protect JDK 1.1 compatibility.
  
  Revision  Changes    Path
  1.4       +20 -5     jakarta-commons/logging/src/java/org/apache/commons/logging/impl/SimpleLog.java
  
  Index: SimpleLog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/SimpleLog.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SimpleLog.java	26 Feb 2002 04:06:22 -0000	1.3
  +++ SimpleLog.java	15 Jun 2002 20:54:48 -0000	1.4
  @@ -63,6 +63,7 @@
   package org.apache.commons.logging.impl;
   
   import java.io.InputStream;
  +import java.lang.reflect.Method;
   import java.security.AccessControlException;
   import java.text.DateFormat;
   import java.text.SimpleDateFormat;
  @@ -167,9 +168,23 @@
                   }
               }
   
  +            // identify the class loader to attempt resource loading with
  +            ClassLoader classLoader = null;
  +            try {
  +                Method method =
  +                    Thread.class.getMethod("getContextClassLoader", null);
  +                classLoader = (ClassLoader)
  +                    method.invoke(Thread.currentThread(), null);
  +            } catch (Exception e) {
  +                ; // Ignored (security exception or JDK 1.1)
  +            }
  +            if (classLoader == null) {
  +                classLoader = SimpleLog.class.getClassLoader();
  +            }
  +
               // add props from the resource simplelog.properties
               InputStream in =
  -                ClassLoader.getSystemResourceAsStream("simplelog.properties");
  +                classLoader.getResourceAsStream("simplelog.properties");
               if(null != in) {
                   try {
                       simpleLogProps.load(in);
  
  
  

--
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