You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2005/10/20 17:09:37 UTC
svn commit: r326922 - in /cocoon/trunk/src:
java/org/apache/cocoon/components/blocks/
test/org/apache/cocoon/test/components/blocks/test1/
test/org/apache/cocoon/test/components/blocks/test1/COB-INF/
test/org/apache/cocoon/test/components/blocks/test1/...
Author: danielf
Date: Thu Oct 20 08:09:23 2005
New Revision: 326922
URL: http://svn.apache.org/viewcvs?rev=326922&view=rev
Log:
Started to add component handling to blocks. This far a block
just have an own component manager for block global
components. I tried to remove the component configurations
completely from the block test1, but the sitemap didn't find
what was the default component and the mime-type of the
serializer, no idea why.
Added:
cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/xconf/
cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/xconf/test1.xconf
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockContext.java
cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java
cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java
cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/block.xml
cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/block-sitemap.xmap
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockContext.java?rev=326922&r1=326921&r2=326922&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockContext.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockContext.java Thu Oct 20 08:09:23 2005
@@ -29,7 +29,6 @@
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.configuration.DefaultConfiguration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
@@ -115,7 +114,7 @@
(SourceResolver) this.serviceManager.lookup(SourceResolver.ROLE);
source = resolver.resolveURI(blockPath);
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- block = builder.build( source.getInputStream() );
+ block = builder.build(source.getInputStream(), source.getURI());
} catch (ServiceException e) {
String msg = "Exception while reading " + blockPath + ": " + e.getMessage();
throw new ConfigurationException(msg, e);
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java?rev=326922&r1=326921&r2=326922&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java Thu Oct 20 08:09:23 2005
@@ -24,6 +24,7 @@
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;
@@ -35,6 +36,7 @@
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;
@@ -51,6 +53,7 @@
private Context context;
private Configuration config;
private ServiceManager parentServiceManager;
+ private ServiceManager serviceManager;
private Processor blockProcessor;
private BlockContext blockContext;
@@ -85,14 +88,53 @@
// any direct access to the global root context
newContext.put(ContextHelper.CONTEXT_ROOT_URL, new URL(this.blockContext.getContextURL()));
newContext.makeReadOnly();
-
- this.blockProcessor = new BlockProcessor();
- LifecycleHelper.setupComponent(this.blockProcessor,
- this.getLogger(),
- newContext,
- this.parentServiceManager,
- this.blockContext.getProcessorConfiguration());
+ // 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() {
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java?rev=326922&r1=326921&r2=326922&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java Thu Oct 20 08:09:23 2005
@@ -84,7 +84,7 @@
try {
source = this.resolver.resolveURI(file);
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- wiring = builder.build( source.getInputStream() );
+ wiring = builder.build(source.getInputStream(), source.getURI());
} catch (SAXException se) {
String msg = "SAXException while reading " + file + ": " + se.getMessage();
throw new ConfigurationException(msg, se);
@@ -123,7 +123,7 @@
this.resolver.resolveURI(CORE_COMPONENTS_XCONF);
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
Configuration coreComponentsConf =
- builder.build(coreComponentsSource.getInputStream());
+ builder.build(coreComponentsSource.getInputStream(), coreComponentsSource.getURI());
LifecycleHelper.setupComponent(blockServiceManager,
this.getLogger(),
Modified: cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/block.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/block.xml?rev=326922&r1=326921&r2=326922&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/block.xml (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/block.xml Thu Oct 20 08:09:23 2005
@@ -28,6 +28,9 @@
implementation="stable"/>
<license href="http://www.apache.org/licenses/">Apache License 2.0</license>
<author href="http://cocoon.apache.org">Apache Cocoon community</author>
+ <components>
+ <include src="COB-INF/xconf/test1.xconf"/>
+ </components>
<sitemap src="block-sitemap.xmap"/>
<properties>
<property name="foo">
Added: cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/xconf/test1.xconf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/xconf/test1.xconf?rev=326922&view=auto
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/xconf/test1.xconf (added)
+++ cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/COB-INF/xconf/test1.xconf Thu Oct 20 08:09:23 2005
@@ -0,0 +1,48 @@
+<?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:components xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+ <source-factories>
+ <component-instance name="block" class="org.apache.cocoon.components.source.impl.BlockSourceFactory"/>
+ </source-factories>
+
+ <input-modules>
+ <component-instance name="block-path" class="org.apache.cocoon.components.modules.input.BlockPathModule" />
+ </input-modules>
+
+ <map:generators default="file">
+ <map:generator name="file" src="org.apache.cocoon.generation.FileGenerator"/>
+ </map:generators>
+
+ <map:transformers default="xslt">
+ <map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer"/>
+ </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:pipes>
+</map:components>
Modified: cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/block-sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/block-sitemap.xmap?rev=326922&r1=326921&r2=326922&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/block-sitemap.xmap (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/test1/block-sitemap.xmap Thu Oct 20 08:09:23 2005
@@ -23,35 +23,13 @@
<!--map:classpath>
<class-dir src="COB-INF/classes"/>
</map:classpath-->
-
- <source-factories>
- <component-instance class="org.apache.cocoon.components.source.impl.BlockSourceFactory" name="block"/>
- </source-factories>
-
- <input-modules>
- <component-instance name="block-path" class="org.apache.cocoon.components.modules.input.BlockPathModule"/>
- </input-modules>
-
- <map:generators default="file">
- <map:generator name="file" src="org.apache.cocoon.generation.FileGenerator"/>
- </map:generators>
-
- <map:transformers default="xslt">
- <map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer"/>
- </map:transformers>
-
+ <map:generators default="file"/>
+ <map:transformers default="xslt"/>
<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:matchers default="wildcard"/>
+ <map:pipes default="noncaching"/>
</map:components>
<map:pipelines>