You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/02/27 11:27:59 UTC

svn commit: r381310 - in /cocoon/trunk: cocoon-blocks-fw/cocoon-blocks-fw-servlet-impl/src/main/java/org/apache/cocoon/blocks/servlet/ cocoon-core/src/main/java/org/apache/cocoon/bean/ cocoon-core/src/main/java/org/apache/cocoon/core/ cocoon-core/src/m...

Author: cziegeler
Date: Mon Feb 27 02:27:58 2006
New Revision: 381310

URL: http://svn.apache.org/viewcvs?rev=381310&view=rev
Log:
Refactor core to make the BootstrapEnvironment optional

Modified:
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-servlet-impl/src/main/java/org/apache/cocoon/blocks/servlet/BlocksManager.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/bean/CocoonWrapper.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/BootstrapEnvironment.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java
    cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java
    cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestBootstrapEnvironment.java
    cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java
    cocoon/trunk/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-servlet-impl/src/main/java/org/apache/cocoon/blocks/servlet/BlocksManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-servlet-impl/src/main/java/org/apache/cocoon/blocks/servlet/BlocksManager.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-servlet-impl/src/main/java/org/apache/cocoon/blocks/servlet/BlocksManager.java (original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-servlet-impl/src/main/java/org/apache/cocoon/blocks/servlet/BlocksManager.java Mon Feb 27 02:27:58 2006
@@ -49,8 +49,6 @@
 import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.components.source.SourceUtil;
 import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
-import org.apache.cocoon.core.MutableSettings;
-import org.apache.cocoon.core.container.spring.BeanFactoryUtil;
 import org.apache.cocoon.core.servlet.CoreUtil;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.impl.URLSource;

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/bean/CocoonWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/bean/CocoonWrapper.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/bean/CocoonWrapper.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/bean/CocoonWrapper.java Mon Feb 27 02:27:58 2006
@@ -19,8 +19,6 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -40,7 +38,6 @@
 import org.apache.cocoon.core.BootstrapEnvironment;
 import org.apache.cocoon.core.CoreUtil;
 import org.apache.cocoon.core.MutableSettings;
-import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.commandline.CommandLineContext;
 import org.apache.cocoon.environment.commandline.FileSavingEnvironment;
@@ -111,17 +108,15 @@
 
         WrapperBootstrapper env = this.getBootstrapEnvironment();
         env.setContextDirectory(contextDir);
-        env.setEnvironmentLogger(this.log);
-        env.setEnvironmentContext(cliContext);
         env.setWorkingDirectory(this.work);
         env.setCachingDirectory(cacheDir);
         env.setBootstrapLogLevel(this.logLevel);
         env.setLoggingConfiguration(this.logKit);
         env.setConfigFile(this.conf);
         env.setLoadClassList(this.classList);
-        this.coreUtil = new CoreUtil(env, cliContext);
+        this.coreUtil = new CoreUtil(cliContext, env);
         this.cocoon = this.coreUtil.createCocoon();
-        this.log = env.logger;
+        this.log = this.coreUtil.getRootLogger();
         this.initialized = true;
     }
 
@@ -571,10 +566,7 @@
      */
     public static class WrapperBootstrapper implements BootstrapEnvironment {
 
-        public Logger logger;
-
         protected Logger environmentLogger;
-        protected Context environmentContext;
         protected String workingDirectory;
         protected String bootstrapLogLevel;
         protected String loggingConfiguration;
@@ -583,14 +575,6 @@
         protected String configFile;
         protected List loadClassList;
 
-        public void setEnvironmentLogger(Logger log) {
-            this.environmentLogger = log;
-        }
-
-        public void setEnvironmentContext(Context context) {
-            this.environmentContext = context;
-        }
-
         public void setWorkingDirectory(File dir) {
             this.workingDirectory = dir.getAbsolutePath();
         }
@@ -644,37 +628,5 @@
                 }
             }
         }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getConfigFile(java.lang.String)
-         */
-        public URL getConfigFile(String configFileName) throws Exception {
-            return new File(configFileName).toURL();
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getContextURL()
-         */
-        public String getContextURL() {
-            try {
-                return new File(this.contextDirectory).toURL().toExternalForm();
-            } catch (MalformedURLException mue) {
-                return "file://" + this.contextDirectory;
-            }
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getEnvironmentContext()
-         */
-        public Context getEnvironmentContext() {
-            return this.environmentContext;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#setLogger(org.apache.avalon.framework.logger.Logger)
-         */
-        public void setLogger(Logger rootLogger) {
-            this.logger = rootLogger;
-        }        
     }
 }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/BootstrapEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/BootstrapEnvironment.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/BootstrapEnvironment.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/BootstrapEnvironment.java Mon Feb 27 02:27:58 2006
@@ -16,16 +16,13 @@
  */
 package org.apache.cocoon.core;
 
-import java.net.URL;
-
 import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.Logger;
 
 /**
- * The BootstrapEnvironment is the connection between the real environment
- * (servlet, cli etc.) and the Cocoon core. The core uses this object to
- * access information from the real environment and to pass several objects
- * back.
+ * The BootstrapEnvironment is an optional hook for the real environment
+ * (servlet, cli etc.) to provide additional information to the Cocoon core.
+ * The core uses this object to access information from the real environment
+ * like configuration and settings.
  * A BootstrapEnvironment can be used to create a new Cocoon system using
  * the {@link CoreUtil}.
  * 
@@ -35,13 +32,6 @@
 public interface BootstrapEnvironment {
 
     /**
-     * Pass the root logger back to the environment. As soon as the
-     * logging system is set up, this method is called.
-     * @param rootLogger The root logger.
-     */
-    void setLogger(Logger rootLogger);
-
-    /**
      * This callback can be used by the environment to add environment specific
      * settings. For example the servlet environment parsed the web.xml and adjusts
      * the settings based on the parameters.
@@ -55,25 +45,4 @@
      * @param context The context passed to all Avalon based components that are context aware.
      */
     void configure(DefaultContext context);
-
-    /**
-     * Create the context object of the environment.
-     * @return The context object.
-     */
-    org.apache.cocoon.environment.Context getEnvironmentContext();
-
-    /**
-     * Returns the URL to the application context.
-     */
-    String getContextURL();
-
-    /**
-     * Set the ConfigFile for the Cocoon object.
-     *
-     * @param configFileName The file location for the cocoon.xconf
-     *
-     * @throws Exception
-     */
-    URL getConfigFile(String configFileName)
-    throws Exception;
 }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java Mon Feb 27 02:27:58 2006
