01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.calyxo.control.conf.impl;
17:
18: import java.util.ArrayList;
19: import java.util.Iterator;
20:
21: import de.odysseus.calyxo.control.conf.PluginsConfig;
22: import de.odysseus.calyxo.base.conf.ConfigException;
23: import de.odysseus.calyxo.base.conf.impl.ConfigImpl;
24:
25: /**
26: * Plugins configuration implementation.
27: *
28: * @author Christoph Beck
29: */
30: public class PluginsConfigImpl extends ConfigImpl implements
31: PluginsConfig {
32: private ArrayList plugins = new ArrayList();
33:
34: /**
35: * Merge other plugins element into the receiver.
36: * Add all plugin configs from other element.
37: */
38: void merge(PluginsConfigImpl other) throws ConfigException {
39: if (other != null) {
40: Iterator otherPlugins = other.getPluginConfigs();
41: while (otherPlugins.hasNext()) {
42: add((PluginConfigImpl) otherPlugins.next());
43: }
44: }
45: }
46:
47: /*
48: * (non-Javadoc)
49: * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_getElementName()
50: */
51: protected String _getElementName() {
52: return "plugins";
53: }
54:
55: /*
56: * (non-Javadoc)
57: * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_addChildren(de.odysseus.calyxo.base.conf.impl.ConfigImpl.Elements)
58: */
59: protected void _addChildren(Elements list) {
60: super ._addChildren(list);
61: list.add(getPluginConfigs());
62: }
63:
64: /*
65: * (non-Javadoc)
66: * @see de.odysseus.calyxo.base.conf.impl.ConfigImpl#_putAttributes(de.odysseus.calyxo.base.conf.impl.ConfigImpl.Attributes)
67: */
68: protected void _putAttributes(Attributes map) {
69: super ._putAttributes(map);
70: // no attributes
71: }
72:
73: /**
74: * Add plugin element.
75: */
76: public void add(PluginConfigImpl value) throws ConfigException {
77: plugins.add(value);
78: }
79:
80: /*
81: * (non-Javadoc)
82: * @see de.odysseus.calyxo.control.conf.PluginsConfig#getPluginConfigs()
83: */
84: public Iterator getPluginConfigs() {
85: return plugins.iterator();
86: }
87: }
|