logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: logging-log4j/src/java/org/apache/log4j/or RendererMap.java
Date Tue, 04 Jan 2005 19:48:48 GMT
ceki        2005/01/04 11:48:48

  Modified:    src/java/org/apache/log4j/or RendererMap.java
  Log:
  Log4j components now see their owning LR.
  
  Revision  Changes    Path
  1.14      +14 -18    logging-log4j/src/java/org/apache/log4j/or/RendererMap.java
  
  Index: RendererMap.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/or/RendererMap.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- RendererMap.java	17 Nov 2004 17:41:36 -0000	1.13
  +++ RendererMap.java	4 Jan 2005 19:48:48 -0000	1.14
  @@ -16,10 +16,9 @@
   
   package org.apache.log4j.or;
   
  -import org.apache.log4j.LogManager;
  -import org.apache.log4j.Logger;
   import org.apache.log4j.helpers.Loader;
   import org.apache.log4j.helpers.OptionConverter;
  +import org.apache.log4j.spi.ComponentBase;
   import org.apache.log4j.spi.RendererSupport;
   
   import java.util.Hashtable;
  @@ -30,7 +29,7 @@
   
      @author Ceki Gülcü
      @since version 1.0 */
  -public class RendererMap {
  +public class RendererMap extends ComponentBase {
     static ObjectRenderer defaultRenderer = new DefaultRenderer();
     Hashtable map;
   
  @@ -39,27 +38,22 @@
     }
   
     /**
  -   * Gets a logger named after this class. Note that the instance of the 
  -   * logger may change depending on the 
  -   * {@link org.apache.log4j.spi.RepositorySelector}.
  -   * @return a context dependent Logger
  -   */
  -  private static Logger getLogger() {
  -    return LogManager.getLogger(OptionConverter.class);
  -  }
  -  
  -  /**
        Add a renderer to a hierarchy passed as parameter.
     */
  -  public static void addRenderer(
  -    RendererSupport repository, String renderedClassName,
  +  public void addRenderer(String renderedClassName,
       String renderingClassName) {
       getLogger().debug(
         "Rendering class: [{}, Rendered class: [{}].", renderingClassName, 
         renderedClassName);
  +    
  +    OptionConverter oc = new OptionConverter();
  +    oc.setLoggerRepository(repository);
  +    
  +    
       ObjectRenderer renderer =
  -      (ObjectRenderer) OptionConverter.instantiateByClassName(
  -        renderingClassName, ObjectRenderer.class, null);
  +      (ObjectRenderer) oc.instantiateByClassName(
  +          renderingClassName, ObjectRenderer.class, null);
  +      
       if (renderer == null) {
         getLogger().error(
           "Could not instantiate renderer [" + renderingClassName + "].");
  @@ -67,7 +61,9 @@
       } else {
         try {
           Class renderedClass = Loader.loadClass(renderedClassName);
  -        repository.setRenderer(renderedClass, renderer);
  +        if(repository != null && repository instanceof RendererSupport) {
  +          ((RendererSupport)repository).setRenderer(renderedClass, renderer);
  +        }
         } catch (ClassNotFoundException e) {
           getLogger().error("Could not find class [" + renderedClassName + "].", e);
         }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message