dlr         02/04/03 08:07:33

  Modified:    src/java/org/apache/velocity/servlet VelocityServlet.java
  Log:
  Changed from "properties" to "org.apache.velocity.properties" to add
  namespace protection for the global hash key INIT_PROPS_KEY.
  Introduced a private OLD_INIT_PROPS_KEY member to provide backwards
  compatibility for the deprecated "properties" key.
  
  I'm unsure what the right way to handle the logging of a deprecation
  warning is, as the Velocity logger has not yet been initialized at the
  time we want to log the warning.  Ideas welcome.
  
  Revision  Changes    Path
  1.45      +36 -7     
jakarta-velocity/src/java/org/apache/velocity/servlet/VelocityServlet.java
  
  Index: VelocityServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/servlet/VelocityServlet.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -u -r1.44 -r1.45
  --- VelocityServlet.java      6 Feb 2002 23:42:01 -0000       1.44
  +++ VelocityServlet.java      3 Apr 2002 16:07:33 -0000       1.45
  @@ -127,7 +127,8 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Geir Magnusson Jr.</a>
    * @author <a href="[EMAIL PROTECTED]">Kent Johnson</a>
  - * $Id: VelocityServlet.java,v 1.44 2002/02/06 23:42:01 dlr Exp $
  + * @author <a href="[EMAIL PROTECTED]">Daniel Rall</a>
  + * $Id: VelocityServlet.java,v 1.45 2002/04/03 16:07:33 dlr Exp $
    */
   public abstract class VelocityServlet extends HttpServlet
   {
  @@ -169,9 +170,16 @@
   
       /**
        * This is the string that is looked for when getInitParameter is
  -     * called.
  +     * called (<code>org.apache.velocity.properties</code>).
        */
  -    protected static final String INIT_PROPS_KEY = "properties";
  +    protected static final String INIT_PROPS_KEY =
  +        "org.apache.velocity.properties";
  +
  +    /**
  +     * Use of this properties key has been deprecated, and will be
  +     * removed in Velocity version 1.5.
  +     */
  +    private static final String OLD_INIT_PROPS_KEY = "properties";
   
       /**
        * Cache of writers
  @@ -256,7 +264,7 @@
        *      &lt;servlet-name&gt; YourServlet &lt/servlet-name&gt;
        *      &lt;servlet-class&gt; your.package.YourServlet &lt;/servlet-class&gt;
        *      &lt;init-param&gt;
  -     *         &lt;param-name&gt; properties &lt;/param-name&gt;
  +     *         &lt;param-name&gt; org.apache.velocity.properties &lt;/param-name&gt;
        *         &lt;param-value&gt; velocity.properties &lt;/param-value&gt;
        *      &lt;/init-param&gt;
        *    &lt;/servlet&gt;
  @@ -267,7 +275,7 @@
        *  <br>
        *  <pre>
        *    &lt;context-param&gt;
  -     *       &lt;param-name&gt; properties &lt;/param-name&gt;
  +     *       &lt;param-name&gt; org.apache.velocity.properties &lt;/param-name&gt;
        *       &lt;param-value&gt; velocity.properties &lt;/param-value&gt;
        *       &lt;description&gt; Path to Velocity configuration &lt;/description&gt;
        *    &lt;/context-param&gt;
  @@ -290,11 +298,32 @@
       protected Properties loadConfiguration(ServletConfig config )
           throws IOException, FileNotFoundException
       {
  +        // This is a little overly complex because of legacy support
  +        // for the initialization properties key "properties".
  +        // References to OLD_INIT_PROPS_KEY should be removed at
  +        // Velocity version 1.5.
           String propsFile = config.getInitParameter(INIT_PROPS_KEY);
           if (propsFile == null || propsFile.length() == 0)
           {
  -            propsFile = config.getServletContext()
  -                .getInitParameter(INIT_PROPS_KEY);
  +            propsFile = config.getInitParameter(OLD_INIT_PROPS_KEY);
  +            if (propsFile == null || propsFile.length() == 0)
  +            {
  +                propsFile = config.getServletContext()
  +                    .getInitParameter(INIT_PROPS_KEY);
  +                if (propsFile == null || propsFile.length() == 0)
  +                {
  +                    propsFile = config.getServletContext()
  +                        .getInitParameter(OLD_INIT_PROPS_KEY);
  +                }
  +                else
  +                {
  +                    // TODO: Log deprecation warning.
  +                }
  +            }
  +            else
  +            {
  +                // TODO: Log deprecation warning.
  +            }
           }
           
           /*
  
  
  

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

Reply via email to