vgritsenko    2004/06/11 13:03:35

  Modified:    src/blocks/xsp/java/org/apache/cocoon/components/language/markup
                        LogicsheetCodeGenerator.java
               src/java/org/apache/cocoon/components/treeprocessor
                        AbstractParentProcessingNode.java
                        ConcreteTreeProcessor.java DefaultTreeBuilder.java
                        TreeProcessor.java
               src/java/org/apache/cocoon/components/treeprocessor/sitemap
                        PipelineNode.java PipelinesNode.java
                        PreparableMatchNode.java SitemapLanguage.java
  Log:
  Fix NullPointerException when reloading sitemap.
  TreeProcessor.treeBuilder was not recycle()d before building new sitemap,
  so DefaultTreeBuilder.disposableNodes of old sitemap was collecting nodes
  from new sitemap. Added recycle().
  
  Revision  Changes    Path
  1.2       +6 -7      
cocoon-2.1/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/LogicsheetCodeGenerator.java
  
  Index: LogicsheetCodeGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/xsp/java/org/apache/cocoon/components/language/markup/LogicsheetCodeGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogicsheetCodeGenerator.java      10 Mar 2004 12:58:04 -0000      1.1
  +++ LogicsheetCodeGenerator.java      11 Jun 2004 20:03:35 -0000      1.2
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -85,8 +85,7 @@
       /**
        * Helper for TransformerFactory.
        */
  -    private SAXTransformerFactory getTransformerFactory()
  -    {
  +    private SAXTransformerFactory getTransformerFactory() {
           if(tfactory == null)  {
               tfactory = (SAXTransformerFactory) 
TransformerFactory.newInstance();
               tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
  @@ -131,7 +130,7 @@
        * @exception Exception If an error occurs during code generation
        */
       public String generateCode(Source source, AbstractXMLPipe filter)
  -            throws Exception {
  +    throws Exception {
           try {
               // set the root XMLReader of the transformer chain
               this.end = filter;
  
  
  
  1.7       +15 -19    
cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java
  
  Index: AbstractParentProcessingNode.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractParentProcessingNode.java 11 Jun 2004 08:51:57 -0000      1.6
  +++ AbstractParentProcessingNode.java 11 Jun 2004 20:03:35 -0000      1.7
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -24,13 +24,12 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
    * @version CVS $Id$
    */
  -
   public abstract class AbstractParentProcessingNode extends 
AbstractProcessingNode {
   
       public AbstractParentProcessingNode(String type) {
           super(type);
       }
  -    
  +
       public AbstractParentProcessingNode() {
       }
   
  @@ -40,14 +39,12 @@
        * @param currentMap the <code>Map<code> of parameters produced by this 
node,
        *            which is added to <code>listOfMap</code>.
        */
  -
  -    protected final boolean invokeNodes(
  -        ProcessingNode[] nodes,
  -        Environment env,
  -        InvokeContext context,
  -        String currentName,
  -        Map currentMap)
  -      throws Exception {
  +    protected final boolean invokeNodes(ProcessingNode[] nodes,
  +                                        Environment env,
  +                                        InvokeContext context,
  +                                        String currentName,
  +                                        Map currentMap)
  +    throws Exception {
   
           currentMap = this.executor.pushVariables(this, env.getObjectModel(), 
currentName, currentMap);
           context.pushMap(currentName,currentMap);
  @@ -70,11 +67,10 @@
       /**
        * Invoke all nodes of a node array in order, until one succeeds.
        */
  -    protected final boolean invokeNodes (
  -        ProcessingNode[] nodes,
  -        Environment env,
  -        InvokeContext context)
  -      throws Exception {
  +    protected final boolean invokeNodes (ProcessingNode[] nodes,
  +                                         Environment env,
  +                                         InvokeContext context)
  +    throws Exception {
   
           for (int i = 0; i < nodes.length; i++) {
               if (nodes[i].invoke(env, context)) {
  
  
  
  1.3       +57 -58    
cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
  
  Index: ConcreteTreeProcessor.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConcreteTreeProcessor.java        9 Jun 2004 11:59:23 -0000       1.2
  +++ ConcreteTreeProcessor.java        11 Jun 2004 20:03:35 -0000      1.3
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -45,42 +45,41 @@
   import org.apache.cocoon.sitemap.SitemapExecutor;
   import org.apache.cocoon.sitemap.impl.DefaultExecutor;
   
  -
   /**
    * The concrete implementation of [EMAIL PROTECTED] Processor}, containing 
the evaluation tree and associated
    * data such as component manager.
  - * 
  + *
    * @version CVS $Id$
    */
   public class ConcreteTreeProcessor extends AbstractLogEnabled implements 
Processor {
   
        /** The processor that wraps us */
        private TreeProcessor wrappingProcessor;
  -     
  +
        /** Component manager defined by the &lt;map:components&gt; of this 
sitemap */
       ComponentManager sitemapComponentManager;
  -    
  +
       private ServiceManager serviceManager;
  - 
  +
        /** Processing nodes that need to be disposed with this processor */
       private List disposableNodes;
  -   
  +
       /** Root node of the processing tree */
       private ProcessingNode rootNode;
  -    
  +
       private Map sitemapComponentConfigurations;
  -    
  +
       private Configuration componentConfigurations;
  -    
  +
       /** Number of simultaneous uses of this processor (either by concurrent 
request or by internal requests) */
       private int requestCount;
  -    
  +
       /** The sitemap executor */
       private SitemapExecutor sitemapExecutor;
  -    
  +
       /** Release the executor */
       private boolean releaseSitemapExecutor;
  -    
  +
        /** Builds a concrete processig, given the wrapping processor */
        public ConcreteTreeProcessor(TreeProcessor wrappingProcessor) {
                this.wrappingProcessor = wrappingProcessor;
  @@ -98,7 +97,7 @@
                       this.getLogger().error("Unable to lookup sitemap 
executor.", ce);
                   }
               }
  -            if ( this.sitemapExecutor == null ) {                
  +            if ( this.sitemapExecutor == null ) {
                   try {
                       this.sitemapExecutor = (SitemapExecutor) this.getClass()
                                    .getClassLoader()
  @@ -116,19 +115,19 @@
               this.sitemapExecutor = 
this.wrappingProcessor.parent.concreteProcessor.sitemapExecutor;
           }
        }
  -     
  +
        /** Set the processor data, result of the treebuilder job */
        public void setProcessorData(ComponentManager manager, ProcessingNode 
rootNode, List disposableNodes) {
                if (this.sitemapComponentManager != null) {
                        throw new IllegalStateException("setProcessorData() can 
only be called once");
                }
  -             
  +
                this.sitemapComponentManager = manager;
                this.serviceManager = new ComponentManagerWrapper(manager);
                this.rootNode = rootNode;
                this.disposableNodes = disposableNodes;
        }
  -     
  +
        /** Set the sitemap component configurations (called as part of the 
tree building process) */
       public void setComponentConfigurations(Configuration 
componentConfigurations) {
           this.componentConfigurations = componentConfigurations;
  @@ -142,30 +141,30 @@
       public Map getComponentConfigurations() {
           // do we have the sitemap configurations prepared for this processor?
           if ( null == this.sitemapComponentConfigurations ) {
  -            
  +
               synchronized (this) {
   
                   if ( this.sitemapComponentConfigurations == null ) {
                       // do we have configurations?
  -                    final Configuration[] childs = 
(this.componentConfigurations == null 
  -                                                     ? null 
  +                    final Configuration[] childs = 
(this.componentConfigurations == null
  +                                                     ? null
                                                        : 
this.componentConfigurations.getChildren());
  -                    
  +
                       if ( null != childs ) {
  -        
  +
                           if ( null == this.wrappingProcessor.parent ) {
                               this.sitemapComponentConfigurations = new 
HashMap(12);
                           } else {
                               // copy all configurations from parent
                               this.sitemapComponentConfigurations = new 
HashMap(
  -                                             
this.wrappingProcessor.parent.getComponentConfigurations()); 
  +                                             
this.wrappingProcessor.parent.getComponentConfigurations());
                           }
  -                        
  +
                           // and now check for new configurations
                           for(int m = 0; m < childs.length; m++) {
  -                            
  +
                               final String r = 
this.wrappingProcessor.roleManager.getRoleForName(childs[m].getName());
  -                            this.sitemapComponentConfigurations.put(r, new 
ChainedConfiguration(childs[m], 
  +                            this.sitemapComponentConfigurations.put(r, new 
ChainedConfiguration(childs[m],
                                                                                
(ChainedConfiguration)this.sitemapComponentConfigurations.get(r)));
                           }
                       } else {
  @@ -174,14 +173,14 @@
                               this.sitemapComponentConfigurations = 
Collections.EMPTY_MAP;
                           } else {
                               // use configuration from parent
  -                            this.sitemapComponentConfigurations = 
this.wrappingProcessor.parent.getComponentConfigurations(); 
  +                            this.sitemapComponentConfigurations = 
this.wrappingProcessor.parent.getComponentConfigurations();
                           }
                       }
                   }
               }
           }
           return this.sitemapComponentConfigurations;    }
  -     
  +
       /**
        * Mark this processor as needing to be disposed. Actual call to [EMAIL 
PROTECTED] #dispose()} will occur when
        * all request processings on this processor will be terminated.
  @@ -191,21 +190,21 @@
                synchronized(this) {
                        this.requestCount--;
                }
  -             
  +
                if (this.requestCount < 0) {
                        // No more users : dispose right now
                        dispose();
                }
        }
  -     
  +
        public TreeProcessor getWrappingProcessor() {
                return this.wrappingProcessor;
        }
  -     
  +
        public Processor getRootProcessor() {
                return this.wrappingProcessor.getRootProcessor();
        }
  -     
  +
       /**
        * Process the given <code>Environment</code> producing the output.
        * @return If the processing is successfull <code>true</code> is 
returned.
  @@ -259,14 +258,14 @@
        */
       protected boolean process(Environment environment, InvokeContext context)
       throws Exception {
  -     
  +
                // Increment the concurrent requests count
                synchronized(this) {
                        requestCount++;
                }
   
                try {
  -                     
  +
                // and now process
                EnvironmentHelper.enterProcessor(this, this.serviceManager, 
environment);
   
  @@ -279,57 +278,57 @@
   
                try {
                    boolean success = this.rootNode.invoke(environment, 
context);
  -                 
  +
                    return success;
   
                } finally {
                    EnvironmentHelper.leaveProcessor();
  -                 // Restore old redirector 
  +                 // Restore old redirector
                    context.setRedirector(oldRedirector);
                }
   
                } finally {
  -                     
  +
                        // Decrement the concurrent request count
                        synchronized(this) {
                                requestCount--;
                        }
  -                     
  +
                        if(requestCount < 0) {
                                // Marked for disposal and no more concurrent 
requests.
                                dispose();
                        }
                }
       }
  -        
  -    
  +
  +
       protected boolean handleCocoonRedirect(String uri, Environment 
environment, InvokeContext context) throws Exception {
  -        
  +
           // Build an environment wrapper
           // If the current env is a facade, change the delegate and continue 
processing the facade, since
           // we may have other redirects that will in turn also change the 
facade delegate
  -        
  +
           MutableEnvironmentFacade facade = environment instanceof 
MutableEnvironmentFacade ?
               ((MutableEnvironmentFacade)environment) : null;
  -        
  +
           if (facade != null) {
               // Consider the facade delegate (the real environment)
               environment = facade.getDelegate();
           }
  -        
  +
           // test if this is a call from flow
           boolean isRedirect = 
(environment.getObjectModel().remove("cocoon:forward") == null);
           Environment newEnv = new ForwardEnvironmentWrapper(environment, uri, 
getLogger());
           if ( isRedirect ) {
               ((ForwardEnvironmentWrapper)newEnv).setInternalRedirect(true);
           }
  -        
  +
           if (facade != null) {
               // Change the facade delegate
               facade.setDelegate((EnvironmentWrapper)newEnv);
               newEnv = facade;
           }
  -        
  +
           // Get the processor that should process this request
           ConcreteTreeProcessor processor;
           if ( newEnv.getURIPrefix().equals("") ) {
  @@ -337,13 +336,13 @@
           } else {
               processor = this;
           }
  -        
  +
           // Process the redirect
   // No more reset since with TreeProcessorRedirector, we need to pop values 
from the redirect location
   //        context.reset();
           return processor.process(newEnv, context);
       }
  -    
  +
        public void dispose() {
           if (this.disposableNodes != null) {
               // we must dispose the nodes in reverse order
  @@ -353,7 +352,7 @@
               }
               this.disposableNodes = null;
           }
  -        
  +
           // Ensure it won't be used anymore
           this.rootNode = null;
           if ( this.releaseSitemapExecutor ) {
  @@ -361,15 +360,15 @@
               this.sitemapExecutor = null;
           }
        }
  -    
  +
       private class TreeProcessorRedirector extends ForwardRedirector {
  -        
  +
           private InvokeContext context;
           public TreeProcessorRedirector(Environment env, InvokeContext 
context) {
               super(env);
               this.context = context;
           }
  -        
  +
           protected void cocoonRedirect(String uri) throws IOException, 
ProcessingException {
               try {
                   ConcreteTreeProcessor.this.handleCocoonRedirect(uri, 
this.env, this.context);
  @@ -384,7 +383,7 @@
               }
           }
       }
  -    
  +
       /**
        * Local extension of EnvironmentWrapper to propagate otherwise blocked
        * methods to the actual environment.
  @@ -415,7 +414,7 @@
           public boolean isResponseModified(long lastModified) {
               return environment.isResponseModified(lastModified);
           }
  -        
  +
           public void setResponseIsNotModified() {
               environment.setResponseIsNotModified();
           }
  @@ -428,7 +427,7 @@
        public String getContext() {
                return wrappingProcessor.getContext();
        }
  -    
  +
       /**
        * Return the sitemap executor
        */
  
  
  
  1.12      +16 -15    
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultTreeBuilder.java   9 Jun 2004 11:59:23 -0000       1.11
  +++ DefaultTreeBuilder.java   11 Jun 2004 20:03:35 -0000      1.12
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -55,9 +55,10 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
    * @version CVS $Id$
    */
  -
  -public class DefaultTreeBuilder extends AbstractLogEnabled implements 
TreeBuilder,
  -  Recomposable, Configurable, Contextualizable, RoleManageable, Recyclable, 
Disposable {
  +public class DefaultTreeBuilder
  +        extends AbstractLogEnabled
  +        implements TreeBuilder, Recomposable, Configurable, Contextualizable,
  +                   RoleManageable, Recyclable, Disposable {
   
       protected Map attributes = new HashMap();
   
  @@ -158,7 +159,7 @@
       public void setAttribute(String name, Object value) {
           this.attributes.put(name, value);
       }
  -    
  +
       /* (non-Javadoc)
        * @see 
org.apache.cocoon.components.treeprocessor.TreeBuilder#getAttribute(java.lang.String)
        */
  @@ -214,7 +215,7 @@
        *
        * @return a selector for node builders
        */
  -    protected ComponentSelector createBuilderSelector(String sitemapVersion) 
  +    protected ComponentSelector createBuilderSelector(String sitemapVersion)
       throws Exception {
   
           // Create the NodeBuilder selector.
  @@ -257,7 +258,7 @@
                   merged.addChild( lc[i] );
               }
           }
  -        // Automagically initialize the selector        
  +        // Automagically initialize the selector
           LifecycleHelper.setupComponent(selector,
               getLogger(),
               this.context,
  @@ -379,15 +380,15 @@
               Configuration treeConfig = handler.getConfiguration();
   
               this.namespace = treeConfig.getNamespace();
  -            
  +
               // get the namespace version
               final int pos = this.namespace.lastIndexOf('/');
               if ( pos == -1 ) {
                   throw new ProcessingException("Namespace " + this.namespace 
+ " does not have a version number.");
               }
               if ( !this.namespace.substring(0, 
pos).equals("http://apache.org/cocoon/sitemap";) ) {
  -                throw new ProcessingException("Namespace " + this.namespace 
+ " is not a valid sitemap namespace.");                
  -            }            
  +                throw new ProcessingException("Namespace " + this.namespace 
+ " is not a valid sitemap namespace.");
  +            }
               return build(treeConfig, this.namespace.substring(pos+1));
           } catch (ProcessingException e) {
               throw e;
  @@ -454,7 +455,7 @@
       public ComponentManager getSitemapComponentManager() {
           return this.manager;
       }
  -    
  +
       /**
        * Setup a <code>ProcessingNode</code> by setting its location, calling 
all
        * the lifecycle interfaces it implements and giving it the parameter 
map if
  @@ -586,7 +587,7 @@
       public void dispose() {
           LifecycleHelper.dispose(this.builderSelector);
   
  -        // Don't dispose manager or roles : they are used by the built tree
  +        // Don't dispose manager or roles: they are used by the built tree
           // and thus must live longer than the builder.
       }
   }
  
  
  
  1.38      +57 -50    
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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- TreeProcessor.java        9 Jun 2004 09:47:47 -0000       1.37
  +++ TreeProcessor.java        11 Jun 2004 20:03:35 -0000      1.38
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -19,6 +19,7 @@
   
   import org.apache.avalon.excalibur.component.RoleManageable;
   import org.apache.avalon.excalibur.component.RoleManager;
  +import org.apache.avalon.excalibur.pool.Recyclable;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.ComponentException;
  @@ -102,16 +103,16 @@
   
       /** The source resolver */
       protected SourceResolver resolver;
  -    
  +
       /** The environment helper */
       private EnvironmentHelper environmentHelper;
  -    
  +
       /** The actual processor (package-private as needs to be accessed by 
ConcreteTreeProcessor) */
       ConcreteTreeProcessor concreteProcessor;
   
       /** The tree builder configuration */
       private Configuration treeBuilderConfiguration;
  -    
  +
       /**
        * Create a TreeProcessor.
        */
  @@ -123,10 +124,10 @@
       /**
        * Create a child processor for a given language
        */
  -    protected TreeProcessor(TreeProcessor parent, 
  -                            DelayedRefreshSourceWrapper sitemapSource, 
  -                            boolean checkReload, 
  -                            String prefix) 
  +    protected TreeProcessor(TreeProcessor parent,
  +                            DelayedRefreshSourceWrapper sitemapSource,
  +                            boolean checkReload,
  +                            String prefix)
       throws Exception {
           this.parent = parent;
   
  @@ -138,7 +139,7 @@
           this.treeBuilderConfiguration = parent.treeBuilderConfiguration;
           this.checkReload = checkReload;
           this.lastModifiedDelay = parent.lastModifiedDelay;
  -        
  +
           // We have our own CM
           this.manager = parent.concreteProcessor.sitemapComponentManager;
           this.resolver = 
(SourceResolver)this.manager.lookup(SourceResolver.ROLE);
  @@ -155,9 +156,9 @@
        *
        * @return a new child processor.
        */
  -    public TreeProcessor createChildProcessor(String src, 
  +    public TreeProcessor createChildProcessor(String src,
                                                 boolean checkReload,
  -                                              String  prefix) 
  +                                              String  prefix)
       throws Exception {
           DelayedRefreshSourceWrapper delayedSource = new 
DelayedRefreshSourceWrapper(
               this.resolver.resolveURI(src), this.lastModifiedDelay);
  @@ -199,16 +200,16 @@
           ContainerUtil.service(this.environmentHelper, new 
ComponentManagerWrapper(manager));
       }
   
  -    /** 
  +    /**
        * Configure the tree processor:
  -     * &lt;processor file="{Location of the sitemap}" 
  +     * &lt;processor file="{Location of the sitemap}"
        *               check-reload="{true|false}"
        *               config="{Location of sitemap tree processor config}&gt;
        *   &lt;reload delay="10"/&gt;
        * &lt;/processor&gt;
  -     * 
  +     *
        * Only the file attribute is required; everything else is optional.
  -     * 
  +     *
        * @see 
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
        */
       public void configure(Configuration config)
  @@ -244,7 +245,7 @@
       /**
        * Create a new tree builder for this sitemap
        */
  -    protected void createTreeBuilder() 
  +    protected void createTreeBuilder()
       throws ConfigurationException {
           // Create a builder for the sitemap language
           try {
  @@ -253,19 +254,18 @@
                       
.loadClass("org.apache.cocoon.components.treeprocessor.sitemap.SitemapLanguage").newInstance();
   
               LifecycleHelper.setupComponent(this.treeBuilder,
  -                getLogger(),
  -                this.context,
  -                this.manager,
  -                this.roleManager,
  -                this.treeBuilderConfiguration
  -            );
  +                                           getLogger(),
  +                                           this.context,
  +                                           this.manager,
  +                                           this.roleManager,
  +                                           this.treeBuilderConfiguration);
           } catch(ConfigurationException ce) {
               throw ce;
           } catch(Exception e) {
               throw new ConfigurationException("Could not setup sitemap 
builder.", e);
           }
       }
  -    
  +
       /**
        * Process the given <code>Environment</code> producing the output.
        * @return If the processing is successfull <code>true</code> is 
returned.
  @@ -277,13 +277,13 @@
        *         ConnectionResetException  If the connection was reset
        */
       public boolean process(Environment environment) throws Exception {
  -     
  +
           setupConcreteProcessor(environment);
  -             
  +
           return this.concreteProcessor.process(environment);
       }
   
  -    
  +
       /**
        * Process the given <code>Environment</code> to assemble
        * a <code>ProcessingPipeline</code>.
  @@ -291,12 +291,12 @@
        */
       public InternalPipelineDescription buildPipeline(Environment environment)
       throws Exception {
  -     
  +
           setupConcreteProcessor(environment);
  -             
  +
           return this.concreteProcessor.buildPipeline(environment);
       }
  -      
  +
       /* (non-Javadoc)
        * @see org.apache.cocoon.Processor#getRootProcessor()
        */
  @@ -305,7 +305,7 @@
           while(result.parent != null) {
               result = result.parent;
           }
  -        
  +
           return result;
       }
   
  @@ -339,10 +339,10 @@
   
       /**
        * The current environment helper used by the MountNode
  -     * @return EnvironmentHelper 
  +     * @return EnvironmentHelper
        */
       public EnvironmentHelper getEnvironmentHelper() {
  -        return this.environmentHelper;   
  +        return this.environmentHelper;
       }
   
       private void setupConcreteProcessor(Environment env) throws Exception {
  @@ -352,7 +352,7 @@
               buildConcreteProcessor(env);
           }
       }
  -    
  +
       private synchronized void buildConcreteProcessor(Environment env) throws 
Exception {
   
           // Now that we entered the synchronized area, recheck what's already
  @@ -368,14 +368,18 @@
           ConcreteTreeProcessor newProcessor = new ConcreteTreeProcessor(this);
           long newLastModified;
           this.setupLogger(newProcessor);
  +
           // We have to do a call to enterProcessor() here as during building
  -        // of the tree, components (e.g. actions) are already instantiated 
  +        // of the tree, components (e.g. actions) are already instantiated
           // (ThreadSafe ones mostly).
           // If these components try to access the current processor or the
           // current service manager they must get this one - which is 
currently
           // in the process of initialization.
           EnvironmentHelper.enterProcessor(this, new 
ComponentManagerWrapper(this.manager), env);
           try {
  +            if (this.treeBuilder instanceof Recyclable) {
  +                ((Recyclable)this.treeBuilder).recycle();
  +            }
               if (this.treeBuilder instanceof Recomposable) {
                   ((Recomposable)this.treeBuilder).recompose(this.manager);
               }
  @@ -385,14 +389,17 @@
               }
   
               if (this.source == null) {
  -                this.source = new 
DelayedRefreshSourceWrapper(this.resolver.resolveURI(this.fileName), 
lastModifiedDelay);
  +                this.source = new 
DelayedRefreshSourceWrapper(this.resolver.resolveURI(this.fileName),
  +                                                              
lastModifiedDelay);
               }
  -            
  +
               newLastModified = this.source.getLastModified();
   
               ProcessingNode root = this.treeBuilder.build(this.source);
   
  -            
newProcessor.setProcessorData(this.treeBuilder.getSitemapComponentManager(), 
root, this.treeBuilder.getDisposableNodes());
  +            
newProcessor.setProcessorData(this.treeBuilder.getSitemapComponentManager(),
  +                                          root,
  +                                          
this.treeBuilder.getDisposableNodes());
           } finally {
               EnvironmentHelper.leaveProcessor();
           }
  @@ -426,14 +433,14 @@
           ContainerUtil.dispose(this.treeBuilder);
           this.treeBuilder = null;
   
  -         if ( this.manager != null ) {
  -             if ( this.source != null ) {
  -                 this.resolver.release(this.source.getSource());
  -                 this.source = null;
  -             }
  -             this.manager.release(this.resolver);
  -             this.resolver = null;
  -             this.manager = null;
  -         }
  -     }
  +        if (this.manager != null) {
  +            if (this.source != null) {
  +                this.resolver.release(this.source.getSource());
  +                this.source = null;
  +            }
  +            this.manager.release(this.resolver);
  +            this.resolver = null;
  +            this.manager = null;
  +        }
  +    }
   }
  
  
  
  1.16      +8 -9      
cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java
  
  Index: PipelineNode.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- PipelineNode.java 18 Mar 2004 15:08:13 -0000      1.15
  +++ PipelineNode.java 11 Jun 2004 20:03:35 -0000      1.16
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -112,7 +112,7 @@
       }
   
       public final boolean invoke(Environment env, InvokeContext context)
  -            throws Exception {
  +    throws Exception {
   
           boolean externalRequest = env.isExternal();
   
  @@ -121,16 +121,15 @@
               return false;
           }
           context.inform(this.processingPipeline, this.parameters,
  -                env.getObjectModel());
  +                       env.getObjectModel());
           try {
               if (invokeNodes(children, env, context)) {
                   return true;
               } else if (!this.isLast) {
                   return false;
               } else {
  -                throw new ResourceNotFoundException(
  -                        "No pipeline matched request: " + env.getURIPrefix()
  -                        + env.getURI());
  +                throw new ResourceNotFoundException("No pipeline matched 
request: " +
  +                                                    env.getURIPrefix() + 
env.getURI());
               }
           } catch (ConnectionResetException cre) {
               // Will be reported by CocoonServlet, rethrowing
  
  
  
  1.13      +9 -10     
cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java
  
  Index: PipelinesNode.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PipelinesNode.java        9 Jun 2004 11:59:23 -0000       1.12
  +++ PipelinesNode.java        11 Jun 2004 20:03:35 -0000      1.13
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -33,12 +33,11 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
    * @version CVS $Id$
    */
  -
   public final class PipelinesNode extends SimpleParentProcessingNode
  -  implements Composable, Disposable {
  +                                 implements Composable, Disposable {
   
       private ComponentManager manager;
  -    
  +
       private ErrorHandlerHelper errorHandlerHelper = new ErrorHandlerHelper();
   
       private ProcessingNode errorHandler;
  @@ -67,7 +66,7 @@
       public void setErrorHandler(ProcessingNode node) {
           this.errorHandler = node;
       }
  -    
  +
       public void setChildren(ProcessingNode[] nodes) {
           // Mark the last pipeline so that it can throw a 
ResourceNotFoundException
           ((PipelineNode)nodes[nodes.length - 1]).setLast(true);
  @@ -82,8 +81,8 @@
        */
       public final boolean invoke(Environment env, InvokeContext context)
       throws Exception {
  -    
  -        // Perform any common invoke functionality 
  +
  +        // Perform any common invoke functionality
           super.invoke(env, context);
   
           // Recompose context (and pipelines) to the local component manager
  
  
  
  1.7       +7 -7      
cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java
  
  Index: PreparableMatchNode.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PreparableMatchNode.java  11 Jun 2004 08:51:56 -0000      1.6
  +++ PreparableMatchNode.java  11 Jun 2004 20:03:35 -0000      1.7
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -103,8 +103,8 @@
        */
       public final boolean invoke(Environment env, InvokeContext context)
       throws Exception {
  -      
  -             // Perform any common invoke functionality 
  +
  +             // Perform any common invoke functionality
                super.invoke(env, context);
   
           Map objectModel = env.getObjectModel();
  @@ -132,7 +132,7 @@
           if (result != null) {
               if (getLogger().isDebugEnabled()) {
                   getLogger().debug("Matcher '" + this.componentName + "' 
matched prepared pattern '" +
  -                    this.pattern + "' at " + this.getLocation());
  +                                  this.pattern + "' at " + 
this.getLocation());
               }
   
               // Invoke children with the matcher results
  
  
  
  1.12      +17 -18    
cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
  
  Index: SitemapLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SitemapLanguage.java      25 May 2004 07:28:25 -0000      1.11
  +++ SitemapLanguage.java      11 Jun 2004 20:03:35 -0000      1.12
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -47,7 +47,6 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
    * @version CVS $Id$
    */
  -
   public class SitemapLanguage extends DefaultTreeBuilder {
   
       // Regexp's for splitting expressions
  @@ -70,11 +69,11 @@
               }
               config = new DefaultConfiguration("", "");
           }
  -        
  +
           final CocoonComponentManager manager = new 
CocoonComponentManager(this.parentManager);
  -        
  +
           manager.enableLogging(getLogger());
  -        
  +
           final LoggerManager loggerManager = (LoggerManager) 
this.parentManager.lookup(LoggerManager.ROLE);
           manager.setLoggerManager(loggerManager);
   
  @@ -314,9 +313,9 @@
   
           return result;
       }
  -    
  +
       /**
  -     * Extract pipeline-hints from the given statement (if any exist) 
  +     * Extract pipeline-hints from the given statement (if any exist)
        *
        * @param role the component role (e.g. <code>Generator.ROLE</code>)
        * @param hint the component hint, i.e. the 'type' attribute
  @@ -348,7 +347,7 @@
               componentHintParams = selector.getPipelineHint(hint);
           } catch (Exception ex) {
               if (getLogger().isWarnEnabled()) {
  -                getLogger().warn("pipeline-hints: Component Exception: could 
not " + 
  +                getLogger().warn("pipeline-hints: Component Exception: could 
not " +
                                "check for component level hints " + ex);
               }
           } finally {
  @@ -359,7 +358,7 @@
               hintParams = componentHintParams;
   
               if (statementHintParams != null) {
  -                hintParams = hintParams + "," + statementHintParams; 
  +                hintParams = hintParams + "," + statementHintParams;
               }
           } else {
               hintParams = statementHintParams;
  @@ -379,19 +378,19 @@
           String[]  expressions = commaSplit.split(hintParams.trim());
   
           if (getLogger().isDebugEnabled()) {
  -            getLogger().debug("pipeline-hints: (aggregate-hint) " + 
hintParams); 
  +            getLogger().debug("pipeline-hints: (aggregate-hint) " + 
hintParams);
           }
   
           for (int i=0; i<expressions.length;i++) {
  -            String [] nameValuePair = equalsSplit.split(expressions[i]); 
  +            String [] nameValuePair = equalsSplit.split(expressions[i]);
   
               try {
                   if (nameValuePair.length < 2) {
                       if (getLogger().isDebugEnabled()) {
  -                        getLogger().debug("pipeline-hints: (name) " + 
nameValuePair[0] 
  +                        getLogger().debug("pipeline-hints: (name) " + 
nameValuePair[0]
                                          + "\npipeline-hints: (value) 
[implicit] true");
                       }
  -  
  +
                       params.put( 
VariableResolverFactory.getResolver(nameValuePair[0], this.manager),
                                   VariableResolverFactory.getResolver("true", 
this.manager));
                   } else {
  @@ -399,7 +398,7 @@
                           getLogger().debug("pipeline-hints: (name) " + 
nameValuePair[0]
                                             + "\npipeline-hints: (value) " + 
nameValuePair[1]);
                       }
  -  
  +
                       params.put( 
VariableResolverFactory.getResolver(nameValuePair[0], this.manager),
                                   
VariableResolverFactory.getResolver(nameValuePair[1], this.manager));
                   }
  @@ -424,5 +423,5 @@
           } else {
               return Arrays.asList(StringUtils.split(labels, ", \t\n\r"));
           }
  -    }   
  +    }
   }
  
  
  

Reply via email to