Author: cziegeler
Date: Wed Oct 20 10:49:38 2004
New Revision: 55171
Modified:
cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java
cocoon/trunk/src/java/org/apache/cocoon/Processor.java
cocoon/trunk/src/java/org/apache/cocoon/ProcessorWrapper.java
cocoon/trunk/src/java/org/apache/cocoon/components/container/CocoonComponentManager.java
cocoon/trunk/src/java/org/apache/cocoon/components/container/DefaultSitemapConfigurationHolder.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
Log:
Tree processor doesn't need role manager anymore
Modified: cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/Cocoon.java Wed Oct 20 10:49:38 2004
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;
@@ -725,12 +724,11 @@
}
}
- /**
- * Get the sitemap component configurations
- * @since 2.1
+ /* (non-Javadoc)
+ * @see org.apache.cocoon.Processor#getComponentConfigurations()
*/
- public Map getComponentConfigurations() {
- return Collections.EMPTY_MAP;
+ public Configuration[] getComponentConfigurations() {
+ return null;
}
/**
Modified: cocoon/trunk/src/java/org/apache/cocoon/Processor.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/Processor.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/Processor.java Wed Oct 20
10:49:38 2004
@@ -15,9 +15,8 @@
*/
package org.apache.cocoon;
-import java.util.Map;
-
import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
@@ -29,7 +28,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* (Apache Software Foundation)
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Id: Processor.java,v 1.12 2004/07/17 10:51:15 joerg Exp $
+ * @version CVS $Id$
*/
public interface Processor extends Component {
@@ -89,9 +88,9 @@
/**
* Get the sitemap component configurations
- * @since 2.1
+ * @since 2.2
*/
- Map getComponentConfigurations();
+ Configuration[] getComponentConfigurations();
/**
* Get the root processor parent of this processor.
Modified: cocoon/trunk/src/java/org/apache/cocoon/ProcessorWrapper.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/ProcessorWrapper.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/ProcessorWrapper.java Wed Oct
20 10:49:38 2004
@@ -15,10 +15,9 @@
*/
package org.apache.cocoon;
-import java.util.Map;
-
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.SourceResolver;
@@ -27,7 +26,7 @@
* This class is a wrapper around the real processor (the <code>Cocoon</code>
class).
* It is necessary to avoid infinite dispose loops
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Id: ProcessorWrapper.java,v 1.6 2004/05/25 07:28:24 cziegeler
Exp $
+ * @version CVS $Id$
*/
public final class ProcessorWrapper
implements Processor, Component, Disposable, ThreadSafe {
@@ -64,7 +63,7 @@
/* (non-Javadoc)
* @see org.apache.cocoon.Processor#getComponentConfigurations()
*/
- public Map getComponentConfigurations() {
+ public Configuration[] getComponentConfigurations() {
return this.processor.getComponentConfigurations();
}
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/container/CocoonComponentManager.java
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/components/container/CocoonComponentManager.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/components/container/CocoonComponentManager.java
Wed Oct 20 10:49:38 2004
@@ -21,6 +21,7 @@
import java.util.Map;
import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
+import org.apache.avalon.excalibur.component.RoleManager;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
@@ -54,6 +55,9 @@
* our lifecycle. */
private ArrayList parentAwareComponents = new ArrayList();
+ /** The role manager */
+ private RoleManager roleManager;
+
/** Create the ComponentManager */
public CocoonComponentManager() {
super( null, Thread.currentThread().getContextClassLoader() );
@@ -100,7 +104,7 @@
holder =
(SitemapConfigurationHolder)this.sitemapConfigurationHolders.get( role );
if ( null == holder ) {
// create new holder
- holder = new DefaultSitemapConfigurationHolder( role );
+ holder = new DefaultSitemapConfigurationHolder( role,
this.roleManager );
this.sitemapConfigurationHolders.put( role, holder );
}
@@ -153,5 +157,14 @@
}
}
parentAwareComponents = null; // null to save memory, and catch logic
bugs.
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.apache.avalon.excalibur.component.RoleManageable#setRoleManager(org.apache.avalon.excalibur.component.RoleManager)
+ */
+ public void setRoleManager(RoleManager roleManager) {
+ this.roleManager = roleManager;
+ super.setRoleManager(roleManager);
}
}
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/container/DefaultSitemapConfigurationHolder.java
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/components/container/DefaultSitemapConfigurationHolder.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/components/container/DefaultSitemapConfigurationHolder.java
Wed Oct 20 10:49:38 2004
@@ -15,9 +15,12 @@
*/
package org.apache.cocoon.components.container;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import org.apache.avalon.excalibur.component.RoleManager;
+import org.apache.avalon.framework.configuration.Configuration;
import org.apache.cocoon.components.ChainedConfiguration;
import org.apache.cocoon.components.SitemapConfigurationHolder;
import org.apache.cocoon.environment.internal.EnvironmentHelper;
@@ -25,26 +28,64 @@
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Id: DefaultSitemapConfigurationHolder.java,v 1.1 2004/05/25
07:28:24 cziegeler Exp $
+ * @version CVS $Id$
*/
public final class DefaultSitemapConfigurationHolder
implements SitemapConfigurationHolder {
/** The role of the sitemap component */
- private String role;
+ private final String role;
+ /** The role manager */
+ private final RoleManager roleManager;
+
/** The prepared configurations indexed by the ChainedConfiguration */
private Map preparedConfigurations;
- public DefaultSitemapConfigurationHolder(String role) {
+ public DefaultSitemapConfigurationHolder(String role, RoleManager manager)
{
this.role = role;
+ this.roleManager = manager;
+ }
+
+ protected Map convert(Configuration[] configs, int index) {
+ Map sitemapComponentConfigurations;
+
+ // do we have configurations?
+ final Configuration[] childs = configs[index].getChildren();
+
+ if ( null != childs && childs.length > 0 ) {
+
+ if ( index == configs.length - 1 ) {
+ sitemapComponentConfigurations = new HashMap(12);
+ } else {
+ // copy all configurations from parent
+ sitemapComponentConfigurations = new
HashMap(this.convert(configs, index+1));
+ }
+
+ // and now check for new configurations
+ for(int m = 0; m < childs.length; m++) {
+
+ final String r =
this.roleManager.getRoleForName(childs[m].getName());
+ sitemapComponentConfigurations.put(r, new
ChainedConfiguration(childs[m],
+
(ChainedConfiguration)sitemapComponentConfigurations.get(r)));
+ }
+ } else {
+ // we don't have configurations
+ if ( index == configs.length - 1 ) {
+ sitemapComponentConfigurations = Collections.EMPTY_MAP;
+ } else {
+ // use configuration from parent
+ sitemapComponentConfigurations = this.convert(configs,
index+1);
+ }
+ }
+ return sitemapComponentConfigurations;
}
/**
* @see SitemapConfigurationHolder#getConfiguration()
*/
public ChainedConfiguration getConfiguration() {
- Map confs =
EnvironmentHelper.getCurrentProcessor().getComponentConfigurations();
+ Map confs =
this.convert(EnvironmentHelper.getCurrentProcessor().getComponentConfigurations(),
0);
return (ChainedConfiguration) (confs == null ? null :
confs.get(this.role));
}
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
Wed Oct 20 10:49:38 2004
@@ -16,8 +16,6 @@
package org.apache.cocoon.components.treeprocessor;
import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -29,7 +27,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.Processor;
-import org.apache.cocoon.components.ChainedConfiguration;
import org.apache.cocoon.components.source.impl.SitemapSourceInfo;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.ForwardRedirector;
@@ -37,7 +34,6 @@
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.internal.EnvironmentHelper;
import org.apache.cocoon.environment.internal.ForwardEnvironmentWrapper;
-import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
import org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade;
import org.apache.cocoon.sitemap.SitemapExecutor;
import org.apache.cocoon.sitemap.impl.DefaultExecutor;
@@ -151,52 +147,23 @@
this.sitemapComponentConfigurations = null;
}
- /**
- * Get the sitemap component configurations
- * @since 2.1
- */
- public Map getComponentConfigurations() {
- // do we have the sitemap configurations prepared for this processor?
- if ( null == this.sitemapComponentConfigurations ) {
-
- synchronized (this) {
-
- if ( this.sitemapComponentConfigurations == null ) {
- // do we have configurations?
- final Configuration[] childs =
(this.componentConfigurations == null
- ? null
- :
this.componentConfigurations.getChildren());
-
- if ( null != childs ) {
-
- if ( null == this.wrappingProcessor.parent ) {
- this.sitemapComponentConfigurations = new
HashMap(12);
- } else {
- // copy all configurations from parent
- this.sitemapComponentConfigurations = new HashMap(
-
this.wrappingProcessor.parent.getComponentConfigurations());
- }
-
- // and now check for new configurations
- for(int m = 0; m < childs.length; m++) {
-
- final String r =
this.wrappingProcessor.rootRoleManager.getRoleForName(childs[m].getName());
- this.sitemapComponentConfigurations.put(r, new
ChainedConfiguration(childs[m],
-
(ChainedConfiguration)this.sitemapComponentConfigurations.get(r)));
- }
- } else {
- // we don't have configurations
- if ( null == this.wrappingProcessor.parent ) {
- this.sitemapComponentConfigurations =
Collections.EMPTY_MAP;
- } else {
- // use configuration from parent
- this.sitemapComponentConfigurations =
this.wrappingProcessor.parent.getComponentConfigurations();
- }
- }
- }
+ public Configuration[] getComponentConfigurations() {
+ if ( this.componentConfigurations == null ) {
+ if ( this.wrappingProcessor.parent != null ) {
+ return
this.wrappingProcessor.parent.getComponentConfigurations();
+ }
+ return null;
+ } else {
+ if ( this.wrappingProcessor.parent == null ) {
+ return new Configuration[] { this.componentConfigurations };
}
+ final Configuration[] parentArray =
this.wrappingProcessor.parent.getComponentConfigurations();
+ final Configuration[] newArray = new
Configuration[parentArray.length+1];
+ System.arraycopy(parentArray, 0, newArray, 1, parentArray.length);
+ newArray[0] = this.componentConfigurations;
+ return newArray;
}
- return this.sitemapComponentConfigurations; }
+ }
/**
* Mark this processor as needing to be disposed. Actual call to [EMAIL
PROTECTED] #dispose()} will occur when
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java
Wed Oct 20 10:49:38 2004
@@ -15,10 +15,6 @@
*/
package org.apache.cocoon.components.treeprocessor;
-import java.util.Map;
-
-import org.apache.avalon.excalibur.component.RoleManageable;
-import org.apache.avalon.excalibur.component.RoleManager;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configurable;
@@ -49,7 +45,7 @@
* Interpreted tree-traversal implementation of a pipeline assembly language.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Id: TreeProcessor.java,v 1.40 2004/07/16 12:36:45 sylvain Exp
$
+ * @version CVS $Id$
*/
public class TreeProcessor
@@ -58,7 +54,6 @@
Processor,
Serviceable,
Configurable,
- RoleManageable,
Contextualizable,
Disposable,
Initializable {
@@ -75,9 +70,6 @@
/** The component manager given by the upper level (root manager or parent
concrete processor) */
protected ServiceManager parentServiceManager;
- /** The root role manager */
- protected RoleManager rootRoleManager;
-
/** Last modification time */
protected long lastModified = 0;
@@ -126,7 +118,6 @@
// Copy all that can be copied from the parent
this.enableLogging(parent.getLogger());
this.context = parent.context;
- this.rootRoleManager = parent.rootRoleManager;
this.source = sitemapSource;
this.treeBuilderConfiguration = parent.treeBuilderConfiguration;
this.checkReload = checkReload;
@@ -165,10 +156,6 @@
this.resolver =
(SourceResolver)this.parentServiceManager.lookup(SourceResolver.ROLE);
}
- public void setRoleManager(RoleManager rm) {
- this.rootRoleManager = rm;
- }
-
public void initialize() throws Exception {
// setup the environment helper
if (this.environmentHelper == null ) {
@@ -274,7 +261,7 @@
/* (non-Javadoc)
* @see org.apache.cocoon.Processor#getComponentConfigurations()
*/
- public Map getComponentConfigurations() {
+ public Configuration[] getComponentConfigurations() {
return this.concreteProcessor.getComponentConfigurations();
}