@@ -31,8 +31,6 @@
 import java.util.Map;
 import java.util.Properties;
 
-import javax.servlet.ServletContext;
-
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
@@ -52,6 +50,7 @@
 import org.apache.cocoon.core.container.util.ComponentContext;
 import org.apache.cocoon.core.container.util.ConfigurationBuilder;
 import org.apache.cocoon.core.container.util.SimpleSourceResolver;
+import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.util.ClassUtils;
 import org.apache.cocoon.util.StringUtils;
 import org.apache.cocoon.util.location.Location;
@@ -95,8 +94,8 @@
     /** The core object. */
     protected Core core;
 
-    /** The servlet context. */
-    protected final ServletContext servletContext;
+    /** The environment context. */
+    protected final Context environmentContext;
 
     /** The container. */
     protected ConfigurableBeanFactory container;
@@ -155,13 +154,24 @@
     
     /**
      * Setup a new instance.
-     * @param environment The hook back to the environment.
+     * @param context     The environment context.
+     * @throws Exception
+     */
+    public CoreUtil(Context              context)
+    throws Exception {
+        this(context, null);
+    }
+
+    /**
+     * Setup a new instance.
+     * @param context     The environment context.
+     * @param environment The optional hook back to the environment.
      * @throws Exception
      */
-    public CoreUtil(BootstrapEnvironment environment,
-                    ServletContext context)
+    public CoreUtil(Context              context,
+                    BootstrapEnvironment environment)
     throws Exception {
-        this.servletContext = context;
+        this.environmentContext = context;
         this.env = environment;
         this.init();
     }
@@ -174,17 +184,19 @@
         // add root url
         try {
             appContext.put(ContextHelper.CONTEXT_ROOT_URL,
-                           new URL(this.env.getContextURL()));
+                           new URL(this.getContextUrl()));
         } catch (MalformedURLException ignore) {
             // we simply ignore this
         }
 
         // add environment context
         this.appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT,
-                            this.env.getEnvironmentContext());
+                            this.environmentContext);
 
         // now add environment specific information
-        this.env.configure(appContext);
+        if ( this.env != null ) {
+            this.env.configure(appContext);
+        }
 
         // create settings
         this.settings = this.createSettings();
@@ -204,13 +216,12 @@
         this.settings.setWorkDirectory(workDir.getAbsolutePath());
 
         // Init logger
