cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r441638 - in /cocoon/trunk/core/cocoon-core/src: main/java/org/apache/cocoon/ main/java/org/apache/cocoon/components/modules/input/ main/java/org/apache/cocoon/components/treeprocessor/ main/java/org/apache/cocoon/components/treeprocessor/s...
Date Fri, 08 Sep 2006 20:30:06 GMT
Author: cziegeler
Date: Fri Sep  8 13:30:05 2006
New Revision: 441638

URL: http://svn.apache.org/viewvc?view=rev&rev=441638
Log:
Major refactoring of per sitemap container: reduce dependencies to spring and avalon
Remove unused code
(unit test framework is currently not working)

Removed:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/impl/SettingsHelper.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/BeanFactoryFactory.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/BeanFactoryFactoryImpl.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/BeanFactoryUtil.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonBeanFactory.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonSettingsConfigurer.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ClassLoaderUtils.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationBuilder.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/XmlConfigCreator.java
Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Processor.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/Container.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiSpringECMFactory.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
    cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java Fri Sep  8 13:30:05 2006
@@ -44,7 +44,9 @@
     /**
      * Avoid construction.
      */
-    private ProcessingUtil() {}
+    private ProcessingUtil() {
+        // empty 
+    }
 
     /**
      * The cleanup threads that are invoked after the processing of a
@@ -101,6 +103,7 @@
      * This method returns the current sitemap component manager. This
      * is the manager that holds all the components of the currently
      * processed (sub)sitemap.
+     * @deprecated This method will be removed.
      */
     static public ServiceManager getSitemapServiceManager() {
         return EnvironmentHelper.getSitemapServiceManager(); 

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Processor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Processor.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Processor.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/Processor.java Fri Sep  8 13:30:05 2006
@@ -20,7 +20,6 @@
 import org.apache.cocoon.components.pipeline.ProcessingPipeline;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.SourceResolver;
-import org.springframework.beans.factory.BeanFactory;
 
 /**
  *
@@ -117,9 +116,6 @@
      * @since 2.2
      */
     Object removeAttribute(String name);
-
-    /** FIXME - Remove this and use ProcessingUtil. */
-    BeanFactory getBeanFactory();
 
     /**
      * Get the parent processor (if any).

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/SettingsInputModule.java Fri Sep  8 13:30:05 2006
@@ -18,12 +18,20 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.configuration.Settings;
-import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.cocoon.core.container.spring.CocoonRequestAttributes;
+import org.apache.cocoon.core.container.spring.Container;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.processing.ProcessInfoProvider;
 import org.apache.commons.collections.IteratorUtils;
 
 /**
@@ -33,21 +41,39 @@
  */
 public final class SettingsInputModule
     extends AbstractLogEnabled
-    implements InputModule, ThreadSafe {
+    implements InputModule, ThreadSafe, Serviceable, Disposable {
 
+    protected ServiceManager manager;
+    protected ProcessInfoProvider infoProvider; 
+    
     /**
-     * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
+    public void service(ServiceManager aManager) throws ServiceException {
+        this.manager = aManager;
+        this.infoProvider = (ProcessInfoProvider)this.manager.lookup(ProcessInfoProvider.ROLE);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if ( this.manager != null ) {
+            this.manager.release(this.infoProvider);
+            this.infoProvider = null;
+            this.manager = null;
+        }
+    }
+
     /**
      * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
      */
     public Object getAttribute(String name, Configuration modeConf, Map objectModel)
     throws ConfigurationException {
-        final Settings settings = (Settings)EnvironmentHelper.getCurrentProcessor().getBeanFactory().getBean(Settings.ROLE);
-        if ( settings != null ) {
-            return settings.getProperty(name);
-        }
-        return null;
+        final Request request = ObjectModelHelper.getRequest(this.infoProvider.getObjectModel());
+        final Container container = Container.getCurrentContainer(this.infoProvider.getServletContext(), new CocoonRequestAttributes(request));
+        final Settings settings = container.getSettings();
+        return settings.getProperty(name);
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java Fri Sep  8 13:30:05 2006
@@ -37,7 +37,7 @@
      */
     public void setBuilder(TreeBuilder treeBuilder) {
         this.treeBuilder = treeBuilder;
-        this.manager = (ServiceManager)treeBuilder.getBeanFactory().getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
+        this.manager = (ServiceManager)treeBuilder.getContainer().getBeanFactory().getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java Fri Sep  8 13:30:05 2006
@@ -21,7 +21,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Stack;
 
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
@@ -30,12 +29,12 @@
 import org.apache.cocoon.ProcessingUtil;
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.components.source.impl.SitemapSourceInfo;
-import org.apache.cocoon.core.container.spring.CocoonBeanFactory;
+import org.apache.cocoon.core.container.spring.CocoonRequestAttributes;
+import org.apache.cocoon.core.container.spring.Container;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.ForwardRedirector;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Redirector;
-import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.environment.internal.ForwardEnvironmentWrapper;
@@ -62,8 +61,6 @@
                                               Disposable,
                                               ExecutionContext {
 
-    private static final String BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE = CocoonBeanFactory.class.getName() + "/Stack";
-
     /** Our ServiceManager */
     private ServiceManager manager;
 
@@ -92,7 +89,7 @@
     protected Map processorAttributes = new HashMap();
 
     /** Bean Factory for this sitemap. */
-    protected BeanFactory beanFactory;
+    protected Container beanFactory;
 
     /** Classloader for this sitemap. */
     protected ClassLoader classLoader;
@@ -110,8 +107,7 @@
     }
 
     /** Set the processor data, result of the treebuilder job */
-    public void setProcessorData(BeanFactory beanFactory,
-                                 ClassLoader classLoader,
+    public void setProcessorData(Container container,
                                  ProcessingNode rootNode,
                                  List disposableNodes,
                                  List enterSitemapEventListeners,
@@ -119,9 +115,9 @@
         if (this.rootNode != null) {
             throw new IllegalStateException("setProcessorData() can only be called once");
         }
-        this.classLoader = classLoader;
-        this.beanFactory = beanFactory;
-        this.manager = (ServiceManager)this.beanFactory.getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
+        this.classLoader = container.getClassLoader();
+        this.beanFactory = container;
+        this.manager = (ServiceManager)this.beanFactory.getBeanFactory().getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
         this.rootNode = rootNode;
         this.disposableNodes = disposableNodes;
         this.enterSitemapEventListeners = enterSitemapEventListeners;
@@ -195,41 +191,6 @@
     }
 
     /**
-     * @see org.apache.cocoon.sitemap.EnterSitemapEventListener#enteredSitemap(org.apache.cocoon.sitemap.EnterSitemapEvent)
-     */
-    protected void enteredSitemap(EnterSitemapEvent event) {
-        final Request request = ObjectModelHelper.getRequest(event.getEnvironment().getObjectModel());
-        final Object oldContext = request.getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, Request.REQUEST_SCOPE);
-        if ( oldContext != null ) {
-            Stack stack = (Stack)request.getAttribute(BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE, Request.REQUEST_SCOPE);
-            if ( stack == null ) {
-                stack = new Stack();
-                request.setAttribute(BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE, stack, Request.REQUEST_SCOPE);
-            }
-            stack.push(oldContext);
-        }
-        request.setAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, this.beanFactory, Request.REQUEST_SCOPE);
-    }
-
-    /**
-     * @see org.apache.cocoon.sitemap.LeaveSitemapEventListener#leftSitemap(org.apache.cocoon.sitemap.LeaveSitemapEvent)
-     */
-    protected void leftSitemap(LeaveSitemapEvent event) {
-        final Request request = ObjectModelHelper.getRequest(event.getEnvironment().getObjectModel());
-        final Stack stack = (Stack)request.getAttribute(BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE, Request.REQUEST_SCOPE);
-        if ( stack == null ) {
-            request.removeAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, Request.REQUEST_SCOPE);
-        } else {
-            final Object oldContext = stack.pop();
-            request.setAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, oldContext, Request.REQUEST_SCOPE);
-            if ( stack.size() == 0 ) {
-                request.removeAttribute(BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE, Request.REQUEST_SCOPE);
-            }
-        }
-    }
-
-
-    /**
      * Do the actual processing, be it producing the response or just building the pipeline
      * @param environment
      * @param context
@@ -246,12 +207,13 @@
 
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(this.classLoader);
+        Object handle = null;
         try {
-            final EnterSitemapEvent enterEvent = new EnterSitemapEvent(this, environment);
-            this.enteredSitemap(enterEvent);
+            handle = this.beanFactory.enteringContext(new CocoonRequestAttributes(ObjectModelHelper.getRequest(environment.getObjectModel())));
             // invoke listeners
             // only invoke if pipeline is not internally
             if ( !context.isBuildingPipelineOnly() ) {
+                final EnterSitemapEvent enterEvent = new EnterSitemapEvent(this, environment);
                 final Iterator enterSEI = this.enterSitemapEventListeners.iterator();
                 while ( enterSEI.hasNext() ) {
                     final EnterSitemapEventListener current = (EnterSitemapEventListener)enterSEI.next();
@@ -282,11 +244,11 @@
 
         } finally {
             this.sitemapExecutor.leaveSitemap(this, environment.getObjectModel());
-            final LeaveSitemapEvent leaveEvent = new LeaveSitemapEvent(this, environment);
-            this.leftSitemap(leaveEvent);
+            this.beanFactory.leavingContext(new CocoonRequestAttributes(ObjectModelHelper.getRequest(environment.getObjectModel())), handle);
             // invoke listeners
             // only invoke if pipeline is not internally
             if ( !context.isBuildingPipelineOnly() ) {
+                final LeaveSitemapEvent leaveEvent = new LeaveSitemapEvent(this, environment);
                 final Iterator leaveSEI = this.leaveSitemapEventListeners.iterator();
                 while ( leaveSEI.hasNext() ) {
                     final LeaveSitemapEventListener current = (LeaveSitemapEventListener)leaveSEI.next();
@@ -463,7 +425,7 @@
      * @see org.apache.cocoon.Processor#getBeanFactory()
      */
     public BeanFactory getBeanFactory() {
-        return this.beanFactory;
+        return this.beanFactory.getBeanFactory();
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java Fri Sep  8 13:30:05 2006
@@ -19,7 +19,7 @@
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.apache.cocoon.core.container.spring.Container;
 
 /**
  *
@@ -29,11 +29,9 @@
 
     String ROLE = TreeBuilder.class.getName();
 
-    ConfigurableListableBeanFactory getBeanFactory();
+    Container getContainer();
 
     ConcreteTreeProcessor getProcessor();
-
-    ClassLoader getClassLoader();
 
     void setProcessor(ConcreteTreeProcessor processor);
 

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java Fri Sep  8 13:30:05 2006
@@ -18,8 +18,6 @@
 import java.io.IOException;
 import java.net.URL;
 
-import javax.servlet.ServletContext;
-
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.configuration.Configurable;
@@ -49,10 +47,6 @@
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.regexp.RE;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.web.context.ServletContextAware;
 import org.xml.sax.SAXException;
 
 /**
@@ -63,7 +57,7 @@
 public class TreeProcessor extends AbstractLogEnabled
                            implements ThreadSafe, Processor, Serviceable,
                                       Configurable, Contextualizable,
-                                      Disposable, Initializable, BeanFactoryAware, ServletContextAware {
+                                      Disposable, Initializable {
 
     /** The parent TreeProcessor, if any */
     protected TreeProcessor parent;
@@ -107,12 +101,6 @@
     /** The actual processor */
     protected ConcreteTreeProcessor concreteProcessor;
 
-    /** Our bean factory. */
-    protected BeanFactory beanFactory;
-
-    /** The servlet context. */
-    protected ServletContext servletContext;
-
     /**
      * Create a TreeProcessor.
      */
@@ -148,8 +136,6 @@
         ContainerUtil.service(this.environmentHelper, this.manager);
         this.environmentHelper.changeContext(sitemapSource, prefix);
         this.sitemapExecutor = parent.sitemapExecutor;
-        this.beanFactory = parent.beanFactory;
-        this.servletContext = parent.servletContext;
     }
 
     /**
@@ -410,10 +396,8 @@
                 treeBuilder.setProcessor(newProcessor);
 
                 ProcessingNode root = treeBuilder.build(sitemapProgram);
-                this.beanFactory = treeBuilder.getBeanFactory();
                 newProcessor.setProcessorData(
-                        this.beanFactory,
-                        treeBuilder.getClassLoader(),
+                        treeBuilder.getContainer(),
                         root,
                         treeBuilder.getDisposableNodes(),
                         treeBuilder.getEnterSitemapEventListeners(),
@@ -502,33 +486,9 @@
     }
 
     /**
-     * @see org.apache.cocoon.Processor#getBeanFactory()
-     */
-    public BeanFactory getBeanFactory() {
-        if ( this.concreteProcessor != null ) {
-            return this.concreteProcessor.getBeanFactory();
-        }
-        return this.beanFactory;
-    }
-
-    /**
-     * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
-     */
-    public void setBeanFactory(BeanFactory factory) throws BeansException {
-        this.beanFactory = factory;
-    }
-
-    /**
      * @see org.apache.cocoon.Processor#getParent()
      */
     public Processor getParent() {
         return this.parent;
-    }
-
-    /**
-     * @see org.springframework.web.context.ServletContextAware#setServletContext(javax.servlet.ServletContext)
-     */
-    public void setServletContext(ServletContext sContext) {
-        this.servletContext = sContext;
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java Fri Sep  8 13:30:05 2006
@@ -48,7 +48,7 @@
         super.setBuilder(treeBuilder);
         // check ssettings for ignoring of internal only pipeline flags
         this.ignoreInternalOnly = false;
-        final Settings settings = (Settings)treeBuilder.getBeanFactory().getBean(Settings.ROLE);
+        final Settings settings = treeBuilder.getContainer().getSettings();
         final String value = settings.getProperty(PipelineNodeBuilder.PROPERTY_SITEMAP_INTERNALONLY);
         if ( value != null ) {
             this.ignoreInternalOnly = Boolean.valueOf(value).booleanValue();

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Fri Sep  8 13:30:05 2006
@@ -24,7 +24,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 
 import javax.servlet.ServletContext;
@@ -35,12 +34,10 @@
 import org.apache.avalon.framework.configuration.AbstractConfiguration;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.context.DefaultContext;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
@@ -55,45 +52,32 @@
 import org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder;
 import org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor;
 import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.NodeBuilderSelector;
 import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
 import org.apache.cocoon.components.treeprocessor.ProcessingNode;
 import org.apache.cocoon.components.treeprocessor.ProcessingNodeBuilder;
 import org.apache.cocoon.components.treeprocessor.ProcessorComponentInfo;
-import org.apache.cocoon.components.treeprocessor.NodeBuilderSelector;
 import org.apache.cocoon.components.treeprocessor.TreeBuilder;
 import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
 import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
-import org.apache.cocoon.configuration.PropertyProvider;
-import org.apache.cocoon.configuration.Settings;
-import org.apache.cocoon.configuration.impl.MutableSettings;
-import org.apache.cocoon.configuration.impl.PropertyHelper;
-import org.apache.cocoon.configuration.impl.SettingsHelper;
-import org.apache.cocoon.core.container.spring.BeanFactoryFactoryImpl;
+import org.apache.cocoon.core.container.spring.Container;
 import org.apache.cocoon.core.container.spring.avalon.AvalonUtils;
 import org.apache.cocoon.core.container.spring.avalon.SitemapHelper;
-import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.generation.Generator;
 import org.apache.cocoon.serialization.Serializer;
 import org.apache.cocoon.sitemap.EnterSitemapEventListener;
 import org.apache.cocoon.sitemap.LeaveSitemapEventListener;
 import org.apache.cocoon.sitemap.PatternException;
 import org.apache.cocoon.sitemap.SitemapParameters;
-import org.apache.cocoon.util.Deprecation;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationImpl;
 import org.apache.cocoon.util.location.LocationUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.TraversableSource;
 import org.apache.regexp.RE;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.ListableBeanFactory;
 
 /**
  * The tree builder for the sitemap language.
@@ -102,15 +86,7 @@
  */
 public class SitemapLanguage
     extends AbstractLogEnabled
-    implements TreeBuilder, Contextualizable, Serviceable, Recyclable, BeanFactoryAware {
-
-    private static final String DEFAULT_CONFIG_PROPERTIES = "config/properties";
-
-    private static final String DEFAULT_CONFIG_XCONF  = "config/xconf";
-
-    private static final String DEFAULT_CONFIG_SPRING = "config/spring";
-
-    private static final String CLASSLOADER_CONFIG_NAME = "classloader";
+    implements TreeBuilder, Contextualizable, Serviceable, Recyclable {
 
     // Regexp's for splitting expressions
     private static final String COMMA_SPLIT_REGEXP = "[\\s]*,[\\s]*";
@@ -119,10 +95,6 @@
 
     protected Map attributes = new HashMap();
 
-    /** Spring application context. */
-    protected ConfigurableListableBeanFactory beanFactory;
-
-
     // ----- lifecycle-related objects ------
 
     /**
@@ -153,7 +125,7 @@
      */
     private ServiceManager itsManager;
 
-    private ConfigurableListableBeanFactory itsBeanFactory;
+    private Container itsContainer;
 
     /**
      * Helper object which sets up components in the context of the processor
@@ -198,9 +170,6 @@
     /** Nodes registered using registerNode() */
     private Map registeredNodes = new HashMap();
 
-    /** Class Loader for this sitemap. */
-    private ClassLoader itsClassLoader = this.getClass().getClassLoader();
-
     /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
@@ -255,17 +224,10 @@
     }
 
     /**
-     * @see org.apache.cocoon.components.treeprocessor.TreeBuilder#getBeanFactory()
+     * @see org.apache.cocoon.components.treeprocessor.TreeBuilder#getContainer()
      */
-    public ConfigurableListableBeanFactory getBeanFactory() {
-        return this.itsBeanFactory;
-    }
-
-    /**
-     * @see org.apache.cocoon.components.treeprocessor.TreeBuilder#getClassLoader()
-     */
-    public ClassLoader getClassLoader() {
-        return this.itsClassLoader;
+    public Container getContainer() {
+        return this.itsContainer;
     }
 
     /**
@@ -371,179 +333,31 @@
     }
 
     /**
-     * compatibility with 2.1.x - check for global variables in sitemap
-     * TODO - This will be removed in later versions!
-     */
-    protected Properties getGlobalSitemapVariables(Configuration tree)
-    throws ConfigurationException {
-        // compatibility with 2.1.x - check for global variables in sitemap
-        // TODO - This will be removed in later versions!
-        Properties globalSitemapVariables = null;
-        if ( tree.getChild("pipelines").getChild("component-configurations", false) != null ) {
-            Deprecation.logger.warn("The 'component-configurations' section in the sitemap is deprecated. Please check for alternatives.");
-            globalSitemapVariables = new Properties();
-            // now check for global variables - if any other element occurs: throw exception
-            Configuration[] children = tree.getChild("pipelines").getChild("component-configurations").getChildren();
-            for(int i=0; i<children.length; i++) {
-                if ( "global-variables".equals(children[i].getName()) ) {
-                    Configuration[] variables = children[i].getChildren();
-                    for(int v=0; v<variables.length; v++) {
-                        globalSitemapVariables.setProperty(variables[v].getName(), variables[v].getValue());
-                    }
-               } else {
-                    throw new ConfigurationException("Component configurations in the sitemap are not allowed for component: " + children[i].getName());
-                }
-            }
-        }
-        return globalSitemapVariables;
-    }
-
-    /**
      * Build a processing tree from a <code>Configuration</code>.
      */
     public ProcessingNode build(Configuration tree) throws Exception {
-        /*
         // get the request
         final Request request = ContextHelper.getRequest(this.context);
-        final String prefix = request.getSitemapURIPrefix();
-        SitemapHelper.createApplicationContext(prefix,
+        this.itsContainer = SitemapHelper.createContainer(
                                                tree, 
                                                (ServletContext)this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT), 
                                                this.processor.getSourceResolver(), 
                                                request);
-        */
+        final Context itsContext = (Context)this.itsContainer.getBeanFactory().getBean(ProcessingUtil.CONTEXT_ROLE);
         // The namespace used in the whole sitemap is the one of the root
         // element
         this.itsNamespace = tree.getNamespace();
 
-        Configuration componentConfig = tree.getChild("components", false);
-        Configuration classPathConfig = null;
-
-        if (componentConfig == null) {
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("Sitemap has no components definition at " + tree.getLocation());
-            }
-        }
-
-        // by default we include configuration files and properties from
-        // predefined locations
-        boolean useDefaultIncludes = true;
-        if ( componentConfig != null ) {
-            useDefaultIncludes = componentConfig.getAttributeAsBoolean("use-default-includes", true);
-        }
-
-        // Context and manager and classloader for the sitemap we build        
-        final Context itsContext = this.createContext();
-
-        // TODO Get factory from spring
-        final BeanFactoryFactoryImpl factory = new BeanFactoryFactoryImpl();
-        factory.setBeanFactory(this.beanFactory);
-
-        // compatibility with 2.1.x - check for global variables in sitemap
-        // TODO - This will be removed in later versions!
-        final Properties globalSitemapVariables = this.getGlobalSitemapVariables(tree);
-
-        // check for sitemap local properties
-        Settings settings = (Settings)factory.getCurrentBeanFactory(itsContext).getBean(Settings.ROLE);
-        if ( componentConfig != null ) {
-            List propertyDirs = null;
-            Configuration[] propertyDirConfigs = componentConfig.getChildren("include-properties");
-            if ( propertyDirConfigs.length > 0 ) {
-                propertyDirs = new ArrayList();
-                for(int i=0; i < propertyDirConfigs.length; i++) {
-                    propertyDirs.add(propertyDirConfigs[i].getAttribute("dir"));
-                }
-            }
-            settings = this.createSettings(settings, propertyDirs, useDefaultIncludes, factory.getCurrentBeanFactory(itsContext), globalSitemapVariables);
-        } else if ( globalSitemapVariables != null ) {
-            MutableSettings s = new MutableSettings(settings);
-            PropertyHelper.replaceAll(globalSitemapVariables, settings);
-            s.configure(globalSitemapVariables);
-            settings = s;
-        }
         // replace properties?
-        if ( componentConfig == null || componentConfig.getAttributeAsBoolean("replace-properties", true) ) {
-            tree = AvalonUtils.replaceProperties(tree, settings);
+        if ( tree.getChild("components").getAttributeAsBoolean("replace-properties", true) ) {
+            tree = AvalonUtils.replaceProperties(tree, this.itsContainer.getSettings());
         }
 
-        // if we want to add the default includes and have no component section
-        // we have to create own!
-        if ( componentConfig == null && useDefaultIncludes ) {
-            componentConfig = new DefaultConfiguration("components",
-                                                       tree.getLocation(),
-                                                       tree.getNamespace(),
-                                                       "");
-        }
-
-        if ( componentConfig != null ) {
-            // before we pass the configuration we have to strip the
-            // additional configuration parts, like classpath as these
-            // are not configurations for the component container
-            final DefaultConfiguration c = new DefaultConfiguration(componentConfig.getName(), 
-                    componentConfig.getLocation(),
-                    componentConfig.getNamespace(),
-                    "");
-            c.addAll(componentConfig);
-            classPathConfig = c.getChild(CLASSLOADER_CONFIG_NAME, false);
-            if ( classPathConfig != null ) {
-                c.removeChild(classPathConfig);
-            }
-            // and now add default includes
-            if ( useDefaultIncludes ) {
-                final SourceResolver resolver = this.processor.getSourceResolver();
-                Source directory = null;
-                try {
-                    directory = resolver.resolveURI(DEFAULT_CONFIG_XCONF, null, CONTEXT_PARAMETERS);
-                    if (directory.exists() && directory instanceof TraversableSource) {
-                        final DefaultConfiguration includeElement = new DefaultConfiguration("include", 
-                                                                                             c.getLocation(),
-                                                                                             c.getNamespace(),
-                                                                                             "");
-                        includeElement.setAttribute("dir", DEFAULT_CONFIG_XCONF);
-                        includeElement.setAttribute("pattern", "*.xconf");
-                        c.addChild(includeElement);
-                    }
-                } finally {
-                    resolver.release(directory);
-                    directory = null;
-                }
-                try {
-                    directory = resolver.resolveURI(DEFAULT_CONFIG_SPRING, null, CONTEXT_PARAMETERS);
-                    if (directory.exists() && directory instanceof TraversableSource) {
-                        final DefaultConfiguration includeElement = new DefaultConfiguration("include-beans", 
-                                                                                             c.getLocation(),
-                                                                                             c.getNamespace(),
-                                                                                             "");
-                        includeElement.setAttribute("dir", DEFAULT_CONFIG_SPRING);
-                        includeElement.setAttribute("pattern", "*.xml");
-                        c.addChild(includeElement);
-                    }
-                } finally {
-                    resolver.release(directory);
-                    directory = null;
-                }
-            }
-            componentConfig = c;
-        }
-
-        // Create class loader
-        this.itsClassLoader = factory.createClassLoader(itsContext, this.processor.getSourceResolver(), classPathConfig);
+        this.itsManager = (ServiceManager) this.itsContainer.getBeanFactory().getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
+        // register listeners
+        this.registerListeners();
 
-        // FIXME: Internal configurations doesn't work in a non bean factory
-        // environment
-        this.itsBeanFactory = factory.createBeanFactory(this.itsClassLoader,
-                                                        this.getLogger(),
-                                                        componentConfig,
-                                                        itsContext,
-                                                        this.processor.getSourceResolver(),
-                                                        settings);
-        this.itsManager = (ServiceManager) this.itsBeanFactory.getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
-        if (componentConfig != null) {
-            // only register listeners if a new bean factory is created
-            this.registerListeners();
-        }
-        this.itsComponentInfo = (ProcessorComponentInfo) this.itsManager
-                .lookup(ProcessorComponentInfo.ROLE);
+        this.itsComponentInfo = (ProcessorComponentInfo) this.itsManager.lookup(ProcessorComponentInfo.ROLE);
         // Create a helper object to setup components
         this.itsLifecycle = new LifecycleHelper(getLogger(), itsContext, this.itsManager, null /* configuration */);
 
@@ -735,7 +549,7 @@
         }
 
         final String beanName = role + '/' + type;
-        if ( !this.itsBeanFactory.containsBean(beanName) ) {
+        if ( !this.itsContainer.getBeanFactory().containsBean(beanName) ) {
             throw new ConfigurationException("Type '" + type + "' does not exist for 'map:"
                     + statement.getName() + "' at " + statement.getLocation());
         }
@@ -787,30 +601,25 @@
      * Register all registered sitemap listeners
      */
     protected void registerListeners() {
-        String[] names = this.itsBeanFactory.getBeanNamesForType(EnterSitemapEventListener.class);
-        for(int i=0; i<names.length; i++) {
-            final String beanName = names[i];
-            this.enterSitemapEventListeners.add(this.itsBeanFactory.getBean(beanName));
-        }
-        names = this.itsBeanFactory.getBeanNamesForType(LeaveSitemapEventListener.class);
-        for(int i=0; i<names.length; i++) {
-            final String beanName = names[i];
-            this.leaveSitemapEventListeners.add(this.itsBeanFactory.getBean(beanName));
+        if ( this.itsContainer.getBeanFactory() instanceof ListableBeanFactory ) {
+            final ListableBeanFactory listableFactory = (ListableBeanFactory)this.itsContainer.getBeanFactory();
+            Map beans = listableFactory.getBeansOfType(EnterSitemapEventListener.class);
+            if ( beans != null ) {
+                final Iterator i = beans.values().iterator();
+                while ( i.hasNext() ) {
+                    this.enterSitemapEventListeners.add(i.next());                    
+                }
+            }
+            beans = listableFactory.getBeansOfType(LeaveSitemapEventListener.class);
+            if ( beans != null ) {
+                final Iterator i = beans.values().iterator();
+                while ( i.hasNext() ) {
+                    this.leaveSitemapEventListeners.add(i.next());
+                }
+            }
         }
     }
 
-    /**
-     * Create the context for this sitemap.
-     */
-    protected Context createContext() {
-        // Create sub-context for this sitemap
-        DefaultContext newContext = new DefaultContext(this.context);
-        Environment env = EnvironmentHelper.getCurrentEnvironment();
-        newContext.put(Constants.CONTEXT_ENV_PREFIX, env.getURIPrefix());
-
-        return newContext;
-    }
-
     // ---- Views management
 
     /** Collection of view names for each label */
@@ -1135,89 +944,4 @@
         }
         return Arrays.asList(StringUtils.split(labels, ", \t\n\r"));
     }
-
-    /**
-     * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
-     */
-    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
-        if (!(beanFactory instanceof ConfigurableListableBeanFactory)) {
-            throw new BeanCreationException(
-                    "Bean factory for tree processor must be an instance of "
-                            + ConfigurableListableBeanFactory.class.getName());
-        }
-        this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
-    }
-
-    /**
-     * Get the settings for Cocoon.
-     * This method reads several property files and merges the result. If there
-     * is more than one definition for a property, the last one wins.
-     * The property files are read in the following order:
-     * 1) PROPERTYDIR/*.properties
-     *    Default values for the core and each block - the order in which the files are read is not guaranteed.
-     * 2) PROPERTYDIR/[RUNNING_MODE]/*.properties
-     *    Default values for the running mode - the order in which the files are read is not guaranteed.
-     * 3) Property providers (ToBeDocumented)
-     *
-     * @return A new Settings object
-     */
-    protected MutableSettings createSettings(Settings    parent,
-                                             List        directories,
-                                             boolean     useDefaultIncludes,
-                                             BeanFactory parentBeanFactory,
-                                             Properties  globalSitemapVariables) {
-        // get the running mode
-        final String mode = parent.getRunningMode();
-        // get properties
-        final Properties properties = new Properties();
-
-        // create an empty settings objects
-        final MutableSettings s = new MutableSettings(parent);
-
-        // read properties from default includes
-        if ( useDefaultIncludes ) {
-        	SourceResolver resolver = this.processor.getSourceResolver();
-            SettingsHelper.readProperties(SitemapLanguage.DEFAULT_CONFIG_PROPERTIES, s, properties, resolver, getLogger());
-            // read all properties from the mode dependent directory
-            SettingsHelper.readProperties(SitemapLanguage.DEFAULT_CONFIG_PROPERTIES + '/' + mode, s, properties, resolver, getLogger());    
-        }
-
-        if ( directories != null ) {
-        	SourceResolver resolver = this.processor.getSourceResolver();
-            final Iterator i = directories.iterator();
-            while ( i.hasNext() ) {
-                final String directory = (String)i.next();
-                // now read all properties from the properties directory
-                SettingsHelper.readProperties(directory, s, properties, resolver, getLogger());
-                // read all properties from the mode dependent directory
-                SettingsHelper.readProperties(directory + '/' + mode, s, properties, resolver, getLogger());
-            }
-        }
-
-        // Next look for a custom property provider in the parent bean factory
-        if (parentBeanFactory != null && parentBeanFactory.containsBean(PropertyProvider.ROLE) ) {
-            try {
-                final Environment env = EnvironmentHelper.getCurrentEnvironment();
-                final PropertyProvider provider = (PropertyProvider)parentBeanFactory.getBean(PropertyProvider.ROLE);
-                // TODO - add the name of the sitemap file to the path
-                final Properties providedProperties = provider.getProperties(s, mode, env.getURIPrefix());
-                if ( providedProperties != null ) {
-                    properties.putAll(providedProperties);
-                }
-            } catch (Exception ignore) {
-                this.getLogger().warn("Unable to get properties from provider.", ignore);
-                this.getLogger().warn("Continuing initialization.");            
-            }
-        }
-        if ( globalSitemapVariables != null ) {
-            properties.putAll(globalSitemapVariables);
-        }
-        PropertyHelper.replaceAll(properties, parent);
-        s.configure(properties);
-
-        return s;
-    }
-
-    /** Parameter map for the context protocol */
-    protected static final Map CONTEXT_PARAMETERS = Collections.singletonMap("force-traversable", Boolean.TRUE);
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java Fri Sep  8 13:30:05 2006
@@ -17,20 +17,18 @@
 package org.apache.cocoon.core.container.spring;
 
 import java.io.IOException;
-import java.util.Stack;
+import java.net.MalformedURLException;
+import java.net.URL;
 
-import javax.servlet.ServletContext;
-
-import org.apache.cocoon.configuration.Settings;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.core.io.ByteArrayResource;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
 import org.springframework.util.ClassUtils;
 import org.springframework.util.ResourceUtils;
 import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.scope.RequestAttributes;
-import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.context.support.XmlWebApplicationContext;
 
 /**
@@ -40,12 +38,7 @@
  * @since 2.2
  * @version $Id$
  */
-public class CocoonWebApplicationContext extends XmlWebApplicationContext implements Container {
-
-    /** The name of the request attribute containing the current bean factory. */
-    public static final String WEB_APPLICATION_CONTEXT_REQUEST_ATTRIBUTE = CocoonWebApplicationContext.class.getName();
-
-    private static final String WEB_APPLICATION_CONTEXT_STACK_REQUEST_ATTRIBUTE = CocoonWebApplicationContext.class.getName() + "/Stack";
+public class CocoonWebApplicationContext extends XmlWebApplicationContext {
 
     /** The base url (already postfixed with a '/'). */
     protected final String baseUrl;
@@ -90,7 +83,18 @@
         // only if the path does not start with a "/" and is not a url
         // we assume it is relative
         if ( path != null && !path.startsWith("/") && !ResourceUtils.isUrl(path) ) {
-            return super.getResourceByPath(this.baseUrl + path);
+            final String absoluteUrl = this.baseUrl + path;
+            if (absoluteUrl.startsWith(CLASSPATH_URL_PREFIX)) {
+                return new ClassPathResource(absoluteUrl.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
+            }
+            try {
+                // try URL
+                URL url = new URL(absoluteUrl);
+                return new UrlResource(url);
+            } catch (MalformedURLException ex) {
+                // no URL -> resolve resource path
+                return super.getResourceByPath(absoluteUrl);
+            }
         }
         return super.getResourceByPath(path);
     }
@@ -101,68 +105,5 @@
      */
     protected String[] getDefaultConfigLocations() {
         return new String[0];
-    }
-
-    /**
-     * Notify about entering this context.
-     * @param attributes The request attributes.
-     * @return A handle which should be passed to {@link #leavingContext(RequestAttributes, Object)}.
-     */
-    public Object enteringContext(RequestAttributes attributes) {
-        final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
-        final Object oldContext = attributes.getAttribute(WEB_APPLICATION_CONTEXT_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
-        if ( oldContext != null ) {
-            Stack stack = (Stack)attributes.getAttribute(WEB_APPLICATION_CONTEXT_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
-            if ( stack == null ) {
-                stack = new Stack();
-                attributes.setAttribute(WEB_APPLICATION_CONTEXT_STACK_REQUEST_ATTRIBUTE, stack, RequestAttributes.SCOPE_REQUEST);
-            }
-            stack.push(oldContext);
-        }
-        attributes.setAttribute(WEB_APPLICATION_CONTEXT_REQUEST_ATTRIBUTE, this, RequestAttributes.SCOPE_REQUEST);
-        Thread.currentThread().setContextClassLoader(this.classLoader);
-        return oldClassLoader;
-    }
-
-    /**
-     * Notify about leaving this context.
-     * @param attributes The request attributes.
-     * @param handle     The returned handle from {@link #enteringContext(RequestAttributes)}.
-     */
-    public void leavingContext(RequestAttributes attributes, Object handle) {
-        Thread.currentThread().setContextClassLoader((ClassLoader)handle);
-        final Stack stack = (Stack)attributes.getAttribute(WEB_APPLICATION_CONTEXT_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
-        if ( stack == null ) {
-            attributes.removeAttribute(WEB_APPLICATION_CONTEXT_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
-        } else {
-            final Object oldContext = stack.pop();
-            attributes.setAttribute(WEB_APPLICATION_CONTEXT_REQUEST_ATTRIBUTE, oldContext, RequestAttributes.SCOPE_REQUEST);
-            if ( stack.size() == 0 ) {
-                attributes.removeAttribute(WEB_APPLICATION_CONTEXT_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
-            }
-        }
-    }
-
-    /**
-     * Return the current web application context.
-     * @param servletContext The servlet context.
-     * @param attributes     The request attributes.
-     * @return The web application context.
-     */
-    public static WebApplicationContext getCurrentContext(ServletContext servletContext,
-                                                          RequestAttributes attributes) {
-        WebApplicationContext parentContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
-        if (attributes.getAttribute(WEB_APPLICATION_CONTEXT_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST) != null) {
-            parentContext = (CocoonWebApplicationContext) attributes
-                    .getAttribute(WEB_APPLICATION_CONTEXT_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
-        }
-        return parentContext;
-    }
-
-    /**
-     * @see org.apache.cocoon.core.container.spring.Container#getSettings()
-     */
-    public Settings getSettings() {
-        return (Settings)this.getBean(Settings.ROLE);
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/Container.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/Container.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/Container.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/Container.java Fri Sep  8 13:30:05 2006
@@ -15,30 +15,105 @@
  */
 package org.apache.cocoon.core.container.spring;
 
+import java.util.Stack;
+
+import javax.servlet.ServletContext;
+
 import org.apache.cocoon.configuration.Settings;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.scope.RequestAttributes;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 
 /**
  * 
  * @version $Id$
  */
-public interface Container {
+public class Container {
+
+    /** The name of the request attribute containing the current bean factory. */
+    public static final String CONTAINER_REQUEST_ATTRIBUTE = Container.class.getName();
+
+    protected static final String CONTAINER_STACK_REQUEST_ATTRIBUTE = Container.class.getName() + "/Stack";
+
+    protected ClassLoader classLoader;
+    protected BeanFactory beanFactory;
+
+    public Container(BeanFactory beanFactory, ClassLoader classLoader) {
+        this.beanFactory = beanFactory;
+        this.classLoader = classLoader;
+    }
+
+    protected static Container ROOT_CONTAINER;
+
+    /**
+     * Return the current web application context.
+     * @param servletContext The servlet context.
+     * @param attributes     The request attributes.
+     * @return The web application context.
+     */
+    public static Container getCurrentContainer(ServletContext servletContext,
+                                                RequestAttributes attributes) {
+        if (attributes.getAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST) != null) {
+            return (Container) attributes
+                    .getAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+        }
+        if ( ROOT_CONTAINER == null ) {
+            final WebApplicationContext parentContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
+            ROOT_CONTAINER = new Container(parentContext, parentContext.getClassLoader());
+        }
+        return ROOT_CONTAINER;
+    }
 
     /**
      * Notify about entering this context.
      * @param attributes The request attributes.
      * @return A handle which should be passed to {@link #leavingContext(RequestAttributes, Object)}.
      */
-    Object enteringContext(RequestAttributes attributes);
+    public Object enteringContext(RequestAttributes attributes) {
+        final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        final Object oldContext = attributes.getAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+        if ( oldContext != null ) {
+            Stack stack = (Stack)attributes.getAttribute(CONTAINER_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+            if ( stack == null ) {
+                stack = new Stack();
+                attributes.setAttribute(CONTAINER_STACK_REQUEST_ATTRIBUTE, stack, RequestAttributes.SCOPE_REQUEST);
+            }
+            stack.push(oldContext);
+        }
+        attributes.setAttribute(CONTAINER_REQUEST_ATTRIBUTE, this, RequestAttributes.SCOPE_REQUEST);
+        Thread.currentThread().setContextClassLoader(this.classLoader);
+        return oldClassLoader;
+    }
 
     /**
      * Notify about leaving this context.
      * @param attributes The request attributes.
      * @param handle     The returned handle from {@link #enteringContext(RequestAttributes)}.
      */
-    void leavingContext(RequestAttributes attributes, Object handle);
+    public void leavingContext(RequestAttributes attributes, Object handle) {
+        Thread.currentThread().setContextClassLoader((ClassLoader)handle);
+        final Stack stack = (Stack)attributes.getAttribute(CONTAINER_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+        if ( stack == null ) {
+            attributes.removeAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+        } else {
+            final Object oldContext = stack.pop();
+            attributes.setAttribute(CONTAINER_REQUEST_ATTRIBUTE, oldContext, RequestAttributes.SCOPE_REQUEST);
+            if ( stack.size() == 0 ) {
+                attributes.removeAttribute(CONTAINER_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+            }
+        }
+    }
+
+    public ClassLoader getClassLoader() {
+        return this.classLoader;
+    }
 
-    ClassLoader getClassLoader();
+    public Settings getSettings() {
+        return (Settings)this.beanFactory.getBean(Settings.ROLE);
+    }
 
-    Settings getSettings();
+    public BeanFactory getBeanFactory() {
+        return this.beanFactory;
+    }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonUtils.java Fri Sep  8 13:30:05 2006
@@ -15,11 +15,17 @@
  */
 package org.apache.cocoon.core.container.spring.avalon;
 
+import java.util.Iterator;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
+import org.apache.cocoon.classloader.ClassLoaderConfiguration;
 import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.configuration.impl.PropertyHelper;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.TraversableSource;
 
 /**
  * Some utility methods for handling Avalon stuff.
@@ -30,16 +36,29 @@
 public class AvalonUtils {
 
     /**
-     * Replace all properties
+     * Replace all properties in the configuration object.
+     * @param tree     The configuration.
+     * @param settings The settings object to resolve the properties.
      */
     public static Configuration replaceProperties(Configuration tree, Settings settings)
     throws ConfigurationException {
+        if ( tree == null || settings == null ) {
+            return tree;
+        }
+        // first clone the tree
         final DefaultConfiguration root = new DefaultConfiguration(tree, true);
-        convert(root, settings);
+        // now replace properties
+        _replaceProperties(root, settings);
         return root;
     }
 
-    protected static void convert(DefaultConfiguration config, Settings settings)
+    /**
+     * Recursivly replace the properties of a configuration object.
+     * @param config   The configuration.
+     * @param settings The settings object to resolve the properties.
+     * @throws ConfigurationException
+     */
+    protected static void _replaceProperties(DefaultConfiguration config, Settings settings)
     throws ConfigurationException {
         final String[] names = config.getAttributeNames();
         for(int i=0; i<names.length; i++) {
@@ -52,7 +71,65 @@
         }
         final Configuration[] children = config.getChildren();
         for(int m=0; m<children.length; m++) {
-            convert((DefaultConfiguration)children[m], settings);
+            _replaceProperties((DefaultConfiguration)children[m], settings);
+        }
+    }
+
+    /**
+     * Read the configuration for a class loader from an Avalon configuration.
+     * This method is used by the sitemap to determine the classpath for the sitemap.
+     * If a lib-directory is configured this method scans the directory and adds
+     * all found jar/zip files to the classpath.
+     * @param resolver   The source resolver for the current sitemap.
+     * @param config     The configuration for the class loader
+     * @return           A class loader configuration object.
+     * @throws Exception
+     */
+    public static ClassLoaderConfiguration createConfiguration(SourceResolver resolver,
+                                                               Configuration  config)
+    throws Exception {
+        final ClassLoaderConfiguration configBean = new ClassLoaderConfiguration();
+        final Configuration[] children = config.getChildren();
+        for (int i = 0; i < children.length; i++) {
+            final Configuration child = children[i];
+            final String name = child.getName();
+            if ("class-dir".equals(name)) {
+                Source src = null;
+                try {
+                    src = resolver.resolveURI(child.getAttribute("src"));
+                    configBean.addClassDirectory(src.getURI());
+                } finally {
+                    resolver.release(src);
+                }
+            } else if ("lib-dir".equals(name)) {
+                Source src = null;
+                try {
+                    src = resolver.resolveURI(child.getAttribute("src"));
+                    if (!src.exists()) {
+                        throw new Exception(src.getURI() + " doesn't exist");
+                    } else if (!(src instanceof TraversableSource) || !((TraversableSource)src).isCollection()) {
+                        throw new Exception(src.getURI() + " is not a directory");
+                    }
+                    Iterator iter = ((TraversableSource)src).getChildren().iterator();
+                    while (iter.hasNext()) {
+                        final Source childSrc = (Source)iter.next();
+                        String childURI = childSrc.getURI();
+                        resolver.release(childSrc);
+                        if (childURI.endsWith(".jar") || childURI.endsWith(".zip")) {
+                            configBean.addClassDirectory(childURI);
+                        }
+                    }
+                } finally {
+                    resolver.release(src);
+                }
+            } else if ("include-classes".equals(name)) {
+                configBean.addInclude(child.getAttribute("pattern"));
+            } else if ("exclude-classes".equals(name)) {
+                configBean.addExclude(child.getAttribute("pattern"));
+            } else {
+                throw new ConfigurationException("Unexpected element " + name + " at " + child.getLocation());
+            }
         }
+        return configBean;
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java Fri Sep  8 13:30:05 2006
@@ -80,15 +80,16 @@
 
     /**
      * This method reads in an Avalon style sitemap.
-     * @param source         The location of the sitemap.
+     * @param src         The location of the sitemap.
      * @param resourceLoader The resource loader to load included configs.
      * @return               A configuration containing all defined objects.
      * @throws Exception
      */
     public static ConfigurationInfo readSitemap(ConfigurationInfo parentInfo,
-                                                String            source,
+                                                String            src,
                                                 ResourceLoader    resourceLoader)
     throws Exception {
+        String source = src;
         if ( source == null || source.trim().length() == 0 ) {
             source = "sitemap.xmap";
         }
@@ -97,13 +98,6 @@
         return converter.configInfo;
     }
 
-    public static ConfigurationInfo readConfiguration(Configuration     config,
-                                                      ConfigurationInfo parentInfo,
-                                                      ResourceLoader    resourceLoader)
-    throws Exception {
-        return readConfiguration(config, null, parentInfo, resourceLoader);
-    }
-
     public static ConfigurationInfo readConfiguration(Configuration     rolesConfig,
                                                       Configuration     componentConfig,
                                                       ConfigurationInfo parentInfo,
@@ -147,6 +141,11 @@
         }
     }
 
+    /**
+     * Convert an avalon url (with possible cocoon protocols) to a spring url.
+     * @param url The avalon url.
+     * @return The spring url.
+     */
     protected String convertUrl(String url) {
         if ( url == null ) {
             return null;
@@ -157,9 +156,9 @@
         if ( url.startsWith("resource:") ) {
             return "classpath:" + url.substring(10);
         }
-        if ( url.indexOf(':') == -1 && !url.startsWith("/")) {
-            return '/' + url;
-        }
+        //if ( url.indexOf(':') == -1 && !url.startsWith("/")) {
+        //    return '/' + url;
+        //}
         return url;
     }
 
@@ -171,12 +170,16 @@
     }
 
     protected String getUrl(String url, String base) {
-        if ( url == null ) {
-            return url;
+        if ( url == null || base == null ) {
+            return this.convertUrl(url);
         }
-        if ( base != null && url.indexOf(":/") < 2) {
-            // TODO - we have to check if url is relative or absolute
-            System.out.println("URL: " + url + " (" + base + ")");            
+        if ( url.indexOf(":/") < 2) {
+            int posSeparator = base.lastIndexOf('/');
+            int posFileSeparator = base.lastIndexOf(File.separatorChar);
+            if ( posFileSeparator > posSeparator ) {
+                posSeparator = posFileSeparator;
+            }
+            return this.convertUrl(base.substring(0, posSeparator+1) + url);
         }
         return this.convertUrl(url);
     }
@@ -186,7 +189,7 @@
         if ( this.logger.isDebugEnabled() ) {
             this.logger.debug("Reading Avalon configuration from " + relativePath);
         }
-        Resource root = this.resolver.getResource(this.convertUrl(relativePath));
+        Resource root = this.resolver.getResource(this.getUrl(relativePath, null));
         final DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(true);
         
         final Configuration config = b.build(this.getInputSource(root));
@@ -211,9 +214,12 @@
         if ( this.logger.isDebugEnabled() ) {
             this.logger.debug("Reading sitemap from " + sitemapLocation);
         }
-        final Resource root = this.resolver.getResource(this.convertUrl(sitemapLocation));
+        final Resource root = this.resolver.getResource(this.getUrl(sitemapLocation, null));
+        if ( this.logger.isDebugEnabled() ) {
+            this.logger.debug("Resolved sitemap: " + root.getURL());
+        }
         final DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(true);
-        
+
         final Configuration config = b.build(this.getInputSource(root));
         // validate cocoon.xconf
         if (!"sitemap".equals(config.getName())) {
@@ -447,7 +453,7 @@
             
         } else {
             // test if directory exists
-            Resource dirResource = this.resolver.getResource(this.convertUrl(directoryURI));
+            Resource dirResource = this.resolver.getResource(this.getUrl(directoryURI, contextURI));
             if ( dirResource.exists() ) {
                 final String pattern = includeStatement.getAttribute("pattern", null);
                 try {
@@ -546,7 +552,7 @@
 
         } else {
             // test if directory exists
-            Resource dirResource = this.resolver.getResource(this.convertUrl(directoryURI));
+            Resource dirResource = this.resolver.getResource(this.getUrl(directoryURI, contextURI));
             if ( dirResource.exists() ) {
                 final String pattern = includeStatement.getAttribute("pattern", null);
                 try {

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java Fri Sep  8 13:30:05 2006
@@ -31,6 +31,7 @@
 import org.apache.cocoon.classloader.ClassLoaderFactory;
 import org.apache.cocoon.core.container.spring.CocoonRequestAttributes;
 import org.apache.cocoon.core.container.spring.CocoonWebApplicationContext;
+import org.apache.cocoon.core.container.spring.Container;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.util.Deprecation;
 import org.apache.excalibur.source.Source;
@@ -94,7 +95,6 @@
         buffer.append(uriPrefix);
         buffer.append("\"/>\n");
         addFooter(buffer);
-        System.out.println("NEW CONFIG: " + buffer.toString());
         return buffer.toString();
     }
 
@@ -219,11 +219,10 @@
         return globalSitemapVariables;
     }
 
-    public static CocoonWebApplicationContext createApplicationContext(String         uriPrefix,
-                                                                       Configuration  config,
-                                                                       ServletContext servletContext,
-                                                                       SourceResolver sitemapResolver,
-                                                                       Request        request)
+    public static Container createContainer(Configuration  config,
+                                            ServletContext servletContext,
+                                            SourceResolver sitemapResolver,
+                                            Request        request)
     throws Exception {
         // let's determine our context url
         Source s = sitemapResolver.resolveURI("a");
@@ -232,14 +231,19 @@
         contextUrl = contextUrl.substring(0, contextUrl.length() - 1);
 
         final RequestAttributes attr = new CocoonRequestAttributes(request);
-        final WebApplicationContext parentContext = CocoonWebApplicationContext.getCurrentContext(servletContext, attr);
+        final Container container = Container.getCurrentContainer(servletContext, attr);
+        // for now we require that the parent container is a web application context (FIXME)
+        if ( !(container.getBeanFactory() instanceof WebApplicationContext) ) {
+            throw new Exception("Parent container is not a web application context: " + container.getBeanFactory());
+        }
+        final WebApplicationContext parentContext = (WebApplicationContext)container.getBeanFactory();
 
         // get classloader
         final ClassLoader classloader = createClassLoader(parentContext, config, servletContext, sitemapResolver);
         // create root bean definition
         final boolean useDefaultIncludes = isUsingDefaultIncludes(config);
         final List propIncludes = getPropertyIncludes(config);
-        final String definition = createDefinition(uriPrefix,
+        final String definition = createDefinition(request.getSitemapURIPrefix(),
                                                    useDefaultIncludes,
                                                    propIncludes,
                                                    getGlobalSitemapVariables(config));
@@ -249,7 +253,7 @@
                                                                                         parentContext,
                                                                                         contextUrl,
                                                                                         definition);
-            return context;
+            return new Container(context, context.getClassLoader());
         } finally {
             PARENT_CONTEXT.set(null);
         }
@@ -277,7 +281,7 @@
         final String factoryRole = config.getAttribute("factory-role", ClassLoaderFactory.ROLE);
 
         // Create a new classloader
-        ClassLoaderConfiguration configBean = ClassLoaderUtils.createConfiguration(sitemapResolver, config);
+        ClassLoaderConfiguration configBean = AvalonUtils.createConfiguration(sitemapResolver, config);
         ClassLoaderFactory clFactory = (ClassLoaderFactory)parentFactory.getBean(factoryRole);
         return clFactory.createClassLoader(Thread.currentThread().getContextClassLoader(),
                                            configBean,

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiSpringECMFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiSpringECMFactory.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiSpringECMFactory.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/osgi/OSGiSpringECMFactory.java Fri Sep  8 13:30:05 2006
@@ -30,10 +30,7 @@
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.cocoon.ProcessingUtil;
 import org.apache.cocoon.configuration.Settings;
-import org.apache.cocoon.core.container.spring.BeanFactoryUtil;
 import org.apache.cocoon.core.container.spring.avalon.AvalonEnvironment;
-import org.apache.cocoon.core.container.spring.ConfigReader;
-import org.apache.cocoon.core.container.spring.avalon.ConfigurationInfo;
 import org.apache.cocoon.environment.Context;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java Fri Sep  8 13:30:05 2006
@@ -25,10 +25,9 @@
 
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.Processor;
 import org.apache.cocoon.components.flow.FlowHelper;
-import org.apache.cocoon.configuration.Settings;
-import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.cocoon.core.container.spring.CocoonRequestAttributes;
+import org.apache.cocoon.core.container.spring.Container;
 import org.apache.commons.jxpath.DynamicPropertyHandler;
 import org.apache.commons.jxpath.JXPathBeanInfo;
 import org.apache.commons.jxpath.JXPathIntrospector;
@@ -45,7 +44,9 @@
 public class TemplateObjectModelHelper {
     
     /** Avoid instantiation */
-    private TemplateObjectModelHelper() {}
+    private TemplateObjectModelHelper() {
+        // empty
+    }
 
     public static void fillContext(Object contextObject, Map map) {
         // Hack: I use jxpath to populate the context object's properties
@@ -127,11 +128,8 @@
             cocoon.put("parameters", new ParametersMap(parameters));
         }
 
-        Processor processor = EnvironmentHelper.getCurrentProcessor();
-        if (processor != null) {
-            final Settings settings = (Settings) processor.getBeanFactory().getBean(Settings.ROLE);
-            cocoon.put("settings", settings);
-        }
+        final Container container = Container.getCurrentContainer(context, new CocoonRequestAttributes(request));
+        cocoon.put("settings", container.getSettings());
 
         final Map map = new HashMap();
         map.put("cocoon", cocoon);

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java Fri Sep  8 13:30:05 2006
@@ -30,11 +30,15 @@
 import org.apache.cocoon.ProcessingUtil;
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.core.container.spring.CocoonRequestAttributes;
+import org.apache.cocoon.core.container.spring.Container;
+import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.xml.XMLConsumer;
 import org.apache.excalibur.source.Source;
-import org.springframework.beans.factory.BeanFactory;
 
 /**
  * Helper class for maintaining the environment stack.
@@ -93,8 +97,8 @@
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
+    public void service(ServiceManager avalonManager) throws ServiceException {
+        this.manager = avalonManager;
         this.resolver = (org.apache.excalibur.source.SourceResolver)
                           this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
         Source source = null;
@@ -391,18 +395,11 @@
     static public ServiceManager getSitemapServiceManager() {
         final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
         if ( stack != null && !stack.isEmpty()) {
-            EnvironmentInfo info = stack.getCurrentInfo();
-            Processor processor = info.processor;
-            BeanFactory factory = info.processor.getBeanFactory();
-            while ( factory == null && processor != null ) {
-                processor = processor.getParent();
-                if ( processor != null ) {
-                    factory = processor.getBeanFactory();
-                }
-            }
-            if ( factory != null ) {
-                return (ServiceManager) factory.getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
-            }
+            final EnvironmentInfo info = stack.getCurrentInfo();
+            final Request request = ObjectModelHelper.getRequest(info.environment.getObjectModel());
+            final Context context = ObjectModelHelper.getContext(info.environment.getObjectModel());
+            final Container container = Container.getCurrentContainer(context, new CocoonRequestAttributes(request));
+            return (ServiceManager)container.getBeanFactory().getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
         }
         return null;
     }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/processing/impl/ProcessInfoProviderImpl.java Fri Sep  8 13:30:05 2006
@@ -48,8 +48,8 @@
     /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
-    public void contextualize(Context context) throws ContextException {
-        this.context = context;
+    public void contextualize(Context aContext) throws ContextException {
+        this.context = aContext;
         this.servletContext = (ServletContext) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
     }
 

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java Fri Sep  8 13:30:05 2006
@@ -91,7 +91,6 @@
         // create the tree processor
         try {
 			TreeProcessor treeProcessor =  new TreeProcessor();
-            treeProcessor.setBeanFactory(this.beanFactory);			
             // TODO (DF/RP) The treeProcessor doesn't need to be a managed component at all. 
             this.processor = (Processor) LifecycleHelper.setupComponent(treeProcessor,
                     this.logger,

Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java?view=diff&rev=441638&r1=441637&r2=441638
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java (original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/core/container/ContainerTestCase.java Fri Sep  8 13:30:05 2006
@@ -36,9 +36,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.Constants;
 import org.apache.cocoon.configuration.impl.MutableSettings;
-import org.apache.cocoon.core.container.spring.BeanFactoryUtil;
 import org.apache.cocoon.core.container.spring.avalon.AvalonEnvironment;
-import org.apache.cocoon.core.container.spring.ConfigReader;
 import org.apache.cocoon.core.container.spring.avalon.ConfigurationInfo;
 import org.apache.cocoon.environment.mock.MockContext;
 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -294,9 +292,11 @@
         avalonEnv.context = this.context;
         avalonEnv.settings = new MutableSettings("test");
         // read roles and components
-        ConfigurationInfo rolesInfo = ConfigReader.readConfiguration(confRM, confCM, null, avalonEnv, null);
+        // FIXME
+        ConfigurationInfo rolesInfo = null;//ConfigReader.readConfiguration(confRM, confCM, null, avalonEnv, null);
         this.addComponents( rolesInfo );
-        this.beanFactory = BeanFactoryUtil.createBeanFactory(avalonEnv, rolesInfo, null, null);
+        // FIXME
+        this.beanFactory = null; //BeanFactoryUtil.createBeanFactory(avalonEnv, rolesInfo, null, null);
 
         this.manager = (ServiceManager)this.beanFactory.getBean(ServiceManager.class.getName());
     }



Mime
View raw message