cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r441648 - in /cocoon/trunk/core/cocoon-core/src/main: java/org/apache/cocoon/components/treeprocessor/ java/org/apache/cocoon/core/container/spring/ java/org/apache/cocoon/core/container/spring/avalon/ resources/org/apache/cocoon/core/conta...
Date Fri, 08 Sep 2006 21:02:39 GMT
Author: cziegeler
Date: Fri Sep  8 14:02:38 2006
New Revision: 441648

URL: http://svn.apache.org/viewvc?view=rev&rev=441648
Log:
Fix handling of default properties location

Modified:
    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/NodeBuilderSelector.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.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/PropertiesElementParser.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.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/resources/org/apache/cocoon/core/container/spring/cocoon.xsd

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=441648&r1=441647&r2=441648
==============================================================================
--- 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 14:02:38 2006
@@ -47,8 +47,6 @@
 import org.apache.cocoon.sitemap.SitemapExecutor;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationImpl;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 
 /**
  * The concrete implementation of {@link Processor}, containing the evaluation tree and associated
@@ -88,8 +86,8 @@
     /** Processor attributes */
     protected Map processorAttributes = new HashMap();
 
-    /** Bean Factory for this sitemap. */
-    protected Container beanFactory;
+    /** Container for this sitemap. */
+    protected Container container;
 
     /** Classloader for this sitemap. */
     protected ClassLoader classLoader;
@@ -116,8 +114,8 @@
             throw new IllegalStateException("setProcessorData() can only be called once");
         }
         this.classLoader = container.getClassLoader();
-        this.beanFactory = container;
-        this.manager = (ServiceManager)this.beanFactory.getBeanFactory().getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
+        this.container = container;
+        this.manager = (ServiceManager)this.container.getBeanFactory().getBean(ProcessingUtil.SERVICE_MANAGER_ROLE);
         this.rootNode = rootNode;
         this.disposableNodes = disposableNodes;
         this.enterSitemapEventListeners = enterSitemapEventListeners;
