cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r378906 - in /cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon: components/treeprocessor/sitemap/ core/container/spring/
Date Sun, 19 Feb 2006 15:02:25 GMT
Author: cziegeler
Date: Sun Feb 19 07:02:24 2006
New Revision: 378906

URL: http://svn.apache.org/viewcvs?rev=378906&view=rev
Log:
Start adding spring based tree processor code

Modified:
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/XmlConfigCreator.java

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?rev=378906&r1=378905&r2=378906&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
Sun Feb 19 07:02:24 2006
@@ -23,6 +23,9 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+
+import javax.servlet.ServletConfig;
+
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
@@ -38,10 +41,17 @@
 import org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder;
 import org.apache.cocoon.components.treeprocessor.DefaultTreeBuilder;
 import org.apache.cocoon.components.treeprocessor.TreeBuilder;
+import org.apache.cocoon.core.Core;
+import org.apache.cocoon.core.container.spring.ApplicationContextFactory;
+import org.apache.cocoon.core.container.spring.AvalonEnvironment;
+import org.apache.cocoon.core.container.spring.CocoonXmlWebApplicationContext;
+import org.apache.cocoon.core.container.spring.ConfigReader;
+import org.apache.cocoon.core.container.spring.ConfigurationInfo;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.generation.Generator;
 import org.apache.cocoon.serialization.Serializer;
+import org.apache.cocoon.servlet.CocoonServlet;
 import org.apache.cocoon.sitemap.ComponentLocator;
 import org.apache.cocoon.sitemap.EnterSitemapEventListener;
 import org.apache.cocoon.sitemap.LeaveSitemapEventListener;
@@ -51,13 +61,22 @@
 import org.apache.cocoon.util.ClassUtils;
 import org.apache.cocoon.util.StringUtils;
 import org.apache.regexp.RE;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
 
 /**
  * The tree builder for the sitemap language.
  *
  * @version $Id$
  */
-public class SitemapLanguage extends DefaultTreeBuilder {
+public class SitemapLanguage
+    extends DefaultTreeBuilder
+    implements ApplicationContextAware {
+
+    /** Spring application context. */
+    protected CocoonXmlWebApplicationContext applicationContext;
 
     // Regexp's for splitting expressions
     private static final String COMMA_SPLIT_REGEXP = "[\\s]*,[\\s]*";
@@ -94,11 +113,6 @@
         // Create the classloader, if needed.
         ServiceManager newManager;
         
-        newManager = new CocoonServiceManager(this.parentProcessorManager, classloader);
-
-        // Go through the component lifecycle
-        ContainerUtil.enableLogging(newManager, this.getLogger());
-        ContainerUtil.contextualize(newManager, context);
         // before we pass the configuration we have to strip the
         // additional configuration parts, like classpath etc. as these
         // are not configurations for the service manager
@@ -111,10 +125,32 @@
         c.removeChild(config.getChild("classpath"));
         c.removeChild(config.getChild("listeners"));
 
-        ContainerUtil.configure(newManager, c);
-        ContainerUtil.initialize(newManager);
+        Logger sitemapLogger;
+        // setup spring container
+        if ( this.applicationContext != null ) {
+            final AvalonEnvironment ae = new AvalonEnvironment();
+            ae.context = context;
+            ae.core = (Core)applicationContext.getBean(Core.ROLE);
+            ae.logger = this.getLogger();
+            ae.servletContext = ((ServletConfig)context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG)).getServletContext();
+            ae.settings = ae.core.getSettings();
+            final ConfigurationInfo ci = ConfigReader.readConfiguration(c, this.applicationContext.getConfigurationInfo(),
ae);
+            System.out.println("Setting up spring based tree processor.");
+            final ApplicationContext sitemapContext = 
+                ApplicationContextFactory.createApplicationContext(ae, ci, this.applicationContext,
false);
+            System.out.println("Looked up core: " + sitemapContext.getBean(Core.ROLE));
+            newManager = (ServiceManager) sitemapContext.getBean(ServiceManager.class.getName());
+            sitemapLogger = (Logger)sitemapContext.getBean(Logger.class.getName());
+        } else {
+            newManager = new CocoonServiceManager(this.parentProcessorManager, classloader);
 
-        Logger sitemapLogger = ((CocoonServiceManager)newManager).getServiceManagerLogger();
+            // Go through the component lifecycle
+            ContainerUtil.enableLogging(newManager, this.getLogger());
+            ContainerUtil.contextualize(newManager, context);
+            ContainerUtil.configure(newManager, c);
+            ContainerUtil.initialize(newManager);
+            sitemapLogger = ((CocoonServiceManager)newManager).getServiceManagerLogger();
+        }
         // check for an application specific container
         final Configuration appContainer = config.getChild("application-container", false);
         if ( appContainer != null ) {
@@ -520,5 +556,15 @@
             return Collections.EMPTY_SET;
         }
         return Arrays.asList(StringUtils.split(labels, ", \t\n\r"));
+    }
+
+    /**
+     * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
+     */
+    public void setApplicationContext(ApplicationContext ae) throws BeansException {
+        if ( ! (ae instanceof CocoonXmlWebApplicationContext) ) {
+            throw new BeanCreationException("Application context for tree processor must
be an instance of " + CocoonXmlWebApplicationContext.class.getName());
+        }
+        this.applicationContext = (CocoonXmlWebApplicationContext)ae;
     }
 }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java?rev=378906&r1=378905&r2=378906&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ApplicationContextFactory.java
