cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r439796 - in /cocoon/trunk/core/cocoon-core/src/main: java/org/apache/cocoon/components/treeprocessor/sitemap/ java/org/apache/cocoon/core/container/spring/ java/org/apache/cocoon/core/container/spring/avalon/ resources/org/apache/cocoon/co...
Date Sun, 03 Sep 2006 16:22:25 GMT
Author: cziegeler
Date: Sun Sep  3 09:22:21 2006
New Revision: 439796

URL: http://svn.apache.org/viewvc?rev=439796&view=rev
Log:
Continue implementation

Added:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java
  (with props)
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonSitemapContextFactoryBean.java
  (with props)
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapDefinitionCreator.java
  (with props)
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
  (with props)
Modified:
    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/SettingsElementParser.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonNamespaceHandler.java
    cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/avalon/avalon.xsd

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?rev=439796&r1=439795&r2=439796&view=diff
==============================================================================
--- 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
Sun Sep  3 09:22:21 2006
@@ -199,15 +199,15 @@
     /**
      * @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 avalonContext) throws ContextException {
+        this.context = avalonContext;
     }
 
     /**
      * @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 serviceManager) throws ServiceException {
+        this.manager = serviceManager;
     }
 
     /**
@@ -418,7 +418,7 @@
         }
 
         // Context and manager and classloader for the sitemap we build        
-        final Context itsContext = createContext(tree);
+        final Context itsContext = this.createContext();
 
         // TODO Get factory from spring
         final BeanFactoryFactoryImpl factory = new BeanFactoryFactoryImpl();
@@ -785,9 +785,9 @@
     }
 
     /**
-     * @see org.apache.cocoon.components.treeprocessor.DefaultTreeBuilder#createContext(org.apache.avalon.framework.configuration.Configuration)
+     * Create the context for this sitemap.
      */
