cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/environment/http HttpContext.java
Date Wed, 17 Oct 2001 09:07:39 GMT
sylvain     01/10/17 02:07:39

  Modified:    src/org/apache/cocoon/environment Tag: cocoon_20_branch
                        Context.java
               src/org/apache/cocoon/environment/commandline Tag:
                        cocoon_20_branch CommandlineContext.java
               src/org/apache/cocoon/environment/http Tag: cocoon_20_branch
                        HttpContext.java
  Log:
  New methods for setting attributes on Context, just like in ServletContext
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.1.1.2.5 +8 -1      xml-cocoon2/src/org/apache/cocoon/environment/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/Context.java,v
  retrieving revision 1.1.1.1.2.4
  retrieving revision 1.1.1.1.2.5
  diff -u -r1.1.1.1.2.4 -r1.1.1.1.2.5
  --- Context.java	2001/10/11 08:56:10	1.1.1.1.2.4
  +++ Context.java	2001/10/17 09:07:38	1.1.1.1.2.5
  @@ -10,18 +10,25 @@
   
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.util.Enumeration;
   
   /**
    * Defines an interface to provide client context information .
    *
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
  - * @version CVS $Revision: 1.1.1.1.2.4 $ $Date: 2001/10/11 08:56:10 $
  + * @version CVS $Revision: 1.1.1.1.2.5 $ $Date: 2001/10/17 09:07:38 $
    *
    */
   
   public interface Context {
   
       Object getAttribute(String name);
  +    
  +    void setAttribute(String name, Object value);
  +    
  +    void removeAttribute(String name);
  +    
  +    Enumeration getAttributeNames();
   
       URL getResource(String path) throws MalformedURLException;
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +25 -3     xml-cocoon2/src/org/apache/cocoon/environment/commandline/CommandlineContext.java
  
  Index: CommandlineContext.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/commandline/CommandlineContext.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- CommandlineContext.java	2001/10/11 08:56:10	1.1.2.4
  +++ CommandlineContext.java	2001/10/17 09:07:38	1.1.2.5
  @@ -7,11 +7,15 @@
    *****************************************************************************/
   package org.apache.cocoon.environment.commandline;
   
  +import org.apache.avalon.excalibur.collections.IteratorEnumeration;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.cocoon.environment.Context;
   
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.util.Enumeration;
  +import java.util.Map;
  +import java.util.HashMap;
   
   /**
    *
  @@ -22,27 +26,45 @@
   
       /** The context directory path*/
       private String contextDir;
  +    
  +    /** The context attributes */
  +    private Map attributes;
   
       /**
        * Constructs a CommandlineContext object from a ServletContext object
        */
       public CommandlineContext (String contextDir) {
           this.contextDir = contextDir;
  +        this.attributes = new HashMap();
       }
   
       public Object getAttribute(String name) {
           getLogger().debug("CommandlineContext: getAttribute=" + name);
  -        //return servletContext.getAttribute(name);
  -        return null;
  +        return this.attributes.get(name);
       }
   
  +    public void setAttribute(String name, Object value) {
  +        getLogger().debug("CommandlineContext: setAttribute=" + name);
  +        this.attributes.put(name, value);
  +    }
  +    
  +    public void removeAttribute(String name) {
  +        getLogger().debug("CommandlineContext: removeAttribute=" + name);
  +        this.attributes.remove(name);
  +    }
  +    
  +    public Enumeration getAttributeNames() {
  +        getLogger().debug("CommandlineContext: getAttributeNames");
  +        return new IteratorEnumeration(this.attributes.keySet().iterator());
  +    }
  +
       public URL getResource(String path) throws MalformedURLException {
           getLogger().debug("CommandlineContext: getResource=" + path);
           //return servletContext.getResource(path);
           return new URL("file:" + this.contextDir + path);
       }
   
  -    public String getRealPath(String path) throws MalformedURLException {
  +    public String getRealPath(String path) {
           getLogger().debug("CommandlineContext: getRealPath=" + path);
           //return servletContext.getRealPath(path);
           return this.contextDir + path;
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.1.1.2.6 +17 -0     xml-cocoon2/src/org/apache/cocoon/environment/http/HttpContext.java
  
  Index: HttpContext.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/http/HttpContext.java,v
  retrieving revision 1.1.1.1.2.5
  retrieving revision 1.1.1.1.2.6
  diff -u -r1.1.1.1.2.5 -r1.1.1.1.2.6
  --- HttpContext.java	2001/10/11 08:56:11	1.1.1.1.2.5
  +++ HttpContext.java	2001/10/17 09:07:38	1.1.1.1.2.6
  @@ -12,6 +12,7 @@
   import javax.servlet.ServletContext;
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.util.Enumeration;
   
   /**
    *
  @@ -34,6 +35,18 @@
           return servletContext.getAttribute(name);
       }
   
  +    public void setAttribute(String name, Object value) {
  +        servletContext.setAttribute(name, value);
  +    }
  +    
  +    public void removeAttribute(String name) {
  +        servletContext.removeAttribute(name);
  +    }
  +    
  +    public Enumeration getAttributeNames() {
  +        return servletContext.getAttributeNames();
  +    }
  +
       public URL getResource(String path)
          throws MalformedURLException {
          return servletContext.getResource(path);
  @@ -45,7 +58,11 @@
               String value = servletContext.getRealPath(path);
               if (value == null) {
                   // Try to figure out the path of the root from that of WEB-INF
  +                try {
                   value = this.servletContext.getResource("/WEB-INF").toString();
  +                } catch (MalformedURLException mue) {
  +                    throw new RuntimeException("Cannot determine the base URL");
  +                }
                   value = value.substring(0,value.length()-"WEB-INF".length());
               }
               return value;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message