cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components AuthenticationManager.java
Date Thu, 20 Mar 2003 11:46:00 GMT
cziegeler    2003/03/20 03:45:59

  Modified:    src/java/org/apache/cocoon Processor.java
                        ProcessorWrapper.java Cocoon.java
               src/java/org/apache/cocoon/components/modules/input
                        SitemapVariableHolder.java
               src/java/org/apache/cocoon/components
                        SitemapConfigurationHolder.java
                        SitemapConfigurable.java
                        CocoonComponentManager.java
               src/java/org/apache/cocoon/components/treeprocessor
                        TreeProcessor.java
               src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components
                        AuthenticationManager.java
  Added:       src/java/org/apache/cocoon/components
                        DefaultSitemapConfigurationHolder.java
  Log:
  Refactoring SitemapConfigurable
  
  Revision  Changes    Path
  1.2       +4 -3      cocoon-2.1/src/java/org/apache/cocoon/Processor.java
  
  Index: Processor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/Processor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Processor.java	9 Mar 2003 00:08:36 -0000	1.1
  +++ Processor.java	20 Mar 2003 11:45:58 -0000	1.2
  @@ -50,8 +50,9 @@
   */
   package org.apache.cocoon;
   
  +import java.util.Map;
  +
   import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.cocoon.components.pipeline.ProcessingPipeline;
   import org.apache.cocoon.environment.Environment;
   
  @@ -91,5 +92,5 @@
        * Get the sitemap component configurations
        * @since 2.1
        */
  -    Configuration getComponentConfigurations();
  +    Map getComponentConfigurations();
   }
  
  
  
  1.2       +4 -3      cocoon-2.1/src/java/org/apache/cocoon/ProcessorWrapper.java
  
  Index: ProcessorWrapper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/ProcessorWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProcessorWrapper.java	9 Mar 2003 00:08:36 -0000	1.1
  +++ ProcessorWrapper.java	20 Mar 2003 11:45:58 -0000	1.2
  @@ -50,9 +50,10 @@
   */
   package org.apache.cocoon;
   
  +import java.util.Map;
  +
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.components.pipeline.ProcessingPipeline;
   import org.apache.cocoon.environment.Environment;
  @@ -98,7 +99,7 @@
        * Get the sitemap component configurations
        * @since 2.1
        */
  -    public Configuration getComponentConfigurations() {
  +    public Map getComponentConfigurations() {
           return this.processor.getComponentConfigurations();
       }
   
  
  
  
  1.5       +4 -3      cocoon-2.1/src/java/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Cocoon.java	13 Mar 2003 14:11:59 -0000	1.4
  +++ Cocoon.java	20 Mar 2003 11:45:58 -0000	1.5
  @@ -99,6 +99,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.net.URL;
  +import java.util.Collections;
   import java.util.Enumeration;
   import java.util.Map;
   
  @@ -708,8 +709,8 @@
        * Get the sitemap component configurations
        * @since 2.1
        */
  -    public Configuration getComponentConfigurations() {
  -        return null;
  +    public Map getComponentConfigurations() {
  +        return Collections.EMPTY_MAP;
       }
   
       /**
  
  
  
  1.3       +4 -3      cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/SitemapVariableHolder.java
  
  Index: SitemapVariableHolder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/SitemapVariableHolder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SitemapVariableHolder.java	19 Mar 2003 12:47:34 -0000	1.2
  +++ SitemapVariableHolder.java	20 Mar 2003 11:45:58 -0000	1.3
  @@ -61,6 +61,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.cocoon.components.SitemapConfigurable;
  +import org.apache.cocoon.components.SitemapConfigurationHolder;
   
   /**
    * This "component" is a trick to get global variables on a per
  @@ -110,10 +111,10 @@
       /**
        * Set the <code>Configuration</code> from a sitemap
        */
  -    public void setSitemapConfiguration(Configuration config)
  +    public void configure(SitemapConfigurationHolder holder)
       throws ConfigurationException {
           // add sitemap configuration
  -        this.manager.add(config);
  +        this.manager.add(holder.getConfiguration());
       }
   
       /**
  
  
  
  1.2       +2 -2      cocoon-2.1/src/java/org/apache/cocoon/components/SitemapConfigurationHolder.java
  
  Index: SitemapConfigurationHolder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/SitemapConfigurationHolder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SitemapConfigurationHolder.java	19 Mar 2003 12:47:34 -0000	1.1
  +++ SitemapConfigurationHolder.java	20 Mar 2003 11:45:58 -0000	1.2
  @@ -80,5 +80,5 @@
        * 
        * @param preparedConfig The prepared configuration
        */
  -    void setPreparedConfiguration(Object preparedConfig);
  +    void setPreparedConfiguration(ChainedConfiguration configuration, Object preparedConfig);
   }
  
  
  
  1.3       +2 -3      cocoon-2.1/src/java/org/apache/cocoon/components/SitemapConfigurable.java
  
  Index: SitemapConfigurable.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/SitemapConfigurable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SitemapConfigurable.java	19 Mar 2003 12:47:34 -0000	1.2
  +++ SitemapConfigurable.java	20 Mar 2003 11:45:58 -0000	1.3
  @@ -50,7 +50,6 @@
   */
   package org.apache.cocoon.components;
   
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   
   /**
  @@ -67,6 +66,6 @@
       /**
        * Set the <code>Configuration</code>.
        */
  -    void setSitemapConfiguration(Configuration config)
  +    void configure(SitemapConfigurationHolder holder)
       throws ConfigurationException;
   }
  
  
  
  1.5       +13 -55    cocoon-2.1/src/java/org/apache/cocoon/components/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CocoonComponentManager.java	20 Mar 2003 08:54:18 -0000	1.4
  +++ CocoonComponentManager.java	20 Mar 2003 11:45:58 -0000	1.5
  @@ -63,8 +63,7 @@
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.ComponentSelector;
   import org.apache.avalon.framework.component.Recomposable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.DefaultConfiguration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Processor;
   import org.apache.cocoon.environment.Environment;
  @@ -153,8 +152,6 @@
   		final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
   		stack.push(new Object[] {env, processor, manager});
       
  -        final EnvironmentDescription desc = (EnvironmentDescription)env.getObjectModel().get(PROCESS_KEY);
  -        desc.addSitemapConfiguration(processor.getComponentConfigurations());
           env.setAttribute("CocoonComponentManager.processor", processor);
       }
   
  @@ -164,8 +161,6 @@
       public static void leaveEnvironment() {
           final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           final Object[] objects = (Object[])stack.pop();
  -        final EnvironmentDescription desc = (EnvironmentDescription)((Environment)objects[0]).getObjectModel().get(PROCESS_KEY);
  -        desc.removeLastSitemapConfiguration();
       }
   
       /**
  @@ -314,29 +309,6 @@
                           }
                           ((RequestLifecycleComponent) component).setup((org.apache.cocoon.environment.SourceResolver)objects[0],
                                                                         objectModel);
  -                        if (component instanceof SitemapConfigurable) {
  -                            List configs = desc.getSitemapConfigurations();
  -                            for(int i=0; i < configs.size(); i++) {
  -                                Configuration parent = (Configuration)configs.get(i);
  -                                Configuration cc = parent.getChild( role, false );
  -                                if ( null != cc ) {
  -                                    ((SitemapConfigurable) component).setSitemapConfiguration(cc);
  -                                } else if ( null != this.roleManager) {
  -
  -                                    // check for hint
  -                                    Configuration[] childs = parent.getChildren();
  -                                    if ( null != childs ) {
  -                                        for(int m = 0; m < childs.length; m++) {
  -                                            final String r = this.roleManager.getRoleForName(childs[m].getName());
  -                                            if ( role.equals(r) ) {
  -                                                ((SitemapConfigurable) component).setSitemapConfiguration(childs[m]);
  -                                                m = childs.length;
  -                                            }
  -                                        }
  -                                    }
  -                                }
  -                            }
  -                        }
                       } catch (Exception local) {
                           throw new ComponentException(role, "Exception during setup of RequestLifecycleComponent.",
local);
                       }
  @@ -345,18 +317,24 @@
               }
           }
           
  -        /*
  -         if ( null != component && component instanceof SitemapConfigurable) {
  +        if ( null != component && component instanceof SitemapConfigurable) {
  +
               // FIXME: how can we prevent that this is called over and over again?
               SitemapConfigurationHolder holder;
               
               holder = (SitemapConfigurationHolder)sitemapConfigurationHolders.get( role
);
               if ( null == holder ) {
                   // create new holder
  +                holder = new DefaultSitemapConfigurationHolder( role );
                   sitemapConfigurationHolders.put( role, holder );
               }
  -            ((SitemapConfigurable)component).configure(holder);
  -        }*/
  +
  +            try {
  +                ((SitemapConfigurable)component).configure(holder);
  +            } catch (ConfigurationException ce) {
  +                throw new ComponentException(role, "Exception during setup of SitemapConfigurable.",
ce);
  +            }
  +        }
           return component;
       }
   
  @@ -482,14 +460,11 @@
   
   final class EnvironmentDescription {
       
  -    private static final Configuration EMPTY_CONFIGURATION = 
  -            new DefaultConfiguration("config", "");
  -    
       Environment environment;
       Map         objectModel;
       Map         requestLifecycleComponents = new HashMap(5);
       List        autoreleaseComponents      = new ArrayList(2);
  -    List        sitemapConfigurations      = new ArrayList(4);    
  +
       /**
        * Constructor
        */
  @@ -525,7 +500,6 @@
           }
           this.requestLifecycleComponents.clear();
           this.autoreleaseComponents.clear();
  -        this.sitemapConfigurations.clear();
           this.environment = null;
           this.objectModel = null;
       }
  @@ -601,22 +575,6 @@
           }
       }
       
  -          
  -    void addSitemapConfiguration(Configuration conf) {
  -        if (conf != null) {
  -            this.sitemapConfigurations.add(conf);
  -        } else {
  -            this.sitemapConfigurations.add(EMPTY_CONFIGURATION);
  -        }
  -    }
  -      
  -    List getSitemapConfigurations() {
  -        return this.sitemapConfigurations;
  -    }
  - 
  -    void removeLastSitemapConfiguration() {
  -        this.sitemapConfigurations.remove(this.sitemapConfigurations.size()-1);
  -    }               
   }
   
   final class CloningInheritableThreadLocal 
  
  
  
  1.1                  cocoon-2.1/src/java/org/apache/cocoon/components/DefaultSitemapConfigurationHolder.java
  
  Index: DefaultSitemapConfigurationHolder.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components;
  
  import java.util.Map;
  
  /**
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: DefaultSitemapConfigurationHolder.java,v 1.1 2003/03/20 11:45:58 cziegeler
Exp $
   */
  public final class DefaultSitemapConfigurationHolder 
      implements SitemapConfigurationHolder {
  
      private String role;
      
      public DefaultSitemapConfigurationHolder(String role) {
          this.role = role;
      }
      
      /**
       * @see org.apache.cocoon.components.SitemapConfigurationHolder#getConfiguration()
       */
      public ChainedConfiguration getConfiguration() {
          Map confs = CocoonComponentManager.getCurrentProcessor().getComponentConfigurations();
          return (ChainedConfiguration) (confs == null ? null : confs.get(this.role));
      }
  
      /**
       * @see org.apache.cocoon.components.SitemapConfigurationHolder#getPreparedConfiguration()
       */
      public Object getPreparedConfiguration() {
          return null;
      }
  
      /**
       * @see org.apache.cocoon.components.SitemapConfigurationHolder#setPreparedConfiguration(java.lang.Object)
       */
      public void setPreparedConfiguration(ChainedConfiguration configuration, Object preparedConfig)
{
      }
  
  }
  
  
  
  1.3       +40 -32    cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
  
  Index: TreeProcessor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TreeProcessor.java	20 Mar 2003 08:54:17 -0000	1.2
  +++ TreeProcessor.java	20 Mar 2003 11:45:58 -0000	1.3
  @@ -69,6 +69,7 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.Processor;
  +import org.apache.cocoon.components.ChainedConfiguration;
   import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.components.ExtendedComponentSelector;
   import org.apache.cocoon.components.LifecycleHelper;
  @@ -150,9 +151,9 @@
       /** Check for reload? */
       protected boolean checkReload;
   
  -    /** component configurations */
  +    /** The component configurations from the sitemap (if any) */
       protected Configuration componentConfigurations;
  -
  +    
       /** The different sitemap component configurations */
       protected Map sitemapComponentConfigurations;
       
  @@ -203,6 +204,7 @@
           // FIXME(VG): Why child isn't configure()d/contextualize(d)/etc ???
           TreeProcessor child = new TreeProcessor(this, manager, language);
           child.enableLogging(getLogger());
  +        child.setRoleManager(this.roleManager);
           child.source = new DelayedRefreshSourceWrapper(source, lastModifiedDelay);
           return child;
       }
  @@ -361,41 +363,47 @@
        * Get the sitemap component configurations
        * @since 2.1
        */
  -    public Configuration getComponentConfigurations() {
  +    public Map getComponentConfigurations() {
           // do we have the sitemap configurations prepared for this processor?
  -        /*if ( null == sitemapComponentConfigurations ) {
  -
  -            // do we have configurations?
  -            final Configuration[] childs = (this.componentConfigurations == null ? null
: this.componentConfigurations.getChildren());
  +        if ( null == this.sitemapComponentConfigurations ) {
               
  -            if ( childs == null ) {
  -                Map configurationMap = null;
  -                if ( null == this.parent ) {
  -                    this.sitemapComponentConfigurations = Collections.EMPTY_MAP;
  -                } else {
  -                    // use configuration from parent
  -                    this.sitemapComponentConfigurations = (Map)this.parent.getComponentConfigurations();

  -                }
  -
  -            } else {
  +            synchronized (this) {
   
  -                Map configurationMap = null;
  -                if ( null == this.parent ) {
  -                    configurationMap = new HashMap(12);
  -                } else {
  -                    // copy all configurations from parent
  -                    configurationMap = new HashMap((Map)this.parent.getComponentConfigurations());

  -                }
  -                
  -                // and now check for new configurations
  -                for(int m = 0; m < childs.length; m++) {
  +                if ( this.sitemapComponentConfigurations == null ) {
  +                    // do we have configurations?
  +                    final Configuration[] childs = (this.componentConfigurations == null

  +                                                     ? null 
  +                                                     : this.componentConfigurations.getChildren());
                       
  -                    //final String r = this.roleManager.getRoleForName(childs[m].getName());
  +                    if ( null != childs ) {
  +        
  +                        if ( null == this.parent ) {
  +                            this.sitemapComponentConfigurations = new HashMap(12);
  +                        } else {
  +                            // copy all configurations from parent
  +                            this.sitemapComponentConfigurations = new HashMap(this.parent.getComponentConfigurations());

  +                        }
  +                        
  +                        // and now check for new configurations
  +                        for(int m = 0; m < childs.length; m++) {
  +                            
  +                            final String r = this.roleManager.getRoleForName(childs[m].getName());
  +                            this.sitemapComponentConfigurations.put(r, new ChainedConfiguration(childs[m],

  +                                                                             (ChainedConfiguration)this.sitemapComponentConfigurations.get(r)));
  +                        }
  +                    } else {
  +                        // we don't have configurations
  +                        if ( null == this.parent ) {
  +                            this.sitemapComponentConfigurations = Collections.EMPTY_MAP;
  +                        } else {
  +                            // use configuration from parent
  +                            this.sitemapComponentConfigurations = this.parent.getComponentConfigurations();

  +                        }
  +                    }
                   }
               }
  -        }*/
  -        
  -        return this.componentConfigurations;
  +        }
  +        return this.sitemapComponentConfigurations;
       }
   
       protected synchronized void setupRootNode(Environment env) throws Exception {
  
  
  
  1.3       +5 -4      cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/AuthenticationManager.java
  
  Index: AuthenticationManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/AuthenticationManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AuthenticationManager.java	19 Mar 2003 12:47:34 -0000	1.2
  +++ AuthenticationManager.java	20 Mar 2003 11:45:59 -0000	1.3
  @@ -66,6 +66,7 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.RequestLifecycleComponent;
   import org.apache.cocoon.components.SitemapConfigurable;
  +import org.apache.cocoon.components.SitemapConfigurationHolder;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.Request;
  @@ -161,10 +162,10 @@
       /**
        * Set the <code>Configuration</code>.
        */
  -    public void setSitemapConfiguration(Configuration config)
  +    public void configure(SitemapConfigurationHolder holder)
       throws ConfigurationException {
  -        this.handlerManager.addConfiguration( config, this.resolver, this.request );
  -        this.handlerManager.addAvailableHandlers( config );
  +        this.handlerManager.addConfiguration( holder.getConfiguration(), this.resolver,
this.request );
  +        this.handlerManager.addAvailableHandlers( holder.getConfiguration() );
       }
   
       /**
  
  
  

Mime
View raw message