cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r383313 - in /cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon: components/treeprocessor/ components/treeprocessor/sitemap/ core/container/spring/
Date Sun, 05 Mar 2006 13:05:18 GMT
Author: cziegeler
Date: Sun Mar  5 05:05:18 2006
New Revision: 383313

URL: http://svn.apache.org/viewcvs?rev=383313&view=rev
Log:
Cleanup

Modified:
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
    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/BeanFactoryUtil.java

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?rev=383313&r1=383312&r2=383313&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
Sun Mar  5 05:05:18 2006
@@ -16,7 +16,6 @@
 package org.apache.cocoon.components.treeprocessor;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -26,7 +25,6 @@
 
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.ProcessingException;
@@ -52,7 +50,6 @@
 import org.apache.cocoon.sitemap.SitemapExecutor;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationImpl;
-import org.apache.commons.jci.listeners.NotificationListener;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 
 /**
@@ -62,7 +59,7 @@
  * @version $Id$
  */
 public class ConcreteTreeProcessor extends AbstractLogEnabled
-                                   implements Processor, Disposable, ExecutionContext, NotificationListener
{
+                                   implements Processor, Disposable, ExecutionContext {
 
     private static final String BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE = CocoonBeanFactory.class.getName()
+ "/Stack";
 
@@ -90,14 +87,11 @@
     private SitemapExecutor sitemapExecutor;
 
     /** Optional event listeners for the enter sitemap event */
-    private List enterSitemapEventListeners = new ArrayList();
+    private List enterSitemapEventListeners = Collections.EMPTY_LIST;
 
     /** Optional event listeners for the leave sitemap event */
-    private List leaveSitemapEventListeners = new ArrayList();
+    private List leaveSitemapEventListeners = Collections.EMPTY_LIST;
 
-    /** Needs a reload? */
-    protected volatile boolean needsReload = false;
-    
     /** Processor attributes */
     protected Map processorAttributes = new HashMap();
 
@@ -116,13 +110,6 @@
         this.sitemapExecutor = sitemapExecutor;
     }
 
-    public void handleNotification() {
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug(this + " got notified that a reload is required");
-        }
-        needsReload = true;
-    }
-    
     /** Set the processor data, result of the treebuilder job */
     public void setProcessorData(ConfigurableBeanFactory beanFactory,
                                  ServiceManager manager,
@@ -213,10 +200,6 @@
         }
     }
 
-    boolean isReloadNeeded() {
-        return needsReload;
-    }
-    
     public TreeProcessor getWrappingProcessor() {
         return this.wrappingProcessor;
     }
@@ -325,8 +308,8 @@
                 this.enteredSitemap(enterEvent);
                 final Iterator enterSEI = this.enterSitemapEventListeners.iterator();
                 while ( enterSEI.hasNext() ) {
-                    final TreeBuilder.EventComponent current = (TreeBuilder.EventComponent)enterSEI.next();
-                    ((EnterSitemapEventListener)current.component).enteredSitemap(enterEvent);
+                    final EnterSitemapEventListener current = (EnterSitemapEventListener)enterSEI.next();
+                    current.enteredSitemap(enterEvent);
                 }
             }
 
@@ -360,8 +343,8 @@
                 this.leftSitemap(leaveEvent);
                 final Iterator leaveSEI = this.leaveSitemapEventListeners.iterator();
                 while ( leaveSEI.hasNext() ) {
-                    final TreeBuilder.EventComponent current = (TreeBuilder.EventComponent)leaveSEI.next();
-                    ((LeaveSitemapEventListener)current.component).leftSitemap(leaveEvent);
+                    final LeaveSitemapEventListener current = (LeaveSitemapEventListener)leaveSEI.next();
+                    current.leftSitemap(leaveEvent);
                 }
             }
 
@@ -444,26 +427,13 @@
         this.rootNode = null;
         this.sitemapExecutor = null;
 
-        // dispose listeners
-        this.disposeListeners(this.enterSitemapEventListeners);
-        this.disposeListeners(this.leaveSitemapEventListeners);
+        // clear listeners
+        this.enterSitemapEventListeners.clear();
+        this.leaveSitemapEventListeners.clear();
         if ( this.beanFactory != null ) {
             this.beanFactory.destroySingletons();
             this.beanFactory = null;
         }
