org.apache.cocoon.components.treeprocessor
Class DefaultTreeBuilder

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.components.treeprocessor.DefaultTreeBuilder
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.logger.LogKitManageable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.framework.component.Recomposable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.excalibur.component.RoleManageable, TreeBuilder
Direct Known Subclasses:
SitemapLanguage

public class DefaultTreeBuilder
extends org.apache.avalon.framework.logger.AbstractLoggable
implements TreeBuilder, org.apache.avalon.framework.component.Recomposable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.excalibur.logger.LogKitManageable, org.apache.avalon.excalibur.component.RoleManageable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.framework.activity.Disposable

Version:
CVS $Id: DefaultTreeBuilder.java,v 1.3.2.5 2002/11/25 21:51:59 sylvain Exp $
Author:
Sylvain Wallez

Field Summary
protected  org.apache.avalon.framework.component.ComponentSelector builderSelector
          Selector for ProcessingNodeBuilders
protected  org.apache.avalon.framework.configuration.Configuration configuration
           
protected  org.apache.avalon.framework.context.Context context
           
protected  java.lang.String fileName
           
protected  java.lang.String languageName
           
protected  LifecycleHelper lifecycle
           
protected  org.apache.avalon.excalibur.logger.LogKitManager logKit
           
protected  org.apache.avalon.framework.component.ComponentManager manager
          Component manager created by createComponentManager(Configuration).
protected  java.lang.String namespace
           
protected  java.lang.String parameterElement
           
protected  org.apache.avalon.framework.component.ComponentManager parentManager
          The parent component manager, set using compose() and recompose() (implementation of Recomposable).
protected  org.apache.avalon.excalibur.component.RoleManager parentRoleManager
          The parent role manager, set using setRoleManager (implementation of RoleManageable).
protected  TreeProcessor processor
          The tree processor that we're building.
protected  org.apache.avalon.excalibur.component.RoleManager roleManager
          Role manager result created by createRoleManager().
 
Constructor Summary
DefaultTreeBuilder()
           
 
Method Summary
 ProcessingNode build(org.apache.avalon.framework.configuration.Configuration tree)
          Build a processing tree from a Configuration.
 ProcessingNode build(Source source)
           
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
           
 void configure(org.apache.avalon.framework.configuration.Configuration config)
           
 void contextualize(org.apache.avalon.framework.context.Context context)
           
protected  org.apache.avalon.framework.component.ComponentSelector createBuilderSelector()
          Create a ComponentSelector for ProcessingNodeBuilders.
protected  org.apache.avalon.framework.component.ComponentManager createComponentManager(org.apache.avalon.framework.configuration.Configuration tree)
          Create a component manager that will be used for all Composable ProcessingNodeBuilders and ProcessingNodes.
 ProcessingNodeBuilder createNodeBuilder(org.apache.avalon.framework.configuration.Configuration config)
           
protected  org.apache.avalon.excalibur.component.RoleManager createRoleManager()
          Create a role manager that will be used by all RoleManageable components.
