Author: vgritsenko Date: Mon Oct 4 16:32:12 2004 New Revision: 53764 Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java Log: Make sure COCOON_PASS_THROUGH is properly reset (even when src is null)
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java Mon Oct 4 16:32:12 2004 @@ -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. @@ -34,7 +34,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @version CVS $Id$ */ -public class MountNode extends AbstractProcessingNode +public class MountNode extends AbstractProcessingNode implements Disposable { /** The 'uri-prefix' attribute */ @@ -54,12 +54,12 @@ /** The value of the 'pass-through' attribute */ private final boolean passThrough; - + /** The key to get the pass_through value fron the Environment*/ - protected final static String COCOON_PASS_THROUGH = new String("COCOON_PASS_THROUGH"); - - public MountNode(VariableResolver prefix, - VariableResolver source, + protected final static String COCOON_PASS_THROUGH = new String("COCOON_PASS_THROUGH"); + + public MountNode(VariableResolver prefix, + VariableResolver source, TreeProcessor parentProcessor, boolean checkReload, boolean passThrough) { @@ -75,32 +75,31 @@ */ public final boolean invoke(Environment env, InvokeContext context) throws Exception { - - Object previousPassThrough = env.getAttribute(COCOON_PASS_THROUGH); - env.setAttribute(COCOON_PASS_THROUGH,new Boolean(passThrough)); - final Map objectModel = env.getObjectModel(); String resolvedSource = this.source.resolve(context, objectModel); String resolvedPrefix = this.prefix.resolve(context, objectModel); - if (resolvedSource.length()==0) { - throw new ProcessingException("Source of mount statement is empty"); + if (resolvedSource.length() == 0) { + throw new ProcessingException("Source of mount statement is empty"); } - + resolvedSource = this.executor.enterSitemap(this, objectModel, resolvedSource); TreeProcessor processor = getProcessor(resolvedSource, resolvedPrefix); + // Save context String oldPrefix = env.getURIPrefix(); String oldURI = env.getURI(); - + Object oldPassThrough = env.getAttribute(COCOON_PASS_THROUGH); + env.setAttribute(COCOON_PASS_THROUGH, new Boolean(passThrough)); + try { processor.getEnvironmentHelper().changeContext(env); if (context.isBuildingPipelineOnly()) { // Propagate pipelines Processor.InternalPipelineDescription pp = processor.buildPipeline(env); - if ( pp != null ) { + if (pp != null) { context.setInternalPipelineDescription(pp); return true; } else { @@ -113,11 +112,12 @@ } finally { // Restore context env.setURI(oldPrefix, oldURI); - if(previousPassThrough != null){ - env.setAttribute(COCOON_PASS_THROUGH,previousPassThrough); - }else{ - env.removeAttribute(COCOON_PASS_THROUGH); - } + if (oldPassThrough != null) { + env.setAttribute(COCOON_PASS_THROUGH, oldPassThrough); + } else { + env.removeAttribute(COCOON_PASS_THROUGH); + } + // Turning recomposing as a test, according to: // http://marc.theaimsgroup.com/?t=106802211400005&r=1&w=2 // Recompose pipelines which may have been recomposed by subsitemap @@ -137,7 +137,7 @@ } else { actualSource = source; } - + processor = this.parentProcessor.createChildProcessor(actualSource, this.checkReload, prefix); // Associate to the original source @@ -150,7 +150,7 @@ /* (non-Javadoc) * @see org.apache.avalon.framework.activity.Disposable#dispose() */ - public void dispose() { + public void dispose() { Iterator iter = this.processors.values().iterator(); while(iter.hasNext()) { ((TreeProcessor)iter.next()).dispose();