cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [12/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/cocoon.roles
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/cocoon.roles?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/cocoon.roles (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/cocoon.roles Thu Nov  3 05:41:06 2005
@@ -0,0 +1,249 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2005 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.
+-->
+<!-- $Id: cocoon.roles 326713 2005-10-19 21:19:29Z sylvain $ -->
+<!DOCTYPE role-list [
+<!ELEMENT role-list (role+)>
+<!ELEMENT role (hint*)>
+<!ELEMENT hint EMPTY>
+<!ATTLIST role-list cocoon-version CDATA #IMPLIED
+>
+<!ATTLIST role name CDATA #REQUIRED
+               shorthand CDATA #REQUIRED
+               default-class CDATA #IMPLIED
+>
+<!ATTLIST hint shorthand CDATA #REQUIRED
+               class CDATA #REQUIRED
+>
+]>
+
+<!-- Roles for the cocoon core. The "cocoon-version" attribute is used by the Cocoon build system
+     for shared blocks, that should add their roles here in 2.1 but not in 2.2 -->
+<role-list cocoon-version = '2.2'>
+  <role name="org.apache.cocoon.components.classloader.ClassLoaderFactory"
+        default-class="org.apache.cocoon.components.classloader.DefaultClassLoaderFactory"/>
+
+  <role name="org.apache.excalibur.source.SourceFactorySelector"
+        shorthand="source-factories"
+        default-class="org.apache.cocoon.core.container.DefaultServiceSelector">
+  </role>
+
+  <role name="org.apache.excalibur.source.SourceResolver"
+        shorthand="source-resolver"
+        default-class="org.apache.cocoon.components.source.CocoonSourceResolver"/>
+
+  <!-- The entity resolver used by most parsers -->
+  <role name="org.apache.excalibur.xml.EntityResolver"
+        shorthand="entity-resolver"
+        default-class="org.apache.cocoon.components.resolver.DefaultResolver"/>
+
+  <!-- Parser:
+
+       Starting with Cocoon 2.1 we have a bunch of different parser:
+       - a SAX parser (producing SAX events)
+       - a DOM parser (producint a document)
+       - an HTML parser (producing SAX events from an HTML document)
+       ...
+  -->
+
+  <!-- This is the usual SAX parser -->
+  <role name="org.apache.excalibur.xml.sax.SAXParser"
+        shorthand="xml-parser"
+        default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
+
+  <!-- This is the usual DOM parser -->
+  <role name="org.apache.excalibur.xml.dom.DOMParser"
+        shorthand="dom-parser"
+        default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
+
+  <!-- A Dom Serializer -->
+  <role default-class="org.apache.excalibur.xml.dom.DefaultDOMSerializer" name="org.apache.excalibur.xml.dom.DOMSerializer" shorthand="dom-serializer"/>
+
+  <!-- XSLT: -->
+  <role name="org.apache.excalibur.xml.xslt.XSLTProcessor"
+        shorthand="xslt-processor"
+        default-class="org.apache.cocoon.components.xslt.TraxProcessor"/>
+
+  <role name="org.apache.excalibur.xml.xpath.XPathProcessor"
+        shorthand="xpath-processor"
+        default-class="org.apache.excalibur.xml.xpath.XPathProcessorImpl"/>
+
+  <!-- Stores: -->
+  <role name="org.apache.excalibur.store.Store"
+       shorthand="store"
+       default-class="org.apache.cocoon.components.store.impl.EHDefaultStore"/>
+
+  <role name="org.apache.excalibur.store.Store/TransientStore"
+        shorthand="transient-store"
+        default-class="org.apache.cocoon.components.store.impl.DefaultTransientStore"/>
+
+<!--
+  The persistent store is only an auxiliary store that shouldn't be
+  used by Cocoon users. It should only be used - if required - by
+  the Store. If we use JCS, we don't need a persistent store.
+  <role name="org.apache.excalibur.store.Store/PersistentStore"
+        shorthand="persistent-store"
+        default-class="org.apache.cocoon.components.store.impl.DefaultPersistentStore"/>
+-->
+  <!-- Normally uses the org.apache.excalibur.store.impl.StoreJanitorImpl as
+       the default-class but as that uses its own Thread spawning there is
+       the org.apache.cocoon.components.store.impl.CocoonStoreJanitor class
+       to use a daemon thread from the org.apache.cocoon.components.thread.RunnableManager
+       component 
+       NOT: As soon as our patch has been accepted by the Excalibur community and an
+            excalibur-store has been release we can switch back to the original 
+            org.apache.excalibur.store.impl.StoreJanitorImpl class
+  -->
+  <role name="org.apache.excalibur.store.StoreJanitor"
+       shorthand="store-janitor"
+       default-class="org.apache.cocoon.components.store.impl.CocoonStoreJanitor"/>
+
+  <!--=========================================================================
+       Sitemap engine
+      =========================================================================-->
+
+  <!-- the sitemap engine -->
+  <role name="org.apache.cocoon.Processor"
+        shorthand="sitemap"
+        default-class="org.apache.cocoon.components.treeprocessor.TreeProcessor"/>
+  
+  <!-- the tree builder for the sitemap language (additional implementations can be added here
+       or in cocoon.xconf for other implementations) -->
+  <role name="org.apache.cocoon.components.treeprocessor.TreeBuilder/sitemap-1.0"
+        default-class="org.apache.cocoon.components.treeprocessor.sitemap.SitemapLanguage"/>
+
+  <!-- the various elements of map:components -->
+  <role name="org.apache.cocoon.components.pipeline.ProcessingPipelineSelector"
+        shorthand="pipes"
+        default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
+
+  <role name="org.apache.cocoon.acting.ActionSelector"
+        shorthand="actions"
+        default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
+      
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        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.cocoon.reading.ReaderSelector"
+        shorthand="readers"
+        default-class="org.apache.cocoon.components.treeprocessor.sitemap.ComponentsSelector"/>
+          
+  <role name="org.apache.cocoon.components.notification.NotifyingBuilder"
+        shorthand="notifying-builder"
+        default-class="org.apache.cocoon.components.notification.DefaultNotifyingBuilder"
+        model="non-thread-safe-pooled"/>  
+
+  <!-- system-defined sitemap components -->
+  <role name="org.apache.cocoon.generation.Generator/&lt;notifier&gt;"
+        default-class="org.apache.cocoon.generation.NotifyingGenerator"
+        model="non-thread-safe-pooled"/>
+        
+  <role name="org.apache.cocoon.generation.Generator/&lt;aggregator&gt;"
+        default-class="org.apache.cocoon.sitemap.DefaultContentAggregator"
+        model="non-thread-safe-pooled"/>
+
+  <role name="org.apache.cocoon.transformation.Transformer/&lt;translator&gt;"
+        default-class="org.apache.cocoon.sitemap.LinkTranslator"
+        model="non-thread-safe-pooled"/>
+
+  <role name="org.apache.cocoon.transformation.Transformer/&lt;gatherer&gt;"
+        default-class="org.apache.cocoon.sitemap.LinkGatherer"
+        model="non-thread-safe-pooled"/>
+	
+  <!--=========================================================================-->
+  
+  <role name="org.apache.cocoon.components.fam.SitemapMonitor"
+        shorthand="fam"
+        default-class="org.apache.cocoon.components.fam.SitemapMonitorImpl"/>
+        
+  <role name="org.apache.cocoon.components.image.ImageEncoderSelector"
+        shorthand="image-encoder"/>
+
+  <role name="org.apache.excalibur.xmlizer.XMLizer"
+        shorthand="xmlizer"
+        default-class="org.apache.excalibur.xmlizer.DefaultXMLizer"/>
+
+  <role name="org.apache.cocoon.components.sax.XMLSerializer"
+        shorthand="xml-serializer"
+        default-class="org.apache.cocoon.components.sax.XMLByteStreamCompiler"/>
+
+  <role name="org.apache.cocoon.components.sax.XMLDeserializer"
+        shorthand="xml-deserializer"
+        default-class="org.apache.cocoon.components.sax.XMLByteStreamInterpreter"/>
+
+  <role name="org.apache.cocoon.components.notification.NotifyingBuilder"
+        shorthand="notifying-builder"
+        default-class="org.apache.cocoon.components.notification.DefaultNotifyingBuilder"/>
+
+  <role name="org.apache.cocoon.caching.Cache"
+        shorthand="cache"
+        default-class="org.apache.cocoon.caching.impl.CacheImpl"/>
+
+  <!-- i18n components for resource bundle handling -->
+  <role name="org.apache.cocoon.i18n.BundleFactory"
+        shorthand="i18n-bundles"
+        default-class="org.apache.cocoon.i18n.XMLResourceBundleFactory"/>
+
+  <!-- Control flow layer: the interpreters selector and continuations  manager -->
+  <role name="org.apache.cocoon.components.flow.InterpreterSelector" 
+        shorthand="flow-interpreters"
+        default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+
+  <role name="org.apache.cocoon.components.flow.ContinuationsManager"
+        shorthand="continuations-manager"
+        default-class="org.apache.cocoon.components.flow.ContinuationsManagerImpl" />
+
+  <!-- input/output modules -->
+  <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.modules.output.OutputModuleSelector"
+        shorthand="output-modules"
+        default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+
+  <role name="org.apache.cocoon.components.modules.input.SitemapVariableHolder"
+        shorthand="global-variables"
+        default-class="org.apache.cocoon.components.modules.input.SitemapVariableHolder"/>
+
+  <!-- Storing data in the current request -->
+  <role name="org.apache.cocoon.components.persistence.RequestDataStore"
+        shorthand="request-data-store"
+        default-class="org.apache.cocoon.components.persistence.RequestDataStoreImpl"/>
+  
+  <!-- Running commands (Runnable) in background -->
+  <role name="org.apache.cocoon.components.thread.RunnableManager"
+        shorthand="runnable-manager"
+        default-class="org.apache.cocoon.components.thread.DefaultRunnableManager"/>
+
+</role-list>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ChainedConfiguration.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ChainedConfiguration.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ChainedConfiguration.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ChainedConfiguration.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,280 @@
+/*
+ * 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;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+/**
+ * This configuration object is used for {@link SitemapConfigurable} 
+ * components. It 'extends' {@link Configuration} by a parent.
+ * 
+ * @since 2.1
+ * 
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: ChainedConfiguration.java 278691 2005-09-05 08:25:57Z cziegeler $
+ */
+public final class ChainedConfiguration implements Configuration {
+
+    private Configuration wrappedConfiguration;
+    
+    private ChainedConfiguration parentConfiguration;
+    
+    /**
+     * Constructor
+     */
+    public ChainedConfiguration(Configuration wrapped,
+                                 ChainedConfiguration parent) {
+        this.wrappedConfiguration = wrapped;
+        this.parentConfiguration = parent;
+    }
+    
+    /** 
+     * Get the parent configuration
+     * @return the parent configuration or null.
+     */
+    public ChainedConfiguration getParent() {
+        return this.parentConfiguration;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttribute(java.lang.String, java.lang.String)
+     */
+    public String getAttribute(String arg0, String arg1) {
+        return this.wrappedConfiguration.getAttribute(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttribute(java.lang.String)
+     */
+    public String getAttribute(String arg0) throws ConfigurationException {
+        return this.wrappedConfiguration.getAttribute(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsBoolean(java.lang.String, boolean)
+     */
+    public boolean getAttributeAsBoolean(String arg0, boolean arg1) {
+        return this.wrappedConfiguration.getAttributeAsBoolean(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsBoolean(java.lang.String)
+     */
+    public boolean getAttributeAsBoolean(String arg0)
+        throws ConfigurationException {
+        return this.wrappedConfiguration.getAttributeAsBoolean(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsFloat(java.lang.String, float)
+     */
+    public float getAttributeAsFloat(String arg0, float arg1) {
+        return this.wrappedConfiguration.getAttributeAsFloat(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsFloat(java.lang.String)
+     */
+    public float getAttributeAsFloat(String arg0)
+        throws ConfigurationException {
+        return this.wrappedConfiguration.getAttributeAsFloat(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsInteger(java.lang.String, int)
+     */
+    public int getAttributeAsInteger(String arg0, int arg1) {
+        return this.wrappedConfiguration.getAttributeAsInteger(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsInteger(java.lang.String)
+     */
+    public int getAttributeAsInteger(String arg0)
+        throws ConfigurationException {
+        return this.wrappedConfiguration.getAttributeAsInteger(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsLong(java.lang.String, long)
+     */
+    public long getAttributeAsLong(String arg0, long arg1) {
+        return this.wrappedConfiguration.getAttributeAsLong(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsLong(java.lang.String)
+     */
+    public long getAttributeAsLong(String arg0) throws ConfigurationException {
+        return this.wrappedConfiguration.getAttributeAsLong(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeNames()
+     */
+    public String[] getAttributeNames() {
+        return this.wrappedConfiguration.getAttributeNames();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getChild(java.lang.String, boolean)
+     */
+    public Configuration getChild(String arg0, boolean arg1) {
+        return this.wrappedConfiguration.getChild(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getChild(java.lang.String)
+     */
+    public Configuration getChild(String arg0) {
+        return this.wrappedConfiguration.getChild(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getChildren()
+     */
+    public Configuration[] getChildren() {
+        return this.wrappedConfiguration.getChildren();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getChildren(java.lang.String)
+     */
+    public Configuration[] getChildren(String arg0) {
+        return this.wrappedConfiguration.getChildren(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getLocation()
+     */
+    public String getLocation() {
+        return this.wrappedConfiguration.getLocation();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getName()
+     */
+    public String getName() {
+        return this.wrappedConfiguration.getName();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getNamespace()
+     */
+    public String getNamespace() throws ConfigurationException {
+        return this.wrappedConfiguration.getNamespace();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValue()
+     */
+    public String getValue() throws ConfigurationException {
+        return this.wrappedConfiguration.getValue();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValue(java.lang.String)
+     */
+    public String getValue(String arg0) {
+        return this.wrappedConfiguration.getValue(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsBoolean()
+     */
+    public boolean getValueAsBoolean() throws ConfigurationException {
+        return this.wrappedConfiguration.getValueAsBoolean();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsBoolean(boolean)
+     */
+    public boolean getValueAsBoolean(boolean arg0) {
+        return this.wrappedConfiguration.getValueAsBoolean(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsFloat()
+     */
+    public float getValueAsFloat() throws ConfigurationException {
+        return this.wrappedConfiguration.getValueAsFloat();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsFloat(float)
+     */
+    public float getValueAsFloat(float arg0) {
+        return this.wrappedConfiguration.getValueAsFloat(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsInteger()
+     */
+    public int getValueAsInteger() throws ConfigurationException {
+        return this.wrappedConfiguration.getValueAsInteger();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsInteger(int)
+     */
+    public int getValueAsInteger(int arg0) {
+        return this.wrappedConfiguration.getValueAsInteger(arg0);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsLong()
+     */
+    public long getValueAsLong() throws ConfigurationException {
+        return this.wrappedConfiguration.getValueAsLong();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsLong(long)
+     */
+    public long getValueAsLong(long arg0) {
+        return this.wrappedConfiguration.getValueAsLong(arg0);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsDouble(java.lang.String, double)
+     */
+    public double getAttributeAsDouble(String arg0, double arg1) {
+        return this.wrappedConfiguration.getAttributeAsDouble(arg0, arg1);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configuration#getAttributeAsDouble(java.lang.String)
+     */
+    public double getAttributeAsDouble(String arg0) throws ConfigurationException {
+        return this.wrappedConfiguration.getAttributeAsDouble(arg0);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsDouble()
+     */
+    public double getValueAsDouble() throws ConfigurationException {
+        return this.wrappedConfiguration.getValueAsDouble();
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configuration#getValueAsDouble(double)
+     */
+    public double getValueAsDouble(double arg0) {
+        return this.wrappedConfiguration.getValueAsDouble(arg0);
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ChainedConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ComponentInfo.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ComponentInfo.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ComponentInfo.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ComponentInfo.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,207 @@
+/*
+ * Copyright 1999-2005 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;
+
+import org.apache.avalon.framework.configuration.Configuration;
+
+/**
+ * Meta-information about a service
+ *  
+ * @version CVS $Id: ComponentInfo.java 312861 2005-10-11 11:46:08Z cziegeler $
+ */
+public final class ComponentInfo {
+
+    public static final int MODEL_UNKNOWN   = -1;
+    public static final int MODEL_PRIMITIVE = 0;
+    public static final int MODEL_SINGLETON = 1;
+    public static final int MODEL_POOLED    = 2;
+    public static final int MODEL_NON_THREAD_SAFE_POOLED = 3;
+
+    public static final String TYPE_SINGLETON = "singleton";
+    public static final String TYPE_POOLED = "pooled";
+    public static final String TYPE_NON_THREAD_SAFE_POOLED = "non-thread-safe-pooled";
+
+    private int model;
+    private String initMethodName;
+    private String destroyMethodName;
+    private String poolInMethodName;
+    private String poolOutMethodName;
+    private String serviceClassName;
+    private Configuration configuration;
+    private String loggerCategory;
+
+    public ComponentInfo() {
+        this.model = MODEL_PRIMITIVE;
+    }
+
+    /**
+     * @return Returns the model.
+     */
+    public int getModel() {
+        return model;
+    }
+
+    /**
+     * @param model The model to set.
+     */
+    public void setModel(int model) {
+        this.model = model;
+    }
+
+    /**
+     * @return Returns the destroyMethod.
+     */
+    public String getDestroyMethodName() {
+        return destroyMethodName;
+    }
+
+    /**
+     * @param destroyMethod The destroyMethod to set.
+     */
+    public void setDestroyMethodName(String destroyMethod) {
+        this.destroyMethodName = destroyMethod;
+    }
+
+    /**
+     * @return Returns the initMethod.
+     */
+    public String getInitMethodName() {
+        return initMethodName;
+    }
+
+    /**
+     * @param initMethod The initMethod to set.
+     */
+    public void setInitMethodName(String initMethod) {
+        this.initMethodName = initMethod;
+    }
+
+    /**
+     * @return Returns the poolInMethodName
+     */
+    public String getPoolInMethodName() {
+        return this.poolInMethodName;
+    }
+
+    /**
+     * @param poolMethod The poolInMethod name to set.
+     */
+    public void setPoolInMethodName(String poolMethod) {
+        this.poolInMethodName = poolMethod;
+    }
+
+    /**
+     * @return Returns the poolOutMethodName
+     */
+    public String getPoolOutMethodName() {
+        return this.poolOutMethodName;
+    }
+
+    /**
+     * @param poolMethod The poolOutMethod name to set.
+     */
+    public void setPoolOutMethodName(String poolMethod) {
+        this.poolOutMethodName = poolMethod;
+    }
+
+    /**
+     * @return Returns the serviceClassName.
+     */
+    public String getServiceClassName() {
+        return serviceClassName;
+    }
+
+    /**
+     * @param serviceClassName The serviceClassName to set.
+     */
+    public void setServiceClassName(String serviceClassName) {
+        this.serviceClassName = serviceClassName;
+    }
+
+    /**
+     * @return Returns the configuration.
+     */
+    public Configuration getConfiguration() {
+        return configuration;
+    }
+
+    /**
+     * @param configuration The configuration to set.
+     */
+    public void setConfiguration(Configuration configuration) {
+        this.configuration = configuration;
+    }
+
+    public String getLocation() {
+        return this.configuration.getLocation();
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString() {
+        return "ServiceInfo: {class=" + this.getServiceClassName()+"}";
+    }
+
+    public void fill(Configuration attr) {
+        // test model
+        final String model = attr.getAttribute("model", null);
+        if ( TYPE_POOLED.equals(model) ) {
+            this.setModel(ComponentInfo.MODEL_POOLED);
+            this.setPoolInMethodName(attr.getAttribute("pool-in", null));
+            this.setPoolOutMethodName(attr.getAttribute("pool-out", null));
+        } else if (TYPE_NON_THREAD_SAFE_POOLED.equals(model)) {
+            this.setModel(ComponentInfo.MODEL_NON_THREAD_SAFE_POOLED);
+            this.setPoolInMethodName(attr.getAttribute("pool-in", null));
+            this.setPoolOutMethodName(attr.getAttribute("pool-out", null));
+        } else if ( TYPE_SINGLETON.equals(model) ) {
+            this.setModel(ComponentInfo.MODEL_SINGLETON);
+        }
+        // init/destroy methods
+        this.setInitMethodName(attr.getAttribute("init", null));
+        this.setDestroyMethodName(attr.getAttribute("destroy", null));
+        // logging
+        this.setLoggerCategory(attr.getAttribute("logger", null));
+    }
+
+    public ComponentInfo duplicate() {
+        ComponentInfo info = new ComponentInfo();
+        info.model = this.model;
+        info.initMethodName = this.initMethodName;
+        info.destroyMethodName = this.destroyMethodName;
+        info.poolInMethodName = this.poolInMethodName;
+        info.poolOutMethodName = this.poolOutMethodName;
+        info.serviceClassName = this.serviceClassName;
+        info.configuration = this.configuration;
+        info.loggerCategory = this.loggerCategory;
+
+        return info;
+    }
+
+    /**
+     * @return Returns the loggerCategory.
+     */
+    public String getLoggerCategory() {
+        return this.loggerCategory;
+    }
+
+    /**
+     * @param loggerCategory The loggerCategory to set.
+     */
+    public void setLoggerCategory(String loggerCategory) {
+        this.loggerCategory = loggerCategory;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ComponentInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,113 @@
+/*
+ * 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;
+
+import java.util.Map;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Response;
+
+/**
+ * A set of constants and methods to access the content of the context
+ * object. Some of the constants are defined in {@link org.apache.cocoon.Constants}.
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: ContextHelper.java 292486 2005-09-29 17:32:59Z bloritsch $
+ */
+
+public final class ContextHelper {
+		
+    /** Application <code>Context</code> Key for the current object model */
+    public static final String CONTEXT_OBJECT_MODEL = "object-model";
+
+    /** Application <code>Context</code> Key for the current request object */
+    public static final String CONTEXT_REQUEST_OBJECT = CONTEXT_OBJECT_MODEL + '.' + ObjectModelHelper.REQUEST_OBJECT;
+
+    /** Application <code>Context</code> Key for the current response object */
+    public static final String CONTEXT_RESPONSE_OBJECT = CONTEXT_OBJECT_MODEL + '.' + ObjectModelHelper.RESPONSE_OBJECT;
+
+    /** Application <code>Context</code> Key for the current sitemap service manager */
+    public static final String CONTEXT_SITEMAP_SERVICE_MANAGER = "sitemap-service-manager";
+    
+    /** Application root directory (as a URL object) @since 2.2 */
+    public static final String CONTEXT_ROOT_URL = "context-root";
+    
+    private ContextHelper() {
+        // Forbid instantiation
+    }
+
+    /**
+     * Return the current request
+     * @param context The component context
+     * @return The request object
+     */
+    public static final Request getRequest(Context context) {
+        // the request object is always present
+        try {
+            return (Request)context.get(CONTEXT_REQUEST_OBJECT);
+        } catch (ContextException ce) {
+            throw new ContextResourceNotFoundException("Unable to get the request object from the context.", ce);
+        }
+    }
+
+    /**
+     * Return the current response
+     * @param context The component context
+     * @return The response
+     */
+    public static final Response getResponse(Context context) {
+        // the response object is always present
+        try {
+            return (Response)context.get(CONTEXT_RESPONSE_OBJECT);
+        } catch (ContextException ce) {
+            throw new ContextResourceNotFoundException("Unable to get the response object from the context.", ce);
+        }
+    }
+
+    /**
+     * Return the current object model
+     * @param context The component context
+     * @return The object model
+     */
+    public static final Map getObjectModel(Context context) {
+        // the object model is always present
+        try {
+            return (Map)context.get(CONTEXT_OBJECT_MODEL);
+        } catch (ContextException ce) {
+            throw new ContextResourceNotFoundException("Unable to get the object model from the context.", ce);
+        }
+    }
+    
+    /**
+     * Return the current sitemap service manager
+     * @param context The component context
+     * @return The sitemap manager if currently a request is processed
+     * @since 2.2
+     */
+    public static final ServiceManager getSitemapServiceManager(Context context) {
+        // the service manager is always present
+        try {
+            return (ServiceManager)context.get(CONTEXT_SITEMAP_SERVICE_MANAGER);
+        } catch (ContextException ce) {
+            throw new ContextResourceNotFoundException("Unable to get the service manager from the context.", ce);
+        }        
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextResourceNotFoundException.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextResourceNotFoundException.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextResourceNotFoundException.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextResourceNotFoundException.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 1999-2005 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;
+
+import org.apache.avalon.framework.CascadingRuntimeException;
+
+/**
+ * The exception thrown when the ContextHelper can't find the necessary
+ * resource.
+ */
+public final class ContextResourceNotFoundException extends CascadingRuntimeException
+{
+    public ContextResourceNotFoundException(String message)
+    {
+        super(message, null);
+    }
+
+    public ContextResourceNotFoundException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/ContextResourceNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,196 @@
+/*
+ * 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;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.activity.Startable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+
+/**
+ * Utility class for setting up Avalon components. Similar to Excalibur's
+ * <code>DefaultComponentFactory</code>, but on existing objects.
+ * <p>
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: LifecycleHelper.java 160568 2005-04-08 17:33:05Z sylvain $
+ */
+public class LifecycleHelper {
+
+    /** The Logger for the component
+     */
+    final private Logger logger;
+
+    /** The Context for the component
+     */
+    final private Context context;
+
+    /** The service manager for this component.
+     */
+    final private ServiceManager serviceManager;
+
+    /** The configuration for this component.
+     */
+    final private Configuration configuration;
+
+    /**
+     * Construct a new <code>LifecycleHelper</code> that can be used repeatedly to
+     * setup several components. 
+     * <p>
+     * <b>Note</b> : if a parameter is <code>null</code>,
+     * the corresponding method isn't called (e.g. if <code>configuration</code> is
+     * <code>null</code>, <code>configure()</code> isn't called).
+     *
+     * @param logger the <code>Logger</code> to pass to <code>LogEnabled</code>s, unless there is
+     *        a <code>LogKitManager</code> and the configuration specifies a logger name.
+     * @param context the <code>Context</code> to pass to <code>Contexutalizable</code>s.
+     * @param serviceManager the service manager to pass to <code>Serviceable</code>s.
+     * @param configuration the <code>Configuration</code> object to pass to new instances.
+     */
+    public LifecycleHelper(final Logger logger,
+                           final Context context,
+                           final ServiceManager serviceManager,
+                           final Configuration configuration) {
+        this.logger = logger;
+        this.context = context;
+        this.serviceManager = serviceManager;
+        this.configuration = configuration;
+    }
+
+
+    /**
+     * Setup a component, including initialization and start.
+     *
+     * @param component the component to setup.
+     * @return the component passed in, to allow function chaining.
+     * @throws Exception if something went wrong.
+     */
+    public Object setupComponent(Object component) throws Exception {
+        return setupComponent(component, true);
+    }
+
+    /**
+     * Setup a component, and optionnaly initializes (if it's <code>Initializable</code>)
+     * and starts it (if it's <code>Startable</code>).
+     *
+     * @param component the component to setup.
+     * @param initializeAndStart if true, <code>intialize()</code> and <code>start()</code>
+     *        will be called.
+     * @return the component passed in, to allow function chaining.
+     * @throws Exception if something went wrong.
+     */
+    public Object setupComponent(Object component, boolean initializeAndStart)
+    throws Exception {
+        return setupComponent(
+            component,
+            this.logger,
+            this.context,
+            this.serviceManager,
+            this.configuration,
+            initializeAndStart);
+    }
+
+    /**
+     * Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger.
+     */
+    public static Object setupComponent(final Object component,
+                                         final Logger logger,
+                                         final Context context,
+                                         final ServiceManager serviceManager,
+                                        final Configuration configuration)
+    throws Exception {
+        return setupComponent(
+            component,
+            logger,
+            context,
+            serviceManager,
+            configuration,
+            true);
+    }
+
+    /**
+     * Alternative setupComponent method that takes a ServiceManager instead of a ComponentManger.
+     */
+    public static Object setupComponent(final Object component,
+                                        final Logger logger,
+                                        final Context context,
+                                        final ServiceManager serviceManager,
+                                        final Configuration configuration,
+                                        final boolean initializeAndStart)
+    throws Exception {
+        if (component instanceof LogEnabled) {
+            ((LogEnabled) component).enableLogging(logger);
+        }
+
+        if (null != context && component instanceof Contextualizable) {
+            ((Contextualizable) component).contextualize(context);
+        }
+
+        if (null != serviceManager && component instanceof Serviceable) {
+            ((Serviceable) component).service(serviceManager);
+        } 
+        
+        if (null != configuration && component instanceof Configurable) {
+            ((Configurable) component).configure(configuration);
+        }
+
+        if (null != configuration && component instanceof Parameterizable) {
+            ((Parameterizable) component).parameterize(
+                Parameters.fromConfiguration(configuration));
+        }
+
+        if (initializeAndStart && component instanceof Initializable) {
+            ((Initializable) component).initialize();
+        }
+
+        if (initializeAndStart && component instanceof Startable) {
+            ((Startable) component).start();
+        }
+
+        return component;
+    }
+
+    /**
+     * Decomission a component, by stopping (if it's <code>Startable</code>) and
+     * disposing (if it's <code>Disposable</code>) a component.
+     */
+    public static final void decommission(final Object component)
+    throws Exception {
+        if (component instanceof Startable) {
+            ((Startable) component).stop();
+        }
+
+        dispose(component);
+    }
+
+    /**
+     * Dispose a component if it's <code>Disposable</code>. Otherwhise, do nothing.
+     */
+    public static final void dispose(final Object component) {
+        if (component instanceof Disposable) {
+            ((Disposable) component).dispose();
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/Preloadable.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/Preloadable.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/Preloadable.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/Preloadable.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * Marker interface for Avalon-managed components that need to be loaded at startup time.
+ * <p>
+ * Components implementing this interface will always be initialized when the service manager that
+ * holds them is created, even if lazy-loading of components is enabled.
+ * <p>
+ * Note that there are also other ways to require a component to be loaded at startup:
+ * <ul>
+ * <li>by implementing the <code>Startable</code> Avalon interface, which defines two additional
+ *     <code>start()</code> and <code>stop()</code> methods</li>
+ * <li>by adding the <code>preload="true"</code> attribute on a component's configuration</li>
+ * </ul>
+ * 
+ * @since 2.2
+ * @version $Id: Preloadable.java 326062 2005-10-18 09:31:53Z sylvain $
+ */
+public interface Preloadable {
+    // nothing, it's just a marker
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/Preloadable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurable.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurable.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurable.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurable.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+/**
+ * Objects implementing this marker interface can get a configuration
+ * from the map:pipelines section of the sitemap when they are created.
+ * Due to a problem in the component handling the
+ * {@link #configure(SitemapConfigurationHolder)} method is actually called
+ * each time the component is looked up!
+ *
+ * @since 2.1
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: SitemapConfigurable.java 55257 2004-10-21 20:36:33Z cziegeler $
+ */
+public interface SitemapConfigurable {
+
+    /**
+     * Set the <code>Configuration</code>.
+     */
+    void configure(SitemapConfigurationHolder holder)
+    throws ConfigurationException;
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurationHolder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurationHolder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurationHolder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurationHolder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+/**
+ * A {@link SitemapConfigurable} component gets the sitemap configuration
+ * using this object.
+ * 
+ * @since 2.1
+ * 
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: SitemapConfigurationHolder.java 55257 2004-10-21 20:36:33Z cziegeler $
+ */
+public interface SitemapConfigurationHolder {
+
+    /**
+     * Get the  configuration for the current sitemap
+     * @return The configuration
+     */
+    ChainedConfiguration getConfiguration();
+    
+    /**
+     * Get the prepared configuration for the current sitemap
+     * @return The configuration or null if no prepared is available
+     */
+    Object getPreparedConfiguration();
+    
+    /**
+     * Set the prepared configuration for the current sitemap.
+     * After it is set by a component, it can be get using
+     * {@link #getPreparedConfiguration()}.
+     * 
+     * @param preparedConfig The prepared configuration
+     */
+    void setPreparedConfiguration(ChainedConfiguration configuration, Object preparedConfig);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/SitemapConfigurationHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/Block.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/Block.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/Block.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/Block.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 1999-2005 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.blocks;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.cocoon.Processor;
+
+/**
+ * @version SVN $Id: Block.java 306543 2005-10-06 06:23:36Z danielf $
+ */
+public interface Block extends Processor { 
+
+    public static String NAME = Block.class.getName() + "-name";
+    public static String SUPER = "super";
+
+    /**
+     * Get the mount path of the block
+     */
+    public String getMountPath();
+
+    /**
+     * Get a block property
+     */
+    public String getProperty(String name);
+
+    // TODO: We should have a reflection friendly Map getProperties() also
+
+    /**
+     * Takes the scheme specific part of a block URI (the scheme is
+     * the responsibilty of the BlockSource) and resolve it with
+     * respect to the blocks mount point.
+     */
+    public URI absolutizeURI(URI uriToResolve, URI base) throws URISyntaxException;
+
+    /**
+     * Parses and resolves the scheme specific part of a block URI
+     * with respect to the base URI of the current sitemap. The scheme
+     * specific part of the block URI has the form
+     * <code>foo:/bar</code> when refering to another block, in this
+     * case only an absolute path is allowed. For reference to the own
+     * block, both absolute <code>/bar</code> and relative
+     * <code>./foo</code> paths are allowed.
+     */
+    public URI resolveURI(URI uriToResolve, URI base) throws URISyntaxException;
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/Block.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockContext.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockContext.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockContext.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockContext.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,127 @@
+/*
+ * Copyright 1999-2005 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.blocks;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.cocoon.environment.impl.AbstractContext;
+
+/**
+* @version SVN $Id: BlockContext.java 327850 2005-10-23 20:10:10Z danielf $
+*/
+public class BlockContext extends AbstractContext {
+
+    private Hashtable attributes;
+    private BlockWiring wiring;
+    
+    public BlockContext(BlockWiring wiring) {
+        this.wiring = wiring;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return this.attributes.get(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object value) {
+        this.attributes.put(name, value);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#getAttributes()
+     */
+    public Map getAttributes() {
+        return this.attributes;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name) {
+        this.attributes.remove(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#getAttributeNames()
+     */
+    public Enumeration getAttributeNames() {
+        return this.attributes.keys();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#getResource(java.lang.String)
+     */
+    public URL getResource(String path) throws MalformedURLException {
+        String contextURL = this.wiring.getContextURL().toExternalForm();
+        URL resolvedURL = null;
+        try {
+            resolvedURL = ((new URI(contextURL)).resolve(path)).toURL();
+        } catch (URISyntaxException e) {
+            throw new MalformedURLException("Couldn't resolve " + path + " relative " + contextURL +
+                    " error " + e.getMessage());
+        }
+        return resolvedURL;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#getRealPath(java.lang.String)
+     */
+    public String getRealPath(String path) {
+        // We better don't assume that blocks are unpacked
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#getMimeType(java.lang.String)
+     */
+    public String getMimeType(String file) {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#getInitParameter(java.lang.String)
+     */
+    public String getInitParameter(String name) {
+        return this.wiring.getProperty(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Context#getResourceAsStream(java.lang.String)
+     */
+    public InputStream getResourceAsStream(String path) {
+        try {
+            return this.getResource(path).openStream();
+        } catch (IOException e) {
+            // FIXME Error handling
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockManager.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockManager.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockManager.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockManager.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,351 @@
+/*
+ * Copyright 1999-2005 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.blocks;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+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.configuration.DefaultConfiguration;
+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.logger.AbstractLogEnabled;
+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.ContextHelper;
+import org.apache.cocoon.components.LifecycleHelper;
+import org.apache.cocoon.components.container.ComponentContext;
+import org.apache.cocoon.core.container.CoreServiceManager;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+
+/**
+ * @version SVN $Id: BlockManager.java 327987 2005-10-24 07:15:56Z cziegeler $
+ */
+public class BlockManager
+    extends AbstractLogEnabled
+    implements Block, Configurable, Contextualizable, Disposable, Initializable, Serviceable { 
+
+    public static String ROLE = BlockManager.class.getName();
+
+    private Context context;
+    private Configuration config;
+    private ServiceManager parentServiceManager;
+    private ServiceManager serviceManager;
+
+    private Processor blockProcessor;
+    private BlockWiring blockContext;
+
+    // Life cycle
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.parentServiceManager = manager;
+    }
+
+    public void contextualize(Context context) throws ContextException {
+        this.context = context;
+    }
+
+    public void configure(Configuration config)
+        throws ConfigurationException {
+        this.config = config;
+    }
+
+    public void initialize() throws Exception {
+        this.blockContext = new BlockWiring();
+        LifecycleHelper.setupComponent(this.blockContext,
+                                       this.getLogger(),
+                                       this.context,
+                                       this.parentServiceManager,
+                                       this.config);    
+
+        getLogger().debug("Initializing new Block Manager: " + this.blockContext.getId());
+
+        ComponentContext newContext = new ComponentContext(context);
+        // A block is supposed to be an isolated unit so it should not have
+        // any direct access to the global root context
+        newContext.put(ContextHelper.CONTEXT_ROOT_URL, new URL(this.blockContext.getContextURL().toExternalForm()));
+        newContext.makeReadOnly();
+
+        // Create block a service manager with the exposed components of the block
+        if (this.blockContext.getComponentConfiguration() != null) {
+            // The source resolver must be defined in this service
+            // manager, otherwise the root path will be the one from the
+            // parent manager, we add a resolver to get it right. If the
+            // components section contain includes the CoreComponentManager
+            // use the location of the configuration an the parent SourceResolver
+            // for resolving the include.
+            String confLocation = this.blockContext.getContextURL() + "::";
+            DefaultConfiguration sourceManagerConf =
+                new DefaultConfiguration("components", confLocation);
+            DefaultConfiguration resolverConf =
+                new DefaultConfiguration("source-resolver");
+            sourceManagerConf.addChild(resolverConf);
+            ServiceManager sourceResolverSM =
+                new CoreServiceManager(this.parentServiceManager);
+            LifecycleHelper.setupComponent(
+                    sourceResolverSM,
+                    this.getLogger(),
+                    newContext,
+                    null,
+                    sourceManagerConf);
+            
+            DefaultConfiguration componentConf =
+                new DefaultConfiguration("components", confLocation);
+            componentConf.addAll(this.blockContext.getComponentConfiguration());
+            this.serviceManager = new CoreServiceManager(sourceResolverSM);
+            LifecycleHelper.setupComponent(this.serviceManager,
+                    this.getLogger(),
+                    newContext,
+                    null,
+                    componentConf);
+        } else {
+            this.serviceManager = this.parentServiceManager;
+        }
+
+        // Create a processor for the block
+        if (this.blockContext.getProcessorConfiguration() != null) {
+            this.blockProcessor = new BlockProcessor();
+            LifecycleHelper.setupComponent(this.blockProcessor,
+                    this.getLogger(),
+                    newContext,
+                    this.serviceManager,
+                    this.blockContext.getProcessorConfiguration());    
+            
+        }
+    }
+
+    public void dispose() {
+        this.parentServiceManager = null;
+    }
+
+    // Block methods
+
+    // The blocks manager should not be available within a block so I
+    // didn't want to make it part of the parent manager. But this is
+    // a little bit clumsy. Question is what components, if any, the
+    // blocks should have in common.
+    public void setBlocksManager(BlocksManager blocksManager) {
+        this.blockContext.setBlocksManager(blocksManager);
+    }
+
+    /**
+     * Get the mount path of the block
+     */
+    public String getMountPath() {
+        return this.blockContext.getMountPath();
+    }
+
+    /**
+     * Get a block property
+     */
+    public String getProperty(String name) {
+        return this.blockContext.getProperty(name);
+    }
+
+    // TODO: We should have a reflection friendly Map getProperties() also
+
+    /**
+     * Takes the scheme specific part of a block URI (the scheme is
+     * the responsibilty of the BlockSource) and resolve it with
+     * respect to the blocks mount point.
+     */
+    public URI absolutizeURI(URI uriToResolve, URI base) throws URISyntaxException {
+        URI uri = resolveURI(uriToResolve, base);
+        String blockName = uri.getScheme();
+        Block block = null;
+        if (blockName == null)
+            // this block
+            block = this;
+        else
+            // another block
+            block = this.blockContext.getBlock(blockName);
+        if (block == null)
+            throw new URISyntaxException(uriToResolve.toString(), "Unknown block name");
+
+        String mountPath = block.getMountPath();
+        if (mountPath == null)
+            throw new URISyntaxException(uri.toString(), "No mount point for this URI");
+        if (mountPath.endsWith("/"))
+            mountPath = mountPath.substring(0, mountPath.length() - 1);
+        String absoluteURI = mountPath + uri.getSchemeSpecificPart();
+        getLogger().debug("Resolving " + uri.toString() + " to " + absoluteURI);
+        return new URI(absoluteURI);
+    }
+
+    /**
+     * Parses and resolves the scheme specific part of a block URI
+     * with respect to the base URI of the current sitemap. The scheme
+     * specific part of the block URI has the form
+     * <code>foo:/bar</code> when refering to another block, in this
+     * case only an absolute path is allowed. For reference to the own
+     * block, both absolute <code>/bar</code> and relative
+     * <code>./foo</code> paths are allowed.
+     */
+    public URI resolveURI(URI uri, URI base) throws URISyntaxException {
+        getLogger().debug("BlockManager: resolving " + uri.toString() + " with scheme " +
+                          uri.getScheme() + " and ssp " + uri.getSchemeSpecificPart());
+        if (uri.getPath() != null && uri.getPath().length() >= 2 &&
+            uri.getPath().startsWith("./")) {
+            // self reference relative to the current sitemap, e.g. ./foo
+            if (uri.isAbsolute())
+                throw new URISyntaxException(uri.toString(), "When the protocol refers to other blocks the path must be absolute");
+            URI resolvedURI = base.resolve(uri);
+            getLogger().debug("BlockManager: resolving " + uri.toString() +
+                              " to " + resolvedURI.toString() + " with base URI " + base.toString());
+            uri = resolvedURI;
+        }
+        return uri;
+    }
+
+    // The Processor methods
+
+    public boolean process(Environment environment) throws Exception {
+        String blockName = (String)environment.getAttribute(Block.NAME);
+
+        if (blockName != null) {
+            // Request to other block.
+            if (BlockManager.SUPER.equals(blockName)) {
+                // Explicit call to super block
+                // The block name should not be used in the recieving block.
+                environment.removeAttribute(Block.NAME);
+                return this.process(Block.SUPER, environment, true);
+            } else {
+                // Call to named block
+                Block block = this.blockContext.getBlock(blockName);
+                if (block != null) {
+                    // The block name should not be used in the recieving block.
+                    environment.removeAttribute(Block.NAME);
+                    return this.process(blockName, environment);
+                } else {
+                    // If there is a super block, the connection might
+                    // be defined there instead.
+                    return this.process(Block.SUPER, environment, true);
+                }
+            }
+        } else {
+            // Request to the own block
+            boolean result = this.blockProcessor.process(environment);
+
+            return result;
+
+            // Pipelines seem to throw an exception instead of
+            // returning false when the pattern is not found. For the
+            // moment an explicit call of the super block is called in
+            // the end of the sitemap. It might be better to be
+            // explicit about it anyway.
+
+//             if (result) {
+//                 return true;
+//             } else if (this.superId != null) {
+//                 // Wasn't defined in the current block try super block
+//                 return this.process(this.superId, environment, true);
+//             } else {
+//                 return false;
+//             }
+        }
+    }
+
+    private boolean process(String blockName, Environment environment) throws Exception {
+        return this.process(blockName, environment, false);
+    }
+
+    private boolean process(String blockName, Environment environment, boolean superCall)
+        throws Exception {
+        Block block = this.blockContext.getBlock(blockName);
+        if (block == null) {
+            return false;
+        } else if (superCall) {
+            getLogger().debug("Enter processing in super block ");
+            try {
+                // A super block should be called in the context of
+                // the called block to get polymorphic calls resolved
+                // in the right way. Therefore no new current block is
+                // set.
+                return block.process(environment);
+            } finally {
+                getLogger().debug("Leaving processing in super block ");
+            }
+        } else {
+            getLogger().debug("Enter processing in block " + blockName);
+            try {
+                // It is important to set the current block each time
+                // a new block is entered, this is used for the block
+                // protocol
+                EnvironmentHelper.enterProcessor(block, null, environment);
+                return block.process(environment);
+            } finally {
+                EnvironmentHelper.leaveProcessor();
+                getLogger().debug("Leaving processing in block " + blockName);
+            }
+        }
+    }
+
+    // FIXME: Not consistently supported for blocks yet. Most of the
+    // code just use process.
+    public InternalPipelineDescription buildPipeline(Environment environment)
+        throws Exception {
+        return this.blockProcessor.buildPipeline(environment);
+    }
+
+    public Configuration[] getComponentConfigurations() {
+        return this.blockProcessor.getComponentConfigurations();
+    }
+
+    // A block is supposed to be an isolated unit so it should not have
+    // any direct access to the global root sitemap
+    public Processor getRootProcessor() {
+        return this.blockProcessor;
+    }
+    
+    public SourceResolver getSourceResolver() {
+        return this.blockProcessor.getSourceResolver();
+    }
+    
+    public String getContext() {
+        return this.blockProcessor.getContext();
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return this.blockProcessor.getAttribute(name);
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#removeAttribute(java.lang.String)
+     */
+    public Object removeAttribute(String name) {
+        return this.blockProcessor.removeAttribute(name);
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object value) {
+        this.blockProcessor.setAttribute(name, value);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockProcessor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockProcessor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockProcessor.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,193 @@
+/*
+ * Copyright 1999-2005 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.blocks;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+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.configuration.DefaultConfiguration;
+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.logger.AbstractLogEnabled;
+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.ContextHelper;
+import org.apache.cocoon.components.LifecycleHelper;
+import org.apache.cocoon.components.container.CocoonServiceManager;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+
+/**
+ * @version SVN $Id: BlockProcessor.java 325975 2005-10-17 20:10:59Z danielf $
+ */
+public class BlockProcessor
+    extends AbstractLogEnabled
+    implements Processor, Configurable, Contextualizable, Disposable, Initializable, Serviceable { 
+
+    private Context context;
+    private ServiceManager parentServiceManager;
+    private ServiceManager serviceManager;
+    private Configuration config;
+    private SourceResolver sourceResolver;
+    private Processor processor;
+    private EnvironmentHelper environmentHelper;
+
+    /** Processor attributes */
+    protected Map processorAttributes = new HashMap();
+
+    // Life cycle
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.parentServiceManager = manager;
+    }
+
+    public void contextualize(Context context) throws ContextException {
+        this.context = context;
+    }
+
+    public void configure(Configuration config)
+        throws ConfigurationException {
+        this.config = config;
+    }
+
+    public void initialize() throws Exception {
+        // Create an own service manager
+        this.serviceManager = new CocoonServiceManager(this.parentServiceManager);
+
+        String sitemapPath = this.config.getAttribute("src");
+
+        // Hack to put a sitemap configuration for the main sitemap of
+        // the block into the service manager
+        getLogger().debug("BlockProcessor: create sitemap " + sitemapPath);
+        DefaultConfiguration sitemapConf =
+            new DefaultConfiguration("sitemap", "BlockProcessor sitemap: " + " for " + sitemapPath);
+        sitemapConf.setAttribute("file", sitemapPath);
+        sitemapConf.setAttribute("check-reload", "yes");
+        // The source resolver must be defined in this service
+        // manager, otherwise the root path will be the one from the
+        // parent manager
+        DefaultConfiguration resolverConf =
+            new DefaultConfiguration("source-resolver", "BlockProcessor source resolver");
+        DefaultConfiguration conf =
+            new DefaultConfiguration("components", "BlockProcessor components");
+        conf.addChild(sitemapConf);
+        conf.addChild(resolverConf);
+
+        LifecycleHelper.setupComponent(this.serviceManager,
+                                       this.getLogger(),
+                                       this.context,
+                                       null,
+                                       conf);
+
+        this.sourceResolver = (SourceResolver)this.serviceManager.lookup(SourceResolver.ROLE);
+        final Processor processor = EnvironmentHelper.getCurrentProcessor();
+        if (processor != null) {
+            getLogger().debug("processor context" + processor.getContext());
+        }
+        Source sitemapSrc = this.sourceResolver.resolveURI(sitemapPath);
+        getLogger().debug("Sitemap Source " + sitemapSrc.getURI());
+        this.sourceResolver.release(sitemapSrc);
+
+        // Get the Processor and keep it
+        this.processor = (Processor)this.serviceManager.lookup(Processor.ROLE);
+
+        this.environmentHelper =
+            new EnvironmentHelper((URL)this.context.get(ContextHelper.CONTEXT_ROOT_URL));
+        LifecycleHelper.setupComponent(this.environmentHelper,
+                                       this.getLogger(),
+                                       null,
+                                       this.serviceManager,
+                                       null);
+    }
+
+    public void dispose() {
+        if (this.serviceManager != null) {
+            this.serviceManager.release(this.sourceResolver);
+            this.sourceResolver = null;
+            LifecycleHelper.dispose(this.serviceManager);
+            this.serviceManager = null;
+        }
+        if (this.environmentHelper != null) {
+            LifecycleHelper.dispose(this.environmentHelper);
+            this.environmentHelper = null;
+        }
+        this.parentServiceManager = null;
+    }
+
+    // The Processor methods
+
+    public boolean process(Environment environment) throws Exception {
+        return this.processor.process(environment);
+    }
+
+
+    // FIXME: Not consistently supported for blocks yet. Most of the
+    // code just use process.
+    public InternalPipelineDescription buildPipeline(Environment environment)
+        throws Exception {
+        return this.processor.buildPipeline(environment);
+    }
+
+    public Configuration[] getComponentConfigurations() {
+        return null;
+    }
+
+    // A block is supposed to be an isolated unit so it should not have
+    // any direct access to the global root sitemap
+    public Processor getRootProcessor() {
+        return this;
+    }
+    
+    public org.apache.cocoon.environment.SourceResolver getSourceResolver() {
+        return this.environmentHelper;
+    }
+    
+    public String getContext() {
+        return this.environmentHelper.getContext();
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name) {
+        return this.processorAttributes.get(name);
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#removeAttribute(java.lang.String)
+     */
+    public Object removeAttribute(String name) {
+        return this.processorAttributes.remove(name);
+    }
+
+    /**
+     * @see org.apache.cocoon.Processor#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object value) {
+        this.processorAttributes.put(name, value);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/blocks/BlockProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message