@@ -209,7 +207,7 @@
         Thread.currentThread().setContextClassLoader(this.classLoader);
         Object handle = null;
         try {
-            handle = this.beanFactory.enteringContext(new CocoonRequestAttributes(ObjectModelHelper.getRequest(environment.getObjectModel())));
+            handle = this.container.enteringContext(new CocoonRequestAttributes(ObjectModelHelper.getRequest(environment.getObjectModel())));
             // invoke listeners
             // only invoke if pipeline is not internally
             if ( !context.isBuildingPipelineOnly() ) {
@@ -244,7 +242,7 @@
 
         } finally {
             this.sitemapExecutor.leaveSitemap(this, environment.getObjectModel());
-            this.beanFactory.leavingContext(new CocoonRequestAttributes(ObjectModelHelper.getRequest(environment.getObjectModel())),
handle);
+            this.container.leavingContext(new CocoonRequestAttributes(ObjectModelHelper.getRequest(environment.getObjectModel())),
handle);
             // invoke listeners
             // only invoke if pipeline is not internally
             if ( !context.isBuildingPipelineOnly() ) {
@@ -269,8 +267,9 @@
         }
     }
 
-    protected boolean handleCocoonRedirect(String uri, Environment environment, InvokeContext
context)
+    protected boolean handleCocoonRedirect(String uri, Environment env, InvokeContext context)
     throws Exception {
+        Environment environment = env;
         // Build an environment wrapper
         // If the current env is a facade, change the delegate and continue processing the
facade, since
         // we may have other redirects that will in turn also change the facade delegate
@@ -339,9 +338,9 @@
         // clear listeners
         this.enterSitemapEventListeners.clear();
         this.leaveSitemapEventListeners.clear();
-        if ( this.beanFactory != null && this.beanFactory instanceof ConfigurableBeanFactory)
{
-        	((ConfigurableBeanFactory) this.beanFactory).destroySingletons();
-            this.beanFactory = null;
+        if ( this.container != null ) {
+        	this.container.shutdown();
+            this.container = null;
         }
     }
 
@@ -419,13 +418,6 @@
      */
     public String getType() {
         return "sitemap";
-    }
-
-    /**
-     * @see org.apache.cocoon.Processor#getBeanFactory()
-     */
-    public BeanFactory getBeanFactory() {
-        return this.beanFactory.getBeanFactory();
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java?view=diff&rev=441648&r1=441647&r2=441648
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/NodeBuilderSelector.java
Fri Sep  8 14:02:38 2006
@@ -65,8 +65,8 @@
     /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
-    public void contextualize( final Context context ) {
-        this.context = context;
+    public void contextualize( final Context avalonContext ) {
+        this.context = avalonContext;
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java?view=diff&rev=441648&r1=441647&r2=441648
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/SimpleSelectorProcessingNode.java
Fri Sep  8 14:02:38 2006
@@ -46,9 +46,9 @@
         this.selectorRole = selectorRole;
     }
 
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-        this.selector = (ServiceSelector)manager.lookup(selectorRole);
+    public void service(ServiceManager avalonManager) throws ServiceException {
+        this.manager = avalonManager;
+        this.selector = (ServiceSelector)this.manager.lookup(selectorRole);
         
         // Pre-lookup the associated component, and cache it if it's threadsafe
         Object component = this.selector.select(this.getType());

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=441648&r1=441647&r2=441648
==============================================================================
--- 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 14:02:38 2006
@@ -21,6 +21,8 @@
 
 import org.apache.cocoon.configuration.Settings;
 import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.scope.RequestAttributes;
 import org.springframework.web.context.support.WebApplicationContextUtils;
@@ -115,5 +117,13 @@
 
     public BeanFactory getBeanFactory() {
         return this.beanFactory;
+    }
+
+    public void shutdown() {
+        if ( this.beanFactory instanceof ConfigurableApplicationContext ) {
+            ((ConfigurableApplicationContext)this.beanFactory).close();
+        } else if ( this.beanFactory instanceof ConfigurableBeanFactory ) {
+            ((ConfigurableBeanFactory)this.beanFactory).destroySingletons();
+        }
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/PropertiesElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/PropertiesElementParser.java?view=diff&rev=441648&r1=441647&r2=441648
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/PropertiesElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/PropertiesElementParser.java
Fri Sep  8 14:02:38 2006
@@ -18,6 +18,7 @@
 
 import org.apache.cocoon.configuration.Settings;
 import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.w3c.dom.Element;
 
@@ -35,12 +36,12 @@
      * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
org.springframework.beans.factory.xml.ParserContext)
      */
     public BeanDefinition parse(Element element, ParserContext parserContext) {
-        this.addComponent(SubSettingsBeanFactoryPostProcessor.class.getName(),
-                          Settings.ROLE,
-                          "init",
-                          false,
-                          parserContext.getRegistry());
-
-        return null;
+        RootBeanDefinition def =  this.createBeanDefinition(SubSettingsBeanFactoryPostProcessor.class.getName(),
+                "init",
+                false);
+        def.getPropertyValues().addPropertyValue("sitemapUri", element.getAttribute("sitemapUri"));
+        def.getPropertyValues().addPropertyValue("useDefaultIncludes", element.getAttribute("useDefaultIncludes"));
+        this.register(def, Settings.ROLE, parserContext.getRegistry());
+        return def;
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java?view=diff&rev=441648&r1=441647&r2=441648
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java
Fri Sep  8 14:02:38 2006
@@ -26,6 +26,7 @@
 import org.apache.cocoon.configuration.impl.PropertyHelper;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.HierarchicalBeanFactory;
+import org.springframework.core.io.Resource;
 
 /**
  * This is a bean factory post processor which sets up a child settings object.
@@ -42,7 +43,7 @@
 
     protected List directories;
 
-    protected boolean useDefaultIncludes;
+    protected boolean useDefaultIncludes = true;
 
     protected Properties globalSitemapVariables;    
 
@@ -61,6 +62,22 @@
         this.settings.makeReadOnly();
     }
 
+    public void setDirectories(List directories) {
+        this.directories = directories;
+    }
+
+    public void setGlobalSitemapVariables(Properties globalSitemapVariables) {
+        this.globalSitemapVariables = globalSitemapVariables;
+    }
+
+    public void setSitemapUri(String sitemapUri) {
+        this.sitemapUri = sitemapUri;
+    }
+
+    public void setUseDefaultIncludes(boolean useDefaultIncludes) {
+        this.useDefaultIncludes = useDefaultIncludes;
+    }
+
     /**
      * Get the settings for Cocoon.
      * This method reads several property files and merges the result. If there
@@ -106,8 +123,9 @@
         // Next look for a custom property provider in the parent bean factory
         if (parentBeanFactory.containsBean(PropertyProvider.ROLE) ) {
             try {
+                final Resource r = this.resourceLoader.getResource(this.sitemapUri);
                 final PropertyProvider provider = (PropertyProvider)parentBeanFactory.getBean(PropertyProvider.ROLE);
-                final Properties providedProperties = provider.getProperties(s, mode, this.sitemapUri);
+                final Properties providedProperties = provider.getProperties(s, mode, r.getURL().toExternalForm());
                 if ( providedProperties != null ) {
                     properties.putAll(providedProperties);
                 }

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=441648&r1=441647&r2=441648
==============================================================================
--- 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 14:02:38 2006
@@ -42,6 +42,7 @@
 
 
 /**
+ * FIXME - This class can only handle the case if the sitemap is named "sitemap.xmap"!!!
  * @version $Id$
  * @since 2.2
  */
@@ -58,12 +59,15 @@
     protected static String createDefinition(String     uriPrefix,
                                              boolean    useDefaultIncludes,
                                              List       includes,
-                                             Properties globalVariables) {
+                                             Properties globalVariables,
+                                             String     sitemapUri) {
         final StringBuffer buffer = new StringBuffer();
         addHeader(buffer);
         // Settings
         buffer.append("  <cocoon:properties useDefaultIncludes=\"");
         buffer.append(useDefaultIncludes);
+        buffer.append("\" sitemapUri=\"");
+        buffer.append(sitemapUri);
         buffer.append("\">\n");
         if ( includes != null && includes.size() > 0 ) {
             buffer.append("    <property name=\"directories\">\n      <list>\n");
@@ -246,7 +250,8 @@
         final String definition = createDefinition(request.getSitemapURIPrefix(),
                                                    useDefaultIncludes,
                                                    propIncludes,
-                                                   getGlobalSitemapVariables(config));
+                                                   getGlobalSitemapVariables(config),
+                                                   "sitemap.xmap");
         PARENT_CONTEXT.set(parentContext);
         try {
             final CocoonWebApplicationContext context = new CocoonWebApplicationContext(classloader,

Modified: cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd?view=diff&rev=441648&r1=441647&r2=441648
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd
Fri Sep  8 14:02:38 2006
@@ -29,6 +29,7 @@
      <xsd:complexContent>
        <xsd:extension base="xsd:anyType">
          <xsd:attribute name="useDefaultIncludes" type="xsd:string" use="optional"></xsd:attribute>
+         <xsd:attribute name="sitemapUri" type="xsd:string" use="required"></xsd:attribute>
        </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>



Mime
View raw message