01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.treeprocessor;
18:
19: import org.apache.avalon.framework.component.ComponentException;
20: import org.apache.avalon.framework.component.ComponentManager;
21: import org.apache.avalon.framework.component.Recomposable;
22: import org.apache.avalon.framework.configuration.Configuration;
23: import org.apache.avalon.framework.configuration.ConfigurationException;
24: import org.apache.avalon.framework.logger.AbstractLogEnabled;
25:
26: /**
27: *
28: * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
29: * @version CVS $Id: AbstractProcessingNodeBuilder.java 433543 2006-08-22 06:22:54Z crossley $
30: */
31: public abstract class AbstractProcessingNodeBuilder extends
32: AbstractLogEnabled implements ProcessingNodeBuilder,
33: Recomposable {
34:
35: protected TreeBuilder treeBuilder;
36:
37: protected ComponentManager manager;
38:
39: public void compose(ComponentManager manager)
40: throws ComponentException {
41: this .manager = manager;
42: }
43:
44: public void recompose(ComponentManager manager)
45: throws ComponentException {
46: this .manager = manager;
47: }
48:
49: public void setBuilder(TreeBuilder treeBuilder) {
50: this .treeBuilder = treeBuilder;
51: }
52:
53: /**
54: * Does this node accept parameters ? Default is true : if a builder that doesn't
55: * have parameters doesn't override this method, erroneous parameters will be silently
56: * ignored.
57: */
58: protected boolean hasParameters() {
59: return true;
60: }
61:
62: /**
63: * Check if the namespace URI of the given configuraition is the same as the
64: * one given by the builder.
65: */
66: protected void checkNamespace(Configuration config)
67: throws ConfigurationException {
68: if (!this .treeBuilder.getNamespace().equals(
69: config.getNamespace())) {
70: String msg = "Invalid namespace '" + config.getNamespace()
71: + "' at " + config.getLocation();
72: throw new ConfigurationException(msg);
73: }
74: }
75: }
|