cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/servlet CocoonServlet.java
Date Fri, 25 May 2001 22:00:51 GMT
dims        01/05/25 15:00:50

  Modified:    src/org/apache/cocoon Cocoon.java Constants.java Main.java
               src/org/apache/cocoon/servlet CocoonServlet.java
  Log:
  - Remove CONTEXT_ROOT_PATH
  - Figure out what to do if getRealPath fails (WebLogic/WAR deployment)
  
  Revision  Changes    Path
  1.4       +5 -4      xml-cocoon2/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Cocoon.java	2001/05/25 14:25:58	1.3
  +++ Cocoon.java	2001/05/25 22:00:46	1.4
  @@ -53,7 +53,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
(Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/05/25 14:25:58 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/05/25 22:00:46 $
    */
   public class Cocoon extends AbstractLoggable implements ThreadSafe, Component, Initializable,
Disposable, Modifiable, Processor, Contextualizable {
       /** The application context */
  @@ -196,9 +196,10 @@
               try {
                   p = (Parser)this.componentManager.lookup(Roles.PARSER);
                   SAXConfigurationHandler b = new SAXConfigurationHandler();
  -                ClassLoader cl = (ClassLoader) this.context.get(Constants.CONTEXT_CLASS_LOADER);
  -                File location = new File(new File((String)this.context.get(Constants.CONTEXT_ROOT_PATH)),
userRoles);
  -                InputSource is = new InputSource(new BufferedInputStream(new FileInputStream(location)));
  +                org.apache.cocoon.environment.Context context = 
  +                    (org.apache.cocoon.environment.Context) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
  +                URL url = context.getResource(userRoles);
  +                InputSource is = new InputSource(new BufferedInputStream(url.openStream()));
                   p.setContentHandler(b);
                   is.setSystemId(this.configurationFile.toExternalForm());
                   p.parse(is);
  
  
  
  1.4       +1 -2      xml-cocoon2/src/org/apache/cocoon/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Constants.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Constants.java	2001/05/25 14:25:58	1.3
  +++ Constants.java	2001/05/25 22:00:47	1.4
  @@ -10,7 +10,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/05/25 14:25:58 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/05/25 22:00:47 $
    */
   
   public interface Constants {
  @@ -59,7 +59,6 @@
       String ERROR_NAMESPACE_PREFIX = "error";
   
       String CONTEXT_ENVIRONMENT_CONTEXT = "environment-context";
  -    String CONTEXT_ROOT_PATH       = "root-path";
       String CONTEXT_CLASS_LOADER    = "class-loader";
       String CONTEXT_WORK_DIR        = "work-directory";
       String CONTEXT_UPLOAD_DIR      = "upload-directory";
  
  
  
  1.3       +1 -2      xml-cocoon2/src/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java	2001/05/14 08:38:25	1.2
  +++ Main.java	2001/05/25 22:00:47	1.3
  @@ -47,7 +47,7 @@
    * Command line entry point.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/05/14 08:38:25 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/05/25 22:00:47 $
    */
   
   public class Main {
  @@ -214,7 +214,6 @@
               appContext.put(Constants.CONTEXT_WORK_DIR, work);
               appContext.put(Constants.CONTEXT_UPLOAD_DIR, contextDir + "image-dir");
               appContext.put(Constants.CONTEXT_CONFIG_URL, conf.toURL());
  -            appContext.put(Constants.CONTEXT_ROOT_PATH, contextDir);
               Cocoon c = new Cocoon();
               c.setLogger(log);
               c.contextualize(appContext);
  
  
  
  1.8       +24 -8     xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CocoonServlet.java	2001/05/25 16:01:48	1.7
  +++ CocoonServlet.java	2001/05/25 22:00:50	1.8
  @@ -57,7 +57,7 @@
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/05/25 16:01:48 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/05/25 22:00:50 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -142,9 +142,6 @@
           this.appContext.put(Constants.CONTEXT_CONFIG_URL,
                   this.getConfigFile(conf.getInitParameter("configurations"), this.servletContext));
   
  -        if(this.servletContext.getRealPath("/") != null)
  -            this.appContext.put(Constants.CONTEXT_ROOT_PATH, this.servletContext.getRealPath("/"));
  -
           // get allow reload parameter, default is true
           String value = conf.getInitParameter("allow-reload");
           this.allowReload = (value == null || value.equals("yes") || value.equals("true"));
  @@ -273,7 +270,10 @@
           }
   
           if (logDir == null) {
  -            logDir = context.getRealPath("/") + "/WEB-INF/logs/";
  +            if(context.getRealPath("/") != null)
  +                logDir = context.getRealPath("/") + "/WEB-INF/logs/";
  +            else
  +                logDir = "./WEB-INF/logs/";
           }
   
           this.appContext.put(Constants.CONTEXT_LOG_DIR, logDir);
  @@ -534,10 +534,26 @@
                                          HttpServletResponse res)
       throws Exception {
           HttpEnvironment env;
  -
  -        File root = new File(this.servletContext.getRealPath("/"));
  +        URL url = null;
  +        
  +        String path = this.servletContext.getRealPath("/");
  +        log.debug("getRealPath for /: " + path);
  +        if(path == null) {
  +            // Try to figure out the path of the root from that of WEB-INF
  +            path = this.servletContext.getRealPath("/WEB-INF");
  +            log.debug("getRealPath for /WEB-INF: " + path);
  +            path = path.substring(0,path.length()-"WEB-INF".length());
  +            log.debug("Path for Root: " + path);
  +        }
  +        
  +        if(path.indexOf(':')>1)
  +            url = new URL(path);
  +        else 
  +            url = (new File(path)).toURL();
  +        log.debug("URL for Root: " + url);
  +        
           env = new HttpEnvironment(uri,
  -                                  root.toURL(),                                
  +                                  url,                                
                                     req,
                                     res,
                                     this.servletContext,
  
  
  

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