cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r160323 - in cocoon/trunk/src: java/org/apache/cocoon/components/modules/input/ java/org/apache/cocoon/components/treeprocessor/sitemap/ java/org/apache/cocoon/generation/ java/org/apache/cocoon/sitemap/impl/ test/org/apache/cocoon/generation/ test/org/apache/cocoon/generation/sub/
Date Wed, 06 Apr 2005 20:06:59 GMT
Author: danielf
Date: Wed Apr  6 13:06:56 2005
New Revision: 160323

URL: http://svn.apache.org/viewcvs?view=rev&rev=160323
Log:
Working (hopefully :) ) VPC generator. Changed location of resolved sources from Avalon context to environment, and removed the AvalonContextModule that only was added for this task.

Added:
    cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/EnvironmentAttributeModule.java   (with props)
    cocoon/trunk/src/java/org/apache/cocoon/sitemap/impl/AbstractVirtualSitemapComponent.java   (with props)
    cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-source-param-expected.xml   (with props)
Removed:
    cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/AvalonContextModule.java
Modified:
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNode.java
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNodeBuilder.java
    cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCsNodeBuilder.java
    cocoon/trunk/src/java/org/apache/cocoon/generation/VirtualPipelineGenerator.java
    cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.java
    cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.xtest
    cocoon/trunk/src/test/org/apache/cocoon/generation/sub/sitemap.xmap
    cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-sitemap.xmap

Added: cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/EnvironmentAttributeModule.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/EnvironmentAttributeModule.java?view=auto&rev=160323
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/EnvironmentAttributeModule.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/EnvironmentAttributeModule.java Wed Apr  6 13:06:56 2005
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cocoon.components.modules.input;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+
+/**
+ * EnvironmentAttributeModule provides access to the current
+ * Environment, intended for internal use in VPCs.
+ *
+ * @version $Id$
+ */
+public class EnvironmentAttributeModule implements InputModule {
+
+    public Object getAttribute( String name, Configuration modeConf, Map objectModel )
+    throws ConfigurationException {
+        return EnvironmentHelper.getCurrentEnvironment().getAttribute(name);
+    }
+
+    public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
+        throws ConfigurationException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Iterator getAttributeNames(Configuration modeConf, Map objectModel)
+        throws ConfigurationException {
+        throw new UnsupportedOperationException();
+    }
+}

