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/java/org/apache/cocoon Constants.java
Date Mon, 08 Mar 2004 12:07:40 GMT
cziegeler    2004/03/08 04:07:40

  Modified:    src/java/org/apache/cocoon/components/treeprocessor
                        DefaultTreeBuilder.java
                        AbstractProcessingNodeBuilder.java
               src/java/org/apache/cocoon/sitemap SitemapParameters.java
               src/java/org/apache/cocoon/matching
                        AbstractWildcardMatcher.java
                        AbstractRegexpMatcher.java
               src/java/org/apache/cocoon/components/treeprocessor/variables
                        VariableResolver.java
               src/java/org/apache/cocoon/components/pipeline
                        AbstractProcessingPipeline.java
               src/java/org/apache/cocoon Constants.java
  Log:
  Move sitemap location out of the Parameters object again.
  First solution for bug 27432
  
  Revision  Changes    Path
  1.8       +5 -7      cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
  
  Index: DefaultTreeBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultTreeBuilder.java	5 Mar 2004 13:02:51 -0000	1.7
  +++ DefaultTreeBuilder.java	8 Mar 2004 12:07:39 -0000	1.8
  @@ -34,18 +34,16 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.cocoon.Constants;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.ExtendedComponentSelector;
   import org.apache.cocoon.components.LifecycleHelper;
   import org.apache.cocoon.components.source.SourceUtil;
  -import org.apache.cocoon.components.treeprocessor.variables.NOPVariableResolver;
   import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
   import org.apache.cocoon.sitemap.PatternException;
  +import org.apache.cocoon.sitemap.SitemapParameters;
   import org.apache.excalibur.source.Source;
   
   import java.util.ArrayList;
  -import java.util.Collections;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
  @@ -471,11 +469,11 @@
   
           if (children.length == 0) {
               // Parameters are only the component's location
  -            return Collections.singletonMap(new NOPVariableResolver(Constants.SITEMAP_PARAMETERS_LOCATION),
new NOPVariableResolver(config.getLocation()));
  +            // TODO Optimize this
  +            return new SitemapParameters.ExtendedHashMap(config);
           }
   
  -        Map params = new HashMap();
  -        params.put(new NOPVariableResolver(Constants.SITEMAP_PARAMETERS_LOCATION), new
NOPVariableResolver(config.getLocation()));
  +        Map params = new SitemapParameters.ExtendedHashMap(config, children.length+1);
           for (int i = 0; i < children.length; i++) {
               Configuration child = children[i];
               if (true) { // FIXME : check namespace
  
  
  
  1.4       +5 -8      cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java
  
  Index: AbstractProcessingNodeBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractProcessingNodeBuilder.java	5 Mar 2004 13:02:51 -0000	1.3
  +++ AbstractProcessingNodeBuilder.java	8 Mar 2004 12:07:39 -0000	1.4
  @@ -21,12 +21,10 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.cocoon.Constants;
   import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
   import org.apache.cocoon.sitemap.PatternException;
  +import org.apache.cocoon.sitemap.SitemapParameters;
   
  -import java.util.Collections;
  -import java.util.HashMap;
   import java.util.Map;
   
   /**
  @@ -75,12 +73,11 @@
   
           if (children.length == 0) {
               // Parameters are only the component's location
  -            return Collections.singletonMap(Constants.SITEMAP_PARAMETERS_LOCATION, config.getLocation());
  +            // TODO Optimize this
  +            return new SitemapParameters.ExtendedHashMap(config);
           }
   
  -        Map params = new HashMap(children.length+1);
  -        // Add the location information as a parameter
  -        params.put(Constants.SITEMAP_PARAMETERS_LOCATION, config.getLocation());
  +        Map params = new SitemapParameters.ExtendedHashMap(config, children.length+1);
           for (int i = 0; i < children.length; i++) {
               Configuration child = children[i];
               if (true) { // FIXME : check namespace
  
  
  
  1.2       +45 -2     cocoon-2.1/src/java/org/apache/cocoon/sitemap/SitemapParameters.java
  
  Index: SitemapParameters.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/sitemap/SitemapParameters.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SitemapParameters.java	7 Mar 2004 18:56:17 -0000	1.1
  +++ SitemapParameters.java	8 Mar 2004 12:07:39 -0000	1.2
  @@ -15,6 +15,9 @@
    */
   package org.apache.cocoon.sitemap;
   
  +import java.util.HashMap;
  +
  +import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.parameters.Parameters;
   
   /**
  @@ -32,11 +35,51 @@
           return null;   
       }
       */
  -    public String getStatementLocation(String name) {
  +    public String getStatementLocation() {
           return this.statementLocation;   
       }
       
       public void setStatementLocation(String value) {
           this.statementLocation = value;   
  +    }
  +    
  +    /**
  +     * Return the location  - if available
  +     */
  +    public static String getStatementLocation(Parameters param) {
  +        String value = null;
  +        if ( param instanceof SitemapParameters ) {
  +            value = ((SitemapParameters)param).getStatementLocation();
  +        }
  +        if ( value == null ) {
  +            value = "[unknown location]";
  +        }
  +        return value;
  +    }
  +    
  +    public static class ExtendedHashMap extends HashMap {
  +        
  +        protected Configuration configuration;
  +        
  +        public ExtendedHashMap(Configuration conf) {
  +            super();
  +            this.configuration = conf;
  +        }
  +        
  +        public ExtendedHashMap(Configuration conf, int capacity) {
  +            super(capacity);
  +            this.configuration = conf;
  +        }
  +
  +        public String getLocation() {
  +            if ( this.configuration != null ) {
  +                return this.configuration.getLocation();
  +            } 
  +            return null;
  +        }
  +        
  +        public Configuration getConfiguration() {
  +            return this.configuration;
  +        }
       }
   }
  
  
  
  1.4       +3 -3      cocoon-2.1/src/java/org/apache/cocoon/matching/AbstractWildcardMatcher.java
  
  Index: AbstractWildcardMatcher.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/matching/AbstractWildcardMatcher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractWildcardMatcher.java	5 Mar 2004 13:02:56 -0000	1.3
  +++ AbstractWildcardMatcher.java	8 Mar 2004 12:07:39 -0000	1.4
  @@ -17,9 +17,9 @@
   
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.apache.cocoon.Constants;
   import org.apache.cocoon.matching.helpers.WildcardHelper;
   import org.apache.cocoon.sitemap.PatternException;
  +import org.apache.cocoon.sitemap.SitemapParameters;
   
   import java.util.HashMap;
   import java.util.Map;
  @@ -48,7 +48,7 @@
   
           if(preparedPattern == null) {
               throw new PatternException("A pattern is needed at " +
  -                parameters.getParameter(Constants.SITEMAP_PARAMETERS_LOCATION, "unknown
location"));
  +                    SitemapParameters.getStatementLocation(parameters));
           }
   
           String match = getMatchString(objectModel, parameters);
  
  
  
  1.4       +3 -4      cocoon-2.1/src/java/org/apache/cocoon/matching/AbstractRegexpMatcher.java
  
  Index: AbstractRegexpMatcher.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/matching/AbstractRegexpMatcher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractRegexpMatcher.java	5 Mar 2004 13:02:56 -0000	1.3
  +++ AbstractRegexpMatcher.java	8 Mar 2004 12:07:39 -0000	1.4
  @@ -17,8 +17,8 @@
   
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.apache.cocoon.Constants;
   import org.apache.cocoon.sitemap.PatternException;
  +import org.apache.cocoon.sitemap.SitemapParameters;
   import org.apache.regexp.RE;
   import org.apache.regexp.RECompiler;
   import org.apache.regexp.REProgram;
  @@ -74,8 +74,7 @@
       public Map preparedMatch(Object preparedPattern, Map objectModel, Parameters parameters)
throws PatternException {
   
           if(preparedPattern == null) {
  -            throw new PatternException("A pattern is needed at " +
  -                parameters.getParameter(Constants.SITEMAP_PARAMETERS_LOCATION, "unknown
location"));
  +            throw new PatternException("A pattern is needed at " + SitemapParameters.getStatementLocation(parameters));
           }
   
           RE re = new RE((REProgram)preparedPattern);
  
  
  
  1.4       +14 -4     cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolver.java
  
  Index: VariableResolver.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolver.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- VariableResolver.java	5 Mar 2004 13:02:53 -0000	1.3
  +++ VariableResolver.java	8 Mar 2004 12:07:39 -0000	1.4
  @@ -15,9 +15,11 @@
    */
   package org.apache.cocoon.components.treeprocessor.variables;
   
  +import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.components.treeprocessor.InvokeContext;
   import org.apache.cocoon.sitemap.PatternException;
  +import org.apache.cocoon.sitemap.SitemapParameters;
   
   import java.util.Collections;
   import java.util.HashMap;
  @@ -88,8 +90,10 @@
               return Parameters.EMPTY_PARAMETERS;
           }
   
  -        Parameters result = new Parameters();
  -
  +        SitemapParameters result = new SitemapParameters();
  +        if ( expressions instanceof SitemapParameters.ExtendedHashMap ) {
  +            result.setStatementLocation(((SitemapParameters.ExtendedHashMap)expressions).getLocation());
   
  +        }
           Iterator iter = expressions.entrySet().iterator();
           while (iter.hasNext()) {
               Map.Entry entry = (Map.Entry)iter.next();
  @@ -114,7 +118,13 @@
               return EMPTY_MAP;
           }
   
  -        Map result = new HashMap(size);
  +        Map result;
  +        if ( expressions instanceof SitemapParameters.ExtendedHashMap ) {
  +            Configuration config = ((SitemapParameters.ExtendedHashMap)expressions).getConfiguration();
  +            result = new SitemapParameters.ExtendedHashMap(config, size );   
  +        } else {
  +            result = new HashMap(size);
  +        }
   
           Iterator iter = expressions.entrySet().iterator();
           while (iter.hasNext()) {
  
  
  
  1.20      +10 -3     cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
  
  Index: AbstractProcessingPipeline.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- AbstractProcessingPipeline.java	5 Mar 2004 13:02:50 -0000	1.19
  +++ AbstractProcessingPipeline.java	8 Mar 2004 12:07:39 -0000	1.20
  @@ -25,7 +25,6 @@
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ConnectionResetException;
  -import org.apache.cocoon.Constants;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.environment.Environment;
  @@ -35,6 +34,7 @@
   import org.apache.cocoon.reading.Reader;
   import org.apache.cocoon.serialization.Serializer;
   import org.apache.cocoon.sitemap.SitemapModelComponent;
  +import org.apache.cocoon.sitemap.SitemapParameters;
   import org.apache.cocoon.transformation.Transformer;
   import org.apache.cocoon.xml.XMLConsumer;
   import org.apache.cocoon.xml.XMLProducer;
  @@ -774,6 +774,13 @@
       }
       
       protected String getLocation(Parameters param) {
  -        return param.getParameter(Constants.SITEMAP_PARAMETERS_LOCATION, "[unknown location]");
  +        String value = null;
  +        if ( param instanceof SitemapParameters ) {
  +            value = ((SitemapParameters)param).getStatementLocation();
  +        }
  +        if ( value == null ) {
  +            value = "[unknown location]";
  +        }
  +        return value;
       }
   }
  
  
  
  1.12      +1 -6      cocoon-2.1/src/java/org/apache/cocoon/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/Constants.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Constants.java	5 Mar 2004 13:02:42 -0000	1.11
  +++ Constants.java	8 Mar 2004 12:07:40 -0000	1.12
  @@ -277,11 +277,6 @@
        */
       public static final boolean DESCRIPTOR_RELOADABLE_DEFAULT = true;
       
  -    /**
  -     * The special parameter passed to each sitemap component (matchers, generators, etc)
that
  -     * contains the location of the sitemap statement where this component is used.
  -     */
  -    public static final String SITEMAP_PARAMETERS_LOCATION = "org.apache.cocoon.sitemap/Location";
   }
   
   
  
  
  

Mime
View raw message