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/config PropertySetter.java
Date Tue, 04 Jan 2005 16:19:29 GMT
ceki        2005/01/04 08:19:28

  Modified:    src/java/org/apache/log4j PropertyConfigurator.java
               src/java/org/apache/log4j/config PropertySetter.java
  Log:
  PropertySetter now extends ComponentBase. Modified PropertyConfigurator to adapt to changes
in PropertySetter.
  
  Revision  Changes    Path
  1.78      +12 -5     logging-log4j/src/java/org/apache/log4j/PropertyConfigurator.java
  
  Index: PropertyConfigurator.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/PropertyConfigurator.java,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- PropertyConfigurator.java	28 Dec 2004 18:25:57 -0000	1.77
  +++ PropertyConfigurator.java	4 Jan 2005 16:19:28 -0000	1.78
  @@ -381,7 +381,7 @@
         }
   
         configureRootCategory(properties, repository);
  -      configureLoggerFactory(properties);
  +      configureLoggerFactory(properties, repository);
         parseCatsAndRenderers(properties, repository);
   
         getLogger(repository).debug("Finished configuring.");
  @@ -468,7 +468,7 @@
   
        @see #parseCatsAndRenderers
      */
  -  protected void configureLoggerFactory(Properties props) {
  +  protected void configureLoggerFactory(Properties props, LoggerRepository repository)
{
       String factoryClassName =
         OptionConverter.findAndSubst(LOGGER_FACTORY_KEY, props);
   
  @@ -476,7 +476,9 @@
         loggerFactory =
           (LoggerFactory) OptionConverter.instantiateByClassName(
             factoryClassName, LoggerFactory.class, loggerFactory);
  -      PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + ".");
  +      PropertySetter setter = new PropertySetter(loggerFactory);
  +      setter.setLoggerRepository(repository);
  +      setter.setProperties(props, FACTORY_PREFIX + ".");
       }
     }
   
  @@ -692,14 +694,19 @@
             getLogger(repository).debug(
               "Parsing layout options for \"" + appenderName + "\".");
   
  -          PropertySetter.setProperties(layout, props, layoutPrefix + ".");
  +          PropertySetter layoutPS = new PropertySetter(layout);
  +          layoutPS.setLoggerRepository(repository);
  +          layoutPS.setProperties(props, layoutPrefix + ".");
  +          
             activateOptions(layout);
             getLogger(repository).debug(
               "End of parsing for \"" + appenderName + "\".");
           }
         }
   
  -      PropertySetter.setProperties(appender, props, prefix + ".");
  +      PropertySetter appenderPS = new PropertySetter(appender);
  +      appenderPS.setLoggerRepository(repository);
  +      appenderPS.setProperties(props, prefix + ".");
         activateOptions(appender);
         getLogger(repository).debug("Parsed \"" + appenderName + "\" options.");
       }
  
  
  
  1.25      +4 -32     logging-log4j/src/java/org/apache/log4j/config/PropertySetter.java
  
  Index: PropertySetter.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/config/PropertySetter.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- PropertySetter.java	18 Nov 2004 19:37:45 -0000	1.24
  +++ PropertySetter.java	4 Jan 2005 16:19:28 -0000	1.25
  @@ -19,6 +19,7 @@
   
   import org.apache.log4j.*;
   import org.apache.log4j.helpers.OptionConverter;
  +import org.apache.log4j.spi.ComponentBase;
   
   import java.beans.BeanInfo;
   import java.beans.IntrospectionException;
  @@ -52,7 +53,7 @@
      @author Anders Kristensen
      @since 1.1
    */
  -public class PropertySetter {
  +public class PropertySetter extends ComponentBase {
     public static final int NOT_FOUND = 0;
     public static final int AS_PROPERTY = 1;
     public static final int AS_COLLECTION = 2;
  @@ -91,24 +92,8 @@
     }
   
     /**
  -     Set the properties of an object passed as a parameter in one
  -     go. The <code>properties</code> are parsed relative to a
  -     <code>prefix</code>.
  -
  -     @param obj The object to configure.
  -     @param properties A java.util.Properties containing keys and values.
  -     @param prefix Only keys having the specified prefix will be set.
  -  */
  -  public static void setProperties(
  -    Object obj, Properties properties, String prefix) {
  -    new PropertySetter(obj).setProperties(properties, prefix);
  -  }
  -
  -  /**
  -     Set the properites for the object that match the
  -     <code>prefix</code> passed as parameter.
  -
  -
  +   * Set the properites for the object that match the <code>prefix</code> 
  +   * passed as parameter.
      */
     public void setProperties(Properties properties, String prefix) {
       int len = prefix.length();
  @@ -137,13 +122,6 @@
       }
     }
   
  -  Logger getLogger() {
  -    if (logger == null) {
  -      logger = LogManager.getLogger(this.getClass().getName());
  -    }
  -    return logger;
  -  }
  -
     /**
        Set a property on this PropertySetter's Object. If successful, this
        method will invoke a setter method on the underlying Object. The
  @@ -406,10 +384,4 @@
   
       return null;
     }
  -
  -  //public void activate() {
  -  //if (obj instanceof OptionHandler) {
  -  //((OptionHandler) obj).activateOptions();
  -  //}
  -  //}
   }
  
  
  

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