cziegeler 2002/07/04 00:12:21 Modified: src/java/org/apache/cocoon/components/source SitemapSource.java src/java/org/apache/cocoon/components/source/impl SitemapSource.java src/java/org/apache/cocoon/environment/wrapper EnvironmentWrapper.java Log: Fixing bug for "nested cocoon: source spanning multiple sitemaps" PR: 10281 Submitted by:[EMAIL PROTECTED] (Tim Myers) Revision Changes Path 1.20 +15 -4 xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java Index: SitemapSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- SitemapSource.java 2 Jul 2002 08:32:07 -0000 1.19 +++ SitemapSource.java 4 Jul 2002 07:12:20 -0000 1.20 @@ -110,6 +110,9 @@ /** The processor */ private Processor processor; + /** The pipeline processor */ + private Processor pipelineProcessor; + /** The environment */ private EnvironmentWrapper environment; @@ -238,7 +241,14 @@ try { ByteArrayOutputStream os = new ByteArrayOutputStream(); this.environment.setOutputStream(os); - this.processingPipeline.process(this.environment); + try { + CocoonComponentManager.enterEnvironment(this.environment, + this.environment.getObjectModel(), + this.pipelineProcessor); + this.processingPipeline.process(this.environment); + } finally { + CocoonComponentManager.leaveEnvironment(); + } return new ByteArrayInputStream(os.toByteArray()); } catch (ProcessingException e) { @@ -267,8 +277,8 @@ reset(); try { this.environment.setURI(this.prefix, this.uri); - this.environment.changeToLastContext(); this.processingPipeline = this.processor.processInternal(this.environment); + this.pipelineProcessor = this.environment.changeToLastContext(); String redirectURL = this.environment.getRedirectURL(); if (redirectURL != null) { if (redirectURL.indexOf(":") == -1) { @@ -325,7 +335,7 @@ try { CocoonComponentManager.enterEnvironment(this.environment, this.environment.getObjectModel(), - this.processor); + this.pipelineProcessor); this.processingPipeline.process(this.environment, consumer); } finally { CocoonComponentManager.leaveEnvironment(); @@ -351,6 +361,7 @@ this.redirectSource = null; this.exception = null; this.needsRefresh = true; + this.pipelineProcessor = null; } public void recycle() { 1.15 +15 -4 xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java Index: SitemapSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- SitemapSource.java 2 Jul 2002 08:32:07 -0000 1.14 +++ SitemapSource.java 4 Jul 2002 07:12:21 -0000 1.15 @@ -117,6 +117,9 @@ /** The processor */ private Processor processor; + /** The pipeline processor */ + private Processor pipelineProcessor; + /** The environment */ private EnvironmentWrapper environment; @@ -243,7 +246,14 @@ try { ByteArrayOutputStream os = new ByteArrayOutputStream(); this.environment.setOutputStream(os); - this.processingPipeline.process(this.environment); + try { + CocoonComponentManager.enterEnvironment(this.environment, + this.environment.getObjectModel(), + this.pipelineProcessor); + this.processingPipeline.process(this.environment); + } finally { + CocoonComponentManager.leaveEnvironment(); + } return new ByteArrayInputStream(os.toByteArray()); } catch (ResourceNotFoundException e) { @@ -299,7 +309,7 @@ this.environment.setURI(this.prefix, this.uri); this.processingPipeline = this.processor.processInternal(this.environment); - this.environment.changeToLastContext(); + this.pipelineProcessor = this.environment.changeToLastContext(); String redirectURL = this.environment.getRedirectURL(); if (redirectURL == null) { SourceValidity[] eventPipelineValidities = this.processingPipeline.getValiditiesForEventPipeline(); @@ -364,7 +374,7 @@ try { CocoonComponentManager.enterEnvironment(this.environment, this.environment.getObjectModel(), - this.processor); + this.pipelineProcessor); this.processingPipeline.process(this.environment, consumer); } finally { CocoonComponentManager.leaveEnvironment(); @@ -391,6 +401,7 @@ this.redirectValidity = null; this.exception = null; this.needsRefresh = true; + this.pipelineProcessor = null; } public void recycle() { 1.18 +17 -2 xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Index: EnvironmentWrapper.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- EnvironmentWrapper.java 2 Jul 2002 08:32:07 -0000 1.17 +++ EnvironmentWrapper.java 4 Jul 2002 07:12:21 -0000 1.18 @@ -51,7 +51,9 @@ package org.apache.cocoon.environment.wrapper; import org.apache.avalon.framework.component.ComponentManager; +import org.apache.cocoon.Processor; import org.apache.cocoon.ProcessingException; +import org.apache.cocoon.components.CocoonComponentManager; import org.apache.cocoon.environment.AbstractEnvironment; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.ObjectModelHelper; @@ -102,6 +104,9 @@ /** The stream to output to */ private OutputStream outputStream; + /** The processor used */ + private Processor processor; + /** * Constructs an EnvironmentWrapper object from a Request * and Response objects @@ -194,6 +199,14 @@ } /** + * The treeprocessor sets up new managers per sitemap. Set the + * "current" one for this environment. + */ + public void setComponentManager(ComponentManager manager) { + super.setComponentManager( manager ); + this.processor = (Processor)CocoonComponentManager.getCurrentEnvironment()[4]; + } + /** * Get the output stream */ public OutputStream getOutputStream() @@ -284,11 +297,13 @@ /** * Change the current context to the last one set by changeContext() + * and return the processor */ - public void changeToLastContext() { + public Processor changeToLastContext() { this.setContext(this.lastContext); this.setURIPrefix(this.lastPrefix); this.uris = this.lastURI; + return this.processor; } /**
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]