protected  ProcessingNode createTree(org.apache.avalon.framework.configuration.Configuration tree)
          Create the tree once component manager and node builders have been set up.
 void dispose()
           
 java.util.List getDisposableNodes()
          Return the list of ProcessingNodes part of this tree that are Disposable.
 java.lang.String getFileName()
           
 java.lang.String getLanguage()
          Returns the language that is being built (e.g.
 java.lang.String getNamespace()
          Get the namespace URI that builders should use to find their nodes.
 java.lang.String getParameterName()
          Returns the name of the parameter element.
protected  java.util.Map getParameters(org.apache.avalon.framework.configuration.Configuration config)
          Get <xxx:parameter> elements as a Map of ListOfMapResolvers, that can be turned into parameters using ListOfMapResolver.buildParameters().
 TreeProcessor getProcessor()
           
 ProcessingNode getRegisteredNode(java.lang.String name)
           
 java.lang.String getTypeForStatement(org.apache.avalon.framework.configuration.Configuration statement, java.lang.String role)
          Get the type for a statement : it returns the 'type' attribute if present, and otherwhise the default hint of the ExtendedSelector designated by role role.
protected  void linkNodes()
          Resolve links : call linkNode() on all LinkedProcessingNodeBuilders.
 void recompose(org.apache.avalon.framework.component.ComponentManager manager)
           
 void recycle()
           
 void registerNode(java.lang.String name, ProcessingNode node)
          Register a ProcessingNode under a given name.
 void setLogKitManager(org.apache.avalon.excalibur.logger.LogKitManager logKit)
           
 void setProcessor(TreeProcessor processor)
           
 void setRoleManager(org.apache.avalon.excalibur.component.RoleManager rm)
           
 ProcessingNode setupNode(ProcessingNode node, org.apache.avalon.framework.configuration.Configuration config)
          Setup a ProcessingNode by setting its location, calling all the lifecycle interfaces it implements and giving it the parameter map if it's a ParameterizableNode.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

processor

protected TreeProcessor processor
The tree processor that we're building.

context

protected org.apache.avalon.framework.context.Context context

logKit

protected org.apache.avalon.excalibur.logger.LogKitManager logKit

parentManager

protected org.apache.avalon.framework.component.ComponentManager parentManager
The parent component manager, set using compose() and recompose() (implementation of Recomposable).

parentRoleManager

protected org.apache.avalon.excalibur.component.RoleManager parentRoleManager
The parent role manager, set using setRoleManager (implementation of RoleManageable).

configuration

protected org.apache.avalon.framework.configuration.Configuration configuration

manager

protected org.apache.avalon.framework.component.ComponentManager manager
Component manager created by createComponentManager(Configuration).

roleManager

protected org.apache.avalon.excalibur.component.RoleManager roleManager
Role manager result created by createRoleManager().

builderSelector

protected org.apache.avalon.framework.component.ComponentSelector builderSelector
Selector for ProcessingNodeBuilders

lifecycle

protected LifecycleHelper lifecycle

namespace

protected java.lang.String namespace

parameterElement

protected java.lang.String parameterElement

languageName

protected java.lang.String languageName

fileName

protected java.lang.String fileName
Constructor Detail

DefaultTreeBuilder

public DefaultTreeBuilder()
Method Detail

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable

setLogKitManager

public void setLogKitManager(org.apache.avalon.excalibur.logger.LogKitManager logKit)
Specified by:
setLogKitManager in interface org.apache.avalon.excalibur.logger.LogKitManageable

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
             throws org.apache.avalon.framework.component.ComponentException
Specified by:
compose in interface org.apache.avalon.framework.component.Composable

recompose

public void recompose(org.apache.avalon.framework.component.ComponentManager manager)
               throws org.apache.avalon.framework.component.ComponentException
Specified by:
recompose in interface org.apache.avalon.framework.component.Recomposable

setRoleManager

public void setRoleManager(org.apache.avalon.excalibur.component.RoleManager rm)
Specified by:
setRoleManager in interface org.apache.avalon.excalibur.component.RoleManageable

configure

public void configure(org.apache.avalon.framework.configuration.Configuration config)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable

createRoleManager

protected org.apache.avalon.excalibur.component.RoleManager createRoleManager()
                                                                       throws java.lang.Exception
Create a role manager that will be used by all RoleManageable components. The default here is to create a role manager with the contents of the <roles> element of the configuration.

Subclasses can redefine this method to create roles from other sources than the one used here.

Returns:
the role manager

createComponentManager

protected org.apache.avalon.framework.component.ComponentManager createComponentManager(org.apache.avalon.framework.configuration.Configuration tree)
                                                                                 throws java.lang.Exception
Create a component manager that will be used for all Composable ProcessingNodeBuilders and ProcessingNodes.

The default here is to simply return the manager set by compose(), i.e. the component manager set by the calling TreeProcessor.

Subclasses can redefine this method to create a component manager local to a tree, such as for sitemap's <map:components>.

Returns:
a component manager

createBuilderSelector

protected org.apache.avalon.framework.component.ComponentSelector createBuilderSelector()
                                                                                 throws java.lang.Exception
Create a ComponentSelector for ProcessingNodeBuilders. It creates a selector with the contents of the "node" element of the configuration.
Returns:
a selector for node builders

setProcessor

public void setProcessor(TreeProcessor processor)
Specified by:
setProcessor in interface TreeBuilder

getProcessor

public TreeProcessor getProcessor()
Specified by:
getProcessor in interface TreeBuilder

getLanguage

public java.lang.String getLanguage()
Returns the language that is being built (e.g. "sitemap").
Specified by:
getLanguage in interface TreeBuilder

getParameterName

public java.lang.String getParameterName()
Returns the name of the parameter element.
Specified by:
getParameterName in interface TreeBuilder

registerNode

public void registerNode(java.lang.String name,
                         ProcessingNode node)
Register a ProcessingNode under a given name. For example, ResourceNodeBuilder stores here the ProcessingNodes it produces for use by sitemap pipelines. This allows to turn the tree into a graph.
Specified by:
registerNode in interface TreeBuilder

getRegisteredNode

public ProcessingNode getRegisteredNode(java.lang.String name)
Specified by:
getRegisteredNode in interface TreeBuilder
Following copied from interface: org.apache.cocoon.components.treeprocessor.TreeBuilder
Throws:
java.lang.IllegalStateException -  

createNodeBuilder

public ProcessingNodeBuilder createNodeBuilder(org.apache.avalon.framework.configuration.Configuration config)
                                        throws java.lang.Exception
Specified by:
createNodeBuilder in interface TreeBuilder

createTree

protected ProcessingNode createTree(org.apache.avalon.framework.configuration.Configuration tree)
                             throws java.lang.Exception
Create the tree once component manager and node builders have been set up. Can be overriden by subclasses to perform pre/post tree creation operations.

linkNodes

protected void linkNodes()
                  throws java.lang.Exception
Resolve links : call linkNode() on all LinkedProcessingNodeBuilders. Can be overriden by subclasses to perform pre/post resolution operations.

getNamespace

public java.lang.String getNamespace()
Get the namespace URI that builders should use to find their nodes.
Specified by:
getNamespace in interface TreeBuilder

build

public ProcessingNode build(Source source)
                     throws java.lang.Exception
Specified by:
build in interface TreeBuilder

getFileName

public java.lang.String getFileName()
Specified by:
getFileName in interface TreeBuilder

build

public ProcessingNode build(org.apache.avalon.framework.configuration.Configuration tree)
                     throws java.lang.Exception
Build a processing tree from a Configuration.
Specified by:
build in interface TreeBuilder

getDisposableNodes

public java.util.List getDisposableNodes()
Return the list of ProcessingNodes part of this tree that are Disposable. Care should be taken to properly dispose them before trashing the processing tree.
Specified by:
getDisposableNodes in interface TreeBuilder

setupNode

public ProcessingNode setupNode(ProcessingNode node,
                                org.apache.avalon.framework.configuration.Configuration config)
                         throws java.lang.Exception
Setup a ProcessingNode by setting its location, calling all the lifecycle interfaces it implements and giving it the parameter map if it's a ParameterizableNode.

As a convenience, the node is returned by this method to allow constructs like return treeBuilder.setupNode(new MyNode(), config).

Specified by:
setupNode in interface TreeBuilder

getParameters

protected java.util.Map getParameters(org.apache.avalon.framework.configuration.Configuration config)
                               throws org.apache.avalon.framework.configuration.ConfigurationException
Get <xxx:parameter> elements as a Map of ListOfMapResolvers, that can be turned into parameters using ListOfMapResolver.buildParameters().
Returns:
the Map of ListOfMapResolver, or null if there are no parameters.

getTypeForStatement

public java.lang.String getTypeForStatement(org.apache.avalon.framework.configuration.Configuration statement,
                                            java.lang.String role)
                                     throws org.apache.avalon.framework.configuration.ConfigurationException
Get the type for a statement : it returns the 'type' attribute if present, and otherwhise the default hint of the ExtendedSelector designated by role role.
Specified by:
getTypeForStatement in interface TreeBuilder
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - if the default type could not be found.

recycle

public void recycle()
Specified by:
recycle in interface org.apache.avalon.excalibur.pool.Recyclable

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.