Propchange: cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/EnvironmentAttributeModule.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNode.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNode.java?view=diff&r1=160322&r2=160323
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNode.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNode.java Wed Apr  6 13:06:56 2005
@@ -1,40 +1,40 @@
-/*
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.treeprocessor.sitemap;
-
-import java.util.Set;
-
-import org.apache.cocoon.components.treeprocessor.NamedContainerNode;
-
-/**
- * A VPC node that just invokes its children and store what parameters are sources.
- *
- * @version $Id$
- */
-
-public class VPCNode extends NamedContainerNode {
-
-    Set sourceSet;
-
-    public VPCNode(String name, Set sourceSet) {
-        super(name);
-        this.sourceSet = sourceSet;
-    }
-
-    public Set getSources() {
-        return this.sourceSet;
-    }
-}
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import java.util.Set;
+
+import org.apache.cocoon.components.treeprocessor.NamedContainerNode;
+
+/**
+ * A VPC node that just invokes its children and store what parameters are sources.
+ *
+ * @version $Id$
+ */
+
+public class VPCNode extends NamedContainerNode {
+
+    Set sourceSet;
+
+    public VPCNode(String name, Set sourceSet) {
+        super(name);
+        this.sourceSet = sourceSet;
+    }
+
+    public Set getSources() {
+        return this.sourceSet;
+    }
+}

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNodeBuilder.java?view=diff&r1=160322&r2=160323
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNodeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCNodeBuilder.java Wed Apr  6 13:06:56 2005
@@ -1,84 +1,65 @@
-/*
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.treeprocessor.sitemap;
-
-import java.util.HashSet;
-
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.cocoon.Constants;
-import org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder;
-import org.apache.cocoon.components.treeprocessor.ProcessingNode;
-import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder;
-import org.apache.cocoon.components.treeprocessor.NamedContainerNodeBuilder;
-import org.apache.cocoon.components.treeprocessor.ProcessingNode;
-
-/**
- * Handles a virtual sitemap component.
- *
- * @version $Id$
- */
-public class VPCNodeBuilder extends NamedContainerNodeBuilder
-    implements Contextualizable, LinkedProcessingNodeBuilder {
-
-    private DefaultContext context;
-    private String type;
-    private String name;
-
-    public void contextualize(Context context) throws ContextException {
-        this.context = (DefaultContext) context;
-    }
-
-    public ProcessingNode buildNode(Configuration config) throws Exception {
-        this.type = config.getName();
-        this.name = config.getAttribute(this.nameAttr);
-
-        // Find out which parameters that should be handled as sources
-        // and put the info in the context.
-        Configuration[] sources = config.getChildren("source");
-        HashSet sourceSet = new HashSet();
-        for (int j = 0; j < sources.length; j++)
-            sourceSet.add(sources[j].getAttribute("param"));
-        
-        VPCNode node = new VPCNode(this.name, sourceSet);
-        this.setupNode(node, config);
-
-        return node;
-    }
-
-    public void linkNode() throws Exception {
-        // Stuff this node into the context of current Sitemap so that
-        // VirtualPipelineComponent can find it. 
-        //
-        // This probably doesn't work if the component is redifined in
-        // a subsitemap, either the stack functionality in DefaultContext
-        // should be used for context switches, or this info should
-        // be put in the current processor instead.
-        //
-        // The plural "s" is because the category name is from the
-        // embeding container and I didn't found a way to get that name.
-        // But for VPCs we know that a generator is part of the
-        // category geerators etc.
-
-        ProcessingNode node = 
-            CategoryNodeBuilder.getNamedNode(this.treeBuilder, this.type + "s", this.name);
-        
-        this.context.put(Constants.CONTEXT_VPC_PREFIX + this.type + "-" + this.name, node);
-    }
-}
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import java.util.HashSet;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.components.treeprocessor.NamedContainerNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+
+/**
+ * Handles a virtual sitemap component.
+ *
+ * @version $Id$
+ */
+public class VPCNodeBuilder extends NamedContainerNodeBuilder
+    implements Contextualizable {
+
+    private DefaultContext context;
+
+    // FIXME: The class is thread safe, will that work with Contextualizable?
+    public void contextualize(Context context) throws ContextException {
+        this.context = (DefaultContext) context;
+    }
+
+    public ProcessingNode buildNode(Configuration config) throws Exception {
+        String type = config.getName();
+        String name = config.getAttribute(this.nameAttr);
+
+        // Find out which parameters that should be handled as sources
+        // and put the info in the context.
+        Configuration[] sources = config.getChildren("source");
+        HashSet sourceSet = new HashSet();
+        for (int j = 0; j < sources.length; j++)
+            sourceSet.add(sources[j].getAttribute("param"));
+        
+        VPCNode node = new VPCNode(name, sourceSet);
+        this.setupNode(node, config);
+
+        // Stuff this node into the context of current Sitemap so that
+        // VirtualPipelineComponent can find it. 
+        //
+        this.context.put(Constants.CONTEXT_VPC_PREFIX + type + "-" + name, node);
+
+        return node;
+    }
+}

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCsNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCsNodeBuilder.java?view=diff&r1=160322&r2=160323
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCsNodeBuilder.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/VPCsNodeBuilder.java Wed Apr  6 13:06:56 2005
@@ -1,46 +1,46 @@
-/*
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.treeprocessor.sitemap;
-
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-
-import org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder;
-import org.apache.cocoon.generation.VirtualPipelineGenerator;
-
-/**
- * Handles a set of virtual sitemap components.
- *
- * @version $Id$
- */
-public class VPCsNodeBuilder extends CategoryNodeBuilder {
-
-    /**
-     * Checks if a child element is a VPC, and if not throws a <code>ConfigurationException</code>.
-     *
-     * @param child the child configuration to check.
-     * @return <code>true</code> if this child should be considered or <code>false</code>
-     *         if it should be ignored.
-     * @throws ConfigurationException if this child isn't allowed.
-     */
-    protected boolean isChild(Configuration child) throws ConfigurationException {
-
-        checkNamespace(child);
-
-        String clazz = child.getAttribute("src");
-        return VirtualPipelineGenerator.class.getName().equals(clazz);
-    }
-}
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+import org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder;
+import org.apache.cocoon.generation.VirtualPipelineGenerator;
+
+/**
+ * Handles a set of virtual sitemap components.
+ *
+ * @version $Id$
+ */
+public class VPCsNodeBuilder extends CategoryNodeBuilder {
+
+    /**
+     * Checks if a child element is a VPC, and if not throws a <code>ConfigurationException</code>.
+     *
+     * @param child the child configuration to check.
+     * @return <code>true</code> if this child should be considered or <code>false</code>
+     *         if it should be ignored.
+     * @throws ConfigurationException if this child isn't allowed.
+     */
+    protected boolean isChild(Configuration child) throws ConfigurationException {
+
+        checkNamespace(child);
+
+        String clazz = child.getAttribute("src");
+        return VirtualPipelineGenerator.class.getName().equals(clazz);
+    }
+}

Modified: cocoon/trunk/src/java/org/apache/cocoon/generation/VirtualPipelineGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/generation/VirtualPipelineGenerator.java?view=diff&r1=160322&r2=160323
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/generation/VirtualPipelineGenerator.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/generation/VirtualPipelineGenerator.java Wed Apr  6 13:06:56 2005
@@ -15,253 +15,68 @@
  */
 package org.apache.cocoon.generation;
 
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.parameters.Parameters;
-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.Constants;
 import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.components.source.SourceUtil;
-import org.apache.cocoon.components.pipeline.ProcessingPipeline;
-import org.apache.cocoon.components.pipeline.VirtualProcessingPipeline;
-import org.apache.cocoon.components.treeprocessor.CategoryNode;
-import org.apache.cocoon.components.treeprocessor.InvokeContext;
-import org.apache.cocoon.components.treeprocessor.ProcessingNode;
-import org.apache.cocoon.components.treeprocessor.sitemap.VPCNode;
 import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.cocoon.sitemap.impl.AbstractVirtualSitemapComponent;
 import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceException;
-import org.apache.excalibur.xml.sax.XMLizable;
 
 import org.xml.sax.SAXException;
 
 import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 
