cziegeler 2004/02/06 03:42:46
Modified: src/java/org/apache/cocoon/components/source/impl
SitemapSource.java
src/java/org/apache/cocoon/components/cprocessor
InvokeContext.java TreeProcessor.java
src/java/org/apache/cocoon/components/cprocessor/sitemap
MountNode.java
src/java/org/apache/cocoon ProcessorWrapper.java Cocoon.java
Processor.java
src/java/org/apache/cocoon/environment/internal
EnvironmentHelper.java
src/java/org/apache/cocoon/components/pipeline
ProcessingPipeline.java
AbstractProcessingPipeline.java
Log:
Enhancing the internal processing: only one step to remove the overhead of
the environment context
Revision Changes Path
1.26 +16 -22
cocoon-2.2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Index: SitemapSource.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- SitemapSource.java 31 Jan 2004 16:56:24 -0000 1.25
+++ SitemapSource.java 6 Feb 2004 11:42:46 -0000 1.26
@@ -63,7 +63,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.Processor;
import org.apache.cocoon.ResourceNotFoundException;
-import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.ObjectModelHelper;
@@ -108,15 +107,12 @@
/** The processor */
private Processor processor;
- /** The pipeline processor */
- private Processor pipelineProcessor;
+ /** The pipeline description */
+ private Processor.InternalPipelineDescription pipelineDescription;
/** The environment */
private MutableEnvironmentFacade environment;
- /** The <code>ProcessingPipeline</code> */
- private ProcessingPipeline processingPipeline;
-
/** The redirect <code>Source</code> */
private Source redirectSource;
@@ -230,12 +226,12 @@
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
this.environment.setOutputStream(os);
- EnvironmentHelper.enterProcessor(this.pipelineProcessor,
+
EnvironmentHelper.enterProcessor(this.pipelineDescription.lastProcessor,
this.manager,
this.environment);
try {
- this.processingPipeline.process(this.environment);
+
this.pipelineDescription.processingPipeline.process(this.environment);
} finally {
EnvironmentHelper.leaveProcessor();
}
@@ -308,20 +304,19 @@
this.systemIdForCaching = this.systemId;
try {
this.processKey =
EnvironmentHelper.startProcessing(this.environment);
- this.processingPipeline =
this.processor.buildPipeline(this.environment);
- this.pipelineProcessor =
EnvironmentHelper.getLastProcessor(this.environment);
-
this.pipelineProcessor.getEnvironmentHelper().setContext(this.environment);
+ this.pipelineDescription =
this.processor.buildPipeline(this.environment);
+
this.pipelineDescription.lastProcessor.getEnvironmentHelper().setContext(this.environment);
String redirectURL = this.environment.getRedirectURL();
if (redirectURL == null) {
- EnvironmentHelper.enterProcessor(this.pipelineProcessor,
+
EnvironmentHelper.enterProcessor(this.pipelineDescription.lastProcessor,
this.manager,
this.environment);
try {
-
this.processingPipeline.prepareInternal(this.environment);
- this.sourceValidity =
this.processingPipeline.getValidityForEventPipeline();
- final String eventPipelineKey =
this.processingPipeline.getKeyForEventPipeline();
+
this.pipelineDescription.processingPipeline.prepareInternal(this.environment);
+ this.sourceValidity =
this.pipelineDescription.processingPipeline.getValidityForEventPipeline();
+ final String eventPipelineKey =
this.pipelineDescription.processingPipeline.getKeyForEventPipeline();
if (eventPipelineKey != null) {
StringBuffer buffer = new
StringBuffer(this.systemId);
if (this.systemId.indexOf('?') == -1) {
@@ -385,11 +380,11 @@
}
// We have to add an environment changer
// for clean environment stack handling.
- EnvironmentHelper.enterProcessor(this.pipelineProcessor,
+
EnvironmentHelper.enterProcessor(this.pipelineDescription.lastProcessor,
this.manager,
this.environment);
try {
- this.processingPipeline.process(this.environment,
+
this.pipelineDescription.processingPipeline.process(this.environment,
EnvironmentHelper.createEnvironmentAwareConsumer(consumer));
} finally {
EnvironmentHelper.leaveProcessor();
@@ -410,9 +405,9 @@
* Reset everything
*/
private void reset() {
- if (this.processingPipeline != null) {
- this.processor.releasePipeline(this.environment,
this.processingPipeline);
- this.processingPipeline = null;
+ if (this.pipelineDescription != null) {
+ this.pipelineDescription.release();
+ this.pipelineDescription = null;
}
if (this.processKey != null) {
EnvironmentHelper.endProcessing(this.environment,
this.processKey);
@@ -427,7 +422,6 @@
this.redirectValidity = null;
this.exception = null;
this.needsRefresh = true;
- this.pipelineProcessor = null;
}
/**
1.7 +32 -7
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/InvokeContext.java
Index: InvokeContext.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/InvokeContext.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- InvokeContext.java 5 Feb 2004 13:58:55 -0000 1.6
+++ InvokeContext.java 6 Feb 2004 11:42:46 -0000 1.7
@@ -61,6 +61,7 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.Processor;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.components.cprocessor.variables.VariableResolver;
@@ -105,6 +106,12 @@
/** The ProcessingPipeline used */
protected ProcessingPipeline processingPipeline;
+ /** The internal pipeline description */
+ protected Processor.InternalPipelineDescription
internalPipelineDescription;
+
+ /** The last processor */
+ protected Processor lastProcessor;
+
/**
* Create an <code>InvokeContext</code> without existing pipelines. This
also means
* the current request is external.
@@ -166,9 +173,6 @@
this.pipelinesManager = this.currentManager;
this.processingPipeline =
(ProcessingPipeline)this.pipelinesManager.lookup(ProcessingPipeline.ROLE);
- if (this.isBuildingPipelineOnly) {
-
this.processingPipeline.setInternalServiceManager(this.pipelinesManager);
- }
this.processingPipeline.reservice( this.pipelinesManager );
this.processingPipeline.setup(
VariableResolver.buildParameters(this.processingPipelineParameters,
@@ -181,8 +185,29 @@
/**
* Set the processing pipeline for sub-sitemaps
*/
- public void setProcessingPipeline(ProcessingPipeline pipeline) {
- this.processingPipeline = pipeline;
+ public void
setInternalPipelineDescription(Processor.InternalPipelineDescription desc) {
+ this.processingPipeline = desc.processingPipeline;
+ this.pipelinesManager = desc.pipelineManager;
+ this.lastProcessor = desc.lastProcessor;
+ }
+
+ /**
+ * Get the pipeline description
+ */
+ public Processor.InternalPipelineDescription
getInternalPipelineDescription() {
+ if ( this.internalPipelineDescription == null ) {
+ this.internalPipelineDescription = new
Processor.InternalPipelineDescription(
+ this.processingPipeline, this.pipelinesManager);
+ this.internalPipelineDescription.lastProcessor =
this.lastProcessor;
+ }
+ return this.internalPipelineDescription;
+ }
+
+ /**
+ * Set the last processor
+ */
+ public void setLastProcessor(Processor p) {
+ this.lastProcessor = p;
}
/**
@@ -289,7 +314,7 @@
*/
public void dispose() {
// Release pipelines, if any
- if (!this.isBuildingPipelineOnly && this.pipelinesManager != null) {
+ if (this.internalPipelineDescription == null &&
this.pipelinesManager != null) {
if (this.processingPipeline != null) {
this.pipelinesManager.release( this.processingPipeline );
this.processingPipeline = null;
1.18 +3 -10
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/TreeProcessor.java
Index: TreeProcessor.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/TreeProcessor.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- TreeProcessor.java 5 Feb 2004 13:58:55 -0000 1.17
+++ TreeProcessor.java 6 Feb 2004 11:42:46 -0000 1.18
@@ -79,7 +79,6 @@
import org.apache.cocoon.Constants;
import org.apache.cocoon.Processor;
import org.apache.cocoon.components.ChainedConfiguration;
-import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.components.sax.XMLTeePipe;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
@@ -452,12 +451,13 @@
return processor.process(newEnv, context);
}
- public ProcessingPipeline buildPipeline(Environment environment) throws
Exception {
+ public InternalPipelineDescription buildPipeline(Environment
environment) throws Exception {
InvokeContext context = new InvokeContext(true);
context.enableLogging(getLogger());
+ context.setLastProcessor(this);
try {
if (process(environment, context)) {
- return context.getProcessingPipeline();
+ return context.getInternalPipelineDescription();
} else {
return null;
}
@@ -540,13 +540,6 @@
*/
public EnvironmentHelper getEnvironmentHelper() {
return m_environmentHelper;
- }
-
- /* (non-Javadoc)
- * @see
org.apache.cocoon.Processor#releasePipeline(org.apache.cocoon.components.pipeline.ProcessingPipeline)
- */
- public void releasePipeline(Environment environment, ProcessingPipeline
pipeline) {
- pipeline.releaseInternalPipeline();
}
/**
1.7 +4 -4
cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/MountNode.java
Index: MountNode.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/MountNode.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MountNode.java 28 Jan 2004 10:17:12 -0000 1.6
+++ MountNode.java 6 Feb 2004 11:42:46 -0000 1.7
@@ -61,13 +61,13 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.cocoon.Processor;
import org.apache.cocoon.components.cprocessor.AbstractProcessingNode;
import org.apache.cocoon.components.cprocessor.InvokeContext;
import org.apache.cocoon.components.cprocessor.ProcessingNode;
import org.apache.cocoon.components.cprocessor.TreeProcessor;
import org.apache.cocoon.components.cprocessor.variables.VariableResolver;
import
org.apache.cocoon.components.cprocessor.variables.VariableResolverFactory;
-import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.sitemap.PatternException;
@@ -141,9 +141,9 @@
if (context.isBuildingPipelineOnly()) {
// Propagate pipelines
- ProcessingPipeline pp = processor.buildPipeline(env);
+ Processor.InternalPipelineDescription pp =
processor.buildPipeline(env);
if (pp != null) {
- context.setProcessingPipeline(pp);
+ context.setInternalPipelineDescription(pp);
return true;
} else {
return false;
1.11 +2 -10
cocoon-2.2/src/java/org/apache/cocoon/ProcessorWrapper.java
Index: ProcessorWrapper.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/ProcessorWrapper.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ProcessorWrapper.java 10 Jan 2004 14:38:19 -0000 1.10
+++ ProcessorWrapper.java 6 Feb 2004 11:42:46 -0000 1.11
@@ -54,7 +54,6 @@
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.internal.EnvironmentHelper;
@@ -92,16 +91,9 @@
/* (non-Javadoc)
* @see
org.apache.cocoon.Processor#buildPipeline(org.apache.cocoon.environment.Environment)
*/
- public ProcessingPipeline buildPipeline(Environment environment)
+ public InternalPipelineDescription buildPipeline(Environment environment)
throws Exception {
return this.processor.buildPipeline(environment);
- }
-
- /* (non-Javadoc)
- * @see
org.apache.cocoon.Processor#releasePipeline(org.apache.cocoon.components.pipeline.ProcessingPipeline)
- */
- public void releasePipeline(Environment environment, ProcessingPipeline
pipeline) {
- this.processor.releasePipeline(environment, pipeline);
}
/* (non-Javadoc)
1.36 +4 -23 cocoon-2.2/src/java/org/apache/cocoon/Cocoon.java
Index: Cocoon.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/Cocoon.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- Cocoon.java 10 Jan 2004 14:38:19 -0000 1.35
+++ Cocoon.java 6 Feb 2004 11:42:46 -0000 1.36
@@ -69,7 +69,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.components.language.generator.ProgramGenerator;
-import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.ObjectModelHelper;
@@ -410,12 +409,10 @@
}
}
- /**
- * Process the given <code>Environment</code> to assemble
- * a <code>ProcessingPipeline</code>.
- * @since 2.1
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.Processor#buildPipeline(org.apache.cocoon.environment.Environment)
*/
- public ProcessingPipeline buildPipeline(Environment environment)
+ public InternalPipelineDescription buildPipeline(Environment environment)
throws Exception {
if (disposed) {
throw new IllegalStateException("You cannot process a Disposed
Cocoon engine.");
@@ -523,21 +520,5 @@
return this.environmentHelper.getContext();
}
- /* (non-Javadoc)
- * @see
org.apache.cocoon.Processor#releasePipeline(org.apache.cocoon.components.pipeline.ProcessingPipeline)
- */
- public void releasePipeline(Environment environment, ProcessingPipeline
pipeline) {
- Processor processor = null;
- try {
- processor = (Processor) this.serviceManager.lookup(
Processor.ROLE );
- processor.releasePipeline(environment, pipeline);
- } catch (ServiceException ignore) {
- // In fact this can never happen, therefore we ignore it
- this.getLogger().error("Unable to lookup processor.", ignore);
- } finally {
- this.serviceManager.release(processor);
- }
- }
-
}
1.15 +24 -9 cocoon-2.2/src/java/org/apache/cocoon/Processor.java
Index: Processor.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/Processor.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Processor.java 10 Jan 2004 14:38:19 -0000 1.14
+++ Processor.java 6 Feb 2004 11:42:46 -0000 1.15
@@ -52,6 +52,7 @@
import java.util.Map;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.internal.EnvironmentHelper;
@@ -67,6 +68,26 @@
String ROLE = Processor.class.getName();
+ public class InternalPipelineDescription {
+
+ public InternalPipelineDescription(ProcessingPipeline pp,
ServiceManager s) {
+ this.processingPipeline = pp;
+ this.pipelineManager = s;
+ }
+ public ProcessingPipeline processingPipeline;
+ public ServiceManager pipelineManager;
+ public Processor lastProcessor;
+
+ public void release() {
+ if (this.pipelineManager != null) {
+ this.pipelineManager.release(this.processingPipeline);
+ this.pipelineManager = null;
+ }
+ this.lastProcessor = null;
+ this.processingPipeline = null;
+ }
+ }
+
/**
* Process the given <code>Environment</code> producing the output.
* @return If the processing is successful <code>true</code> is returned.
@@ -84,18 +105,12 @@
* Process the given <code>Environment</code> to assemble
* a <code>ProcessingPipeline</code>.
* Don't forget to release the pipeline using
- * [EMAIL PROTECTED] releasePipeline(Environment, ProcessingPipeline)}.
+ * [EMAIL PROTECTED] releasePipeline(Environment,
InternalPipelineDescription)}.
* @since 2.1
*/
- ProcessingPipeline buildPipeline(Environment environment)
+ InternalPipelineDescription buildPipeline(Environment environment)
throws Exception;
- /**
- * Release the pipeline delivered by [EMAIL PROTECTED]
buildPipeline(Environment)}
- * @since 2.2
- */
- void releasePipeline(Environment environment, ProcessingPipeline
pipeline);
-
/**
* Get the sitemap component configurations
* @since 2.1
1.6 +1 -15
cocoon-2.2/src/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java
Index: EnvironmentHelper.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EnvironmentHelper.java 28 Jan 2004 10:17:14 -0000 1.5
+++ EnvironmentHelper.java 6 Feb 2004 11:42:46 -0000 1.6
@@ -96,11 +96,6 @@
* in the object model */
static protected final String PROCESS_KEY =
EnvironmentHelper.class.getName();
- /** The key used to store the last processor information
- * in the environment context
- */
- static protected final String LAST_PROCESSOR_KEY = "global:" +
PROCESS_KEY + "/processor";
-
/** The environment information */
static protected final InheritableThreadLocal environmentStack = new
CloningInheritableThreadLocal();
@@ -411,7 +406,6 @@
stack.setOffset(stack.size()-1);
EnvironmentContext ctx =
(EnvironmentContext)env.getObjectModel().get(PROCESS_KEY);
- ctx.addAttribute(LAST_PROCESSOR_KEY, processor);
ForwardRedirector redirector = new ForwardRedirector(env);
redirector.enableLogging(processor.getEnvironmentHelper().getLogger());
@@ -532,14 +526,6 @@
return info.manager;
}
return null;
- }
-
- /**
- * Return the processor that is actually processing the request
- */
- public static Processor getLastProcessor(Environment env) {
- EnvironmentContext context = (EnvironmentContext)
env.getObjectModel().get(PROCESS_KEY);
- return (Processor)env.getAttribute(LAST_PROCESSOR_KEY);
}
/**
1.9 +1 -17
cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
Index: ProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ProcessingPipeline.java 5 Feb 2004 13:59:01 -0000 1.8
+++ ProcessingPipeline.java 6 Feb 2004 11:42:46 -0000 1.9
@@ -158,22 +158,6 @@
throws ProcessingException;
/**
- * Release this component if it is used as an internal pipeline
- * When the pipeline is used during an internal processing, the part
looking
- * up the pipeline object is not able to release it anymore.
- * So, in this case the pipeline itself remembers the service manager
- * and can release itself using this method.
- */
- void releaseInternalPipeline();
-
- /**
- * Set the manager that looked up this pipeline for internal
- * pipeline processing. This allows the [EMAIL PROTECTED]
#releaseInternalPipeline}
- * method to release itself
- */
- void setInternalServiceManager(ServiceManager manager);
-
- /**
* Prepare an internal processing
* @param environment The current environment.
* @throws ProcessingException
1.29 +1 -21
cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
Index: AbstractProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- AbstractProcessingPipeline.java 5 Feb 2004 13:59:01 -0000 1.28
+++ AbstractProcessingPipeline.java 6 Feb 2004 11:42:46 -0000 1.29
@@ -148,9 +148,6 @@
/** The current Processor */
protected Processor processor;
- /** The internal manager for releasing */
- private ServiceManager internalManager;
-
/* (non-Javadoc)
* @see
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
@@ -158,23 +155,6 @@
throws ServiceException {
this.manager = manager;
this.newManager = manager;
- }
-
- /* (non-Javadoc)
- * @see
org.apache.cocoon.components.pipeline.ProcessingPipeline#release()
- */
- public final void releaseInternalPipeline() {
- if ( this.internalManager != null ) {
- this.internalManager.release(this);
- this.internalManager = null;
- }
- }
-
- /* (non-Javadoc)
- * @see
org.apache.cocoon.components.pipeline.ProcessingPipeline#setInternalServiceManager(org.apache.avalon.framework.service.ServiceManager)
- */
- public final void setInternalServiceManager(ServiceManager manager) {
- this.internalManager = manager;
}
/**