Source Code Cross Referenced for OracleXAConnection.java in  » Database-JDBC-Connection-Pool » xapool » org » enhydra » jdbc » oracle » 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 » Database JDBC Connection Pool » xapool » org.enhydra.jdbc.oracle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * XAPool: Open Source XA JDBC Pool
003:         * Copyright (C) 2003 Objectweb.org
004:         * Initial Developer: Lutris Technologies Inc.
005:         * Contact: xapool-public@lists.debian-sf.objectweb.org
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
020:         * USA
021:         */
022:        package org.enhydra.jdbc.oracle;
023:
024:        import oracle.jdbc.xa.client.OracleXAResource;
025:        import oracle.jdbc.xa.OracleXid;
026:        import org.enhydra.jdbc.standard.StandardXAConnection;
027:        import org.enhydra.jdbc.standard.StandardXADataSource;
028:
029:        import javax.transaction.xa.XAResource;
030:        import javax.transaction.xa.XAException;
031:        import javax.transaction.xa.Xid;
032:        import java.util.Hashtable;
033:        import java.sql.SQLException;
034:
035:        /**
036:         * Provides an Oracle specific instance of StandardXAConnection. Almost all of
037:         * the required functionality is provided curtesy of the generic super class
038:         * which looks after most of the transaction state management. Oracle's
039:         * own resource manager is informed that it is part of a global transaction
040:         * and looks after the detail thereafter.
041:         */
042:        public final class OracleXAConnection extends StandardXAConnection {
043:
044:            private XAResource xarsrc = null;
045:            private static Hashtable txctxs = new Hashtable();
046:
047:            /**
048:             * Creates the first free connection.
049:             */
050:            public OracleXAConnection(StandardXADataSource dataSource,
051:                    String user, String password) throws SQLException {
052:                super (dataSource, user, password); // creates the first Connection object
053:            }
054:
055:            private OracleXid getOracleXid(Xid xid) throws XAException {
056:                if (!(xid instanceof  OracleXid)) {
057:                    byte[] txctx = (byte[]) txctxs.get(xid);
058:                    dataSource.log.debug("txctx is " + txctx);
059:                    OracleXid newXid = new OracleXid(xid.getFormatId(), xid
060:                            .getGlobalTransactionId(),
061:                            xid.getBranchQualifier(), txctx);
062:                    return newXid;
063:                } else {
064:                    return (OracleXid) xid;
065:                }
066:            }
067:
068:            public void commit(Xid xid, boolean flag) throws XAException {
069:                dataSource.log.debug("commit:" + xid.getGlobalTransactionId());
070:                xarsrc.commit(getOracleXid(xid), flag);
071:                xaDataSource.freeConnection(xid, false);
072:                txctxs.remove(xid);
073:            }
074:
075:            public void end(Xid xid, int flags) throws XAException {
076:                dataSource.log.debug("end" + ":" + xid.getFormatId() + ":"
077:                        + xid.getGlobalTransactionId() + ":"
078:                        + xid.getBranchQualifier() + ":" + flags);
079:                xarsrc.end(getOracleXid(xid), flags);
080:            }
081:
082:            public void forget(Xid xid) throws XAException {
083:                dataSource.log.debug("forget" + ":"
084:                        + xid.getGlobalTransactionId());
085:                xarsrc.forget(getOracleXid(xid));
086:                xaDataSource.freeConnection(xid, false);
087:                txctxs.remove(xid);
088:            }
089:
090:            public int prepare(Xid xid) throws XAException {
091:                dataSource.log.debug("prepare" + ":"
092:                        + xid.getGlobalTransactionId());
093:                int res = xarsrc.prepare(getOracleXid(xid));
094:                if (res == XA_RDONLY) {
095:                    xaDataSource.freeConnection(xid, false);
096:                    txctxs.remove(xid);
097:                }
098:                return res;
099:            }
100:
101:            public void rollback(Xid xid) throws XAException {
102:                dataSource.log.debug("rollback" + ":"
103:                        + xid.getGlobalTransactionId());
104:                xarsrc.rollback(getOracleXid(xid));
105:                xaDataSource.freeConnection(xid, false);
106:                txctxs.remove(xid);
107:            }
108:
109:            public void start(Xid xid, int flags) throws XAException {
110:                dataSource.log.debug("start" + ":" + xid.getFormatId() + ":"
111:                        + xid.getGlobalTransactionId() + ":"
112:                        + xid.getBranchQualifier() + ":" + flags);
113:                doStart(xid, flags);
114:                xarsrc = new OracleXAResource(curCon.con);
115:                OracleXid oXid = getOracleXid(xid);
116:                xarsrc.start(oXid, flags);
117:                txctxs.put(xid, oXid.getTxContext());
118:                curCon = null;
119:                con = null;
120:            }
121:
122:            public boolean isSameRM(XAResource res) throws XAException {
123:                if (!(res instanceof  OracleXAConnection)) {
124:                    dataSource.log.debug("isSameRM returning false");
125:                    return false;
126:                }
127:                OracleXAConnection ores = (OracleXAConnection) res;
128:                if (ores.xarsrc.isSameRM(xarsrc)) {
129:                    dataSource.log.debug("isSameRM returning true");
130:                    return true;
131:                }
132:                dataSource.log.debug("isSameRM returning false");
133:                return false;
134:            }
135:
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.