-/**
- * TODO List:
- * <ul>
- * <li>Implement parameters support
- * <li>Resolve src parameter and pass to the pipeline
- * <li>Refactor ProcessingPipelines implementations
- * <li>Implement caching
- * </ul>
- */
-public class VirtualPipelineGenerator extends AbstractLogEnabled
-    implements Generator, Serviceable, Disposable, Contextualizable, Configurable {
-
-    private SourceResolver resolver;
-    private DefaultContext context;
-    private ServiceManager manager;
-    private XMLConsumer consumer;
-    private ProcessingNode node;
-    private ProcessingPipeline pipeline;
-    private String sourceMapName;
-    private Map sourceMap = new HashMap();
-    private Set sources;
-    private String name;
-
-
-    private class MyInvokeContext extends InvokeContext {
-        public MyInvokeContext() throws Exception {
-            super(true);
-            super.processingPipeline = new VirtualProcessingPipeline(VirtualPipelineGenerator.this.context);
-        }
-    }
 
-    public void contextualize(Context context) throws ContextException {
-        this.context = (DefaultContext)context;
-    }
+public class VirtualPipelineGenerator extends AbstractVirtualSitemapComponent
+    implements Generator {
 
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
+    protected XMLConsumer consumer;
 
-    /**
-     * Release all resources.
-     */
-    public void dispose() {
-        try {
-            Iterator sources =
-                this.sourceMap.values().iterator();
-            while (sources.hasNext()) {
-                Source source = (Source)sources.next();
-                // These are allready disposed, why?
-                //this.resolver.release(source);
-            }
-        } catch (Exception e) {
-            throw new RuntimeException("Could not dispose sources", e);
-        }
-        this.manager = null;
-    }
-
-    public void configure(Configuration configuration) throws ConfigurationException {
-        this.name = configuration.getAttribute("name");
-        this.sourceMapName = Constants.CONTEXT_ENV_PREFIX + "-source-map-" + this.name;
-        try {
-            this.node =
-                (ProcessingNode)this.context.get(Constants.CONTEXT_VPC_PREFIX +
-                                                 "generator-" + this.name);
-            this.sources = ((VPCNode)node).getSources();
-        } catch (Exception e) {
-            throw new ConfigurationException("Can not find VirtualPipelineGenerator '" +
-                                             this.name + "' configuration");
-        }
+    protected String getTypeName() {
+        return "generator";
     }
 
     public void setConsumer(XMLConsumer consumer) {
         this.consumer = consumer;
     }
 
-    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
-    throws ProcessingException, SAXException, IOException {
-
-        this.resolver = resolver;
-
-        // save callers resolved sources if there are any
-        Map oldSourceMap = null;
-        try {
-            oldSourceMap = (Map)this.context.get(this.sourceMapName);
-        } catch (ContextException e) {
-            // This VPC has not been used by the caller
-        }
-        // place for resolved sources
-        this.context.put(this.sourceMapName, this.sourceMap);
-
-        Environment env = EnvironmentHelper.getCurrentEnvironment();
-        String oldPrefix = env.getURIPrefix();
-        String oldURI    = env.getURI();
-        MyInvokeContext invoker = null;
-
-        try {
-            // resolve the sources in the parameter map before switching context
-            Map resolvedParams = resolveParams(par, src);
-
-            String uri = (String) this.context.get(Constants.CONTEXT_ENV_URI);
-            String prefix = (String) this.context.get(Constants.CONTEXT_ENV_PREFIX);
-            env.setURI(prefix, uri);
-
-            invoker = new MyInvokeContext();
-            invoker.enableLogging(getLogger());
-            invoker.service(this.manager);
-            invoker.pushMap(null, resolvedParams);
-
-            this.node.invoke(env, invoker);
-            this.pipeline = invoker.getProcessingPipeline();
-        } catch (Exception e) {
-            throw new ProcessingException("Oops", e);
-        } finally {
-            if (invoker != null) {
-                invoker.popMap();
-                invoker.dispose();
-            }
-            // Restore context
-            env.setURI(oldPrefix, oldURI);
-            // restore sourceMap
-            this.context.put(this.sourceMapName, oldSourceMap);
-        }
-    }
-
-    private Map resolveParams(Parameters par, String src)
-        throws ProcessingException, IOException {
-        HashMap map = new HashMap();
-
-        // resolve and map params
-        Iterator names = par.getParameterNames();
-        while (names.hasNext()) {
-            String name = (String)names.next();
-            String value = par.getParameter(name, null);
-            if (this.sources.contains(name))
-                value = resolveAndMapSourceURI(name, value);
-            map.put(name, value);
-        }
-
-        // resolve and map src
-        if (src != null)
-            map.put("src", resolveAndMapSourceURI("src", src));
-        
-        return map;
-    }
-
-    private String resolveAndMapSourceURI(String name, String uri)
-        throws ProcessingException, IOException {
-
-        // Resolve the URI
-        getLogger().debug("VPCGenerator: resolve " + name + " = " + uri);
-        Source src = null;
-        try {
-            src = this.resolver.resolveURI(uri);
-        } catch (SourceException se) {
-            throw SourceUtil.handle("Error during resolving of " + uri, se);
-        }
-
-        getLogger().debug("VPCGenerator: URI " + name + " = " + src.getURI());
-
-        // Save the source
-        this.sourceMap.put(name, src);
-
-        // Create a new URI that refers to the source in the context
-        String mappedURI;
-        if (src instanceof XMLizable)
-            mappedURI = "xmodule:avalon-context:" + this.sourceMapName + "#" + name;
-        else
-            mappedURI = "module:avalon-context:" + this.sourceMapName + "#" + name;
-        
-        getLogger().debug("VPCGenerator: mapped URI " + name + " = " + mappedURI);
-
-        return mappedURI;
-    }
-
     public void generate()
     throws IOException, SAXException, ProcessingException {
 
-        // save callers resolved sources if there are any
-        Map oldSourceMap = null;
-        try {
-            oldSourceMap = (Map)this.context.get(this.sourceMapName);
-        } catch (ContextException e) {
-            // This VPC has not been used by the caller
-        }
-        // place for resolved sources
-        this.context.put(this.sourceMapName, this.sourceMap);
-
         // Should use SourceResolver of the this components' sitemap, not caller sitemap
         // Have to switch to another environment...
         Environment env = EnvironmentHelper.getCurrentEnvironment();
         String oldPrefix = env.getURIPrefix();
         String oldURI    = env.getURI();
+
+        // save callers resolved sources if there are any
+        Map oldSourceMap = (Map)env.getAttribute(this.sourceMapName);
+        // place for resolved sources
+        env.setAttribute(this.sourceMapName, this.sourceMap);
+
         try {
-            String uri = (String) this.context.get(Constants.CONTEXT_ENV_URI);
-            String prefix = (String) this.context.get(Constants.CONTEXT_ENV_PREFIX);
-            env.setURI(prefix, uri);
-
-            this.pipeline.prepareInternal(env);
-        } catch (Exception e) {
-            throw new ProcessingException("Oops", e);
-        } finally {
-            // Restore context
-            env.setURI(oldPrefix, oldURI);
-        }
+            try {
+                String uri = (String) this.context.get(Constants.CONTEXT_ENV_URI);
+                String prefix = (String) this.context.get(Constants.CONTEXT_ENV_PREFIX);
+                env.setURI(prefix, uri);
+                
+                this.pipeline.prepareInternal(env);
+            } catch (Exception e) {
+                throw new ProcessingException("Oops", e);
+            } finally {
+                // Restore context
+                env.setURI(oldPrefix, oldURI);
+            }
 
-        this.pipeline.process(env, this.consumer);
+            this.pipeline.process(env, this.consumer);
 
-        // restore sourceMap
-        this.context.put(this.sourceMapName, oldSourceMap);
+        } finally {
+            // restore sourceMap
+            if (oldSourceMap != null)
+                env.setAttribute(this.sourceMapName, oldSourceMap);
+            else
+                env.removeAttribute(this.sourceMapName);
+        }
     }
-}
+ }

