Source Code Cross Referenced for ConfigurationBuilderImpl.java in  » ESB » celtix-1.0 » org » objectweb » celtix » configuration » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » celtix 1.0 » org.objectweb.celtix.configuration.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.configuration.impl;
002:
003:        import java.io.IOException;
004:        import java.io.InputStream;
005:        import java.util.HashMap;
006:        import java.util.Map;
007:        import java.util.ResourceBundle;
008:
009:        import org.objectweb.celtix.common.i18n.BundleUtils;
010:        import org.objectweb.celtix.common.i18n.Message;
011:        import org.objectweb.celtix.configuration.Configuration;
012:        import org.objectweb.celtix.configuration.ConfigurationBuilder;
013:        import org.objectweb.celtix.configuration.ConfigurationException;
014:        import org.objectweb.celtix.configuration.ConfigurationMetadata;
015:        import org.objectweb.celtix.resource.DefaultResourceManager;
016:
017:        public class ConfigurationBuilderImpl implements  ConfigurationBuilder {
018:            protected static final ResourceBundle BUNDLE = BundleUtils
019:                    .getBundle(ConfigurationBuilderImpl.class);
020:
021:            protected Map<String, Map<String, Configuration>> configurations;
022:            private Map<String, ConfigurationMetadata> models;
023:
024:            public ConfigurationBuilderImpl() {
025:                models = new HashMap<String, ConfigurationMetadata>();
026:                configurations = new HashMap<String, Map<String, Configuration>>();
027:
028:                /*
029:                add("config-metadata/bus-config.xml");
030:                add("config-metadata/endpoint-config.xml");
031:                add("config-metadata/http-client-config.xml");
032:                add("config-metadata/http-listener-config.xml");
033:                add("config-metadata/http-server-config.xml");
034:                add("config-metadata/port-config.xml");
035:                add("config-metadata/service-config.xml");
036:                 */
037:            }
038:
039:            public Configuration getConfiguration(String namespaceUri, String id) {
040:                Map<String, Configuration> instances = configurations
041:                        .get(namespaceUri);
042:                if (null == instances) {
043:                    if (null == getModel(namespaceUri)) {
044:                        throw new ConfigurationException(new Message(
045:                                "UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
046:                    }
047:                    return null;
048:                }
049:                return instances.get(id);
050:            }
051:
052:            public Configuration getConfiguration(String namespaceUri,
053:                    String id, Configuration parent) {
054:                if (parent == null) {
055:                    return null;
056:                }
057:
058:                Configuration c = parent.getChild(namespaceUri, id);
059:                if (null == c && null == getModel(namespaceUri)) {
060:                    throw new ConfigurationException(new Message(
061:                            "UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
062:                }
063:                return c;
064:            }
065:
066:            public Configuration buildConfiguration(String namespaceUri,
067:                    String id, Configuration parent) {
068:                ConfigurationMetadata model = getModel(namespaceUri);
069:                if (null == model) {
070:                    throw new ConfigurationException(new Message(
071:                            "UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
072:                }
073:                /*
074:                if (parent != null && !isValidChildConfiguration(model, parent)) {
075:                    throw new ConfigurationException(new Message("INVALID_CHILD_CONFIGURATION",
076:                                                                 BUNDLE, namespaceUri,
077:                                                                 parent.getModel().getNamespaceURI()));
078:                }
079:                 */
080:                if (parent == null && !isValidTopConfiguration(model, parent)) {
081:                    throw new ConfigurationException(new Message(
082:                            "INVALID_TOP_CONFIGURATION", BUNDLE, namespaceUri));
083:                }
084:
085:                Configuration c = new AbstractConfigurationImpl(model, id,
086:                        parent);
087:                if (null == parent) {
088:                    Map<String, Configuration> instances = configurations
089:                            .get(namespaceUri);
090:                    if (null == instances) {
091:                        instances = new HashMap<String, Configuration>();
092:                        configurations.put(namespaceUri, instances);
093:                    }
094:                    instances.put(id, c);
095:                }
096:                return c;
097:            }
098:
099:            /* The presence of parentNamespaceURI means that the underlying type of
100:             * configuration can only be created as a child of a configuration with
101:             * namespace 'parentNamespace'. The absence of this attribute means that it
102:             * can be be created as a top level configuration object
103:             **/
104:            protected boolean isValidTopConfiguration(
105:                    ConfigurationMetadata model, Configuration parent) {
106:                String parentNamespaceURI = model.getParentNamespaceURI();
107:
108:                if (parentNamespaceURI == null || "".equals(parentNamespaceURI)) {
109:                    return true;
110:                }
111:
112:                return false;
113:            }
114:
115:            /*
116:            private boolean isValidChildConfiguration(ConfigurationMetadata model, Configuration parent) {
117:                if (parent != null && parent.getModel().getNamespaceURI().equals(model.getParentNamespaceURI())) {
118:                    return true;
119:                }
120:
121:                return false;
122:            }
123:             */
124:
125:            public Configuration buildConfiguration(String namespaceUri,
126:                    String id) {
127:                return buildConfiguration(namespaceUri, id, null);
128:            }
129:
130:            public final void addModel(ConfigurationMetadata model) {
131:                models.put(model.getNamespaceURI(), model);
132:            }
133:
134:            public ConfigurationMetadata getModel(String namespaceUri) {
135:                return models.get(namespaceUri);
136:            }
137:
138:            public void addModel(String resource) {
139:
140:                InputStream is = null;
141:                if (resource != null) {
142:                    is = loadResource(resource);
143:                    if (is == null) {
144:                        throw new ConfigurationException(new Message(
145:                                "METADATA_RESOURCE_EXC", BUNDLE, resource));
146:                    }
147:                }
148:
149:                ConfigurationMetadata model = null;
150:                ConfigurationMetadataBuilder builder = new ConfigurationMetadataBuilder(
151:                        true);
152:                if (null != is) {
153:                    try {
154:                        model = builder.build(is);
155:                    } catch (IOException ex) {
156:                        throw new ConfigurationException(new Message(
157:                                "METADATA_RESOURCE_EXC", BUNDLE, resource), ex);
158:                    }
159:                } else {
160:                    model = new ConfigurationMetadataImpl();
161:                }
162:
163:                addModel(model);
164:            }
165:
166:            private InputStream loadResource(String resourceName) {
167:                return DefaultResourceManager.instance().getResourceAsStream(
168:                        resourceName);
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.