Source Code Cross Referenced for EntityConfigUtil.java in  » ERP-CRM-Financial » ofbiz » org » ofbiz » entity » config » 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 » ERP CRM Financial » ofbiz » org.ofbiz.entity.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         *******************************************************************************/package org.ofbiz.entity.config;
019:
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import javolution.util.FastMap;
025:
026:        import org.ofbiz.base.config.GenericConfigException;
027:        import org.ofbiz.base.config.ResourceLoader;
028:        import org.ofbiz.base.util.Debug;
029:        import org.ofbiz.base.util.UtilXml;
030:        import org.ofbiz.entity.GenericEntityConfException;
031:        import org.ofbiz.entity.GenericEntityException;
032:        import org.w3c.dom.Document;
033:        import org.w3c.dom.Element;
034:
035:        /**
036:         * Misc. utility method for dealing with the entityengine.xml file
037:         *
038:         */
039:        public class EntityConfigUtil {
040:
041:            public static final String module = EntityConfigUtil.class
042:                    .getName();
043:            public static final String ENTITY_ENGINE_XML_FILENAME = "entityengine.xml";
044:
045:            // ========== engine info fields ==========
046:            protected static String txFactoryClass;
047:            protected static String txFactoryUserTxJndiName;
048:            protected static String txFactoryUserTxJndiServerName;
049:            protected static String txFactoryTxMgrJndiName;
050:            protected static String txFactoryTxMgrJndiServerName;
051:
052:            protected static Map resourceLoaderInfos = FastMap.newInstance();
053:            protected static Map delegatorInfos = FastMap.newInstance();
054:            protected static Map entityModelReaderInfos = FastMap.newInstance();
055:            protected static Map entityGroupReaderInfos = FastMap.newInstance();
056:            protected static Map entityEcaReaderInfos = FastMap.newInstance();
057:            protected static Map entityDataReaderInfos = FastMap.newInstance();
058:            protected static Map fieldTypeInfos = FastMap.newInstance();
059:            protected static Map datasourceInfos = FastMap.newInstance();
060:
061:            protected static Element getXmlRootElement()
062:                    throws GenericEntityConfException {
063:                try {
064:                    return ResourceLoader
065:                            .getXmlRootElement(ENTITY_ENGINE_XML_FILENAME);
066:                } catch (GenericConfigException e) {
067:                    throw new GenericEntityConfException(
068:                            "Could not get entity engine XML root element", e);
069:                }
070:            }
071:
072:            protected static Document getXmlDocument()
073:                    throws GenericEntityConfException {
074:                try {
075:                    return ResourceLoader
076:                            .getXmlDocument(ENTITY_ENGINE_XML_FILENAME);
077:                } catch (GenericConfigException e) {
078:                    throw new GenericEntityConfException(
079:                            "Could not get entity engine XML document", e);
080:                }
081:            }
082:
083:            static {
084:                try {
085:                    initialize(getXmlRootElement());
086:                } catch (Exception e) {
087:                    Debug.logError(e, "Error loading entity config XML file "
088:                            + ENTITY_ENGINE_XML_FILENAME, module);
089:                }
090:            }
091:
092:            public static synchronized void reinitialize()
093:                    throws GenericEntityException {
094:                try {
095:                    ResourceLoader
096:                            .invalidateDocument(ENTITY_ENGINE_XML_FILENAME);
097:                    initialize(getXmlRootElement());
098:                } catch (Exception e) {
099:                    throw new GenericEntityException(
100:                            "Error reloading entity config XML file "
101:                                    + ENTITY_ENGINE_XML_FILENAME, e);
102:                }
103:            }
104:
105:            public static void initialize(Element rootElement)
106:                    throws GenericEntityException {
107:                Element transactionFactoryElement = UtilXml.firstChildElement(
108:                        rootElement, "transaction-factory");
109:                if (transactionFactoryElement == null) {
110:                    throw new GenericEntityConfException(
111:                            "ERROR: no transaction-factory definition was found in "
112:                                    + ENTITY_ENGINE_XML_FILENAME);
113:                }
114:
115:                txFactoryClass = transactionFactoryElement
116:                        .getAttribute("class");
117:
118:                Element userTxJndiElement = UtilXml.firstChildElement(
119:                        transactionFactoryElement, "user-transaction-jndi");
120:                if (userTxJndiElement != null) {
121:                    txFactoryUserTxJndiName = userTxJndiElement
122:                            .getAttribute("jndi-name");
123:                    txFactoryUserTxJndiServerName = userTxJndiElement
124:                            .getAttribute("jndi-server-name");
125:                } else {
126:                    txFactoryUserTxJndiName = null;
127:                    txFactoryUserTxJndiServerName = null;
128:                }
129:
130:                Element txMgrJndiElement = UtilXml.firstChildElement(
131:                        transactionFactoryElement, "transaction-manager-jndi");
132:                if (txMgrJndiElement != null) {
133:                    txFactoryTxMgrJndiName = txMgrJndiElement
134:                            .getAttribute("jndi-name");
135:                    txFactoryTxMgrJndiServerName = txMgrJndiElement
136:                            .getAttribute("jndi-server-name");
137:                } else {
138:                    txFactoryTxMgrJndiName = null;
139:                    txFactoryTxMgrJndiServerName = null;
140:                }
141:
142:                // not load all of the maps...
143:                List childElements = null;
144:                Iterator elementIter = null;
145:
146:                // resource-loader - resourceLoaderInfos
147:                childElements = UtilXml.childElementList(rootElement,
148:                        "resource-loader");
149:                elementIter = childElements.iterator();
150:                while (elementIter.hasNext()) {
151:                    Element curElement = (Element) elementIter.next();
152:                    ResourceLoaderInfo resourceLoaderInfo = new ResourceLoaderInfo(
153:                            curElement);
154:                    resourceLoaderInfos.put(resourceLoaderInfo.name,
155:                            resourceLoaderInfo);
156:                }
157:
158:                // delegator - delegatorInfos
159:                childElements = UtilXml.childElementList(rootElement,
160:                        "delegator");
161:                elementIter = childElements.iterator();
162:                while (elementIter.hasNext()) {
163:                    Element curElement = (Element) elementIter.next();
164:                    DelegatorInfo delegatorInfo = new DelegatorInfo(curElement);
165:                    delegatorInfos.put(delegatorInfo.name, delegatorInfo);
166:                }
167:
168:                // entity-model-reader - entityModelReaderInfos
169:                childElements = UtilXml.childElementList(rootElement,
170:                        "entity-model-reader");
171:                elementIter = childElements.iterator();
172:                while (elementIter.hasNext()) {
173:                    Element curElement = (Element) elementIter.next();
174:                    EntityModelReaderInfo entityModelReaderInfo = new EntityModelReaderInfo(
175:                            curElement);
176:                    entityModelReaderInfos.put(entityModelReaderInfo.name,
177:                            entityModelReaderInfo);
178:                }
179:
180:                // entity-group-reader - entityGroupReaderInfos
181:                childElements = UtilXml.childElementList(rootElement,
182:                        "entity-group-reader");
183:                elementIter = childElements.iterator();
184:                while (elementIter.hasNext()) {
185:                    Element curElement = (Element) elementIter.next();
186:                    EntityGroupReaderInfo entityGroupReaderInfo = new EntityGroupReaderInfo(
187:                            curElement);
188:                    entityGroupReaderInfos.put(entityGroupReaderInfo.name,
189:                            entityGroupReaderInfo);
190:                }
191:
192:                // entity-eca-reader - entityEcaReaderInfos
193:                childElements = UtilXml.childElementList(rootElement,
194:                        "entity-eca-reader");
195:                elementIter = childElements.iterator();
196:                while (elementIter.hasNext()) {
197:                    Element curElement = (Element) elementIter.next();
198:                    EntityEcaReaderInfo entityEcaReaderInfo = new EntityEcaReaderInfo(
199:                            curElement);
200:                    entityEcaReaderInfos.put(entityEcaReaderInfo.name,
201:                            entityEcaReaderInfo);
202:                }
203:
204:                // entity-data-reader - entityDataReaderInfos
205:                childElements = UtilXml.childElementList(rootElement,
206:                        "entity-data-reader");
207:                elementIter = childElements.iterator();
208:                while (elementIter.hasNext()) {
209:                    Element curElement = (Element) elementIter.next();
210:                    EntityDataReaderInfo entityDataReaderInfo = new EntityDataReaderInfo(
211:                            curElement);
212:                    entityDataReaderInfos.put(entityDataReaderInfo.name,
213:                            entityDataReaderInfo);
214:                }
215:
216:                // field-type - fieldTypeInfos
217:                childElements = UtilXml.childElementList(rootElement,
218:                        "field-type");
219:                elementIter = childElements.iterator();
220:                while (elementIter.hasNext()) {
221:                    Element curElement = (Element) elementIter.next();
222:                    FieldTypeInfo fieldTypeInfo = new FieldTypeInfo(curElement);
223:                    fieldTypeInfos.put(fieldTypeInfo.name, fieldTypeInfo);
224:                }
225:
226:                // datasource - datasourceInfos
227:                childElements = UtilXml.childElementList(rootElement,
228:                        "datasource");
229:                elementIter = childElements.iterator();
230:                while (elementIter.hasNext()) {
231:                    Element curElement = (Element) elementIter.next();
232:                    DatasourceInfo datasourceInfo = new DatasourceInfo(
233:                            curElement);
234:                    datasourceInfos.put(datasourceInfo.name, datasourceInfo);
235:                }
236:            }
237:
238:            public static String getTxFactoryClass() {
239:                return txFactoryClass;
240:            }
241:
242:            public static String getTxFactoryUserTxJndiName() {
243:                return txFactoryUserTxJndiName;
244:            }
245:
246:            public static String getTxFactoryUserTxJndiServerName() {
247:                return txFactoryUserTxJndiServerName;
248:            }
249:
250:            public static String getTxFactoryTxMgrJndiName() {
251:                return txFactoryTxMgrJndiName;
252:            }
253:
254:            public static String getTxFactoryTxMgrJndiServerName() {
255:                return txFactoryTxMgrJndiServerName;
256:            }
257:
258:            public static ResourceLoaderInfo getResourceLoaderInfo(String name) {
259:                return (ResourceLoaderInfo) resourceLoaderInfos.get(name);
260:            }
261:
262:            public static DelegatorInfo getDelegatorInfo(String name) {
263:                return (DelegatorInfo) delegatorInfos.get(name);
264:            }
265:
266:            public static EntityModelReaderInfo getEntityModelReaderInfo(
267:                    String name) {
268:                return (EntityModelReaderInfo) entityModelReaderInfos.get(name);
269:            }
270:
271:            public static EntityGroupReaderInfo getEntityGroupReaderInfo(
272:                    String name) {
273:                return (EntityGroupReaderInfo) entityGroupReaderInfos.get(name);
274:            }
275:
276:            public static EntityEcaReaderInfo getEntityEcaReaderInfo(String name) {
277:                return (EntityEcaReaderInfo) entityEcaReaderInfos.get(name);
278:            }
279:
280:            public static EntityDataReaderInfo getEntityDataReaderInfo(
281:                    String name) {
282:                return (EntityDataReaderInfo) entityDataReaderInfos.get(name);
283:            }
284:
285:            public static FieldTypeInfo getFieldTypeInfo(String name) {
286:                return (FieldTypeInfo) fieldTypeInfos.get(name);
287:            }
288:
289:            public static DatasourceInfo getDatasourceInfo(String name) {
290:                return (DatasourceInfo) datasourceInfos.get(name);
291:            }
292:
293:            public static Map getDatasourceInfos() {
294:                return datasourceInfos;
295:            }
296:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.