cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject svn commit: rev 35754 - in cocoon/branches/butterfly/src: java/org/apache/butterfly/servlet java/org/apache/butterfly/source webapp
Date Thu, 05 Aug 2004 21:59:57 GMT
Author: ugo
Date: Thu Aug  5 14:59:56 2004
New Revision: 35754

Modified:
   cocoon/branches/butterfly/src/java/org/apache/butterfly/servlet/ButterflyServlet.java
   cocoon/branches/butterfly/src/java/org/apache/butterfly/source/SourceResolver.java
   cocoon/branches/butterfly/src/webapp/sitemap.groovy
Log:
Contextualized the sourceresolver

Modified: cocoon/branches/butterfly/src/java/org/apache/butterfly/servlet/ButterflyServlet.java
==============================================================================
--- cocoon/branches/butterfly/src/java/org/apache/butterfly/servlet/ButterflyServlet.java
(original)
+++ cocoon/branches/butterfly/src/java/org/apache/butterfly/servlet/ButterflyServlet.java
Thu Aug  5 14:59:56 2004
@@ -18,6 +18,7 @@
 import groovy.lang.GroovyClassLoader;
 import groovy.lang.GroovyObject;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -31,6 +32,7 @@
 
 import org.apache.butterfly.environment.Environment;
 import org.apache.butterfly.environment.http.HttpEnvironment;
+import org.apache.butterfly.source.SourceResolver;
 import org.apache.commons.lang.BooleanUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -65,6 +67,13 @@
         */
         this.containerEncoding = "ISO-8859-1";
         this.defaultFormEncoding = "ISO-8859-1";
+        // Contextualize the source resolver
+        SourceResolver resolver = (SourceResolver) this.applicationContext.getBean("sourceResolver");
+        try {
+            resolver.setBaseURL(new File(servletContext.getRealPath("/")).toURL());
+        } catch (MalformedURLException e) {
+            throw new ServletException(e);
+        }
     }
     
     /* (non-Javadoc)

Modified: cocoon/branches/butterfly/src/java/org/apache/butterfly/source/SourceResolver.java
==============================================================================
--- cocoon/branches/butterfly/src/java/org/apache/butterfly/source/SourceResolver.java	(original)
+++ cocoon/branches/butterfly/src/java/org/apache/butterfly/source/SourceResolver.java	Thu
Aug  5 14:59:56 2004
@@ -32,11 +32,17 @@
     
     public SourceResolver() {
         try {
-            // TODO: contextualize it
             baseURL = new File(System.getProperty("user.dir")).toURL();
         } catch (MalformedURLException e) {
             throw new SourceException(e);
         }
+    }
+    
+    /**
+     * @param baseURL The baseURL to set.
+     */
+    public void setBaseURL(URL baseURL) {
+        this.baseURL = baseURL;
     }
     
     /**

Modified: cocoon/branches/butterfly/src/webapp/sitemap.groovy
==============================================================================
--- cocoon/branches/butterfly/src/webapp/sitemap.groovy	(original)
+++ cocoon/branches/butterfly/src/webapp/sitemap.groovy	Thu Aug  5 14:59:56 2004
@@ -17,18 +17,18 @@
   
     boolean setup(String requestPath) {
         if (requestPath == "") {
-            generate "build/webapp/welcome.xml"
-            transform "trax", "build/webapp/welcome.xslt" 
+            generate "welcome.xml"
+            transform "trax", "welcome.xslt" 
             serialize "xml"
         } else if (m = (requestPath =~ "(.*)\.html")) {
             // TODO: paths should be relative to the webapp context!
-            generate "build/webapp/" + m.group(1) + ".xml"
-            transform "trax", "build/webapp/welcome.xslt" 
+            generate m.group(1) + ".xml"
+            transform "trax", "welcome.xslt" 
             serialize "xml"
         } else if (m = (requestPath =~ "images/(.*)\.gif")) {
-            read "build/webapp/resources/images/" + m.group(1) + ".gif", "image/gif"
+            read "resources/images/" + m.group(1) + ".gif", "image/gif"
         } else if (m = (requestPath =~ "styles/(.*)\.css")) {
-            read "build/webapp/resources/styles/" + m.group(1) + ".css", "text/css"
+            read "resources/styles/" + m.group(1) + ".css", "text/css"
         } else {
             return false;
         }

Mime
View raw message