You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by dl...@apache.org on 2002/04/16 23:23:31 UTC

cvs commit: jakarta-turbine-3/src/java/org/apache/turbine TurbineConfig.java

dlr         02/04/16 14:23:31

  Modified:    src/java/org/apache/turbine TurbineConfig.java
  Log:
  o Improved ctor documentation.
  
  o Implemented setAttribute(String, Object), and made ctor
  implementation take the fact that the ServletContext attributes are
  now read/write (instead of read-only like previously).
  
  Revision  Changes    Path
  1.6       +17 -14    jakarta-turbine-3/src/java/org/apache/turbine/TurbineConfig.java
  
  Index: TurbineConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/TurbineConfig.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -u -r1.5 -r1.6
  --- TurbineConfig.java	9 Apr 2002 17:29:34 -0000	1.5
  +++ TurbineConfig.java	16 Apr 2002 21:23:31 -0000	1.6
  @@ -62,14 +62,17 @@
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.Enumeration;
  +import java.util.Hashtable;
   import java.util.HashMap;
   import java.util.Map;
   import java.util.Set;
   import java.util.Vector;
  +
   import javax.servlet.RequestDispatcher;
   import javax.servlet.Servlet;
   import javax.servlet.ServletConfig;
   import javax.servlet.ServletContext;
  +
   import org.apache.turbine.Turbine;
   import org.apache.turbine.RunData;
   import org.apache.commons.logging.LogFactory;
  @@ -100,7 +103,7 @@
    * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
  - * @version $Id: TurbineConfig.java,v 1.5 2002/04/09 17:29:34 jtaylor Exp $
  + * @version $Id: TurbineConfig.java,v 1.6 2002/04/16 21:23:31 dlr Exp $
    */
   public class TurbineConfig implements ServletConfig, ServletContext
   {
  @@ -138,12 +141,16 @@
        *
        * @param path The web application root (i.e. the path for file lookup).
        * @param attributes Servlet container (or emulator) attributes.
  -     * @param initParams initialization parameters.
  +     * @param initParams Global (i.e. psuedo-context wide)
  +     * initialization parameters.
        */
       public TurbineConfig(String path, Map attributes, Map initParams)
       {
           root = new File(path);
  -        this.attributes = attributes;
  +        // Since attributes are read/write, they need thread-safe
  +        // storage.
  +        this.attributes = (attributes instanceof Hashtable ? attributes :
  +                           new Hashtable(attributes));
           this.initParams = initParams;
       }
   
  @@ -152,7 +159,7 @@
        */
       public TurbineConfig(String path, Map initParams)
       {
  -        this(path, new HashMap(0), initParams);
  +        this(path, new Hashtable(0), initParams);
       }
   
       /**
  @@ -313,7 +320,7 @@
               FileInputStream fis = new FileInputStream(getRealPath(s));
               return new BufferedInputStream(fis);
           }
  -        catch(FileNotFoundException e)
  +        catch (FileNotFoundException e)
           {
               return null;
           }
  @@ -361,9 +368,9 @@
        * Returns the servlet container attribute with the given name, or
        * null if there is no attribute by that name.
        */
  -    public Object getAttribute(String s)
  +    public Object getAttribute(String name)
       {
  -        return attributes.get(s);
  +        return attributes.get(name);
       }
   
       /**
  @@ -539,14 +546,10 @@
       }
   
       /**
  -     * Not implemented.
  -     *
  -     * A method in ServletConfig or ServletContext interface that is not
  -     * implemented and will throw <code>UnsuportedOperationException</code>
  -     * upon invocation
  +     * Sets the attribute identified by <code>name</code>.
        */
  -    public void setAttribute( String s, Object o )
  +    public void setAttribute(String name, Object obj)
       {
  -        throw new UnsupportedOperationException();
  +        attributes.put(name, obj);
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>