cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r429017 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring: CocoonBeanFactory.java ComponentInfo.java ConfigReader.java
Date Sat, 05 Aug 2006 17:47:26 GMT
Author: cziegeler
Date: Sat Aug  5 10:47:25 2006
New Revision: 429017

URL: http://svn.apache.org/viewvc?rev=429017&view=rev
Log:
Fix setting of lazy init and alias handling

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonBeanFactory.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonBeanFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonBeanFactory.java?rev=429017&r1=429016&r2=429017&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonBeanFactory.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonBeanFactory.java
Sat Aug  5 10:47:25 2006
@@ -185,21 +185,19 @@
                 }
                 ContainerUtil.contextualize(bean, this.context);
                 ContainerUtil.service(bean, (ServiceManager)this.beanFactory.getBean(ServiceManager.class.getName()));
-                if ( info != null ) {
-                    Configuration config = info.getConfiguration();
-                    if ( config == null ) {
-                        config = EMPTY_CONFIG;
-                    }
-                    if ( bean instanceof Configurable ) {
-                        ContainerUtil.configure(bean, config);
-                    } else if ( bean instanceof Parameterizable ) {
-                        Parameters p = info.getParameters();
-                        if ( p == null ) {
-                            p = Parameters.fromConfiguration(config);
-                            info.setParameters(p);
-                        }
-                        ContainerUtil.parameterize(bean, p);
+                Configuration config = info.getConfiguration();
+                if ( config == null ) {
+                    config = EMPTY_CONFIG;
+                }
+                if ( bean instanceof Configurable ) {
+                    ContainerUtil.configure(bean, config);
+                } else if ( bean instanceof Parameterizable ) {
+                    Parameters p = info.getParameters();
+                    if ( p == null ) {
+                        p = Parameters.fromConfiguration(config);
+                        info.setParameters(p);
                     }
+                    ContainerUtil.parameterize(bean, p);
                 }
                 ContainerUtil.initialize(bean);
             } catch (Exception e) {

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java?rev=429017&r1=429016&r2=429017&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ComponentInfo.java
Sat Aug  5 10:47:25 2006
@@ -211,16 +211,16 @@
 
     public void fill(Configuration config) {
         // test model
-        final String model = config.getAttribute("model", null);
-        if ( TYPE_POOLED.equals(model) ) {
+        final String componentModel = config.getAttribute("model", null);
+        if ( TYPE_POOLED.equals(componentModel) ) {
             this.setModel(ComponentInfo.MODEL_POOLED);
             this.setPoolInMethodName(config.getAttribute("pool-in", null));
             this.setPoolOutMethodName(config.getAttribute("pool-out", null));
-        } else if (TYPE_NON_THREAD_SAFE_POOLED.equals(model)) {
+        } else if (TYPE_NON_THREAD_SAFE_POOLED.equals(componentModel)) {
             this.setModel(ComponentInfo.MODEL_POOLED);
             this.setPoolInMethodName(config.getAttribute("pool-in", null));
             this.setPoolOutMethodName(config.getAttribute("pool-out", null));
-        } else if ( TYPE_SINGLETON.equals(model) ) {
+        } else if ( TYPE_SINGLETON.equals(componentModel) ) {
             this.setModel(ComponentInfo.MODEL_SINGLETON);
         }
         // init/destroy methods

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java?rev=429017&r1=429016&r2=429017&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
Sat Aug  5 10:47:25 2006
@@ -191,8 +191,7 @@
         final Iterator i = this.configInfo.getClassNames().values().iterator();
         while ( i.hasNext() ) {
             final ComponentInfo current = (ComponentInfo)i.next();
-            // TODO
-            //current.setLazyInit(true);
+            current.setLazyInit(true);
             this.configInfo.addComponent(current);
         }
         this.configInfo.clearClassNames();
@@ -243,24 +242,36 @@
     
             // Find the className
             String className = componentConfig.getAttribute("class", null);
+            // If it has a "name" attribute, add it to the role (similar to the
+            // declaration within a service selector)
+            // Note: this has to be done *after* finding the className above as we change
the role
+            String name = componentConfig.getAttribute("name", null);
             ComponentInfo info;
             if (className == null) {
                 // Get the default class name for this role
                 info = (ComponentInfo)this.configInfo.getClassNames().get( role );
                 if (info == null) {
+                    if ( this.configInfo.getComponents().get( role) != null ) {
+                        throw new ConfigurationException("Duplicate component definition
for role " + role + " at " + componentConfig.getLocation());
+                    }
                     throw new ConfigurationException("Cannot find a class for role " + role
+ " at " + componentConfig.getLocation());
                 }
-                this.configInfo.getClassNames().remove(info);
                 className = info.getComponentClassName();
+                if ( name != null ) {
+                    info = info.copy();                    
+                } else if ( !className.endsWith("Selector") ) {
+                    this.configInfo.getClassNames().remove(role);
+                }
             } else {                    
                 info = new ComponentInfo();
             }
-            // If it has a "name" attribute, add it to the role (similar to the
-            // declaration within a service selector)
+            // check for name attribute
             // Note: this has to be done *after* finding the className above as we change
the role
-            String name = componentConfig.getAttribute("name", null);
             if (name != null) {
                 role = role + "/" + name;
+                if ( alias != null ) {
+                    alias = alias + '-' + name;
+                }
             }
             info.fill(componentConfig);
             info.setComponentClassName(className);
@@ -269,7 +280,7 @@
                 info.setAlias(alias);
             }
             info.setConfiguration(componentConfig);
-    
+
             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")
) {
@@ -401,11 +412,12 @@
     }
 
     private boolean match(String uri, String pattern ) {
-        int pos = uri.lastIndexOf('/');
+        String testUri = uri;
+        int pos = testUri.lastIndexOf('/');
         if ( pos != -1 ) {
-            uri = uri.substring(pos+1);
+            testUri = testUri.substring(pos+1);
         }
-        return (WildcardMatcherHelper.match(pattern, uri) != null);      
+        return WildcardMatcherHelper.match(pattern, testUri) != null;      
     }
 
     protected void handleBeanInclude(final String contextURI,



Mime
View raw message