cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r380611 - in /cocoon/trunk: cocoon-core/src/main/java/org/apache/cocoon/bean/ cocoon-core/src/main/java/org/apache/cocoon/core/ cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ cocoon-core/src/main/java/org/apache/cocoon/s...
Date Fri, 24 Feb 2006 07:48:40 GMT
Author: cziegeler
Date: Thu Feb 23 23:48:38 2006
New Revision: 380611

URL: http://svn.apache.org/viewcvs?rev=380611&view=rev
Log:
Simplify configuration

Modified:
    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/core/container/spring/ApplicationContextFactory.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServlet.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java

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=380611&r1=380610&r2=380611&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 Thu Feb
23 23:48:38 2006
@@ -653,13 +653,6 @@
         }
 
         /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getContextForWriting()
-         */
-        public File getContextForWriting() {
-            return new File(this.contextDirectory);
-        }
-
-        /**
          * @see org.apache.cocoon.core.BootstrapEnvironment#getContextURL()
          */
         public String getContextURL() {

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=380611&r1=380610&r2=380611&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
Thu Feb 23 23:48:38 2006
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.core;
 
-import java.io.File;
 import java.net.URL;
 
 import org.apache.avalon.framework.context.DefaultContext;
@@ -67,13 +66,6 @@
      * Returns the URL to the application context.
      */
     String getContextURL();
-
-    /**
-     * Returns a file to the application context.
-     * @return A file pointing to the context or null if the context is not
-     *         writeable.
-     */
-    File getContextForWriting();
 
     /**
      * Set the ConfigFile for the Cocoon object.

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=380611&r1=380610&r2=380611&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 Thu Feb 23
23:48:38 2006
@@ -196,20 +196,8 @@
         final String workDirParam = this.settings.getWorkDirectory();
         File workDir;
         if (workDirParam != null) {
-            if (this.env.getContextForWriting() == null) {
-                // No context path : consider work-directory as absolute
-                workDir = new File(workDirParam);
-            } else {
-                // Context path exists : is work-directory absolute ?
-                File workDirParamFile = new File(workDirParam);
-                if (workDirParamFile.isAbsolute()) {
-                    // Yes : keep it as is
-                    workDir = workDirParamFile;
-                } else {
-                    // No : consider it relative to context path
-                    workDir = new File(this.env.getContextForWriting(), workDirParam);
-                }
-            }
+            // No context path : consider work-directory as absolute
+            workDir = new File(workDirParam);
         } else {
             workDir = new File("cocoon-files");
         }
@@ -225,7 +213,6 @@
         // Output some debug info
         if (this.log.isDebugEnabled()) {
             this.log.debug("Context URL: " + this.env.getContextURL());
-            this.log.debug("Writeable Context: " + this.env.getContextForWriting());
             if (workDirParam != null) {
                 this.log.debug("Using work-directory " + workDir);
             } else {
@@ -236,19 +223,7 @@
         final String uploadDirParam = this.settings.getUploadDirectory();
         File uploadDir;
         if (uploadDirParam != null) {
-            if (this.env.getContextForWriting() == null) {
-                uploadDir = new File(uploadDirParam);
-            } else {
-                // Context path exists : is upload-directory absolute ?
-                File uploadDirParamFile = new File(uploadDirParam);
-                if (uploadDirParamFile.isAbsolute()) {
-                    // Yes : keep it as is
-                    uploadDir = uploadDirParamFile;
-                } else {
-                    // No : consider it relative to context path
-                    uploadDir = new File(this.env.getContextForWriting(), uploadDirParam);
-                }
-            }
+            uploadDir = new File(uploadDirParam);
             if (this.log.isDebugEnabled()) {
                 this.log.debug("Using upload-directory " + uploadDir);
             }
@@ -265,19 +240,7 @@
         String cacheDirParam = this.settings.getCacheDirectory();
         File cacheDir;
         if (cacheDirParam != null) {
-            if (this.env.getContextForWriting() == null) {
-                cacheDir = new File(cacheDirParam);
-            } else {
-                // Context path exists : is cache-directory absolute ?
-                File cacheDirParamFile = new File(cacheDirParam);
-                if (cacheDirParamFile.isAbsolute()) {
-                    // Yes : keep it as is
-                    cacheDir = cacheDirParamFile;
-                } else {
-                    // No : consider it relative to context path
-                    cacheDir = new File(this.env.getContextForWriting(), cacheDirParam);
-                }
-            }
+            cacheDir = new File(cacheDirParam);
             if (this.log.isDebugEnabled()) {
                 this.log.debug("Using cache-directory " + cacheDir);
             }
@@ -805,17 +768,9 @@
                             this.log.debug("extraClassPath is not absolute replacing using
token: [" + s + "] : " + path);
                         }
                     } else {
-                        String path = null;
-                        if (this.env.getContextForWriting() != null) {
-                            path = this.env.getContextForWriting() + s;
-                            if (this.log.isDebugEnabled()) {
-                                this.log.debug("extraClassPath is not absolute pre-pending
context path: " + path);
-                            }
-                        } else {
-                            path = this.settings.getWorkDirectory() + s;
-                            if (this.log.isDebugEnabled()) {
-                                this.log.debug("extraClassPath is not absolute pre-pending
work-directory: " + path);
-                            }
+                        String path = this.settings.getWorkDirectory() + s;
+                        if (this.log.isDebugEnabled()) {
+                            this.log.debug("extraClassPath is not absolute pre-pending work-directory:
" + path);
                         }
                         sb.append(path);
                     }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java?rev=380611&r1=380610&r2=380611&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java
Thu Feb 23 23:48:38 2006
@@ -84,9 +84,6 @@
                                                                                     env.context);
         context.addBeanFactoryPostProcessor(new CocoonSettingsConfigurer(env.settings));
 
-        // TODO: Add context specific information
-        //context.setSourceResolver(this.resolver);
-        //context.setEnvironmentHelper(this.environmentHelper);
         context.setServletContext(env.servletContext);
         context.refresh();
         if ( info.rootLogger != null ) {

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java?rev=380611&r1=380610&r2=380611&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
Thu Feb 23 23:48:38 2006
@@ -16,11 +16,9 @@
 package org.apache.cocoon.core.container.spring;
 
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.util.Map;
 import java.util.Stack;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
@@ -33,13 +31,10 @@
 import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.sitemap.EnterSitemapEvent;
 import org.apache.cocoon.sitemap.EnterSitemapEventListener;
 import org.apache.cocoon.sitemap.LeaveSitemapEvent;
 import org.apache.cocoon.sitemap.LeaveSitemapEventListener;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanCreationException;
 import org.springframework.beans.factory.BeanFactory;
@@ -52,7 +47,6 @@
 import org.springframework.context.ApplicationListener;
 import org.springframework.context.event.ContextClosedEvent;
 import org.springframework.core.io.Resource;
-import org.springframework.core.io.UrlResource;
 import org.springframework.web.context.support.XmlWebApplicationContext;
 
 /**
@@ -66,12 +60,9 @@
     extends XmlWebApplicationContext
     implements EnterSitemapEventListener, LeaveSitemapEventListener, ApplicationListener
{
 
-    public static final String DEFAULT_SPRING_CONFIG = "conf/applicationContext.xml";
     public static final String APPLICATION_CONTEXT_REQUEST_ATTRIBUTE = "application-context";
 
     final private Resource avalonResource;
-    protected SourceResolver resolver;
-    protected String baseURL;
 
     protected final Logger avalonLogger;
     protected final Context avalonContext;
@@ -153,58 +144,13 @@
         return beanFactory;
     }
 
-    public void setSourceResolver(SourceResolver aResolver) {
-        this.resolver = aResolver;
-    }
-
-    public void setEnvironmentHelper(EnvironmentHelper eh) {
-        this.baseURL = eh.getContext();
-        if ( !this.baseURL.endsWith("/") ) {
-            this.baseURL = this.baseURL + '/';
-        }
-    }
-
-    /**
-     * Resolve file paths beneath the root of the web application.
-     * <p>Note: Even if a given path starts with a slash, it will get
-     * interpreted as relative to the web application root directory
-     * (which is the way most servlet containers handle such paths).
-     * @see org.springframework.web.context.support.ServletContextResource
-     */
-    protected Resource getResourceByPath(String path) {
-        if ( path.startsWith("/") ) {
-            path = path.substring(1);
-        }
-        path = this.baseURL + path;
-        try {
-            return new UrlResource(path);
-        } catch (MalformedURLException mue) {
-            // FIXME - for now, we simply call super
-            return super.getResourceByPath(path);
-        }
-    }
-
     /**
-     * The default location for the context is "conf/applicationContext.xml"
-     * which is searched relative to the current sitemap.
-     * @return The default config locations if they exist otherwise an empty array.
+     * We don't have any default locations - this application context is a nested one
+     * which is configured through a sitemap. All possible configuration files are
+     * configured in the sitemap.
+     * @return An empty array.
      */
     protected String[] getDefaultConfigLocations() {
-        if ( this.resolver != null ) {
-            Source testSource = null;
-            try {
-                testSource = this.resolver.resolveURI(DEFAULT_SPRING_CONFIG);
-                if (testSource.exists()) {
-                    return new String[] {DEFAULT_SPRING_CONFIG};
-                }
-            } catch(MalformedURLException e) {
-                throw new CascadingRuntimeException("Malformed URL when resolving Spring
default config location [ " + DEFAULT_SPRING_CONFIG + "]. This is an unrecoverable programming
error. Check the code where this exception was thrown.", e);
-            } catch(IOException e) {
-                throw new CascadingRuntimeException("Cannot resolve default config location
["+ DEFAULT_SPRING_CONFIG + "] due to an IOException. See cause for details.", e);
-            } finally {
-                this.resolver.release(testSource);
-            }
-        }        
         return new String[]{};
     }
 

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=380611&r1=380610&r2=380611&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 Thu
Feb 23 23:48:38 2006
@@ -178,7 +178,7 @@
         }
 
         // initialize settings
-        ServletBootstrapEnvironment env = new ServletBootstrapEnvironment(conf, this.servletContextPath,
this.servletContextURL);
+        ServletBootstrapEnvironment env = new ServletBootstrapEnvironment(conf, this.servletContextURL);
 
         try {
             this.coreUtil = new CoreUtil(env, this.servletContext);
@@ -593,20 +593,13 @@
         implements BootstrapEnvironment {
 
         private final ServletConfig config;
-        private final File writeableContextPath;
         private final String contextPath;
         public Logger logger;
         private final HttpContext environmentContext;
 
         public ServletBootstrapEnvironment(ServletConfig config, 
-                                           String writeablePath,
                                            String path) {
             this.config = config;
-            if ( writeablePath == null ) {
-                this.writeableContextPath = null;
-            } else {
-                this.writeableContextPath = new File(writeablePath);
-            }
             this.contextPath = path;
             this.environmentContext = new HttpContext(this.config.getServletContext());
         }
@@ -645,14 +638,6 @@
          */
         public String getContextURL() {
             return this.contextPath;
-        }
-
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getContextForWriting()
-         */
-        public File getContextForWriting() {
-            return this.writeableContextPath;
         }
 
         /**

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=380611&r1=380610&r2=380611&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
Thu Feb 23 23:48:38 2006
@@ -223,7 +223,7 @@
         }
 
         // initialize settings
-        PortletBootstrapEnvironment env = new PortletBootstrapEnvironment(conf, this.portletContextPath,
this.portletContextURL);
+        PortletBootstrapEnvironment env = new PortletBootstrapEnvironment(conf, this.portletContextURL);
 
         try {
             this.coreUtil = new CoreUtil(env, env.getEnvironmentContext());
@@ -770,20 +770,13 @@
     implements BootstrapEnvironment {
 
         private final PortletConfig config;
-        private final File          writeableContextPath;
         private final String        contextPath;
         public Logger logger;
         private final Context       environmentContext;
 
         public PortletBootstrapEnvironment(PortletConfig config,
-                                           String        writeablePath,
                                            String        path) {
             this.config = config;
-            if ( writeablePath == null ) {
-                this.writeableContextPath = null;
-            } else {
-                this.writeableContextPath = new File(writeablePath);
-            }
             this.contextPath = path;
             this.environmentContext = new PortletContext(this.config.getPortletContext());
         }
@@ -821,14 +814,6 @@
             return this.contextPath;
         }
 
-
-        /**
-         * @see org.apache.cocoon.core.BootstrapEnvironment#getContextForWriting()
-         */
-        public File getContextForWriting() {
-            return this.writeableContextPath;
-        }
-
         /**
          * @see org.apache.cocoon.core.BootstrapEnvironment#configure(org.apache.avalon.framework.context.DefaultContext)
          */
@@ -910,43 +895,28 @@
             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.getPortletContext().getRealPath("/WEB-INF/classes");
-                String libDir = this.config.getPortletContext().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;
+            // 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 {
+                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);
-                }
+            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 (libDirURL != null && libDirURL.toExternalForm().startsWith("file:"))
{
+                root = new File(libDirURL.toExternalForm().substring("file:".length()));
+            }
 
-                if (classDirURL != null) {
-                    buildClassPath.append(classDirURL.toExternalForm());
-                }
+            if (classDirURL != null) {
+                buildClassPath.append(classDirURL.toExternalForm());
             }
 
             // Unable to find lib directory. Going the hard way.



Mime
View raw message