-    }
-
-    protected void disposeListeners(List l) {
-        Iterator i = l.iterator();
-        while ( i.hasNext() ) {
-            final TreeBuilder.EventComponent current = (TreeBuilder.EventComponent)i.next();
-            if ( current.releaseUsingManager ) {
-                this.manager.release(current.component);
-            } else {
-                ContainerUtil.dispose(current.component);
-            }
-        }
-        l.clear();        
     }
 
     private class TreeProcessorRedirector extends ForwardRedirector {

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java?rev=383313&r1=383312&r2=383313&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
Sun Mar  5 05:05:18 2006
@@ -20,7 +20,7 @@
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 
 /**
  *
@@ -30,21 +30,10 @@
 
     String ROLE = TreeBuilder.class.getName();
 
-    public static class EventComponent {
-        
-        public final Object component;
-        public final boolean releaseUsingManager;
-        
-        public EventComponent(Object c, boolean releaseUsingManager) {
-            this.component = c;
-            this.releaseUsingManager = releaseUsingManager;
-        }
-    }
+    ConfigurableListableBeanFactory getBeanFactory();
 
-    ConfigurableBeanFactory getBeanFactory();
-    
     ServiceManager getServiceManager();
-    
+
     ConcreteTreeProcessor getProcessor();
 
     void setProcessor(ConcreteTreeProcessor processor);
@@ -92,7 +81,6 @@
      */
     ProcessingNode setupNode(ProcessingNode node, Configuration config) throws Exception;
 
-
     /**
      * Get the type for a statement : it returns the 'type' attribute if present,
      * and otherwhise the default hint for the <code>ServiceSelector</code> identified
by
@@ -121,13 +109,11 @@
      * @return A list of {@link EventComponent}s.
      */
     List getEnterSitemapEventListeners();
-    
+
     /**
      * Return all event listers that are registered for the
      * {@link org.apache.cocoon.sitemap.LeaveSitemapEvent}.
      * @return A list of {@link EventComponent}s.
      */
     List getLeaveSitemapEventListeners();
-    
-
 }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java?rev=383313&r1=383312&r2=383313&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
Sun Mar  5 05:05:18 2006
@@ -334,7 +334,7 @@
             this.environmentHelper.changeContext(this.source, "");
         }
 
