01: package org.objectweb.celtix.bus.configuration;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import org.objectweb.celtix.common.i18n.Message;
07: import org.objectweb.celtix.configuration.Configuration;
08: import org.objectweb.celtix.configuration.ConfigurationException;
09: import org.objectweb.celtix.configuration.ConfigurationMetadata;
10: import org.objectweb.celtix.configuration.impl.ConfigurationBuilderImpl;
11:
12: public class CeltixConfigurationBuilder extends
13: ConfigurationBuilderImpl {
14:
15: public CeltixConfigurationBuilder() {
16:
17: addModel("config-metadata/bus-config.xml");
18: addModel("config-metadata/endpoint-config.xml");
19: addModel("config-metadata/http-client-config.xml");
20: addModel("config-metadata/http-listener-config.xml");
21: addModel("config-metadata/http-server-config.xml");
22: addModel("config-metadata/port-config.xml");
23: addModel("config-metadata/jms-client-config.xml");
24: addModel("config-metadata/jms-server-config.xml");
25: addModel("config-metadata/rm-config.xml");
26: addModel("config-metadata/wsa-config.xml");
27: addModel("config-metadata/instrumentation-config.xml");
28: }
29:
30: public Configuration buildConfiguration(String namespaceUri,
31: String id, Configuration parent) {
32: ConfigurationMetadata model = getModel(namespaceUri);
33: if (null == model) {
34: throw new ConfigurationException(new Message(
35: "UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
36: }
37: /*
38: if (parent != null && !isValidChildConfiguration(model, parent)) {
39: throw new ConfigurationException(new Message("INVALID_CHILD_CONFIGURATION",
40: BUNDLE, namespaceUri,
41: parent.getModel().getNamespaceURI()));
42: }
43: */
44: if (parent == null && !isValidTopConfiguration(model, parent)) {
45: throw new ConfigurationException(new Message(
46: "INVALID_TOP_CONFIGURATION", BUNDLE, namespaceUri));
47: }
48:
49: Configuration c = new CeltixConfigurationImpl(model, id, parent);
50: if (null == parent) {
51: Map<String, Configuration> instances = configurations
52: .get(namespaceUri);
53: if (null == instances) {
54: instances = new HashMap<String, Configuration>();
55: configurations.put(namespaceUri, instances);
56: }
57: instances.put(id, c);
58: }
59: return c;
60: }
61: }
|