cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r438150 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring: AbstractSettingsBeanFactoryPostProcessor.java avalon/AvalonElementParser.java avalon/ConfigurationReader.java
Date Tue, 29 Aug 2006 18:35:57 GMT
Author: cziegeler
Date: Tue Aug 29 11:35:56 2006
New Revision: 438150

URL: http://svn.apache.org/viewvc?rev=438150&view=rev
Log:
Finally fix lazy initialization bug and clean up logging

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.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/ConfigurationReader.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java?rev=438150&r1=438149&r2=438150&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractSettingsBeanFactoryPostProcessor.java
Tue Aug 29 11:35:56 2006
@@ -96,14 +96,16 @@
      */
     protected void readProperties(String          directoryName,
                                   Properties      properties) {
+        if ( this.logger.isDebugEnabled() ) {
+            this.logger.debug("Reading settings from directory: " + directoryName);
+        }
         final String pattern = directoryName + "/*.properties";
         PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(new
ServletContextResourceLoader(this.servletContext));
         Resource[] resources = null;
         try {
             resources = resolver.getResources(pattern);
         } catch (IOException ignore) {
-            this.servletContext.log("Unable to read properties from directory '" + directoryName
+ "' - Continuing initialization.");
-            this.logger.debug("Unable to read properties from directory '" + directoryName
+ "' - Continuing initialization.", ignore);
+            this.logger.info("Unable to read properties from directory '" + directoryName
+ "' - Continuing initialization.", ignore);
         }
         if ( resources != null ) {
             final List propertyUris = new ArrayList();
@@ -117,13 +119,14 @@
             while ( i.hasNext() ) {
                 Resource src = (Resource)i.next();
                 try {
+                    if ( this.logger.isDebugEnabled() ) {
+                        this.logger.debug("Reading settings from '" + src.getURL() + "'.");
+                    }
                     final InputStream propsIS = src.getInputStream();
-                    this.servletContext.log("Reading settings from '" + src.getURL() + "'.");
                     properties.load(propsIS);
                     propsIS.close();
                 } catch (IOException ignore) {
-                    this.servletContext.log("Unable to read properties from file '" + src.getDescription()
+ "' - Continuing initialization.");
-                    this.logger.debug("Unable to read properties from file '" + src.getDescription()
+ "' - Continuing initialization.", ignore);
+                    this.logger.info("Unable to read properties from file '" + src.getDescription()
+ "' - Continuing initialization.", ignore);
                 }
             }
         }

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=438150&r1=438149&r2=438150&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
Tue Aug 29 11:35:56 2006
@@ -60,6 +60,40 @@
     protected final Log logger = LogFactory.getLog(getClass());
 
     /**
+     * Register a bean definition
+     * @param holder
+     * @param registry
+     */
+    protected void register(BeanDefinition beanDef,
+                            String         beanName,
+                            BeanDefinitionRegistry registry) {
+        this.register(beanDef, beanName, null, registry);
+    }
+
+    /**
+     * Register a bean definition
+     * @param holder
+     * @param 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);
+    }
+
+    /**
      * @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) {
@@ -108,8 +142,7 @@
             beanDef.getPropertyValues().addPropertyValue("context", new RuntimeBeanReference(ProcessingUtil.CONTEXT_ROLE));
             beanDef.getPropertyValues().addPropertyValue("configurationInfo", new RuntimeBeanReference(ConfigurationInfo.class.getName()));
 
-            final BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDef, AvalonBeanPostProcessor.class.getName());
-            BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
+            this.register(beanDef, AvalonBeanPostProcessor.class.getName(), parserContext.getRegistry());
 
         } catch (Exception e) {
             throw new BeanDefinitionStoreException("Unable to read Avalon configuration from
'" + location + "'.",e);
@@ -121,9 +154,8 @@
     protected void addLogger(String configuration,
                              BeanDefinitionRegistry registry) {
         final RootBeanDefinition beanDef = this.getBeanDefinition(AvalonLoggerFactoryBean.class,
"init", true);
-        final BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDef, ProcessingUtil.LOGGER_ROLE);
         beanDef.getPropertyValues().addPropertyValue("loggingConfiguration", configuration);
-        BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
+        this.register(beanDef, ProcessingUtil.LOGGER_ROLE, registry);
     }
 
     protected RootBeanDefinition getBeanDefinition(Class   componentClass,
@@ -149,8 +181,7 @@
                                 BeanDefinitionRegistry registry) {
         final RootBeanDefinition beanDef = this.getBeanDefinition(componentClass, initMethod,
requiresSettings);
         
-        final BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDef, role);
-        BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
+        this.register(beanDef, role, registry);
     }
 
     public void createConfig(ConfigurationInfo info,
@@ -222,13 +253,7 @@
                     beanDef.getPropertyValues().addPropertyValue("default", current.getDefaultValue());
                 }
             }
-            final BeanDefinitionHolder holder;
-            if ( current.getAlias() == null ) {
-                holder = new BeanDefinitionHolder(beanDef, beanName);
-            } else {
-                holder = new BeanDefinitionHolder(beanDef, beanName, new String[] {current.getAlias()});
               
-            }
-            BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
+            this.register(beanDef, beanName, current.getAlias(), registry);
 
             if ( poolable ) {
                 // add the factory for poolables
@@ -254,8 +279,7 @@
                 if ( current.getPoolOutMethodName() != null ) {
                     poolableBeanDef.getPropertyValues().addPropertyValue("poolOutMethodName",
current.getPoolOutMethodName());
                 }
-                BeanDefinitionHolder poolableHolder = new BeanDefinitionHolder(poolableBeanDef,
this.xml(role));
-                BeanDefinitionReaderUtils.registerBeanDefinition(poolableHolder, registry);
+                this.register(poolableBeanDef, this.xml(role), registry);
                 pooledRoles.add(role);
             }
         }
@@ -310,16 +334,14 @@
         beanDef.setLazyInit(false);
         beanDef.getPropertyValues().addPropertyValue("data", info.getData());
         beanDef.setInitMethodName("init");
-        final BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDef, ProcessorComponentInfo.ROLE);
-        BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
+        this.register(beanDef, ProcessorComponentInfo.ROLE, registry);
 
         final RootBeanDefinition ciBeanDef = new RootBeanDefinition();
         ciBeanDef.setBeanClass(ConfigurationInfoFactoryBean.class);
         ciBeanDef.setSingleton(true);
         ciBeanDef.setLazyInit(false);
         ciBeanDef.getPropertyValues().addPropertyValue("configurationInfo", configInfo);
-        final BeanDefinitionHolder ciHolder = new BeanDefinitionHolder(ciBeanDef, ConfigurationInfo.class.getName());
-        BeanDefinitionReaderUtils.registerBeanDefinition(ciHolder, registry);
+        this.register(ciBeanDef, ConfigurationInfo.class.getName(), registry);
     }
 
     protected static void prepareSelector(ProcessorComponentInfo info,

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java?rev=438150&r1=438149&r2=438150&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
Tue Aug 29 11:35:56 2006
@@ -150,8 +150,8 @@
 
     protected void convert(String relativePath)
     throws Exception {
-        if ( this.logger.isInfoEnabled() ) {
-            this.logger.info("Reading Avalon configuration from " + relativePath);
+        if ( this.logger.isDebugEnabled() ) {
+            this.logger.debug("Reading Avalon configuration from " + relativePath);
         }
         Resource root = this.resolver.getResource(this.convertUrl(relativePath));
         final DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(true);
@@ -163,8 +163,7 @@
                     + config.toString());
         }
         if (this.logger.isDebugEnabled()) {
-            this.logger.debug("Configuration version: "
-                    + config.getAttribute("version"));
+            this.logger.debug("Configuration version: " + config.getAttribute("version"));
         }
         if (!Constants.CONF_VERSION.equals(config.getAttribute("version"))) {
             throw new ConfigurationException(
@@ -176,8 +175,8 @@
 
     protected void convert(Configuration config, Configuration additionalConfig, String rootUri)
     throws Exception {
-        if ( this.logger.isInfoEnabled() ) {
-            this.logger.info("Converting Avalon configuration from configuration object:
" + config);
+        if ( this.logger.isDebugEnabled() ) {
+            this.logger.debug("Converting Avalon configuration from configuration object:
" + config);
         }
         // 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.
@@ -196,8 +195,8 @@
         if ( rootUri != null ) {
             final String userRoles = config.getAttribute("user-roles", null);
             if (userRoles != null) {
-                if ( this.logger.isInfoEnabled() ) {
-                    this.logger.info("Reading additional user roles: " + userRoles);
+                if ( this.logger.isDebugEnabled() ) {
+                    this.logger.debug("Reading additional user roles: " + userRoles);
                 }
                 final Resource userRolesSource = this.resolver.getResource(this.getUrl(userRoles,
rootUri));
                 final DefaultConfigurationBuilder b = new DefaultConfigurationBuilder(true);
@@ -293,6 +292,9 @@
                 }
             } else {                    
                 info = new ComponentInfo();
+                if ( !className.endsWith("Selector") ) {
+                    this.configInfo.removeRole(role);
+                }
             }
             // check for name attribute
             // Note: this has to be done *after* finding the className above as we change
the role
@@ -397,8 +399,8 @@
         final String uri = src.getURL().toExternalForm();
 
         if (!loadedURIs.contains(uri)) {
-            if ( this.logger.isInfoEnabled() ) {
-                this.logger.info("Loading configuration: " + uri);
+            if ( this.logger.isDebugEnabled() ) {
+                this.logger.debug("Loading configuration: " + uri);
             }
             // load it and store it in the read set
             Configuration includeConfig = null;



Mime
View raw message