-    protected Context createContext(Configuration tree) throws Exception {
+    protected Context createContext() {
         // Create sub-context for this sitemap
         DefaultContext newContext = new DefaultContext(this.context);
         Environment env = EnvironmentHelper.getCurrentEnvironment();

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java?rev=439796&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java
Sun Sep  3 09:22:21 2006
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.container.spring;
+
+import org.apache.cocoon.configuration.Settings;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+
+/**
+ * This is a base class for all bean definition parser used in Cocoon.
+ * It provides some utility methods.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public abstract class AbstractElementParser implements BeanDefinitionParser {
+
+    /** Logger (we use the same logging mechanism as Spring!) */
+    protected final Log logger = LogFactory.getLog(getClass());
+
+    /**
+     * Register a bean definition.
+     * @param beanDef  The bean definition.
+     * @param beanName The name of the bean.
+     * @param registry The registry.
+     */
+    protected void register(BeanDefinition beanDef,
+                            String         beanName,
+                            BeanDefinitionRegistry registry) {
+        this.register(beanDef, beanName, null, registry);
+    }
+
+    /**
+     * Register a bean definition.
+     * @param beanDef  The bean definition.
+     * @param beanName The name of the bean.
+     * @param alias    Optional alias.
+     * @param registry The registry.
+     */
+    protected void register(BeanDefinition beanDef,
+                            String         beanName,
+                            String         alias,
+                            BeanDefinitionRegistry registry) {
+        if ( this.logger.isDebugEnabled() ) {
+            this.logger.debug("Registering bean with name " + beanName +
+                              (alias != null ? " (alias=" + alias + ") " : " ") +
+                              beanDef);
+        }
+        final BeanDefinitionHolder holder;
+        if ( alias != null ) {
+            holder = new BeanDefinitionHolder(beanDef, beanName, new String[] {alias});
+        } else {
+            holder = new BeanDefinitionHolder(beanDef, beanName);
+        }
+        BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
+    }
+
+    /**
+     * Helper method to create a new bean definition.
+     * @param componentClass    The class of the implementation.
+     * @param initMethod        Optional initialization method.
+     * @param requiresSettings  If set to true, this bean has a property "settings" for the
settings object.
+     * @return A new root bean definition.
+     */
+    protected RootBeanDefinition createBeanDefinition(Class   componentClass,
+                                                      String  initMethod,
+                                                      boolean requiresSettings) {
+        final RootBeanDefinition beanDef = new RootBeanDefinition();
+        beanDef.setBeanClass(componentClass);      
+        beanDef.setSingleton(true);
+        beanDef.setLazyInit(false);
+        if ( initMethod != null ) {
+            beanDef.setInitMethodName(initMethod);
+        }
+        if ( requiresSettings ) {
+            beanDef.getPropertyValues().addPropertyValue("settings", new RuntimeBeanReference(Settings.ROLE));
+        }
+        return beanDef;
+    }
+
+    /**
+     * Helper method to create a new bean definition.
+     * @param componentClass    The class of the implementation.
+     * @param initMethod        Optional initialization method.
+     * @param requiresSettings  If set to true, this bean has a property "settings" for the
settings object.
+     * @return A new root bean definition.
+     */
+    protected RootBeanDefinition createBeanDefinition(String   componentClass,
+                                                      String  initMethod,
+                                                      boolean requiresSettings) {
+        final RootBeanDefinition beanDef = new RootBeanDefinition();
+        beanDef.setBeanClassName(componentClass);      
+        beanDef.setSingleton(true);
+        beanDef.setLazyInit(false);
+        if ( initMethod != null ) {
+            beanDef.setInitMethodName(initMethod);
+        }
+        if ( requiresSettings ) {
+            beanDef.getPropertyValues().addPropertyValue("settings", new RuntimeBeanReference(Settings.ROLE));
+        }
+        return beanDef;
+    }
+
+    /**
+     * Add a new bean definition to the registry.
+     * @param componentClass    The class of the implementation.
+     * @param beanName          The name of the bean.
+     * @param initMethod        Optional initialization method.
+     * @param requiresSettings  If set to true, this bean has a property "settings" for the
settings object.
+     * @param registry          The bean registry.
+     */
+    protected void addComponent(Class                  componentClass,
+                                String                 beanName,
+                                String                 initMethod,
+                                boolean                requiresSettings,
+                                BeanDefinitionRegistry registry) {
+        final RootBeanDefinition beanDef = this.createBeanDefinition(componentClass, initMethod,
requiresSettings);
+
+        this.register(beanDef, beanName, registry);
+    }
+
+    /**
+     * Add a new bean definition to the registry.
+     * @param componentClass    The class of the implementation.
+     * @param beanName          The name of the bean.
+     * @param initMethod        Optional initialization method.
+     * @param requiresSettings  If set to true, this bean has a property "settings" for the
settings object.
+     * @param registry          The bean registry.
+     */
+    protected void addComponent(String                 componentClass,
+                                String                 beanName,
+                                String                 initMethod,
+                                boolean                requiresSettings,
+                                BeanDefinitionRegistry registry) {
+        final RootBeanDefinition beanDef = this.createBeanDefinition(componentClass, initMethod,
requiresSettings);
+
+        this.register(beanDef, beanName, registry);
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java?rev=439796&r1=439795&r2=439796&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
Sun Sep  3 09:22:21 2006
@@ -17,13 +17,7 @@
 package org.apache.cocoon.core.container.spring;
 
 import org.apache.cocoon.configuration.Settings;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.w3c.dom.Element;
 
@@ -35,10 +29,7 @@
  * @version $Id$
  * @since 2.2
  */
-public class SettingsElementParser implements BeanDefinitionParser {
-
-    /** Logger (we use the same logging mechanism as Spring!) */
-    protected final Log logger = LogFactory.getLog(getClass());
+public class SettingsElementParser extends AbstractElementParser {
 
     /** The name of the configuration attribute to use a different processor class. */
     public static final String PROCESSOR_CLASS_NAME_ATTR = "processorClassName";
@@ -52,14 +43,7 @@
         if ( value != null && value.trim().length() > 0 ) {
             componentClassName = element.getAttribute(PROCESSOR_CLASS_NAME_ATTR);
         }
-        final RootBeanDefinition beanDef = new RootBeanDefinition();
-        beanDef.setBeanClassName(componentClassName);      
-        beanDef.setSingleton(true);
-        beanDef.setLazyInit(false);
-        beanDef.setInitMethodName("init");
-        
-        final BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDef, Settings.ROLE);
-        BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
+        this.addComponent(componentClassName, Settings.ROLE, "init", false, parserContext.getRegistry());
 
         return null;
     }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java?rev=439796&r1=439795&r2=439796&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonElementParser.java
Sun Sep  3 09:22:21 2006
@@ -29,22 +29,18 @@
 import org.apache.cocoon.components.pipeline.ProcessingPipeline;
 import org.apache.cocoon.components.treeprocessor.ProcessorComponentInfo;
 import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.core.container.spring.AbstractElementParser;
 import org.apache.cocoon.generation.Generator;
 import org.apache.cocoon.matching.Matcher;
 import org.apache.cocoon.reading.Reader;
 import org.apache.cocoon.selection.Selector;
 import org.apache.cocoon.serialization.Serializer;
 import org.apache.cocoon.transformation.Transformer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
 import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.BeanDefinitionParser;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.springframework.core.io.ResourceLoader;
 import org.w3c.dom.Element;
@@ -58,47 +54,7 @@
  * @version $Id$
  * @since 2.2
  */
-public class AvalonElementParser implements BeanDefinitionParser {
-
-    /** Logger (we use the same logging mechanism as Spring!) */
-    protected final Log logger = LogFactory.getLog(getClass());
-
-    /**
-     * Register a bean definition.
-     * @param beanDef  The bean definition.
-     * @param beanName The name of the bean.
-     * @param registry The registry.
-     */
-    protected void register(BeanDefinition beanDef,
-                            String         beanName,
-                            BeanDefinitionRegistry registry) {
-        this.register(beanDef, beanName, null, registry);
-    }
-
-    /**
-     * Register a bean definition.
-     * @param beanDef  The bean definition.
-     * @param beanName The name of the bean.
-     * @param alias    Optional alias.
-     * @param registry The registry.
-     */
-    protected void register(BeanDefinition beanDef,
-                            String         beanName,
-                            String         alias,
-                            BeanDefinitionRegistry registry) {
-        if ( this.logger.isDebugEnabled() ) {
-            this.logger.debug("Registering bean with name " + beanName +
-                              (alias != null ? " (alias=" + alias + ") " : " ") +
-                              beanDef);
-        }
-        final BeanDefinitionHolder holder;
-        if ( alias != null ) {
-            holder = new BeanDefinitionHolder(beanDef, beanName, new String[] {alias});
-        } else {
-            holder = new BeanDefinitionHolder(beanDef, beanName);
-        }
-        BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
-    }
+public class AvalonElementParser extends AbstractElementParser {
 
     /**
      * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
org.springframework.beans.factory.xml.ParserContext)
@@ -168,47 +124,6 @@
         final RootBeanDefinition beanDef = this.createBeanDefinition(AvalonLoggerFactoryBean.class,
"init", true);
         beanDef.getPropertyValues().addPropertyValue("loggingConfiguration", configuration);
         this.register(beanDef, ProcessingUtil.LOGGER_ROLE, registry);
-    }
-
-    /**
-     * Helper method to create a new bean definition.
-     * @param componentClass    The class of the implementation.
-     * @param initMethod        Optional initialization method.
-     * @param requiresSettings  If set to true, this bean has a property "settings" for the
settings object.
-     * @return A new root bean definition.
-     */
-    protected RootBeanDefinition createBeanDefinition(Class   componentClass,
-                                                      String  initMethod,
-                                                      boolean requiresSettings) {
-        final RootBeanDefinition beanDef = new RootBeanDefinition();
-        beanDef.setBeanClass(componentClass);      
-        beanDef.setSingleton(true);
-        beanDef.setLazyInit(false);
-        if ( initMethod != null ) {
-            beanDef.setInitMethodName(initMethod);
-        }
-        if ( requiresSettings ) {
-            beanDef.getPropertyValues().addPropertyValue("settings", new RuntimeBeanReference(Settings.ROLE));
-        }
-        return beanDef;
-    }
-
-    /**
-     * Add a new bean definition to the registry.
-     * @param componentClass    The class of the implementation.
-     * @param beanName          The name of the bean.
-     * @param initMethod        Optional initialization method.
-     * @param requiresSettings  If set to true, this bean has a property "settings" for the
settings object.
-     * @param registry          The bean registry.
-     */
-    protected void addComponent(Class                  componentClass,
-                                String                 beanName,
-                                String                 initMethod,
-                                boolean                requiresSettings,
-                                BeanDefinitionRegistry registry) {
-        final RootBeanDefinition beanDef = this.createBeanDefinition(componentClass, initMethod,
requiresSettings);
-
-        this.register(beanDef, beanName, registry);
     }
 
     public void createConfig(ConfigurationInfo      info,

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonNamespaceHandler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonNamespaceHandler.java?rev=439796&r1=439795&r2=439796&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonNamespaceHandler.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonNamespaceHandler.java
Sun Sep  3 09:22:21 2006
@@ -75,5 +75,6 @@
      */
     public void init() {
         registerBeanDefinitionParser("avalon", new AvalonElementParser());
+        registerBeanDefinitionParser("sitemap", new SitemapElementParser());
     }
 }

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonSitemapContextFactoryBean.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonSitemapContextFactoryBean.java?rev=439796&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonSitemapContextFactoryBean.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonSitemapContextFactoryBean.java
Sun Sep  3 09:22:21 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.container.spring.avalon;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.ProcessingUtil;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.HierarchicalBeanFactory;
+
+/**
+ * This factory bean creates a context for a sitemap.
+ * It is part of the Spring bridge for Avalon integration.
+ *
+ * @since 2.2
+ * @version $Id$
+ */
+public class AvalonSitemapContextFactoryBean
+    implements FactoryBean, BeanFactoryAware {
+
+    /** The Avalon context. */
+    protected Context context;
+
+    /** The bean factory. */
+    protected BeanFactory beanFactory;
+
+    /** Environment uri prefix. */
+    protected String uriPrefix;
+
+    public void setUriPrefix(String uriPrefix) {
+        this.uriPrefix = uriPrefix;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
+     */
+    public void setBeanFactory(BeanFactory factory) throws BeansException {
+        this.beanFactory = factory;
+    }
+
+    /**
+     * Create the Avalon context object.
+     * @throws Exception
+     */
+    protected void init()
+    throws Exception {
+        final BeanFactory parentBeanFactory = ((HierarchicalBeanFactory)this.beanFactory).getParentBeanFactory();
+        // create new Avalon context
+        final DefaultContext appContext = new DefaultContext((Context)parentBeanFactory.getBean(ProcessingUtil.CONTEXT_ROLE));
+        appContext.put(Constants.CONTEXT_ENV_PREFIX, this.uriPrefix);
+
+        this.context = appContext;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.FactoryBean#getObject()
+     */
+    public Object getObject() throws Exception {
+        return this.context;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+     */
+    public Class getObjectType() {
+        return Context.class;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+     */
+    public boolean isSingleton() {
+        return true;
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonSitemapContextFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonSitemapContextFactoryBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapDefinitionCreator.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapDefinitionCreator.java?rev=439796&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapDefinitionCreator.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapDefinitionCreator.java
Sun Sep  3 09:22:21 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.container.spring.avalon;
+
+
+/**
+ * @version $Id$
+ * @since 2.2
+ */
+public class SitemapDefinitionCreator {
+
+    public static String createDefinition(String uriPrefix) {
+        final StringBuffer buffer = new StringBuffer();
+        addHeader(buffer);
+        // Settings
+        // Avalon
+        buffer.append("<avalon:sitemap uriPrefix=\"");
+        buffer.append(uriPrefix);
+        buffer.append("\"/>");
+        addFooter(buffer);
+        return buffer.toString();
+    }
+
+    protected static void addHeader(StringBuffer buffer) {
+        buffer.append("<beans xmlns=\"http://www.springframework.org/schema/beans\"");
+        buffer.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
+        buffer.append(" xmlns:util=\"http://www.springframework.org/schema/util\"");
+        buffer.append(" xmlns:cocoon=\"http://org.apache.cocoon/core\"");
+        buffer.append(" xmlns:avalon=\"http://org.apache.cocoon/avalon\"");
+        buffer.append(" xsi:schemaLocation=\"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd");
+        buffer.append(" http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd");
+        buffer.append(" http://org.apache.cocoon/core http://org.apache.cocoon/core.xsd");
+        buffer.append(" http://org.apache.cocoon/avalon http://org.apache.cocoon/avalon.xsd\">");
+    }
+
+    protected static void addFooter(StringBuffer buffer) {
+        buffer.append("</beans>");
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapDefinitionCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapDefinitionCreator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java?rev=439796&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
Sun Sep  3 09:22:21 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.container.spring.avalon;
+
+import org.apache.cocoon.ProcessingUtil;
+import org.apache.cocoon.core.container.spring.AbstractElementParser;
+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;
+
+/**
+ * @version $Id$
+ * @since 2.2
+ */
+public class SitemapElementParser extends AbstractElementParser {
+
+    /**
+     * @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) {
+        // register per sitemap context
+        // we get the uriPrefix from the configuration
+        final String uriPrefix = element.getAttribute("uriPrefix");
+        RootBeanDefinition beanDefinition = this.createBeanDefinition(AvalonSitemapContextFactoryBean.class,
+                                                                      "init",
+                                                                      false);
+        beanDefinition.getPropertyValues().addPropertyValue("uriPrefix", uriPrefix);
+        this.register(beanDefinition, ProcessingUtil.CONTEXT_ROLE, parserContext.getRegistry());
+
+        return null;
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/avalon/avalon.xsd
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/avalon/avalon.xsd?rev=439796&r1=439795&r2=439796&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/avalon/avalon.xsd
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/avalon/avalon.xsd
Sun Sep  3 09:22:21 2006
@@ -19,10 +19,14 @@
         xmlns:tns="http://org.apache.cocoon/avalon">
 
     <xsd:element name="avalon" type="tns:avalonType"/>
+    <xsd:element name="sitemap" type="tns:sitemapType"/>
 
     <xsd:complexType name="avalonType">
     	<xsd:attribute name="location" type="xsd:string"></xsd:attribute>
     	<xsd:attribute name="loggingConfiguration" type="xsd:string" use="optional"></xsd:attribute>
     </xsd:complexType>
 
+    <xsd:complexType name="sitemapType">
+    	<xsd:attribute name="uriPrefix" type="xsd:string"></xsd:attribute>
+    </xsd:complexType>
 </xsd:schema>



Mime
View raw message