Added: cocoon/trunk/src/java/org/apache/cocoon/sitemap/impl/AbstractVirtualSitemapComponent.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/sitemap/impl/AbstractVirtualSitemapComponent.java?view=auto&rev=160323
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/sitemap/impl/AbstractVirtualSitemapComponent.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/sitemap/impl/AbstractVirtualSitemapComponent.java Wed Apr  6 13:06:56 2005
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.sitemap.impl;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.parameters.Parameters;
+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.Constants;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.components.pipeline.ProcessingPipeline;
+import org.apache.cocoon.components.pipeline.VirtualProcessingPipeline;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.sitemap.VPCNode;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.cocoon.sitemap.SitemapModelComponent;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.xml.sax.XMLizable;
+
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * TODO List:
+ * <ul>
+ * <li>Refactor ProcessingPipelines implementations
+ * <li>Implement caching
+ * </ul>
+ */
+public abstract class AbstractVirtualSitemapComponent extends AbstractLogEnabled
+    implements SitemapModelComponent, Serviceable, Disposable, Contextualizable, Configurable {
+
+    protected SourceResolver resolver;
+    protected DefaultContext context;
+    protected ServiceManager manager;
+    protected ProcessingNode node;
+    protected ProcessingPipeline pipeline;
+    protected String sourceMapName;
+    protected Map sourceMap = new HashMap();
+    protected Set sources;
+    protected String name;
+
+
+    protected class MyInvokeContext extends InvokeContext {
+        public MyInvokeContext() throws Exception {
+            super(true);
+            super.processingPipeline = new VirtualProcessingPipeline(AbstractVirtualSitemapComponent.this.context);
+        }
+    }
+
+    abstract protected String getTypeName();
+
+    public void contextualize(Context context) throws ContextException {
+        this.context = (DefaultContext)context;
+    }
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+    }
+
+    /**
+     * Release all resources.
+     */
+    public void dispose() {
+        try {
+            Iterator sources =
+                this.sourceMap.values().iterator();
+            while (sources.hasNext()) {
+                Source source = (Source)sources.next();
+                // FIXME
+                // These are allready disposed, why?
+                //this.resolver.release(source);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("Could not dispose sources", e);
+        }
+        this.manager = null;
+    }
+
+    public void configure(Configuration configuration) throws ConfigurationException {
+        this.name = configuration.getAttribute("name");
+        this.sourceMapName =
+            Constants.CONTEXT_ENV_PREFIX + "-" + getTypeName() + "-source-map-" + this.name;
+        try {
+            this.node = (ProcessingNode)this.context.get(Constants.CONTEXT_VPC_PREFIX +
+                                                         getTypeName() + "-" + this.name);
+            this.sources = ((VPCNode)node).getSources();
+        } catch (Exception e) {
+            throw new ConfigurationException("Can not find VirtualPipelineComponent '" +
+                                             this.name + "' configuration");
+        }
+    }
+
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
+    throws ProcessingException, SAXException, IOException {
+        this.resolver = resolver;
+
+        Environment env = EnvironmentHelper.getCurrentEnvironment();
+        String oldPrefix = env.getURIPrefix();
+        String oldURI    = env.getURI();
+
+        // save callers resolved sources if there are any
+        Map oldSourceMap = (Map)env.getAttribute(this.sourceMapName);
+        // place for resolved sources
+        env.setAttribute(this.sourceMapName, this.sourceMap);
+
+        MyInvokeContext invoker = null;
+
+        try {
+            // resolve the sources in the parameter map before switching context
+            Map resolvedParams = resolveParams(par, src);
+
+            String uri = (String) this.context.get(Constants.CONTEXT_ENV_URI);
+            String prefix = (String) this.context.get(Constants.CONTEXT_ENV_PREFIX);
+            env.setURI(prefix, uri);
+
+            invoker = new MyInvokeContext();
+            invoker.enableLogging(getLogger());
+            invoker.service(this.manager);
+            invoker.pushMap(null, resolvedParams);
+
+            this.node.invoke(env, invoker);
+            this.pipeline = invoker.getProcessingPipeline();
+        } catch (Exception e) {
+            throw new ProcessingException("Oops", e);
+        } finally {
+            if (invoker != null) {
+                invoker.popMap();
+                invoker.dispose();
+            }
+            // Restore context
+            env.setURI(oldPrefix, oldURI);
+            // restore sourceMap
+            if (oldSourceMap != null)
+                env.setAttribute(this.sourceMapName, oldSourceMap);
+            else
+                env.removeAttribute(this.sourceMapName);
+        }
+    }
+
+    protected Map resolveParams(Parameters par, String src)
+        throws ProcessingException, IOException {
+        HashMap map = new HashMap();
+
+        // resolve and map params
+        Iterator names = par.getParameterNames();
+        while (names.hasNext()) {
+            String name = (String)names.next();
+            String value = par.getParameter(name, null);
+            if (this.sources.contains(name))
+                value = resolveAndMapSourceURI(name, value);
+            map.put(name, value);
+        }
+
+        // resolve and map src
+        if (src != null)
+            map.put("src", resolveAndMapSourceURI("src", src));
+        
+        return map;
+    }
+
+    protected String resolveAndMapSourceURI(String name, String uri)
+        throws ProcessingException, IOException {
+
+        // Resolve the URI
+        Source src = null;
+        try {
+            src = this.resolver.resolveURI(uri);
+        } catch (SourceException se) {
+            throw SourceUtil.handle("Error during resolving of " + uri, se);
+        }
+
+        // Save the source
+        this.sourceMap.put(name, src);
+
+        // Create a new URI that refers to the source in the context
+        String mappedURI;
+        if (src instanceof XMLizable)
+            mappedURI = "xmodule:environment-attribute:" + this.sourceMapName + "#" + name;
+        else
+            mappedURI = "module:environment-attribute:" + this.sourceMapName + "#" + name;
+        
+        return mappedURI;
+    }
+}