Sun Feb 19 07:02:24 2006
@@ -60,7 +60,7 @@
         CocoonXmlWebApplicationContext context = new CocoonXmlWebApplicationContext(rsc,

                                                                                     parent,
                                                                                     logger,
-                                                                                    info.getComponents(),
+                                                                                    info,
                                                                                     env.context);
         context.addBeanFactoryPostProcessor(new CocoonSettingsConfigurer(env.settings));
 

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java?rev=378906&r1=378905&r2=378906&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
Sun Feb 19 07:02:24 2006
@@ -60,24 +60,28 @@
 
     protected final Logger avalonLogger;
     protected final Context avalonContext;
-    protected final Map avalonComponentDefinitions;
+    protected final ConfigurationInfo avalonConfiguration;
 
     public CocoonXmlWebApplicationContext(ApplicationContext parent) {
         this(null, parent, null, null, null);
     }
 
-    public CocoonXmlWebApplicationContext(Resource avalonResource,
+    public CocoonXmlWebApplicationContext(Resource           avalonResource,
                                           ApplicationContext parent,
                                           Logger             avalonLogger,
-                                          Map                avalonComponentDefs,
+                                          ConfigurationInfo  avalonConfiguration,
                                           Context            avalonContext) {
         this.setParent(parent);
         this.avalonResource = avalonResource;
         this.avalonLogger = avalonLogger;
-        this.avalonComponentDefinitions = avalonComponentDefs;
+        this.avalonConfiguration = avalonConfiguration;
         this.avalonContext = avalonContext;
     }
 
+    public ConfigurationInfo getConfigurationInfo() {
+        return this.avalonConfiguration;
+    }
+
     /**
      * @see org.springframework.web.context.support.XmlWebApplicationContext#loadBeanDefinitions(org.springframework.beans.factory.xml.XmlBeanDefinitionReader)
      */
@@ -94,8 +98,8 @@
      */
     protected DefaultListableBeanFactory createBeanFactory() {
         DefaultListableBeanFactory beanFactory = super.createBeanFactory();
-        if ( this.avalonComponentDefinitions != null ) {
-            AvalonPostProcessor processor = new AvalonPostProcessor(this.avalonComponentDefinitions,
+        if ( this.avalonConfiguration != null ) {
+            AvalonPostProcessor processor = new AvalonPostProcessor(this.avalonConfiguration.getComponents(),
                                                                     this.avalonContext,
                                                                     this.avalonLogger,
                                                                     beanFactory);

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java?rev=378906&r1=378905&r2=378906&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java
Sun Feb 19 07:02:24 2006
@@ -41,7 +41,7 @@
     private String destroyMethodName;
     private String poolInMethodName;
     private String poolOutMethodName;
-    private String serviceClassName;
+    private String componentClassName;
     private Configuration configuration;
     private Parameters parameters;
     private String loggerCategory;
@@ -124,15 +124,15 @@
     /**
      * @return Returns the serviceClassName.
      */
-    public String getServiceClassName() {
-        return serviceClassName;
+    public String getComponentClassName() {
+        return componentClassName;
     }
 
     /**
      * @param serviceClassName The serviceClassName to set.
      */
-    public void setServiceClassName(String serviceClassName) {
-        this.serviceClassName = serviceClassName;
+    public void setComponentClassName(String serviceClassName) {
+        this.componentClassName = serviceClassName;
     }
 
     /**
@@ -157,7 +157,7 @@
      * @see java.lang.Object#toString()
      */
     public String toString() {
-        return "ServiceInfo: {class=" + this.getServiceClassName()+"}";
+        return "ServiceInfo: {class=" + this.getComponentClassName()+"}";
     }
 
     public void fill(Configuration attr) {
@@ -218,4 +218,14 @@
         this.parameters = parameters;
     }
 
+    /**
+     * Is this a selector?
+     */
+    public boolean isSelector() {
+        if ( this.componentClassName.equals("org.apache.cocoon.core.container.DefaultServiceSelector")
+             || this.componentClassName.equals("org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector")
) {
+            return true;
+        }
+        return false;
+    }
 }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java?rev=378906&r1=378905&r2=378906&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
Sun Feb 19 07:02:24 2006
@@ -48,23 +48,11 @@
 
     protected SourceResolver resolver;
 
-    /** Map for shorthand to role mapping. */
-    private final Map shorthands = new HashMap();
-
-    /** Map for role to default classname mapping. */
-    private final Map classNames = new HashMap();
-
-    /** Map for role->key to classname mapping. */
-    private final Map keyClassNames = new HashMap();
-
-    /** List of components. */
-    private final Map components = new HashMap();
-
-    /** Root logger. */
-    private String rootLogger;
+    /** The configuration info. */
+    protected ConfigurationInfo configInfo;
 
     /** Avalon environment. */
-    private AvalonEnvironment environment;
+    protected AvalonEnvironment environment;
 
     public static ConfigurationInfo readConfiguration(String source, AvalonEnvironment env)
     throws Exception {
@@ -75,16 +63,53 @@
         ConfigReader converter = new ConfigReader();
         converter.resolver = sourceResolver;
         converter.environment = env;
-
+        converter.configInfo = new ConfigurationInfo();
+        
         converter.convert(source);
+        final Iterator i = converter.configInfo.getClassNames().values().iterator();
+        while ( i.hasNext() ) {
+            final ComponentInfo current = (ComponentInfo)i.next();
+            converter.configInfo.addComponent(current);
+        }
+        converter.configInfo.clearClassNames();
+
+        return converter.configInfo;
+    }
+
+    public static ConfigurationInfo readConfiguration(Configuration config,
+                                                      ConfigurationInfo parentInfo,
+                                                      AvalonEnvironment env)
+    throws Exception {
+        final SimpleSourceResolver sourceResolver = new SimpleSourceResolver();
+        sourceResolver.enableLogging(env.logger);
+        sourceResolver.contextualize(env.context);
+
+        ConfigReader converter = new ConfigReader();
+        converter.resolver = sourceResolver;
+        converter.environment = env;
+        converter.configInfo = new ConfigurationInfo(parentInfo);
+        // now add selectors from parent
+        if ( parentInfo != null ) {
+            final Iterator i = parentInfo.getComponents().values().iterator();
+            while ( i.hasNext() ) {
+                final ComponentInfo current = (ComponentInfo)i.next();
+                if ( current.isSelector() ) {
+                    converter.configInfo.getClassNames().put(current.getRole(), current);
+                }
+            }
+        }
+        converter.convert(config);
+        final Iterator i = converter.configInfo.getClassNames().values().iterator();
+        while ( i.hasNext() ) {
+            final ComponentInfo current = (ComponentInfo)i.next();
+            converter.configInfo.addComponent(current);
+        }
+        converter.configInfo.clearClassNames();
 
-        ConfigurationInfo info = new ConfigurationInfo();
-        info.setComponents(converter.components);
-        info.setRootLogger(converter.rootLogger);
-        return info;
+        return converter.configInfo;        
     }
 
-    public ConfigReader() {
+    private ConfigReader() {
         // nothing to do
     }
 
@@ -97,20 +122,25 @@
             
             // It's possible to define a logger on a per sitemap/service manager base.
             // This is the default logger for all components defined with this sitemap/manager.
-            this.rootLogger = config.getAttribute("logger", null);
+            this.configInfo.setRootLogger(config.getAttribute("logger", null));
 
             // and load configuration with a empty list of loaded configurations
-            parseConfiguration(config, root.getURI(), new HashSet());
-            final Iterator i = this.classNames.values().iterator();
-            while ( i.hasNext() ) {
-                final ComponentInfo current = (ComponentInfo)i.next();
-                this.components.put(current.getRole(), current);
-            }
+            this.parseConfiguration(config, root.getURI(), new HashSet());
         } finally {
             this.resolver.release(root);
         }
     }
 
+    protected void convert(Configuration config)
+    throws Exception {
+        // It's possible to define a logger on a per sitemap/service manager base.
+        // This is the default logger for all components defined with this sitemap/manager.
+        this.configInfo.setRootLogger(config.getAttribute("logger", null));
+
+        // and load configuration with a empty list of loaded configurations
+        this.parseConfiguration(config, null, new HashSet());
+    }
+
     protected void parseConfiguration(final Configuration configuration,
                                       String contextURI,
                                       Set loadedURIs) 
@@ -131,7 +161,7 @@
                 String role = componentConfig.getAttribute("role", null);
                 if (role == null) {
                     // Get the role from the role manager if not explicitely specified
-                    role = (String)this.shorthands.get( componentName );
+                    role = (String)this.configInfo.getShorthands().get( componentName );
                     if (role == null) {
                         // Unknown role
                         throw new ConfigurationException("Unknown component type '" + componentName
+
@@ -144,12 +174,12 @@
                 ComponentInfo info;
                 if (className == null) {
                     // Get the default class name for this role
-                    info = (ComponentInfo)this.classNames.get( role );
+                    info = (ComponentInfo)this.configInfo.getClassNames().get( role );
                     if (info == null) {
                         throw new ConfigurationException("Cannot find a class for role "
+ role + " at " + componentConfig.getLocation());
                     }
-                    this.classNames.remove(info);
-                    className = info.getServiceClassName();
+                    this.configInfo.getClassNames().remove(info);
+                    className = info.getComponentClassName();
                 } else {                    
                     info = new ComponentInfo();
                 }
@@ -161,11 +191,11 @@
                     role = role + "/" + name;
                 }
                 info.fill(componentConfig);
-                info.setServiceClassName(className);
+                info.setComponentClassName(className);
                 info.setRole(role);
                 info.setConfiguration(componentConfig);
 
-                this.components.put(info.getRole(), info);
+                this.configInfo.addComponent(info);
                 // now if this is a selector, then we have to register the single components
                 if ( info.getConfiguration() != null && className.endsWith("Selector")
) {
                     String classAttribute = null;
@@ -195,9 +225,9 @@
                             final ComponentInfo childInfo = new ComponentInfo();
                             childInfo.fill(current);
                             childInfo.setConfiguration(current);
-                            childInfo.setServiceClassName(current.getAttribute(classAttribute));
+                            childInfo.setComponentClassName(current.getAttribute(classAttribute));
                             childInfo.setRole(componentRole + current.getAttribute("name"));
-                            this.components.put(childInfo.getRole(), childInfo);
+                            this.configInfo.addComponent(childInfo);
                         }
                     }
                 }
@@ -329,7 +359,7 @@
 
             if (shorthand != null) {
                 // Store the shorthand and check that its consistent with any previous one
-                Object previous = this.shorthands.put( shorthand, roleName );
+                Object previous = this.configInfo.getShorthands().put( shorthand, roleName
);
                 if (previous != null && !previous.equals(roleName)) {
                     throw new ConfigurationException("Shorthand '" + shorthand + "' already
used for role " +
                             previous + ": inconsistent declaration at " + role.getLocation());
@@ -337,19 +367,19 @@
             }
 
             if ( defaultClassName != null ) {
-                ComponentInfo info = (ComponentInfo)this.classNames.get(roleName);
+                ComponentInfo info = (ComponentInfo)this.configInfo.getClassNames().get(roleName);
                 if (info == null) {
                     // Create a new info and store it
                     info = new ComponentInfo();
-                    info.setServiceClassName(defaultClassName);
+                    info.setComponentClassName(defaultClassName);
                     info.fill(role);
                     info.setRole(roleName);
                     info.setConfiguration(role);
-                    this.classNames.put(roleName, info);
+                    this.configInfo.getClassNames().put(roleName, info);
                 } else {
                     // Check that it's consistent with the existing info
-                    if (!defaultClassName.equals(info.getServiceClassName())) {
-                        throw new ConfigurationException("Invalid redeclaration: default
class already set to " + info.getServiceClassName() +
+                    if (!defaultClassName.equals(info.getComponentClassName())) {
+                        throw new ConfigurationException("Invalid redeclaration: default
class already set to " + info.getComponentClassName() +
                                 " for role " + roleName + " at " + role.getLocation());
                     }
                     //FIXME: should check also other ServiceInfo members
@@ -358,10 +388,10 @@
 
             final Configuration[] keys = role.getChildren( "hint" );
             if( keys.length > 0 ) {
-                Map keyMap = (Map)this.keyClassNames.get(roleName);
+                Map keyMap = (Map)this.configInfo.getKeyClassNames().get(roleName);
                 if (keyMap == null) {
                     keyMap = new HashMap();
-                    this.keyClassNames.put(roleName, keyMap);
+                    this.configInfo.getKeyClassNames().put(roleName, keyMap);
                 }
 
                 for( int j = 0; j < keys.length; j++ ) {
@@ -373,14 +403,14 @@
                     ComponentInfo info = (ComponentInfo)keyMap.get(shortHand);
                     if (info == null) {       
                         info = new ComponentInfo();
-                        info.setServiceClassName(className);
+                        info.setComponentClassName(className);
                         info.fill(key);
                         info.setConfiguration(key);
                         keyMap.put( shortHand, info );
                     } else {
                         // Check that it's consistent with the existing info
-                        if (!className.equals(info.getServiceClassName())) {
-                            throw new ConfigurationException("Invalid redeclaration: class
already set to " + info.getServiceClassName() +
+                        if (!className.equals(info.getComponentClassName())) {
+                            throw new ConfigurationException("Invalid redeclaration: class
already set to " + info.getComponentClassName() +
                                     " for hint " + shortHand + " at " + key.getLocation());
                         }
                         //FIXME: should check also other ServiceInfo members

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java?rev=378906&r1=378905&r2=378906&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigurationInfo.java
Sun Feb 19 07:02:24 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.core.container.spring;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -27,16 +28,35 @@
  */
 public class ConfigurationInfo {
 
-    protected Map components;
-    
+    /** Root logger. */
     protected String rootLogger;
 
-    public Map getComponents() {
-        return components;
+    /** Map for shorthand to role mapping. */
+    private final Map shorthands;
+
+    /** Map for role to default classname mapping. */
+    private final Map classNames;
+
+    /** Map for role->key to classname mapping. */
+    private final Map keyClassNames;
+
+    /** List of components. */
+    private final Map components = new HashMap();
+
+    public ConfigurationInfo() {
+        this.shorthands = new HashMap();
+        this.classNames = new HashMap();
+        this.keyClassNames = new HashMap();
     }
 
-    public void setComponents(Map components) {
-        this.components = components;
+    public ConfigurationInfo(ConfigurationInfo parent) {
+        this.shorthands = new HashMap(parent.shorthands);
+        this.classNames = new HashMap(parent.classNames);
+        this.keyClassNames = new HashMap(parent.keyClassNames);
+    }
+
+    public Map getComponents() {
+        return components;
     }
 
     public String getRootLogger() {
@@ -47,5 +67,23 @@
         this.rootLogger = rootLogger;
     }
 
+    public void addComponent(ComponentInfo info) {
+        this.components.put(info.getRole(), info);
+    }
+
+    public Map getClassNames() {
+        return this.classNames;
+    }
+
+    public void clearClassNames() {
+        this.classNames.clear();
+    }
+
+    public Map getShorthands() {
+        return this.shorthands;
+    }
 
+    public Map getKeyClassNames() {
+        return this.keyClassNames;
+    }
 }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/XmlConfigCreator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/XmlConfigCreator.java?rev=378906&r1=378905&r2=378906&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/XmlConfigCreator.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/XmlConfigCreator.java
Sun Feb 19 07:02:24 2006
@@ -66,13 +66,12 @@
             final ComponentInfo current = (ComponentInfo)entry.getValue();
             final String role = current.getRole();
     
-            String className = current.getServiceClassName();
+            String className = current.getComponentClassName();
             boolean isSelector = false;
             boolean singleton = true;
             boolean poolable = false;
-            // Test for Selector - we skip them
-            if ( className.equals("org.apache.cocoon.core.container.DefaultServiceSelector")
-                 || className.equals("org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector")
) {
+            // Test for Selector - we just create a wrapper for them to flatten the hierarchy
+            if ( current.isSelector() ) {
                 // Add selector
                 className = AvalonServiceSelector.class.getName();
                 isSelector = true;



Mime
View raw message