-        this.log = BeanFactoryUtil.createRootLogger(servletContext,
-                                                              this.settings);
-        this.env.setLogger(this.log);
+        this.log = BeanFactoryUtil.createRootLogger(this.environmentContext,
+                                                    this.settings);
 
         // Output some debug info
         if (this.log.isDebugEnabled()) {
-            this.log.debug("Context URL: " + this.env.getContextURL());
+            this.log.debug("Context URL: " + this.getContextUrl());
             if (workDirParam != null) {
                 this.log.debug("Using work-directory " + workDir);
             } else {
@@ -257,7 +268,7 @@
         this.settings.setCacheDirectory(cacheDir.getAbsolutePath());
 
         // update configuration
-        final URL u = this.env.getConfigFile(this.settings.getConfiguration());
+        final URL u = this.getConfigFile(this.settings.getConfiguration());
         this.settings.setConfiguration(u.toExternalForm());
         this.appContext.put(Constants.CONTEXT_CONFIG_URL, u);
 
@@ -288,6 +299,10 @@
         return this.core;
     }
 
+    public Logger getRootLogger() {
+        return this.log;
+    }
+
     /**
      * Create a new core instance.
      * This method can be overwritten in sub classes.
@@ -326,13 +341,13 @@
     protected MutableSettings createSettings() {
         // get the running mode
         final String mode = System.getProperty(Settings.PROPERTY_RUNNING_MODE, Settings.DEFAULT_RUNNING_MODE);
-        this.servletContext.log("Running in mode: " + mode);
+        this.environmentContext.log("Running in mode: " + mode);
 
         // create an empty settings objects
         final MutableSettings s = new MutableSettings();
 
         // we need our own resolver
-        final SourceResolver resolver = this.createSourceResolver(new LoggerWrapper(this.servletContext));
+        final SourceResolver resolver = this.createSourceResolver(new LoggerWrapper(this.environmentContext));
 
         // now read all properties from the properties directory
         this.readProperties("context://WEB-INF/properties", s, resolver);
@@ -347,12 +362,14 @@
                 PropertyProvider provider = (PropertyProvider)ClassUtils.newInstance(className);
                 s.fill(provider.getProperties());
             } catch (Exception ignore) {
-                this.servletContext.log("Unable to get property provider for class " + className, ignore);
-                this.servletContext.log("Continuing initialization.");            
+                this.environmentContext.log("Unable to get property provider for class " + className, ignore);
+                this.environmentContext.log("Continuing initialization.");            
             }
         }
         // fill from the environment configuration, like web.xml etc.
-        env.configure(s);
+        if ( this.env != null ) {
+            env.configure(s);
+        }
 
         // read additional properties file
         String additionalPropertyFile = s.getProperty(Settings.PROPERTY_USER_SETTINGS, 
@@ -366,15 +383,15 @@
             }
         }
         if ( additionalPropertyFile != null ) {
-            this.servletContext.log("Reading user settings from '" + additionalPropertyFile + "'");
+            this.environmentContext.log("Reading user settings from '" + additionalPropertyFile + "'");
             final Properties p = new Properties();
             try {
                 FileInputStream fis = new FileInputStream(additionalPropertyFile);
                 p.load(fis);
                 fis.close();
             } catch (IOException ignore) {
-                this.servletContext.log("Unable to read '" + additionalPropertyFile + "'.", ignore);
-                this.servletContext.log("Continuing initialization.");
+                this.environmentContext.log("Unable to read '" + additionalPropertyFile + "'.", ignore);
+                this.environmentContext.log("Continuing initialization.");
             }
         }
         // now overwrite with system properties
@@ -417,7 +434,7 @@
                     final Source src = (Source) c.next();
                     if ( src.getURI().endsWith(".properties") ) {
                         final InputStream propsIS = src.getInputStream();
-                        this.servletContext.log("Reading settings from '" + src.getURI() + "'.");
+                        this.environmentContext.log("Reading settings from '" + src.getURI() + "'.");
                         final Properties p = new Properties();
                         p.load(propsIS);
                         propsIS.close();
@@ -426,8 +443,8 @@
                 }
             }
         } catch (IOException ignore) {
-            this.servletContext.log("Unable to read from directory 'WEB-INF/properties'.", ignore);
-            this.servletContext.log("Continuing initialization.");            
+            this.environmentContext.log("Unable to read from directory 'WEB-INF/properties'.", ignore);
+            this.environmentContext.log("Continuing initialization.");            
         } finally {
             resolver.release(directory);
         }
@@ -617,7 +634,7 @@
         env.context = this.appContext;
         env.core = this.core;
         env.logger = this.log;
-        env.servletContext = this.env.getEnvironmentContext();
+        env.servletContext = this.environmentContext;
         env.settings = this.core.getSettings();
         ConfigurableBeanFactory rootContext = BeanFactoryUtil.createRootApplicationContext(env);
         ConfigurationInfo result = ConfigReader.readConfiguration(settings.getConfiguration(), env);
@@ -625,6 +642,93 @@
 
         return mainContext;
     }
+    /**
+     * @see org.apache.cocoon.core.BootstrapEnvironment#getConfigFile(java.lang.String)
+     */
+    protected URL getConfigFile(final String configFileName)
+    throws Exception {
+        final String usedFileName;
+
+        if (configFileName == null) {
+            if (this.log.isWarnEnabled()) {
+                this.log.warn("No configuration for Cocoon configuration file specified, attempting to use '/WEB-INF/cocoon.xconf'");
+            }
+            usedFileName = "/WEB-INF/cocoon.xconf";
+        } else {
+            usedFileName = configFileName;
+        }
+
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("Using configuration file: " + usedFileName);
+        }
+
+        URL result;
+        try {
+            // test if this is a qualified url
+            if (usedFileName.indexOf(':') == -1) {
+                result = this.environmentContext.getResource(usedFileName);
+            } else {
+                result = new URL(usedFileName);
+            }
+        } catch (Exception mue) {
+            String msg = "Setting for 'configurations' is invalid : " + usedFileName;
+            this.log.error(msg, mue);
+            throw new CoreInitializationException(msg, mue);
+        }
+
+        if (result == null) {
+            File resultFile = new File(usedFileName);
+            if (resultFile.isFile()) {
+                try {
+                    result = resultFile.getCanonicalFile().toURL();
+                } catch (Exception e) {
+                    String msg = "Init parameter 'configurations' is invalid : " + usedFileName;
+                    this.log.error(msg, e);
+                    throw new CoreInitializationException(msg, e);
+                }
+            }
+        }
+
+        if (result == null) {
+            String msg = "Init parameter 'configuration' doesn't name an existing resource : " + usedFileName;
+            this.log.error(msg);
+            throw new CoreInitializationException(msg);
+        }
+        return result;
+    }
+
+    protected String getContextUrl() {
+        String servletContextURL;
+        String servletContextPath = this.environmentContext.getRealPath("/");
+        String path = servletContextPath;
+
+        if (path == null) {
+            // Try to figure out the path of the root from that of WEB-INF/web.xml
+            try {
+                path = this.environmentContext.getResource("/WEB-INF/web.xml").toString();
+            } catch (MalformedURLException me) {
+                throw new CoreInitializationException("Unable to get resource 'WEB-INF/web.xml'.", me);
+            }
+            path = path.substring(0, path.length() - "WEB-INF/web.xml".length());
+        }
+        try {
+            if (path.indexOf(':') > 1) {
+                servletContextURL = path;
+            } else {
+                servletContextURL = new File(path).toURL().toExternalForm();
+            }
+        } catch (MalformedURLException me) {
+            // VG: Novell has absolute file names starting with the
+            // volume name which is easily more then one letter.
+            // Examples: sys:/apache/cocoon or sys:\apache\cocoon
+            try {
+                servletContextURL = new File(path).toURL().toExternalForm();
+            } catch (MalformedURLException ignored) {
+                throw new CoreInitializationException("Unable to determine servlet context URL.", me);
+            }
+        }
+        return servletContextURL;
+    }
 
     /**
      * Handle the <code>load-class</code> parameter. This overcomes
@@ -739,9 +843,9 @@
     }
 
     protected static final class LoggerWrapper implements Logger {
-        private final ServletContext env;
+        private final Context env;
 
-        public LoggerWrapper(ServletContext env) {
+        public LoggerWrapper(Context env) {
             this.env = env;
         }
 

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java Mon Feb 27 02:27:58 2006
@@ -52,7 +52,6 @@
      * and HttpServletResponse objects
      */
     public HttpEnvironment(String uri,
-                           String root,
                            HttpServletRequest req,
                            HttpServletResponse res,
                            ServletContext servletContext,

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java Mon Feb 27 02:27:58 2006
@@ -17,8 +17,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.HashMap;
 
 import javax.servlet.ServletConfig;
@@ -86,18 +84,6 @@
     protected ServletContext servletContext;
 
     /**
-     * This is the path to the servlet context (or the result
-     * of calling getRealPath('/') on the ServletContext.
-     * Note, that this can be null.
-     */
-    protected String servletContextPath;
-
-    /**
-     * This is the url to the servlet context directory
-     */
-    protected String servletContextURL;
-
-    /**
      * The RequestFactory is responsible for wrapping multipart-encoded
      * forms and for handing the file payload of incoming requests
      */
@@ -130,60 +116,13 @@
 
         super.init(conf);
 
-        this.servletContextPath = this.servletContext.getRealPath("/");
-        String path = this.servletContextPath;
-        // these two variables are just for debugging. We can't log at this point
-        // as the logger isn't initialized yet.
-        String debugPathOne = null, debugPathTwo = null;
-        if (path == null) {
-            // Try to figure out the path of the root from that of WEB-INF/web.xml
-            try {
-                path = this.servletContext.getResource("/WEB-INF/web.xml").toString();
-            } catch (MalformedURLException me) {
-                throw new ServletException("Unable to get resource 'WEB-INF/web.xml'.", me);
-            }
-            debugPathOne = path;
-            path = path.substring(0, path.length() - "WEB-INF/web.xml".length());
-            debugPathTwo = path;
-        }
-        try {
-            if (path.indexOf(':') > 1) {
-                this.servletContextURL = path;
-            } else {
-                this.servletContextURL = new File(path).toURL().toExternalForm();
-            }
-        } catch (MalformedURLException me) {
-            // VG: Novell has absolute file names starting with the
-            // volume name which is easily more then one letter.
-            // Examples: sys:/apache/cocoon or sys:\apache\cocoon
-            try {
-                this.servletContextURL = new File(path).toURL().toExternalForm();
-            } catch (MalformedURLException ignored) {
-                throw new ServletException("Unable to determine servlet context URL.", me);
-            }
-        }
-
-        try {
-            // FIXME (VG): We shouldn't have to specify these. Need to override
-            // jaxp implementation of weblogic before initializing logger.
-            // This piece of code is also required in the Cocoon class.
-            String value = System.getProperty("javax.xml.parsers.SAXParserFactory");
-            if (value != null && value.startsWith("weblogic")) {
-                System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
-                System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
-            }
-        } catch (Exception e) {
-            // Ignore security exception
-            this.servletContext.log("CocoonServlet: Could not check system properties, got: " + e);
-        }
-
         // initialize settings
-        ServletBootstrapEnvironment env = new ServletBootstrapEnvironment(conf, this.servletContextURL);
+        ServletBootstrapEnvironment env = new ServletBootstrapEnvironment(conf);
 
         try {
-            this.coreUtil = new CoreUtil(env, this.servletContext);
-            this.environmentContext = env.getEnvironmentContext();
-            this.log = env.logger;
+            this.environmentContext = new HttpContext(conf.getServletContext());
+            this.coreUtil = new CoreUtil(this.environmentContext, env);
+            this.log = this.coreUtil.getRootLogger();
         } catch (Exception e) {
             if ( e instanceof ServletException ) {
                 throw (ServletException)e;
@@ -191,15 +130,6 @@
             throw new ServletException(e);
         }
 
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug(this.coreUtil.getSettings().toString());
-            getLogger().debug("getRealPath for /: " + this.servletContextPath);
-            if (this.servletContextPath == null) {
-                getLogger().debug("getResource for /WEB-INF: " + debugPathOne);
-                getLogger().debug("Path for Root: " + debugPathTwo);
-            }
-        }
-
         this.containerEncoding = this.getInitParameter("container-encoding", "ISO-8859-1");
         this.requestFactory = new RequestFactory(coreUtil.getSettings().isAutosaveUploads(),
                                                  new File(coreUtil.getCore().getSettings().getUploadDirectory()),
@@ -528,7 +458,6 @@
             formEncoding = this.coreUtil.getSettings().getFormEncoding();
         }
         env = new HttpEnvironment(uri,
-                                  this.servletContextURL,
                                   req,
                                   res,
                                   this.servletContext,
@@ -593,22 +522,9 @@
         implements BootstrapEnvironment {
 
         private final ServletConfig config;
-        private final String contextPath;
-        public Logger logger;
-        private final HttpContext environmentContext;
 
-        public ServletBootstrapEnvironment(ServletConfig config, 
-                                           String path) {
+        public ServletBootstrapEnvironment(ServletConfig config) {
             this.config = config;
-            this.contextPath = path;
-            this.environmentContext = new HttpContext(this.config.getServletContext());
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#setLogger(org.apache.avalon.framework.logger.Logger)
-         */
-        public void setLogger(Logger rootLogger) {
-            this.logger = rootLogger;
         }
 
         /**
@@ -627,241 +543,10 @@
         }
 
         /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getEnvironmentContext()
-         */
-        public Context getEnvironmentContext() {
-            return this.environmentContext;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getContextURL()
-         */
-        public String getContextURL() {
-            return this.contextPath;
-        }
-
-        /**
          * @see org.apache.cocoon.core.BootstrapEnvironment#configure(org.apache.avalon.framework.context.DefaultContext)
          */
         public void configure(DefaultContext context) {
             context.put(CONTEXT_SERVLET_CONFIG, this.config);
         }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getConfigFile(java.lang.String)
-         */
-        public URL getConfigFile(final String configFileName)
-        throws Exception {
-            final String usedFileName;
-
-            if (configFileName == null) {
-                if (this.logger.isWarnEnabled()) {
-                    this.logger.warn("Servlet initialization argument 'configurations' not specified, attempting to use '/WEB-INF/cocoon.xconf'");
-                }
-                usedFileName = "/WEB-INF/cocoon.xconf";
-            } else {
-                usedFileName = configFileName;
-            }
-
-            if (this.logger.isDebugEnabled()) {
-                this.logger.debug("Using configuration file: " + usedFileName);
-            }
-
-            URL result;
-            try {
-                // test if this is a qualified url
-                if (usedFileName.indexOf(':') == -1) {
-                    result = this.config.getServletContext().getResource(usedFileName);
-                } else {
-                    result = new URL(usedFileName);
-                }
-            } catch (Exception mue) {
-                String msg = "Init parameter 'configurations' is invalid : " + usedFileName;
-                this.logger.error(msg, mue);
-                throw new ServletException(msg, mue);
-            }
-
-            if (result == null) {
-                File resultFile = new File(usedFileName);
-                if (resultFile.isFile()) {
-                    try {
-                        result = resultFile.getCanonicalFile().toURL();
-                    } catch (Exception e) {
-                        String msg = "Init parameter 'configurations' is invalid : " + usedFileName;
-                        this.logger.error(msg, e);
-                        throw new ServletException(msg, e);
-                    }
-                }
-            }
-
-            if (result == null) {
-                String msg = "Init parameter 'configuration' doesn't name an existing resource : " + usedFileName;
-                this.logger.error(msg);
-                throw new ServletException(msg);
-            }
-            return result;
-        }
-
-// (RP) comment this stuff out as it isn't used any more except in the StatusGenerator and I also think it returns wrong information
-//      under some circumstances.
-//        /**
-//         * This builds the important ClassPath used by this Servlet.  It
-//         * does so in a Servlet Engine neutral way.  It uses the
-//         * <code>ServletContext</code>'s <code>getRealPath</code> method
-//         * to get the Servlet 2.2 identified classes and lib directories.
-//         * It iterates in alphabetical order through every file in the
-//         * lib directory and adds it to the classpath.
-//         *
-//         * Also, we add the files to the ClassLoader for the Cocoon system.
-//         * In order to protect ourselves from skitzofrantic classloaders,
-//         * we need to work with a known one.
-//         *
-//         * We need to get this to work properly when Cocoon is in a war.
-//         *
-//         */
-//        public String getClassPath(Settings settings) {
-//            StringBuffer buildClassPath = new StringBuffer();
-//
-//            File root = null;
-//            if (this.getContextForWriting() != null) {
-//                // Old method.  There *MUST* be a better method than this...
-//
-//                String classDir = this.config.getServletContext().getRealPath("/WEB-INF/classes");
-//                String libDir = this.config.getServletContext().getRealPath("/WEB-INF/lib");
-//
-//                if (libDir != null) {
-//                    root = new File(libDir);
-//                }
-//
-//                if (classDir != null) {
-//                    buildClassPath.append(classDir);
-//                }
-//            } else {
-//                // New(ish) method for war'd deployments
-//                URL classDirURL = null;
-//                URL libDirURL = null;
-//
-//                try {
-//                    classDirURL = this.config.getServletContext().getResource("/WEB-INF/classes");
-//                } catch (MalformedURLException me) {
-//                    this.logger.warn("Unable to add WEB-INF/classes to the classpath", me);
-//                }
-//
-//                try {
-//                    libDirURL = this.config.getServletContext().getResource("/WEB-INF/lib");
-//                } catch (MalformedURLException me) {
-//                    this.logger.warn("Unable to add WEB-INF/lib to the classpath", me);
-//                }
-//
-//                if (libDirURL != null && libDirURL.toExternalForm().startsWith("file:")) {
-//                    root = new File(libDirURL.toExternalForm().substring("file:".length()));
-//                }
-//
-//                if (classDirURL != null) {
-//                    buildClassPath.append(classDirURL.toExternalForm());
-//                }
-//            }
-//
-//            // Unable to find lib directory. Going the hard way.
-//            if (root == null) {
-//                root = this.extractLibraries(settings);
-//            }
-//
-//            if (root != null && root.isDirectory()) {
-//                File[] libraries = root.listFiles();
-//                Arrays.sort(libraries);
-//                for (int i = 0; i < libraries.length; i++) {
-//                    String fullName = IOUtils.getFullFilename(libraries[i]);
-//                    buildClassPath.append(File.pathSeparatorChar).append(fullName);
-//                }
-//            }
-//
-//            buildClassPath.append(File.pathSeparatorChar)
-//                          .append(SystemUtils.JAVA_CLASS_PATH);
-//
-//            return buildClassPath.toString();
-//        }
-// 
-//        private File extractLibraries(Settings settings) {
-//            try {
-//                URL manifestURL = this.config.getServletContext().getResource("/META-INF/MANIFEST.MF");
-//                if (manifestURL == null) {
-//                    this.logger.fatalError("Unable to get Manifest");
-//                    return null;
-//                }
-//
-//                Manifest mf = new Manifest(manifestURL.openStream());
-//                Attributes attr = mf.getMainAttributes();
-//                String libValue = attr.getValue("Cocoon-Libs");
-//                if (libValue == null) {
-//                    this.logger.fatalError("Unable to get 'Cocoon-Libs' attribute from the Manifest");
-//                    return null;
-//                }
-//
-//                List libList = new ArrayList();
-//                for (StringTokenizer st = new StringTokenizer(libValue, " "); st.hasMoreTokens();) {
-//                    libList.add(st.nextToken());
-//                }
-//
-//                File root = new File(settings.getWorkDirectory(), "lib");
-//                root.mkdirs();
-//
-//                File[] oldLibs = root.listFiles();
-//                for (int i = 0; i < oldLibs.length; i++) {
-//                    String oldLib = oldLibs[i].getName();
-//                    if (!libList.contains(oldLib)) {
-//                        this.logger.debug("Removing old library " + oldLibs[i]);
-//                        oldLibs[i].delete();
-//                    }
-//                }
-//
-//                this.logger.warn("Extracting libraries into " + root);
-//                byte[] buffer = new byte[65536];
-//                for (Iterator i = libList.iterator(); i.hasNext();) {
-//                    String libName = (String) i.next();
-//
-//                    long lastModified = -1;
-//                    try {
-//                        lastModified = Long.parseLong(attr.getValue("Cocoon-Lib-" + libName.replace('.', '_')));
-//                    } catch (Exception e) {
-//                        this.logger.debug("Failed to parse lastModified: " + attr.getValue("Cocoon-Lib-" + libName.replace('.', '_')));
-//                    }
-//
-//                    File lib = new File(root, libName);
-//                    if (lib.exists() && lib.lastModified() != lastModified) {
-//                        this.logger.debug("Removing modified library " + lib);
-//                        lib.delete();
-//                    }
-//                    InputStream is = null;
-//                    OutputStream os = null;
-//                    try {
-//                        is = this.servletContext.getResourceAsStream("/WEB-INF/lib/" + libName);
-//                        if (is != null) {
-//                            this.getLogger().debug("Extracting " + libName);
-//                            os = new FileOutputStream(lib);
-//                            int count;
-//                            while ((count = is.read(buffer)) > 0) {
-//                                os.write(buffer, 0, count);
-//                            }
-//                        } else {
-//                            this.getLogger().warn("Skipping " + libName);
-//                        }
-//                    } finally {
-//                        if (os != null) os.close();
-//                        if (is != null) is.close();
-//                    }
-//
-//                    if (lastModified != -1) {
-//                        lib.setLastModified(lastModified);
-//                    }
-//                }
-//
-//                return root;
-//            } catch (IOException e) {
-//                this.logger.fatalError("Exception while processing Manifest file", e);
-//                return null;
-//            }
-//        }
-//
     }
 }

Modified: cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java (original)
+++ cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/SitemapTestCase.java Mon Feb 27 02:27:58 2006
@@ -76,8 +76,6 @@
         this.classDir = this.getClassDirURL().toExternalForm();
         BootstrapEnvironment env = 
             new TestBootstrapEnvironment(this.getConfiguration(),
-                                         this.classDir,
-                                         environmentContext,
                                          this.processorClassName);
 
         this.coreUtil = new TestCoreUtil(env);

Modified: cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestBootstrapEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestBootstrapEnvironment.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestBootstrapEnvironment.java (original)
+++ cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestBootstrapEnvironment.java Mon Feb 27 02:27:58 2006
@@ -15,43 +15,23 @@
  */
 package org.apache.cocoon.core;
 
-import java.net.URL;
-
 import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.Logger;
 import org.apache.cocoon.core.BootstrapEnvironment;
 import org.apache.cocoon.core.MutableSettings;
-import org.apache.cocoon.environment.Context;
 
 public class TestBootstrapEnvironment
     implements BootstrapEnvironment {
     
     private final String configuration;
-    private final String contextPath;
-    public Logger logger;
-    private final Context environmentContext;
     private String processorClassName;
 
     public TestBootstrapEnvironment(String configuration,
-                                    String contextPath,
-                                    Context environmentContext,
                                     String processorClassName) {
         this.configuration = configuration;
-        this.contextPath = contextPath;
-        this.environmentContext = environmentContext;
         this.processorClassName = processorClassName;
     }
 
     /**
-     * Pass the root logger back to the environment. As soon as the
-     * logging system is set up, this method is called.
-     * @param rootLogger The root logger.
-     */
-    public void setLogger(Logger rootLogger) {
-        this.logger = rootLogger;
-    }
-
-    /**
      * @see org.apache.cocoon.core.BootstrapEnvironment#configure(org.apache.cocoon.core.MutableSettings)
      */
     public void configure(MutableSettings settings) {
@@ -62,27 +42,4 @@
 
     public void configure(DefaultContext context) {
     }
-
-    public Context getEnvironmentContext() {
-        return this.environmentContext;
-    }
-    
-    /**
-     * Returns the URL to the application context.
-     */
-    public String getContextURL() {
-        return this.contextPath;
-    }
-
-    /**
-     * Set the ConfigFile for the Cocoon object.
-     *
-     * @param configFileName The file location for the cocoon.xconf
-     *
-     * @throws Exception
-     */
-    public URL getConfigFile(String configFileName) throws Exception {
-        return new URL(this.contextPath + configFileName);
-    }
-
 }

Modified: cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java (original)
+++ cocoon/trunk/cocoon-core/src/test/java/org/apache/cocoon/core/TestCoreUtil.java Mon Feb 27 02:27:58 2006
@@ -22,7 +22,7 @@
 public class TestCoreUtil extends CoreUtil {
 
     public TestCoreUtil(BootstrapEnvironment env) throws Exception {
-        super(env, new MockContext());
+        super(new MockContext(), env);
         this.classloader = TestCoreUtil.class.getClassLoader();
     }
 

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java Mon Feb 27 02:27:58 2006
@@ -16,21 +16,9 @@
 package org.apache.cocoon.portlet;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.PrintStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -61,8 +49,6 @@
 import org.apache.cocoon.environment.portlet.PortletEnvironment;
 import org.apache.cocoon.portlet.multipart.MultipartActionRequest;
 import org.apache.cocoon.portlet.multipart.RequestFactory;
-import org.apache.cocoon.util.IOUtils;
-import org.apache.commons.lang.SystemUtils;
 
 /**
  * This is the entry point for Cocoon execution as an JSR-168 Portlet.
@@ -103,18 +89,6 @@
     protected javax.portlet.PortletContext portletContext;
 
     /**
-     * This is the path to the portlet context (or the result
-     * of calling getRealPath('/') on the PortletContext.
-     * Note, that this can be null.
-     */
-    protected String portletContextPath;
-
-    /**
-     * This is the url to the portlet context directory
-     */
-    protected String portletContextURL;
-
-    /**
      * The RequestFactory is responsible for wrapping multipart-encoded
      * forms and for handing the file payload of incoming requests
      */
@@ -173,62 +147,14 @@
 
         super.init(conf);
         this.portletContext = conf.getPortletContext();
-        this.portletContextPath = this.portletContext.getRealPath("/");
-
-        String path = this.portletContextPath;
-        // these two variables are just for debugging. We can't log at this point
-        // as the logger isn't initialized yet.
-        String debugPathOne = null, debugPathTwo = null;
-        if (path == null) {
-            // Try to figure out the path of the root from that of WEB-INF
-            try {
-                path = this.portletContext.getResource("/WEB-INF").toString();
-            } catch (MalformedURLException me) {
-                throw new PortletException("Unable to get resource 'WEB-INF'.", me);
-            }
-            debugPathOne = path;
-            path = path.substring(0, path.length() - "WEB-INF".length());
-            debugPathTwo = path;
-        }
-
-        try {
-            if (path.indexOf(':') > 1) {
-                this.portletContextURL = path;
-            } else {
-                this.portletContextURL = new File(path).toURL().toExternalForm();
-            }
-        } catch (MalformedURLException me) {
-            // VG: Novell has absolute file names starting with the
-            // volume name which is easily more then one letter.
-            // Examples: sys:/apache/cocoon or sys:\apache\cocoon
-            try {
-                this.portletContextURL = new File(path).toURL().toExternalForm();
-            } catch (MalformedURLException ignored) {
-                throw new PortletException("Unable to determine portlet context URL.", me);
-            }
-        }
-
-        try {
-            // FIXME (VG): We shouldn't have to specify these. Need to override
-            // jaxp implementation of weblogic before initializing logger.
-            // This piece of code is also required in the Cocoon class.
-            String value = System.getProperty("javax.xml.parsers.SAXParserFactory");
-            if (value != null && value.startsWith("weblogic")) {
-                System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
-                System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
-            }
-        } catch (SecurityException e) {
-            // Ignore security exception
-           this.portletContext.log("CocoonPortlet: Could not check system properties, got: " + e);
-        }
 
         // initialize settings
-        PortletBootstrapEnvironment env = new PortletBootstrapEnvironment(conf, this.portletContextURL);
+        PortletBootstrapEnvironment env = new PortletBootstrapEnvironment(conf);
 
         try {
-            this.coreUtil = new CoreUtil(env, env.getEnvironmentContext());
-            this.environmentContext = env.getEnvironmentContext();
-            this.log = env.logger;
+            this.environmentContext = new PortletContext(conf.getPortletContext());
+            this.coreUtil = new CoreUtil(this.environmentContext, env);
+            this.log = this.coreUtil.getRootLogger();
         } catch (Exception e) {
             if ( e instanceof PortletException ) {
                 throw (PortletException)e;
@@ -236,14 +162,6 @@
             throw new PortletException(e);
         }
 
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("getRealPath for /: " + this.portletContextPath);
-            if (this.portletContextPath == null) {
-                getLogger().debug("getResource for /WEB-INF: " + debugPathOne);
-                getLogger().debug("Path for Root: " + debugPathTwo);
-            }
-        }
-
         this.containerEncoding = getInitParameter("container-encoding", "ISO-8859-1");
         this.settings = this.coreUtil.getCore().getSettings();
         this.requestFactory = new RequestFactory(this.settings.isAutosaveUploads(),
@@ -770,22 +688,9 @@
     implements BootstrapEnvironment {
 
         private final PortletConfig config;
-        private final String        contextPath;
-        public Logger logger;
-        private final Context       environmentContext;
 
-        public PortletBootstrapEnvironment(PortletConfig config,
-                                           String        path) {
+        public PortletBootstrapEnvironment(PortletConfig config) {
             this.config = config;
-            this.contextPath = path;
-            this.environmentContext = new PortletContext(this.config.getPortletContext());
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#setLogger(org.apache.avalon.framework.logger.Logger)
-         */
-        public void setLogger(Logger rootLogger) {
-            this.logger = rootLogger;
         }
 
         /**
@@ -801,225 +706,12 @@
         }
 
         /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getEnvironmentContext()
-         */
-        public Context getEnvironmentContext() {
-            return this.environmentContext;
-        }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getContextURL()
-         */
-        public String getContextURL() {
-            return this.contextPath;
-        }
-
-        /**
          * @see org.apache.cocoon.core.BootstrapEnvironment#configure(org.apache.avalon.framework.context.DefaultContext)
          */
         public void configure(DefaultContext context) {
             // Add the portlet configuration
             context.put(CONTEXT_PORTLET_CONFIG, this.config);
         }
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getConfigFile(java.lang.String)
-         */
-        public URL getConfigFile(final String configFileName)
-        throws Exception {
-            final String usedFileName;
-
-            if (configFileName == null) {
-                if (this.logger.isWarnEnabled()) {
-                    this.logger.warn("Servlet initialization argument 'configurations' not specified, attempting to use '/WEB-INF/cocoon.xconf'");
-                }
-                usedFileName = "/WEB-INF/cocoon.xconf";
-            } else {
-                usedFileName = configFileName;
-            }
-
-            if (this.logger.isDebugEnabled()) {
-                this.logger.debug("Using configuration file: " + usedFileName);
-            }
-
-            URL result;
-            try {
-                // test if this is a qualified url
-                if (usedFileName.indexOf(':') == -1) {
-                    result = this.config.getPortletContext().getResource(usedFileName);
-                } else {
-                    result = new URL(usedFileName);
-                }
-            } catch (Exception mue) {
-                String msg = "Init parameter 'configurations' is invalid : " + usedFileName;
-                this.logger.error(msg, mue);
-                throw new PortletException(msg, mue);
-            }
-
-            if (result == null) {
-                File resultFile = new File(usedFileName);
-                if (resultFile.isFile()) {
-                    try {
-                        result = resultFile.getCanonicalFile().toURL();
-                    } catch (Exception e) {
-                        String msg = "Init parameter 'configurations' is invalid : " + usedFileName;
-                        this.logger.error(msg, e);
-                        throw new PortletException(msg, e);
-                    }
-                }
-            }
-
-            if (result == null) {
-                String msg = "Init parameter 'configuration' doesn't name an existing resource : " + usedFileName;
-                this.logger.error(msg);
-                throw new PortletException(msg);
-            }
-            return result;
-        }
-
-        /**
-         * This builds the important ClassPath used by this Servlet.  It
-         * does so in a Servlet Engine neutral way.  It uses the
-         * <code>ServletContext</code>'s <code>getRealPath</code> method
-         * to get the Servlet 2.2 identified classes and lib directories.
-         * It iterates in alphabetical order through every file in the
-         * lib directory and adds it to the classpath.
-         *
-         * Also, we add the files to the ClassLoader for the Cocoon system.
-         * In order to protect ourselves from skitzofrantic classloaders,
-         * we need to work with a known one.
-         *
-         * We need to get this to work properly when Cocoon is in a war.
-         */
-        public String getClassPath(Settings settings) {
-            StringBuffer buildClassPath = new StringBuffer();
-
-            File root = null;
-            // New(ish) method for war'd deployments
-            URL classDirURL = null;
-            URL libDirURL = null;
-
-            try {
-                classDirURL = this.config.getPortletContext().getResource("/WEB-INF/classes");
-            } catch (MalformedURLException me) {
-                this.logger.warn("Unable to add WEB-INF/classes to the classpath", me);
-            }
-
-            try {
-                libDirURL = this.config.getPortletContext().getResource("/WEB-INF/lib");
-            } catch (MalformedURLException me) {
-                this.logger.warn("Unable to add WEB-INF/lib to the classpath", me);
-            }
-
-            if (libDirURL != null && libDirURL.toExternalForm().startsWith("file:")) {
-                root = new File(libDirURL.toExternalForm().substring("file:".length()));
-            }
-
-            if (classDirURL != null) {
-                buildClassPath.append(classDirURL.toExternalForm());
-            }
-
-            // Unable to find lib directory. Going the hard way.
-            if (root == null) {
-                root = this.extractLibraries(settings);
-            }
-
-            if (root != null && root.isDirectory()) {
-                File[] libraries = root.listFiles();
-                Arrays.sort(libraries);
-                for (int i = 0; i < libraries.length; i++) {
-                    String fullName = IOUtils.getFullFilename(libraries[i]);
-                    buildClassPath.append(File.pathSeparatorChar).append(fullName);
-                }
-            }
-
-            buildClassPath.append(File.pathSeparatorChar)
-                          .append(SystemUtils.JAVA_CLASS_PATH);
-
-            return buildClassPath.toString();
-        }
-
-        private File extractLibraries(Settings settings) {
-            try {
-                URL manifestURL = this.config.getPortletContext().getResource("/META-INF/MANIFEST.MF");
-                if (manifestURL == null) {
-                    this.logger.fatalError("Unable to get Manifest");
-                    return null;
-                }
-
-                Manifest mf = new Manifest(manifestURL.openStream());
-                Attributes attr = mf.getMainAttributes();
-                String libValue = attr.getValue("Cocoon-Libs");
-                if (libValue == null) {
-                    this.logger.fatalError("Unable to get 'Cocoon-Libs' attribute from the Manifest");
-                    return null;
-                }
-
-                List libList = new ArrayList();
-                for (StringTokenizer st = new StringTokenizer(libValue, " "); st.hasMoreTokens();) {
-                    libList.add(st.nextToken());
-                }
-
-                File root = new File(settings.getWorkDirectory(), "lib");
-                root.mkdirs();
-
-                File[] oldLibs = root.listFiles();
-                for (int i = 0; i < oldLibs.length; i++) {
-                    String oldLib = oldLibs[i].getName();
-                    if (!libList.contains(oldLib)) {
-                        this.logger.debug("Removing old library " + oldLibs[i]);
-                        oldLibs[i].delete();
-                    }
-                }
-
-                this.logger.warn("Extracting libraries into " + root);
-                byte[] buffer = new byte[65536];
-                for (Iterator i = libList.iterator(); i.hasNext();) {
-                    String libName = (String) i.next();
-
-                    long lastModified = -1;
-                    try {
-                        lastModified = Long.parseLong(attr.getValue("Cocoon-Lib-" + libName.replace('.', '_')));
-                    } catch (Exception e) {
-                        this.logger.debug("Failed to parse lastModified: " + attr.getValue("Cocoon-Lib-" + libName.replace('.', '_')));
-                    }
-
-                    File lib = new File(root, libName);
-                    if (lib.exists() && lib.lastModified() != lastModified) {
-                        this.logger.debug("Removing modified library " + lib);
-                        lib.delete();
-                    }
-
-                    InputStream is = this.config.getPortletContext().getResourceAsStream("/WEB-INF/lib/" + libName);
-                    if (is == null) {
-                        this.logger.warn("Skipping " + libName);
-                    } else {
-                        this.logger.debug("Extracting " + libName);
-                        OutputStream os = null;
-                        try {
-                            os = new FileOutputStream(lib);
-                            int count;
-                            while ((count = is.read(buffer)) > 0) {
-                                os.write(buffer, 0, count);
-                            }
-                        } finally {
-                            if (is != null) is.close();
-                            if (os != null) os.close();
-                        }
-                    }
-
-                    if (lastModified != -1) {
-                        lib.setLastModified(lastModified);
-                    }
-                }
-
-                return root;
-            } catch (IOException e) {
-                this.logger.fatalError("Exception while processing Manifest file", e);
-                return null;
-            }
-        }
-
     }
 
 }

Modified: cocoon/trunk/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java?rev=381310&r1=381309&r2=381310&view=diff
==============================================================================
--- cocoon/trunk/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java (original)
+++ cocoon/trunk/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java Mon Feb 27 02:27:58 2006
@@ -49,7 +49,6 @@
     implements Configurable, LogEnabled, Serviceable { 
 
     private String containerEncoding;
-    private String contextURL;
 
     private Logger logger;
     private ServiceManager serviceManager;
@@ -107,7 +106,6 @@
             sitemapPath = "/" + sitemapPath;
 
         Context context = CoreUtil.createContext(config, core.getSettings(), sitemapPath);
-        this.contextURL = CoreUtil.getContextURL(this.getServletContext(), sitemapPath);
         
         try {
             this.processor = (Processor) ClassUtils.newInstance(TreeProcessor.class.getName());
@@ -151,7 +149,6 @@
         }
         HttpEnvironment env =
             new HttpEnvironment(uri,
-                    this.contextURL,
                     request,
                     response,
                     this.getServletContext(),