Propchange: cocoon/trunk/src/java/org/apache/cocoon/sitemap/impl/AbstractVirtualSitemapComponent.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.java?view=diff&r1=160322&r2=160323
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.java (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.java Wed Apr  6 13:06:56 2005
@@ -1,120 +1,120 @@
-/*
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.generation;
-
-import java.net.URL;
-
-import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.cocoon.Constants;
-import org.apache.cocoon.Processor;
-import org.apache.cocoon.SitemapComponentTestCase;
-import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.internal.EnvironmentHelper;
-import org.apache.cocoon.environment.mock.MockEnvironment;
-
-public class VirtualPipelineGeneratorTestCase extends SitemapComponentTestCase {
-
-    private Processor processor;
-    private String classDir;
-    private URL classDirURL;
-
-    public void setUp() throws Exception {
-        this.classDirURL = getClassDirURL();
-        this.classDir = this.classDirURL.toExternalForm();
-        super.setUp();
-        this.processor = (Processor)this.lookup(Processor.ROLE);
-    }
-
-    public void tearDown() throws Exception {
-        this.release(this.processor);
-        super.tearDown();
-    }
-
-    // Hack to get the URL to the directory that this class is in
-    private URL getClassDirURL() throws RuntimeException {
-        String className = getClass().getName().replace( '.', '/' ) + ".class";
-        try {
-            String classURL =
-                getClass().getClassLoader().getResource( className ).toExternalForm();
-            String classDir = classURL.substring(0, classURL.lastIndexOf('/') + 1);
-
-            return new URL(classDir);
-        } catch (Exception e) {
-            throw new RuntimeException("Couldn't create URL for " + className, e);
-        }
-    }
-
-    protected void addContext(DefaultContext context) {
-        super.addContext(context);
-        context.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, getContext());
-        context.put(ContextHelper.CONTEXT_ROOT_URL, this.classDirURL);
-    }
-
-    protected boolean addSourceFactories() {
-        return false;
-    }
-
-    public byte[] process(String uri) throws Exception {
-        MockEnvironment env = new MockEnvironment();
-        env.setURI("", uri);
-        getRequest().setEnvironment(env);
-        env.setObjectModel(getObjectModel());
-
-        EnvironmentHelper.enterProcessor(this.processor, this.getManager(), env);
-        try {
-            this.processor.process(env);
-            getLogger().info("Output: " + new String(env.getOutput(), "UTF-8"));
-
-            return env.getOutput();
-        } finally {
-            EnvironmentHelper.leaveProcessor();
-        }
-    }
-
-    public void pipeTest(String uri, String expectedSource) throws Exception {
-        byte[] expected = loadByteArray(this.classDir + expectedSource);
-        byte[] actual = process(uri);
-        assertIdentical(expected, actual);
-    }
-
-    public void testSimplePipe() throws Exception {
-        pipeTest("test", "vpc-test.xml");
-    }
-
-    public void testVirtualPipe() throws Exception {
-        pipeTest("v1", "vpc-test.xml");
-    }
-
-    public void testVirtualPipeParam() throws Exception {
-        pipeTest("v2", "vpc-param-expected.xml");
-    }
-
-    public void testVirtualPipeSourceParam() throws Exception {
-        process("v3");
-    }
-
-    public void testVirtualSubPipeSourceParam() throws Exception {
-        process("sub/v3");
-    }
-
-    public void testVirtualPipeSrc() throws Exception {
-        process("v4");
-    }
-
-    public void testVirtualSubPipeSrc() throws Exception {
-        process("sub/v4");
-    }
-}
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.generation;
+
+import java.net.URL;
+
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.SitemapComponentTestCase;
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.cocoon.environment.mock.MockEnvironment;
+
+public class VirtualPipelineGeneratorTestCase extends SitemapComponentTestCase {
+
+    private Processor processor;
+    private String classDir;
+    private URL classDirURL;
+
+    public void setUp() throws Exception {
+        this.classDirURL = getClassDirURL();
+        this.classDir = this.classDirURL.toExternalForm();
+        super.setUp();
+        this.processor = (Processor)this.lookup(Processor.ROLE);
+    }
+
+    public void tearDown() throws Exception {
+        this.release(this.processor);
+        super.tearDown();
+    }
+
+    // Hack to get the URL to the directory that this class is in
+    private URL getClassDirURL() throws RuntimeException {
+        String className = getClass().getName().replace( '.', '/' ) + ".class";
+        try {
+            String classURL =
+                getClass().getClassLoader().getResource( className ).toExternalForm();
+            String classDir = classURL.substring(0, classURL.lastIndexOf('/') + 1);
+
+            return new URL(classDir);
+        } catch (Exception e) {
+            throw new RuntimeException("Couldn't create URL for " + className, e);
+        }
+    }
+
+    protected void addContext(DefaultContext context) {
+        super.addContext(context);
+        context.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, getContext());
+        context.put(ContextHelper.CONTEXT_ROOT_URL, this.classDirURL);
+    }
+
+    protected boolean addSourceFactories() {
+        return false;
+    }
+
+    public byte[] process(String uri) throws Exception {
+        MockEnvironment env = new MockEnvironment();
+        env.setURI("", uri);
+        getRequest().setEnvironment(env);
+        env.setObjectModel(getObjectModel());
+
+        EnvironmentHelper.enterProcessor(this.processor, this.getManager(), env);
+        try {
+            this.processor.process(env);
+            getLogger().info("Output: " + new String(env.getOutput(), "UTF-8"));
+
+            return env.getOutput();
+        } finally {
+            EnvironmentHelper.leaveProcessor();
+        }
+    }
+
+    public void pipeTest(String uri, String expectedSource) throws Exception {
+        byte[] expected = loadByteArray(this.classDir + expectedSource);
+        byte[] actual = process(uri);
+        assertIdentical(expected, actual);
+    }
+
+    public void testSimplePipe() throws Exception {
+        pipeTest("test", "vpc-test.xml");
+    }
+
+    public void testVirtualPipe() throws Exception {
+        pipeTest("v1", "vpc-test.xml");
+    }
+
+    public void testVirtualPipeParam() throws Exception {
+        pipeTest("v2", "vpc-param-expected.xml");
+    }
+
+    public void testVirtualPipeSourceParam() throws Exception {
+        pipeTest("v3", "vpc-source-param-expected.xml");
+    }
+
+    public void testVirtualSubPipeSourceParam() throws Exception {
+        pipeTest("sub/v3", "vpc-source-param-expected.xml");
+    }
+
+    public void testVirtualPipeSrc() throws Exception {
+        pipeTest("v4", "vpc-test.xml");
+    }
+
+    public void testVirtualSubPipeSrc() throws Exception {
+        pipeTest("sub/v4", "vpc-test.xml");
+    }
+}

Modified: cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.xtest?view=diff&r1=160322&r2=160323
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.xtest (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/generation/VirtualPipelineGeneratorTestCase.xtest Wed Apr  6 13:06:56 2005
@@ -1,88 +1,91 @@
-<?xml version="1.0"?>
-<!--
-  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.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-
-<testcase>
-  <roles>
-    <role name="org.apache.excalibur.xml.sax.SAXParser"
-          shorthand="xml-parser"
-          default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
-    <role name="org.apache.excalibur.xmlizer.XMLizer"
-          shorthand="xmlizer"
-          default-class="org.apache.excalibur.xmlizer.DefaultXMLizer"/>
-    <role name="org.apache.cocoon.components.pipeline.ProcessingPipelineSelector"
-          shorthand="pipes"
-          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
-    <role name="org.apache.cocoon.matching.MatcherSelector"
-          shorthand="matchers"
-          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
-    <role name="org.apache.cocoon.generation.GeneratorSelector"
-          shorthand="generators"
-          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
-    <role name="org.apache.cocoon.transformation.TransformerSelector"
-          shorthand="transformers"
-          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
-      
-    <role name="org.apache.cocoon.serialization.SerializerSelector"
-          shorthand="serializers"
-          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
-    <role name="org.apache.excalibur.source.SourceFactorySelector"
-          shorthand="source-factories"
-          default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
-    <role name="org.apache.excalibur.source.SourceResolver"
-          shorthand="source-resolver"
-          default-class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
-    <role name="org.apache.cocoon.Processor"
-          shorthand="sitemap"
-          default-class="org.apache.cocoon.components.treeprocessor.TreeProcessor"/>
-    <role name="org.apache.cocoon.components.treeprocessor.TreeBuilder/sitemap-1.0"
-          default-class="org.apache.cocoon.components.treeprocessor.sitemap.SitemapLanguage"/>
-    <role name="org.apache.cocoon.components.modules.input.InputModuleSelector"
-          shorthand="input-modules"
-          default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
-  </roles>
- 
-  <components>
-    <xml-parser class="org.apache.excalibur.xml.impl.JaxpParser">
-      <parameter name="validate" value="false"/>
-      <parameter name="namespace-prefixes" value="false"/>
-      <parameter name="stop-on-warning" value="true"/>
-      <parameter name="stop-on-recoverable-error" value="true"/>
-      <parameter name="reuse-parsers" value="false"/>
-    </xml-parser>
-
-    <xmlizer/>
-
-    <input-modules>
-      <component-instance class="org.apache.cocoon.components.modules.input.AvalonContextModule" name="avalon-context"/>
-    </input-modules>
-
-    <source-factories>
-      <component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource"/>
-      <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory" name="context"/>
-      <component-instance class="org.apache.cocoon.components.source.impl.ModuleSourceFactory" name="module"/>
-      <component-instance class="org.apache.cocoon.components.source.impl.XModuleSourceFactory" name="xmodule"/>
-      <component-instance class="org.apache.excalibur.source.impl.FileSourceFactory" name="file"/>
-      <component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
-    </source-factories>
-
-    <!-- Relative sitemap path works during sitemap execution but
-         give exceptions during decommissioning -->
-    <sitemap file="resource://org/apache/cocoon/generation/vpc-sitemap.xmap"/>
-
-  </components>
- 
-</testcase>
+<?xml version="1.0"?>
+<!--
+  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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<testcase>
+  <roles>
+    <role name="org.apache.excalibur.xml.sax.SAXParser"
+          shorthand="xml-parser"
+          default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
+    <role name="org.apache.excalibur.xmlizer.XMLizer"
+          shorthand="xmlizer"
+          default-class="org.apache.excalibur.xmlizer.DefaultXMLizer"/>
+    <role name="org.apache.cocoon.components.pipeline.ProcessingPipelineSelector"
+          shorthand="pipes"
+          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
+    <role name="org.apache.cocoon.matching.MatcherSelector"
+          shorthand="matchers"
+          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
+    <role name="org.apache.cocoon.generation.GeneratorSelector"
+          shorthand="generators"
+          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
+    <role name="org.apache.cocoon.transformation.TransformerSelector"
+          shorthand="transformers"
+          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
+      
+    <role name="org.apache.cocoon.serialization.SerializerSelector"
+          shorthand="serializers"
+          default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
+    <role name="org.apache.excalibur.source.SourceFactorySelector"
+          shorthand="source-factories"
+          default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+    <role name="org.apache.excalibur.source.SourceResolver"
+          shorthand="source-resolver"
+          default-class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
+    <role name="org.apache.cocoon.Processor"
+          shorthand="sitemap"
+          default-class="org.apache.cocoon.components.treeprocessor.TreeProcessor"/>
+    <role name="org.apache.cocoon.components.treeprocessor.TreeBuilder/sitemap-1.0"
+          default-class="org.apache.cocoon.components.treeprocessor.sitemap.SitemapLanguage"/>
+    <role name="org.apache.cocoon.components.modules.input.InputModuleSelector"
+          shorthand="input-modules"
+          default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+    <role name="org.apache.cocoon.components.fam.SitemapMonitor"
+          shorthand="fam"
+          default-class="org.apache.cocoon.components.fam.SitemapMonitorImpl"/>
+  </roles>
+ 
+  <components>
+    <xml-parser class="org.apache.excalibur.xml.impl.JaxpParser">
+      <parameter name="validate" value="false"/>
+      <parameter name="namespace-prefixes" value="false"/>
+      <parameter name="stop-on-warning" value="true"/>
+      <parameter name="stop-on-recoverable-error" value="true"/>
+      <parameter name="reuse-parsers" value="false"/>
+    </xml-parser>
+
+    <xmlizer/>
+
+    <input-modules>
+      <component-instance class="org.apache.cocoon.components.modules.input.EnvironmentAttributeModule" name="environment-attribute"/>
+    </input-modules>
+
+    <source-factories>
+      <component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource"/>
+      <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory" name="context"/>
+      <component-instance class="org.apache.cocoon.components.source.impl.ModuleSourceFactory" name="module"/>
+      <component-instance class="org.apache.cocoon.components.source.impl.XModuleSourceFactory" name="xmodule"/>
+      <component-instance class="org.apache.excalibur.source.impl.FileSourceFactory" name="file"/>
+      <component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
+    </source-factories>
+
+    <!-- Relative sitemap path works during sitemap execution but
+         give exceptions during decommissioning -->
+    <sitemap file="resource://org/apache/cocoon/generation/vpc-sitemap.xmap"/>
+
+  </components>
+ 
+</testcase>

Modified: cocoon/trunk/src/test/org/apache/cocoon/generation/sub/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/generation/sub/sitemap.xmap?view=diff&r1=160322&r2=160323
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/generation/sub/sitemap.xmap (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/generation/sub/sitemap.xmap Wed Apr  6 13:06:56 2005
@@ -1,40 +1,40 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-
-<!-- SVN $Id$ -->
-
-<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-
-  <map:pipelines>
-    <map:pipeline>
-
-      <map:match pattern="v3">
-        <map:generate type="virtual3">
-          <map:parameter name="source" value="test.xml"/>
-          <map:parameter name="foo" value="bar"/>
-        </map:generate>
-        <map:serialize type="xml"/>
-      </map:match>
-
-      <map:match pattern="v4">
-        <map:generate type="virtual4" src="test.xml"/>
-        <map:serialize type="xml"/>
-      </map:match>
-
-    </map:pipeline>
-  </map:pipelines>
-</map:sitemap>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- SVN $Id$ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:pipelines>
+    <map:pipeline>
+
+      <map:match pattern="v3">
+        <map:generate type="virtual3">
+          <map:parameter name="source" value="test.xml"/>
+          <map:parameter name="foo" value="bar"/>
+        </map:generate>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <map:match pattern="v4">
+        <map:generate type="virtual4" src="test.xml"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+</map:sitemap>

Modified: cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-sitemap.xmap?view=diff&r1=160322&r2=160323
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-sitemap.xmap (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-sitemap.xmap Wed Apr  6 13:06:56 2005
@@ -1,106 +1,106 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-
-<!-- SVN $Id$ -->
-
-<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-
-  <map:components>
-    <map:generators default="file">
-      <map:generator name="file" src="org.apache.cocoon.generation.FileGenerator"/>
-      <map:generator name="jx" src="org.apache.cocoon.generation.JXTemplateGenerator"/>
-      <map:generator name="virtual1" src="org.apache.cocoon.generation.VirtualPipelineGenerator">
-        <map:generate type="file" src="vpc-test.xml"/>
-      </map:generator>
-      <map:generator name="virtual2" src="org.apache.cocoon.generation.VirtualPipelineGenerator">
-        <map:generate type="jx" src="vpc-param.xml">
-           <map:parameter name="foo2" value="{foo}"/>
-        </map:generate>
-      </map:generator>
-      <map:generator name="virtual3" src="org.apache.cocoon.generation.VirtualPipelineGenerator">
-        <map:source param="source"/>
-        <map:generate type="jx" src="vpc-source-param.xml">
-           <map:parameter name="source" value="{source}"/>
-           <map:parameter name="foo2" value="{foo}"/>
-        </map:generate>
-      </map:generator>
-      <map:generator name="virtual4" src="org.apache.cocoon.generation.VirtualPipelineGenerator">
-        <map:generate src="{src}"/>
-      </map:generator>
-    </map:generators>
-
-    <map:transformers default="xslt">
-      <map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer">
-        <xslt-processor-role>xalan</xslt-processor-role>
-      </map:transformer>
-    </map:transformers>
-
-    <map:serializers default="xml">
-      <map:serializer mime-type="text/xml" name="xml" src="org.apache.cocoon.serialization.XMLSerializer"/>
-    </map:serializers>
-
-    <map:matchers default="wildcard">
-      <map:matcher name="wildcard" src="org.apache.cocoon.matching.WildcardURIMatcher"/>
-    </map:matchers>
-
-    <map:pipes default="noncaching">
-      <map:pipe name="noncaching" src="org.apache.cocoon.components.pipeline.impl.NonCachingProcessingPipeline">
-      </map:pipe>
-    </map:pipes>
-  </map:components>
-
-  <map:pipelines>
-    <map:pipeline>
-
-      <map:match pattern="test">
-        <map:generate type="file" src="vpc-test.xml"/>
-        <map:serialize type="xml"/>
-      </map:match>
-
-      <map:match pattern="v1">
-        <map:generate type="virtual1"/>
-        <map:serialize type="xml"/>
-      </map:match>
-
-      <map:match pattern="v2">
-        <map:generate type="virtual2">
-          <map:parameter name="foo" value="bar"/>
-        </map:generate>
-        <map:serialize type="xml"/>
-      </map:match>
-
-      <map:match pattern="v3">
-        <map:generate type="virtual3">
-          <map:parameter name="source" value="vpc-test.xml"/>
-          <map:parameter name="foo" value="bar"/>
-        </map:generate>
-        <map:serialize type="xml"/>
-      </map:match>
-
-      <map:match pattern="sub/**">
-	<map:mount uri-prefix="sub"
-                   src="resource://org/apache/cocoon/generation/sub/"/>
-      </map:match>
-
-      <map:match pattern="v4">
-        <map:generate type="virtual4" src="vpc-test.xml"/>
-        <map:serialize type="xml"/>
-      </map:match>
-
-    </map:pipeline>
-  </map:pipelines>
-</map:sitemap>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- SVN $Id$ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:components>
+    <map:generators default="file">
+      <map:generator name="file" src="org.apache.cocoon.generation.FileGenerator"/>
+      <map:generator name="jx" src="org.apache.cocoon.generation.JXTemplateGenerator"/>
+      <map:generator name="virtual1" src="org.apache.cocoon.generation.VirtualPipelineGenerator">
+        <map:generate type="file" src="vpc-test.xml"/>
+      </map:generator>
+      <map:generator name="virtual2" src="org.apache.cocoon.generation.VirtualPipelineGenerator">
+        <map:generate type="jx" src="vpc-param.xml">
+           <map:parameter name="foo2" value="{foo}"/>
+        </map:generate>
+      </map:generator>
+      <map:generator name="virtual3" src="org.apache.cocoon.generation.VirtualPipelineGenerator">
+        <map:source param="source"/>
+        <map:generate type="jx" src="vpc-source-param.xml">
+           <map:parameter name="source" value="{source}"/>
+           <map:parameter name="foo2" value="{foo}"/>
+        </map:generate>
+      </map:generator>
+      <map:generator name="virtual4" src="org.apache.cocoon.generation.VirtualPipelineGenerator">
+        <map:generate src="{src}"/>
+      </map:generator>
+    </map:generators>
+
+    <map:transformers default="xslt">
+      <map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer">
+        <xslt-processor-role>xalan</xslt-processor-role>
+      </map:transformer>
+    </map:transformers>
+
+    <map:serializers default="xml">
+      <map:serializer mime-type="text/xml" name="xml" src="org.apache.cocoon.serialization.XMLSerializer"/>
+    </map:serializers>
+
+    <map:matchers default="wildcard">
+      <map:matcher name="wildcard" src="org.apache.cocoon.matching.WildcardURIMatcher"/>
+    </map:matchers>
+
+    <map:pipes default="noncaching">
+      <map:pipe name="noncaching" src="org.apache.cocoon.components.pipeline.impl.NonCachingProcessingPipeline">
+      </map:pipe>
+    </map:pipes>
+  </map:components>
+
+  <map:pipelines>
+    <map:pipeline>
+
+      <map:match pattern="test">
+        <map:generate type="file" src="vpc-test.xml"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <map:match pattern="v1">
+        <map:generate type="virtual1"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <map:match pattern="v2">
+        <map:generate type="virtual2">
+          <map:parameter name="foo" value="bar"/>
+        </map:generate>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <map:match pattern="v3">
+        <map:generate type="virtual3">
+          <map:parameter name="source" value="vpc-test.xml"/>
+          <map:parameter name="foo" value="bar"/>
+        </map:generate>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <map:match pattern="sub/**">
+        <map:mount uri-prefix="sub"
+                   src="resource://org/apache/cocoon/generation/sub/"/>
+      </map:match>
+
+      <map:match pattern="v4">
+        <map:generate type="virtual4" src="vpc-test.xml"/>
+        <map:serialize type="xml"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+</map:sitemap>

Added: cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-source-param-expected.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-source-param-expected.xml?view=auto&rev=160323
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-source-param-expected.xml (added)
+++ cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-source-param-expected.xml Wed Apr  6 13:06:56 2005
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><test source="module:environment-attribute:env-prefix-generator-source-map-virtual3#source" foo2="bar"/>
\ No newline at end of file

Propchange: cocoon/trunk/src/test/org/apache/cocoon/generation/vpc-source-param-expected.xml
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message