As per my previous email with Ceki, this patch modifies the configuration 
file loading code so that while still allowing a 'ref' or anchor portion of 
a URL to specify a class name for a custom configurator, it can also work 
with custom URL schemes such as used in WebLogic to specify a file within an 
archive, e.g.
 zip:/part1/part2/whatever.war#WEB-INF/classes/log4j.properties 

With the new code, for the ref portion of a URL to be considered a 
classname, it must consist of at least one package element and one classname 
element (e.g. mypackage.Myclass), and must not have the file separator 
character in it. Also, when the URL comes from a classloader as opposed to a 
system properly, the code will never consider the ref to be a classname, 
since that wouldn't make sense (e.g. in this case the ref will always be 
part of a custom URL). 

 ---- 

Index: Category.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/Category.java,v
retrieving revision 1.35
diff -w -r1.35 Category.java
133a134
>       boolean urlRefMayBeConfigurator = true;
135,136d135
<       // so, resource is not a URL:
<       // attempt to get the resource from the class path
138a138,139
>       // if resource is not a URL then
>       // attempt to get the resource from the class path
139a141,143
>         // any ref portion in URL returned by classload is specific to that URL,
>         // not a Configurator class name
>         urlRefMayBeConfigurator = false;
147c151
<       OptionConverter.selectAndConfigure(url, defaultHierarchy);
 ---
>       OptionConverter.selectAndConfigure(url, urlRefMayBeConfigurator, 
>defaultHierarchy);
Index: helpers/OptionConverter.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/helpers/OptionConver 
ter.java,v
retrieving revision 1.17
diff -w -r1.17 OptionConverter.java
402,404c402,411
<      <p>The URL format is important. Its <em>reference</em> part is
<      taken as the class name of the configurator. For example, if you
<      invoke your application using the command line
 ---
>      <p>The URL format is important. If the <em>urlRefMayBeConfigurator</em>
>      param is true, then its <em>reference</em> part (if any) is potentially
>      considered to be the class name of the configurator. Since the ref part
>      may also be used by some custom URL types (e.g. to qualify a specific file
>      within another archive file), for the ref string to be considered a class
>      name, it must be a fully qualified class name including at least one
>      package, and must not contain any file separator characters such as '/' or
>      '\' since those would never be part of a valid class name, and are a strong
>      indication of a custom URL type. For example, if you invoke your
>      application using the command line
415,416c422,423
<      <p>If the URL has no reference part, then the {@link
<      PropertyConfigurator} will parse the URL. However, if the URL
 ---
>      <p>If no configurator is specified via a URL reference part, then the
>      {@link PropertyConfigurator} will parse the URL. However, if the URL
428,429c435,450
<   void selectAndConfigure(URL url, Hierarchy hierarchy) {
<     String clazz = url.getRef();
 ---
>   void selectAndConfigure(URL url, boolean urlRefMayBeConfigurator,
>                           Hierarchy hierarchy) { 
> 
>     // assume a 'ref' portion of a URL may be Configurator class
>     String clazz = null;
>     if (urlRefMayBeConfigurator) {
>       clazz = url.getRef();
>       if (clazz != null) {
>         String fileSep = "/";
>         try { fileSep = System.getProperty("file.separator"); } catch(Exception e) {}
>         // java support non-platform normal file separators, so we should too
>         if (clazz.indexOf('.') == -1 || clazz.indexOf(fileSep) != -1 ||
>             clazz.indexOf('/') != -1 || clazz.indexOf('\\') != -1)
>           clazz = null;
>       }
>     }
433c454
<     if(clazz != null) {
 ---
>     if (clazz != null && clazz.length() > 0) {
442a464,468
>       // hmm, this test is actually no longer valid if we have a custom URL type
>       // such as:
>       // 'zip:/a/b/c/d.war#e/f/log4j.properties'
>       // which is what a custom classloader like WebLogic's may return as a URL
>       // reference to a file inside of an archive
457a484,495
>  
> 
>   /**
>      Configure log4j given a URL.
>      This method signature maintained for compatibility
>    */
>   static
>   public
>   void selectAndConfigure(URL url, Hierarchy hierarchy) {
>     selectAndConfigure(url, true, hierarchy);
>   } 
> 
 

 

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

Reply via email to