You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/04/12 14:34:41 UTC
svn commit: r161044 - in
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor:
ConcreteTreeProcessor.java TreeProcessor.java sitemap/MountNode.java
Author: sylvain
Date: Tue Apr 12 05:34:39 2005
New Revision: 161044
URL: http://svn.apache.org/viewcvs?view=rev&rev=161044
Log:
Fixing the fix: allowing the root sitemap not to be in the webapp context was breaking sitemap source using nested sitemaps. Should be ok now
Modified:
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?view=diff&r1=161043&r2=161044
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java Tue Apr 12 05:34:39 2005
@@ -62,8 +62,6 @@
private Map sitemapComponentConfigurations;
private Configuration componentConfigurations;
-
- private String uriContext;
/** Number of simultaneous uses of this processor (either by concurrent request or by internal requests) */
private int requestCount;
@@ -74,7 +72,7 @@
}
/** Set the processor data, result of the treebuilder job */
- public void setProcessorData(ComponentManager manager, ProcessingNode rootNode, List disposableNodes, String uriContext) {
+ public void setProcessorData(ComponentManager manager, ProcessingNode rootNode, List disposableNodes) {
if (this.sitemapComponentManager != null) {
throw new IllegalStateException("setProcessorData() can only be called once");
}
@@ -82,7 +80,6 @@
this.sitemapComponentManager = manager;
this.rootNode = rootNode;
this.disposableNodes = disposableNodes;
- this.uriContext = uriContext;
}
/** Set the sitemap component configurations (called as part of the tree building process) */
@@ -220,8 +217,6 @@
try {
// and now process
CocoonComponentManager.enterEnvironment(environment, this.sitemapComponentManager, this);
- String oldContext = environment.getContext();
- environment.changeContext("", this.uriContext);
Map objectModel = environment.getObjectModel();
@@ -241,7 +236,6 @@
return success;
} finally {
- environment.changeContext("", oldContext);
CocoonComponentManager.leaveEnvironment(success);
// Restore old redirector and resolver
context.setRedirector(oldRedirector);
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java?view=diff&r1=161043&r2=161044
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java Tue Apr 12 05:34:39 2005
@@ -15,6 +15,8 @@
*/
package org.apache.cocoon.components.treeprocessor;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.util.Map;
import org.apache.avalon.excalibur.component.RoleManageable;
@@ -94,9 +96,6 @@
/** The current language configuration */
protected Configuration currentLanguage;
- /** The file to process */
- protected String fileName;
-
/** Check for reload? */
protected boolean checkReload;
@@ -184,7 +183,7 @@
*/
public void configure(Configuration config)
throws ConfigurationException {
- this.fileName = config.getAttribute("file", null);
+
this.checkReload = config.getAttributeAsBoolean("check-reload", true);
// Obtain the configuration file, or use the XCONF_URL if none
@@ -194,6 +193,14 @@
// Reload check delay. Default is 1 second.
this.lastModifiedDelay = config.getChild("reload").getAttributeAsLong("delay", 1000L);
+ String fileName = config.getAttribute("file", "sitemap.xmap");
+
+ try {
+ this.source = new DelayedRefreshSourceWrapper(this.resolver.resolveURI(fileName), lastModifiedDelay);
+ } catch (Exception e) {
+ throw new ConfigurationException("Cannot resolve " + fileName, e);
+ }
+
// Read the builtin languages definition file
Configuration builtin;
try {
@@ -283,7 +290,13 @@
}
private void setupConcreteProcessor(Environment env) throws Exception {
- // first, check for sitemap changes
+
+ if (this.parent == null) {
+ // Ensure root sitemap uses the correct context, even if not located in the webapp context
+ env.changeContext("", this.source.getURI());
+ }
+
+ // check for sitemap changes
if (this.concreteProcessor == null ||
(this.checkReload && this.source.getLastModified() != this.lastModified)) {
buildConcreteProcessor(env);
@@ -308,40 +321,18 @@
this.setupLogger(newProcessor);
//FIXME (SW): why do we need to enterProcessor here?
CocoonComponentManager.enterEnvironment(env, this.manager, this);
- String oldContext = env.getContext();
try {
if (builder instanceof Recomposable) {
((Recomposable)builder).recompose(this.manager);
}
builder.setProcessor(newProcessor);
-
- if (this.source == null) {
- if (this.fileName == null) {
- // Case of the root sitemap if no explicit config was given
- this.fileName = builder.getFileName();
- }
-
- this.source = new DelayedRefreshSourceWrapper(this.resolver.resolveURI(this.fileName),
- lastModifiedDelay);
-
- if (this.parent == null) {
- // Ensure the root processor has a filename to change its context
- this.fileName = this.source.getURI();
- }
- }
- // Set the context to the sitemap location as components may lookup some resources
- // during their initialization
- env.changeContext("", this.source.getURI());
-
newLastModified = this.source.getLastModified();
ProcessingNode root = builder.build(this.source);
- newProcessor.setProcessorData(builder.getSitemapComponentManager(), root, builder.getDisposableNodes(), this.source.getURI());
+ newProcessor.setProcessorData(builder.getSitemapComponentManager(), root, builder.getDisposableNodes());
} finally {
- // Restore the context (FIXME: need to separate this from URI prefix)
- env.changeContext("", oldContext);
CocoonComponentManager.leaveEnvironment();
this.builderSelector.release(builder);
}
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java?view=diff&r1=161043&r2=161044
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java Tue Apr 12 05:34:39 2005
@@ -103,8 +103,7 @@
boolean pipelineWasBuilt = false;
try {
- // We only change the prefix here. Context will be changed by the processor itself.
- env.changeContext(resolvedPrefix, "");
+ env.changeContext(resolvedPrefix, resolvedSource);
if (context.isBuildingPipelineOnly()) {
// Propagate pipelines