-        if (this.concreteProcessor == null || this.concreteProcessor.isReloadNeeded() ||
+        if (this.concreteProcessor == null ||
                 (this.checkReload && this.source.getLastModified() != this.lastModified))
{
             buildConcreteProcessor(env);
         }
@@ -355,7 +355,7 @@
 
         // Now that we entered the synchronized area, recheck what's already
         // been checked in process().
-        if (this.concreteProcessor != null && source.getLastModified() == this.lastModified
&& !this.concreteProcessor.isReloadNeeded()) {
+        if (this.concreteProcessor != null && source.getLastModified() == this.lastModified)
{
             // Nothing changed
             return;
         }

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=383313&r1=383312&r2=383313&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 Mar  5 05:05:18 2006
@@ -34,14 +34,12 @@
 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.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.ServiceSelector;
@@ -64,8 +62,8 @@
 import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
 import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
 import org.apache.cocoon.core.Settings;
-import org.apache.cocoon.core.container.spring.BeanFactoryUtil;
 import org.apache.cocoon.core.container.spring.AvalonEnvironment;
+import org.apache.cocoon.core.container.spring.BeanFactoryUtil;
 import org.apache.cocoon.core.container.spring.CocoonBeanFactory;
 import org.apache.cocoon.core.container.spring.ConfigReader;
 import org.apache.cocoon.core.container.spring.ConfigurationInfo;
@@ -78,9 +76,7 @@
 import org.apache.cocoon.sitemap.EnterSitemapEventListener;
 import org.apache.cocoon.sitemap.LeaveSitemapEventListener;
 import org.apache.cocoon.sitemap.PatternException;
-import org.apache.cocoon.sitemap.SitemapListener;
 import org.apache.cocoon.sitemap.SitemapParameters;
-import org.apache.cocoon.util.ClassUtils;
 import org.apache.cocoon.util.StringUtils;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationImpl;
@@ -92,7 +88,7 @@
 import org.springframework.beans.factory.BeanCreationException;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 
 /**
  * The tree builder for the sitemap language.
@@ -111,7 +107,7 @@
     protected Map attributes = new HashMap();
 
     /** Spring application context. */
-    protected ConfigurableBeanFactory beanFactory;
+    protected ConfigurableListableBeanFactory beanFactory;
 
 
     // ----- lifecycle-related objects ------
@@ -150,7 +146,7 @@
      */
     private ServiceManager itsManager;
 
-    private ConfigurableBeanFactory itsBeanFactory;
+    private ConfigurableListableBeanFactory itsBeanFactory;
 
     /**
      * Helper object which sets up components in the context of the processor
@@ -253,7 +249,7 @@
     /**
      * @see org.apache.cocoon.components.treeprocessor.TreeBuilder#getBeanFactory()
      */
-    public ConfigurableBeanFactory getBeanFactory() {
+    public ConfigurableListableBeanFactory getBeanFactory() {
         return this.itsBeanFactory;
     }
 
@@ -396,6 +392,8 @@
             this.itsBeanFactory = this.createBeanFactory(this.itsContext, componentConfig);
             this.itsManager = (ServiceManager) this.itsBeanFactory.getBean(ServiceManager.class
                     .getName());
+            // only register listeners if a new bean factory is created
+            this.registerListeners();
         } else {
             this.itsManager = manager;
         }
@@ -655,25 +653,15 @@
      * Build a component manager with the contents of the &lt;map:components&gt;
      * element of the tree.
      */
-    protected ConfigurableBeanFactory createBeanFactory(Context context,
+    protected ConfigurableListableBeanFactory createBeanFactory(Context       context,
                                                         Configuration config)
     throws Exception {
-        ServiceManager newManager;
-
-        // before we pass the configuration we have to strip the
-        // additional configuration parts, like listeners etc. as these
-        // are not configurations for the service manager
-        final DefaultConfiguration c = new DefaultConfiguration(config.getName(), config
-                .getLocation(), config.getNamespace(), "");
-        c.addAll(config);
-        c.removeChild(config.getChild("listeners"));
-
         // setup spring container
         // first, get the correct parent
-        ConfigurableBeanFactory parentContext = this.beanFactory;
+        ConfigurableListableBeanFactory parentContext = this.beanFactory;
         final Request request = ContextHelper.getRequest(context);
         if (request.getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE) != null)
{
-            parentContext = (ConfigurableBeanFactory) request
+            parentContext = (ConfigurableListableBeanFactory) request
                     .getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE);
         }
 
@@ -685,58 +673,27 @@
         ae.settings = (Settings) this.beanFactory.getBean(Settings.ROLE);
         final ConfigurationInfo parentConfigInfo = (ConfigurationInfo) parentContext
                 .getBean(ConfigurationInfo.class.getName());
-        final ConfigurationInfo ci = ConfigReader.readConfiguration(c, parentConfigInfo,
ae);
+        final ConfigurationInfo ci = ConfigReader.readConfiguration(config, parentConfigInfo,
ae);
 
-        final ConfigurableBeanFactory sitemapContext = BeanFactoryUtil.createBeanFactory(ae,
ci,
+        final ConfigurableListableBeanFactory sitemapContext = BeanFactoryUtil.createBeanFactory(ae,
ci,
                 parentContext, false);
-        newManager = (ServiceManager) sitemapContext.getBean(ServiceManager.class.getName());
-        Logger sitemapLogger = (Logger) sitemapContext.getBean(Logger.class.getName());
-
-        // and finally the listeners
-        final Configuration listenersWrapper = config.getChild("listeners", false);
-        if (listenersWrapper != null) {
-            final Configuration[] listeners = listenersWrapper.getChildren("listener");
-            for (int i = 0; i < listeners.length; i++) {
-                final Configuration current = listeners[i];
-                final TreeBuilder.EventComponent listener = this.createListener(newManager,
-                        sitemapLogger, context, current);
-                if (!(listener.component instanceof SitemapListener)) {
-                    throw new ConfigurationException(
-                            "Listener must implement the SitemapListener interface.");
-                }
-                this.addListener(listener);
-            }
-        }
 
         return sitemapContext;
     }
 
     /**
-     * Create a listener
-     */
-    protected TreeBuilder.EventComponent createListener(ServiceManager manager,
-            Logger sitemapLogger, Context context, Configuration config) throws Exception
{
-        // role or class?
-        final String role = config.getAttribute("role", null);
-        if (role != null) {
-            return new TreeBuilder.EventComponent(manager.lookup(role), true);
-        }
-        final String className = config.getAttribute("class");
-        final Object component = ClassUtils.newInstance(className);
-
-        LifecycleHelper.setupComponent(component, sitemapLogger, context, manager, config);
-
-        return new TreeBuilder.EventComponent(component, false);
-    }
-
-    /**
-     * Add a listener
+     * Register all registered sitemap listeners
      */
-    protected void addListener(TreeBuilder.EventComponent listener) {
-        if (listener.component instanceof EnterSitemapEventListener) {
-            this.enterSitemapEventListeners.add(listener);
-        } else if (listener.component instanceof LeaveSitemapEventListener) {
-            this.leaveSitemapEventListeners.add(listener);
+    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));
         }
     }
 
