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/helpers OptionConverter.java
Date Sun, 06 Jun 2004 12:06:04 GMT
ceki        2004/06/06 05:06:04

  Modified:    tests/input/db append-with-jndi1.xml
                        append-with-drivermanager1.xml
                        append-with-pooled-datasource1.xml
                        append-with-datasource1.xml
                        read-with-drivermanager1.xml
                        read-with-pooled-datasource1.xml
                        read-with-datasource1.xml read-with-jndi1.xml
               src/java/org/apache/joran/action ParamAction.java
               src/java/org/apache/log4j/helpers OptionConverter.java
  Log:
  Changes the ParamAction in Joran to allow for variable substitution in
  the name of property as well as its value.
  
  Modified the config files under tests/inpuit/db to handle variation in
  the name of the url property. For example, the Oracle drivers refer to
  the "URL" property instead of "url".
  
  Javadoc corrections in OptionConverter.
  
  Revision  Changes    Path
  1.2       +1 -1      logging-log4j/tests/input/db/append-with-jndi1.xml
  
  Index: append-with-jndi1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/db/append-with-jndi1.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- append-with-jndi1.xml	20 May 2004 11:49:07 -0000	1.1
  +++ append-with-jndi1.xml	6 Jun 2004 12:06:03 -0000	1.2
  @@ -17,7 +17,7 @@
        <connectionSource class="org.apache.log4j.db.DataSourceConnectionSource">
          
          <dataSource class="${dataSourceClass}">
  -         <param name="url" value="${url}"/>
  +         <param name="${url-key:-url}" value="${url}"/>
            <param name="serverName" value="${serverName}"/>
            <param name="databaseName" value="${databaseName}"/>         
          </dataSource>
  
  
  
  1.3       +1 -1      logging-log4j/tests/input/db/append-with-drivermanager1.xml
  
  Index: append-with-drivermanager1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/db/append-with-drivermanager1.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- append-with-drivermanager1.xml	20 May 2004 15:37:59 -0000	1.2
  +++ append-with-drivermanager1.xml	6 Jun 2004 12:06:03 -0000	1.3
  @@ -9,7 +9,7 @@
        <param name="locationInfo" value="true"/>
        <connectionSource class="org.apache.log4j.db.DriverManagerConnectionSource">
          <param name="driverClass" value="${driverClass}"/>
  -       <param name="url" value="${url}"/>
  +       <param name="${url-key:-url}" value="${url}"/>
          <param name="user" value="${user}"/>
          <param name="password" value="${password}"/>
        </connectionSource>
  
  
  
  1.3       +1 -1      logging-log4j/tests/input/db/append-with-pooled-datasource1.xml
  
  Index: append-with-pooled-datasource1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/db/append-with-pooled-datasource1.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- append-with-pooled-datasource1.xml	24 May 2004 16:14:34 -0000	1.2
  +++ append-with-pooled-datasource1.xml	6 Jun 2004 12:06:03 -0000	1.3
  @@ -9,7 +9,7 @@
        <connectionSource class="org.apache.log4j.db.DataSourceConnectionSource">
          
          <dataSource class="${pooledDataSourceClass}">
  -         <param name="url" value="${url}"/>
  +         <param name="${url-key:-url}" value="${url}"/>
            <param name="serverName" value="${serverName}"/>
            <param name="databaseName" value="${databaseName}"/>
            <param name="user" value="${user}"/>
  
  
  
  1.2       +1 -1      logging-log4j/tests/input/db/append-with-datasource1.xml
  
  Index: append-with-datasource1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/db/append-with-datasource1.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- append-with-datasource1.xml	18 May 2004 16:50:43 -0000	1.1
  +++ append-with-datasource1.xml	6 Jun 2004 12:06:03 -0000	1.2
  @@ -9,7 +9,7 @@
        <connectionSource class="org.apache.log4j.db.DataSourceConnectionSource">
          
          <dataSource class="${dataSourceClass}">
  -         <param name="url" value="${url}"/>
  +         <param name="${url-key:-url}" value="${url}"/>
            <param name="serverName" value="${serverName}"/>
            <param name="databaseName" value="${databaseName}"/>         
          </dataSource>
  
  
  
  1.3       +1 -1      logging-log4j/tests/input/db/read-with-drivermanager1.xml
  
  Index: read-with-drivermanager1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/db/read-with-drivermanager1.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- read-with-drivermanager1.xml	24 May 2004 16:14:34 -0000	1.2
  +++ read-with-drivermanager1.xml	6 Jun 2004 12:06:03 -0000	1.3
  @@ -8,7 +8,7 @@
     <plugin name="DB" class="org.apache.log4j.db.DBReceiver">
        <connectionSource class="org.apache.log4j.db.DriverManagerConnectionSource">
          <param name="driverClass" value="${driverClass}"/>
  -       <param name="url" value="${url}"/>
  +       <param name="${url-key:-url}" value="${url}"/>
          <param name="user" value="${user}"/>
          <param name="password" value="${password}"/>
        </connectionSource>
  
  
  
  1.3       +1 -1      logging-log4j/tests/input/db/read-with-pooled-datasource1.xml
  
  Index: read-with-pooled-datasource1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/db/read-with-pooled-datasource1.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- read-with-pooled-datasource1.xml	20 May 2004 11:49:07 -0000	1.2
  +++ read-with-pooled-datasource1.xml	6 Jun 2004 12:06:03 -0000	1.3
  @@ -9,7 +9,7 @@
        <connectionSource class="org.apache.log4j.db.DataSourceConnectionSource">
          
          <dataSource class="${pooledDataSourceClass}">
  -         <param name="url" value="${url}"/>
  +         <param name="${url-key:-url}" value="${url}"/>
            <param name="serverName" value="${serverName}"/>
            <param name="databaseName" value="${databaseName}"/>          
          </dataSource>
  
  
  
  1.3       +1 -1      logging-log4j/tests/input/db/read-with-datasource1.xml
  
  Index: read-with-datasource1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/db/read-with-datasource1.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- read-with-datasource1.xml	20 May 2004 11:49:07 -0000	1.2
  +++ read-with-datasource1.xml	6 Jun 2004 12:06:03 -0000	1.3
  @@ -16,7 +16,7 @@
        <connectionSource class="org.apache.log4j.db.DataSourceConnectionSource">
          
          <dataSource class="${dataSourceClass}">
  -         <param name="url" value="${url}"/>
  +         <param name="${url-key:-url}" value="${url}"/>
            <param name="serverName" value="${serverName}"/>
            <param name="databaseName" value="${databaseName}"/>          
          </dataSource>
  
  
  
  1.2       +1 -1      logging-log4j/tests/input/db/read-with-jndi1.xml
  
  Index: read-with-jndi1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/db/read-with-jndi1.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- read-with-jndi1.xml	20 May 2004 11:49:07 -0000	1.1
  +++ read-with-jndi1.xml	6 Jun 2004 12:06:03 -0000	1.2
  @@ -9,7 +9,7 @@
        <connectionSource class="org.apache.log4j.db.DataSourceConnectionSource">
          
          <dataSource class="${dataSourceClass}">
  -         <param name="url" value="${url}"/>
  +         <param name="${url-key:-url}" value="${url}"/>
            <param name="serverName" value="${serverName}"/>
            <param name="databaseName" value="${databaseName}"/>          
          </dataSource>
  
  
  
  1.11      +4 -0      logging-log4j/src/java/org/apache/joran/action/ParamAction.java
  
  Index: ParamAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/joran/action/ParamAction.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ParamAction.java	18 May 2004 16:50:43 -0000	1.10
  +++ ParamAction.java	6 Jun 2004 12:06:03 -0000	1.11
  @@ -42,6 +42,10 @@
   		Object o = ec.peekObject();
   		PropertySetter propSetter = new PropertySetter(o);		
   		value = ec.subst(OptionConverter.convertSpecialChars(value));
  +    
  +    // allow for variable substitution for name as well
  +    name = ec.subst(name);
  +    
       LogLog.debug("In ParamAction setting parameter ["+name+"] to value ["+value+"].");
   		propSetter.setProperty(name, value);
     }
  
  
  
  1.42      +41 -41    logging-log4j/src/java/org/apache/log4j/helpers/OptionConverter.java
  
  Index: OptionConverter.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/helpers/OptionConverter.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- OptionConverter.java	6 Jun 2004 11:34:13 -0000	1.41
  +++ OptionConverter.java	6 Jun 2004 12:06:03 -0000	1.42
  @@ -26,16 +26,17 @@
   import java.util.Properties;
   
   
  -// Contributors:   Avy Sharell (sharell@online.fr)
  -//                 Matthieu Verbert (mve@zurich.ibm.com)
  +// Contributors:   Avy Sharell 
  +//                 Matthieu Verbert
   //                 Colin Sampaleanu
   
   /**
  -   A convenience class to convert property values to specific types.
  -
  -   @author Ceki G&uuml;lc&uuml;
  -   @author Simon Kitching;
  -   @author Anders Kristensen
  + * A convenience class to convert property values to specific types.
  + * 
  + * @author Ceki G&uuml;lc&uuml;
  + * @author Simon Kitching;
  + * @author Anders Kristensen
  + * @author Avy Sharell
   */
   public class OptionConverter {
     static String DELIM_START = "${";
  @@ -355,40 +356,39 @@
     }
   
     /**
  -     Perform variable substitution in string <code>val</code> from the
  -     values of keys found in the system propeties.
  -
  -     <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
  -
  -     <p>For example, if the System properties contains "key=value", then
  -     the call
  -     <pre>
  -     String s = OptionConverter.substituteVars("Value of key is ${key}.");
  -     </pre>
  -
  -     will set the variable <code>s</code> to "Value of key is value.".
  -
  -     <p>If no value could be found for the specified key, then the
  -     <code>props</code> parameter is searched, if the value could not
  -     be found there, then substitution defaults to the empty string.
  -
  -     <p>For example, if system propeties contains no value for the key
  -     "inexistentKey", then the call
  -
  -     <pre>
  -     String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]");
  -     </pre>
  -     will set <code>s</code> to "Value of inexistentKey is []"
  -
  -     <p>An {@link java.lang.IllegalArgumentException} is thrown if
  -     <code>val</code> contains a start delimeter "${" which is not
  -     balanced by a stop delimeter "}". </p>
  -
  -     <p><b>Author</b> Avy Sharell</a></p>
  -
  -     @param val The string on which variable substitution is performed.
  -     @throws IllegalArgumentException if <code>val</code> is malformed.
  -
  +   * Perform variable substitution in string <code>val</code> from the values
of
  +   * keys found the properties passed as parameter or in the system propeties.
  +   * 
  +   * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
  +   *
  +   * <p>For example, if the properties parameter contains a property "key1" set
  +   * as "value1", then the call <pre>
  +   *  String s = OptionConverter.substituteVars("Value of key is ${key1}.");</pre>
  +   * will set the variable <code>s</code> to "Value of key is value1.".
  +   * 
  +   * <p>If no value could be found for the specified key, then the 
  +   * system properties are searched, if the value could not be found 
  +   * there, then substitution defaults to the empty string.
  +   * 
  +   * <p>For example, if system propeties contains no value for the key 
  +   * "inexistentKey", then the call
  +   * <pre>
  +   * String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]");
</pre>
  +   * will set <code>s</code> to "Value of inexistentKey is []".
  +   * 
  +   * <p>Nevertheless, it is possible to specify a default substitution value 
  +   * using the ":-" operator. For example, the call
  +   * <pre>
  +   * String s = OptionConverter.subsVars("Value of key is [${key2:-val2}]");</pre>
  +   *  will set <code>s</code> to "Value of key is [val2]" even if the "key2"
  +   * property is unset.
  +   * 
  +   * <p>An {@link java.lang.IllegalArgumentException} is thrown if 
  +   * <code>val</code> contains a start delimeter "${" which is not 
  +   * balanced by a stop delimeter "}". </p>
  +   * 
  +   * @param val The string on which variable substitution is performed.
  +   * @throws IllegalArgumentException if <code>val</code> is malformed.
     */
     public static String substVars(String val, Properties props)
       throws IllegalArgumentException {
  
  
  

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