Source Code Cross Referenced for TyrexFactory.java in  » ERP-CRM-Financial » ofbiz » org » ofbiz » entity » transaction » 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.transaction 
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.transaction;
019:
020:        //import java.net.*;
021:        //import java.sql.*;
022:        //import javax.sql.*;
023:        //import javax.transaction.*;
024:        //import org.w3c.dom.Element;
025:
026:        //import org.ofbiz.entity.*;
027:        //import org.ofbiz.entity.config.*;
028:        //import org.ofbiz.base.util.*;
029:
030:        //import tyrex.tm.*;
031:        //import tyrex.resource.*;
032:
033:        /**
034:         * TyrexTransactionFactory - central source for Tyrex JTA objects
035:         */
036:        public class TyrexFactory {
037:            public static final String module = TyrexFactory.class.getName();
038:        }
039:        /*
040:         public class TyrexFactory implements TransactionFactoryInterface {
041:        
042:         public static final String module = TyrexFactory.class.getName();
043:
044:         protected static TransactionDomain td = null;
045:         protected static String DOMAIN_NAME = "default";
046:
047:         static {
048:
049:         td = TransactionDomain.getDomain(DOMAIN_NAME);
050:
051:         if (td == null) {
052:         // probably because there was no tyrexdomain.xml file, try another method:
053:
054:         // For Tyrex version 0.9.8.5 
055:         try {
056:         String resourceName = "tyrexdomain.xml";
057:         URL url = UtilURL.fromResource(resourceName);
058:
059:         if (url != null) {
060:         td = TransactionDomain.createDomain(url.toString());
061:         } else {
062:         Debug.logError("ERROR: Could not create Tyrex Transaction Domain (resource not found):" + resourceName, module);
063:         }
064:         } catch (tyrex.tm.DomainConfigurationException e) {
065:         Debug.logError("Could not create Tyrex Transaction Domain (configuration):", module);
066:         Debug.logError(e, module);
067:         }
068:
069:         if (td != null) {
070:         Debug.logImportant("Got TyrexDomain from classpath (NO tyrex.config file found)", module);
071:         }
072:         } else {
073:         Debug.logImportant("Got TyrexDomain from tyrex.config location", module);
074:         }
075:
076:         if (td != null) {
077:         try {
078:         td.recover();
079:         } catch (tyrex.tm.RecoveryException e) {
080:         Debug.logError("Could not complete recovery phase of Tyrex TransactionDomain creation", module);
081:         Debug.logError(e, module);
082:         }
083:         } else {
084:         Debug.logError("Could not get Tyrex TransactionDomain for domain " + DOMAIN_NAME, module);
085:         }
086:
087:         // For Tyrex version 0.9.7.0 
088:         tyrex.resource.ResourceLimits rls = new tyrex.resource.ResourceLimits();
089:         td = new TransactionDomain("ofbiztx", rls);        
090:         }
091:
092:         public static Resources getResources() {
093:         if (td != null) {
094:         return td.getResources();
095:         } else {
096:         Debug.logWarning("No Tyrex TransactionDomain, not returning resources", module);
097:         return null;
098:         }
099:         }
100:
101:         public static DataSource getDataSource(String dsName) {
102:         Resources resources = getResources();
103:
104:         if (resources != null) {
105:         try {
106:         return (DataSource) resources.getResource(dsName);
107:         } catch (tyrex.resource.ResourceException e) {
108:         Debug.logError(e, "Could not get tyrex dataSource resource with name " + dsName, module);
109:         return null;
110:         }
111:         } else {
112:         return null;
113:         }
114:         }
115:
116:         public TransactionManager getTransactionManager() {
117:         if (td != null) {
118:         return td.getTransactionManager();
119:         } else {
120:         Debug.logWarning("No Tyrex TransactionDomain, not returning TransactionManager", module);
121:         return null;
122:         }
123:         }
124:
125:         public UserTransaction getUserTransaction() {
126:         if (td != null) {
127:         return td.getUserTransaction();
128:         } else {
129:         Debug.logWarning("No Tyrex TransactionDomain, not returning UserTransaction", module);
130:         return null;
131:         }
132:         }
133:        
134:         public String getTxMgrName() {
135:         return "tyrex";
136:         }
137:        
138:         public Connection getConnection(String helperName) throws SQLException, GenericEntityException {
139:         EntityConfigUtil.DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(helperName);
140:
141:         if (datasourceInfo.inlineJdbcElement != null) {
142:         // Use JOTM (xapool.jar) connection pooling
143:         try {
144:         Connection con = TyrexConnectionFactory.getConnection(helperName, datasourceInfo.inlineJdbcElement);
145:         if (con != null) return con;
146:         } catch (Exception ex) {
147:         Debug.logError(ex, "Tyrex is the configured transaction manager but there was an error getting a database Connection through Tyrex for the " + helperName + " datasource. Please check your configuration, class path, etc.", module);
148:         }
149:        
150:         Connection otherCon = ConnectionFactory.tryGenericConnectionSources(helperName, datasourceInfo.inlineJdbcElement);
151:         return otherCon;
152:         } else if (datasourceInfo.tyrexDataSourceElement != null) {
153:         Element tyrexDataSourceElement = datasourceInfo.tyrexDataSourceElement;
154:         String dataSourceName = tyrexDataSourceElement.getAttribute("dataSource-name");
155:
156:         if (UtilValidate.isEmpty(dataSourceName)) {
157:         Debug.logError("dataSource-name not set for tyrex-dataSource element in the " + helperName + " data-source definition", module);
158:         } else {
159:         DataSource tyrexDataSource = TyrexFactory.getDataSource(dataSourceName);
160:
161:         if (tyrexDataSource == null) {
162:         Debug.logError("Got a null data source for dataSource-name " + dataSourceName + " for tyrex-dataSource element in the " + helperName + " data-source definition; trying other sources", module);
163:         } else {
164:         Connection con = tyrexDataSource.getConnection();
165:
166:         if (con != null) {                        
167:         return con;
168:         }
169:         }
170:         }
171:         Connection otherCon = ConnectionFactory.tryGenericConnectionSources(helperName, datasourceInfo.inlineJdbcElement);
172:         return otherCon;
173:         } else {
174:         Debug.logError("Tyrex is the configured transaction manager but no inline-jdbc or tyrex-dataSource element was specified in the " + helperName + " datasource. Please check your configuration", module);
175:         return null;
176:         }
177:         }
178:        
179:         public void shutdown() {
180:         TyrexConnectionFactory.closeAll();
181:         if (td != null) {
182:         td.terminate();
183:         td = null;
184:         }                
185:         }
186:         }
187:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.