@@ -1085,11 +1042,11 @@
      * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
      */
     public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
-        if (!(beanFactory instanceof ConfigurableBeanFactory)) {
+        if (!(beanFactory instanceof ConfigurableListableBeanFactory)) {
             throw new BeanCreationException(
                     "Bean factory for tree processor must be an instance of "
-                            + ConfigurableBeanFactory.class.getName());
+                            + ConfigurableListableBeanFactory.class.getName());
         }
-        this.beanFactory = (ConfigurableBeanFactory) beanFactory;
+        this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
     }
 }

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/BeanFactoryUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/BeanFactoryUtil.java?rev=383313&r1=383312&r2=383313&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/BeanFactoryUtil.java
(original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/BeanFactoryUtil.java
Sun Mar  5 05:05:18 2006
@@ -25,19 +25,15 @@
 import org.apache.avalon.excalibur.logger.Log4JConfLoggerManager;
 import org.apache.avalon.excalibur.logger.ServletLogger;
 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.context.Context;
 import org.apache.avalon.framework.context.DefaultContext;
 import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.ProcessingUtil;
 import org.apache.cocoon.acting.Action;
 import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.components.pipeline.ProcessingPipeline;
 import org.apache.cocoon.components.treeprocessor.ProcessorComponentInfo;
-import org.apache.cocoon.components.treeprocessor.TreeBuilder;
 import org.apache.cocoon.core.CoreInitializationException;
 import org.apache.cocoon.core.Settings;
 import org.apache.cocoon.core.container.util.ConfigurationBuilder;
@@ -49,20 +45,16 @@
 import org.apache.cocoon.selection.Selector;
 import org.apache.cocoon.serialization.Serializer;
 import org.apache.cocoon.servlet.CocoonServlet;
-import org.apache.cocoon.sitemap.EnterSitemapEventListener;
-import org.apache.cocoon.sitemap.LeaveSitemapEventListener;
-import org.apache.cocoon.sitemap.SitemapListener;
 import org.apache.cocoon.transformation.Transformer;
-import org.apache.cocoon.util.ClassUtils;
 import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.io.ByteArrayResource;
 import org.springframework.core.io.Resource;
 import org.springframework.web.context.WebApplicationContext;
 
 /**
- * This utility class helps in creating new Spring {@link ConfigurableBeanFactory} objects
+ * This utility class helps in creating new Spring {@link ConfigurableListableBeanFactory}
objects
  * which support the Avalon style component configuration. It also offers help in setting
  * up the root logger for Cocoon.
  *
@@ -82,10 +74,10 @@
      * @return A new bean factory.
      * @throws Exception
      */
-    public static ConfigurableBeanFactory createBeanFactory(AvalonEnvironment env,
-                                                            ConfigurationInfo info,
-                                                            BeanFactory       parent,
-                                                            boolean           addCocoon)
+    public static ConfigurableListableBeanFactory createBeanFactory(AvalonEnvironment env,
+                                                                    ConfigurationInfo info,
+                                                                    BeanFactory       parent,
+                                                                    boolean           addCocoon)
     throws Exception {
         final String xmlConfig = (new XmlConfigCreator(env.logger)).createConfig(info, addCocoon);
         Resource rsc = new ByteArrayResource(xmlConfig.getBytes("utf-8"));
@@ -117,7 +109,7 @@
      * @return A new root application factory.
      * @throws Exception
      */
-    public static ConfigurableBeanFactory createRootApplicationContext(AvalonEnvironment
 env)
+    public static ConfigurableListableBeanFactory createRootApplicationContext(AvalonEnvironment
 env)
     throws Exception {
         final ApplicationContext parent = (ApplicationContext)env.servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
         CocoonBeanFactory factory = new CocoonBeanFactory(parent);
@@ -258,29 +250,16 @@
      * Build a bean factory with the contents of the &lt;map:components&gt; element
of
      * the tree.
      */
-    protected ConfigurableBeanFactory createBeanFactory(Logger        sitemapLogger,
-                                                        Configuration config,
-                                                        Context       sitemapContext)
+    protected ConfigurableListableBeanFactory createBeanFactory(Logger        sitemapLogger,
+                                                                Configuration config,
+                                                                Context       sitemapContext)
     throws Exception {
-        ServiceManager newManager;
-        
-        // 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
-        final DefaultConfiguration c = new DefaultConfiguration(config.getName(), 
-                                                                config.getLocation(),
-                                                                config.getNamespace(),
-                                                                "");
-        c.addAll(config);
-        c.removeChild(config.getChild("classpath"));
-        c.removeChild(config.getChild("listeners"));
-
         // setup spring container
         // first, get the correct parent
         BeanFactory parentContext = this.beanFactory;
         final Request request = ContextHelper.getRequest(sitemapContext);
         if ( request.getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE) != null
) {
-            parentContext = (ConfigurableBeanFactory)request.getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE);
+            parentContext = (ConfigurableListableBeanFactory)request.getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE);
         }
 
         final AvalonEnvironment ae = new AvalonEnvironment();
@@ -293,64 +272,11 @@
         ae.servletContext = ((ServletConfig)sitemapContext.get(CocoonServlet.CONTEXT_SERVLET_CONFIG)).getServletContext();
         ae.settings = (Settings)parentContext.getBean(Settings.ROLE);
         final ConfigurationInfo parentConfigInfo = (ConfigurationInfo)parentContext.getBean(ConfigurationInfo.class.getName());
-        final ConfigurationInfo ci = ConfigReader.readConfiguration(c, parentConfigInfo,
ae);
+        final ConfigurationInfo ci = ConfigReader.readConfiguration(config, parentConfigInfo,
ae);
 
-        final ConfigurableBeanFactory sitemapFactory = 
+        final ConfigurableListableBeanFactory sitemapFactory = 
             BeanFactoryUtil.createBeanFactory(ae, ci, parentContext, false);
-        newManager = (ServiceManager) sitemapFactory.getBean(ServiceManager.class.getName());
-        sitemapLogger = (Logger)sitemapFactory.getBean(Logger.class.getName());
-
-        // TODO: Add listeners configured by a class as beans to the factory
-        //       Then the factory will handle init/dispose of those components as well
-        //       and the sitemap language can lookup all handles by getting all
-        //       beans of that type.
-        // and finally the listeners
-        
-        final Configuration listenersWrapper = config.getChild("listeners", false);
-        if ( listenersWrapper != null ) {
-            final Configuration[] listeners = listenersWrapper.getChildren("listener"); 
              
-            for(int i = 0; i < listeners.length; i++) {
-                final Configuration current = listeners[i];
-                final TreeBuilder.EventComponent listener = this.createListener(newManager,
sitemapLogger, sitemapContext, current);
-                if ( !(listener.component instanceof SitemapListener) ) {
-                    throw new ConfigurationException("Listener must implement the SitemapListener
interface.");
-                }
-                this.addListener(listener);
-            }
-        }
 
         return sitemapFactory;
-    }
-
-    /**
-     * Create a listener
-     */
-    protected TreeBuilder.EventComponent createListener(ServiceManager manager,
-                                                        Logger sitemapLogger,
-                                                        Context context,
-                                                        Configuration config) 
-    throws Exception {
-        // role or class?
-        final String role = config.getAttribute("role", null);
-        if ( role != null ) {
-            return new TreeBuilder.EventComponent(manager.lookup(role), true);
-        }
-        final String className = config.getAttribute("class");
-        final Object component = ClassUtils.newInstance(className);
-
-        LifecycleHelper.setupComponent(component, sitemapLogger, context, manager, config);
-
-        return new TreeBuilder.EventComponent(component, false);
-    }
-
-    /**
-     * Add a listener
-     */
-    protected void addListener(TreeBuilder.EventComponent listener) {
-        if ( listener.component instanceof EnterSitemapEventListener ) {
-            //this.enterSitemapEventListeners.add(listener);
-        } else if ( listener.component instanceof LeaveSitemapEventListener ) {
-            //this.leaveSitemapEventListeners.add(listener);
-        }
     }
 }



Mime
View raw message