Source Code Cross Referenced for CoreUserTransaction.java in  » J2EE » openejb3 » org » apache » openejb » core » 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 » J2EE » openejb3 » org.apache.openejb.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */package org.apache.openejb.core;
017:
018:        import javax.transaction.HeuristicMixedException;
019:        import javax.transaction.HeuristicRollbackException;
020:        import javax.transaction.NotSupportedException;
021:        import javax.transaction.RollbackException;
022:        import javax.transaction.SystemException;
023:        import javax.transaction.TransactionManager;
024:        import javax.transaction.Status;
025:
026:        import org.apache.openejb.util.LogCategory;
027:        import org.apache.openejb.util.Logger;
028:
029:        /**
030:         * @org.apache.xbean.XBean element="userTransaction"
031:         */
032:        public class CoreUserTransaction implements 
033:                javax.transaction.UserTransaction, java.io.Serializable {
034:            private static final long serialVersionUID = 9203248912222645965L;
035:            private static final Logger transactionLogger = Logger.getInstance(
036:                    LogCategory.TRANSACTION,
037:                    "org.apache.openejb.util.resources");
038:
039:            private transient TransactionManager transactionManager;
040:
041:            public CoreUserTransaction(TransactionManager transactionManager) {
042:                this .transactionManager = transactionManager;
043:            }
044:
045:            private TransactionManager transactionManager() {
046:                if (transactionManager == null) {
047:                    transactionManager = org.apache.openejb.OpenEJB
048:                            .getTransactionManager();
049:                }
050:                return transactionManager;
051:            }
052:
053:            public void begin() throws NotSupportedException, SystemException {
054:                transactionManager().begin();
055:                if (transactionLogger.isInfoEnabled()) {
056:                    transactionLogger.info("Started user transaction "
057:                            + transactionManager().getTransaction());
058:                }
059:            }
060:
061:            public void commit() throws RollbackException,
062:                    HeuristicMixedException, HeuristicRollbackException,
063:                    SecurityException, IllegalStateException, SystemException {
064:                if (transactionLogger.isInfoEnabled()) {
065:                    transactionLogger.info("Committing user transaction "
066:                            + transactionManager().getTransaction());
067:                }
068:                transactionManager().commit();
069:            }
070:
071:            public void rollback() throws IllegalStateException,
072:                    SecurityException, SystemException {
073:                if (transactionLogger.isInfoEnabled()) {
074:                    transactionLogger.info("Rolling back user transaction "
075:                            + transactionManager().getTransaction());
076:                }
077:                transactionManager().rollback();
078:            }
079:
080:            public int getStatus() throws SystemException {
081:                int status = transactionManager().getStatus();
082:                if (transactionLogger.isInfoEnabled()) {
083:                    transactionLogger.info("User transaction "
084:                            + transactionManager().getTransaction()
085:                            + " has status " + getStatus(status));
086:                }
087:                return status;
088:            }
089:
090:            public void setRollbackOnly()
091:                    throws javax.transaction.SystemException {
092:                if (transactionLogger.isInfoEnabled()) {
093:                    transactionLogger
094:                            .info("Marking user transaction for rollback: "
095:                                    + transactionManager().getTransaction());
096:                }
097:                transactionManager().setRollbackOnly();
098:            }
099:
100:            public void setTransactionTimeout(int seconds)
101:                    throws SystemException {
102:                transactionManager().setTransactionTimeout(seconds);
103:            }
104:
105:            private static String getStatus(int status) {
106:                StringBuffer buffer;
107:
108:                buffer = new StringBuffer(100);
109:                switch (status) {
110:                case Status.STATUS_ACTIVE:
111:                    buffer.append("STATUS_ACTIVE: ");
112:                    buffer
113:                            .append("A transaction is associated with the target object and it is in the active state.");
114:                    break;
115:                case Status.STATUS_COMMITTED:
116:                    buffer.append("STATUS_COMMITTED: ");
117:                    buffer
118:                            .append("A transaction is associated with the target object and it has been committed.");
119:                    break;
120:                case Status.STATUS_COMMITTING:
121:                    buffer.append("STATUS_COMMITTING: ");
122:                    buffer
123:                            .append("A transaction is associated with the target object and it is in the process of committing.");
124:                    break;
125:                case Status.STATUS_MARKED_ROLLBACK:
126:                    buffer.append("STATUS_MARKED_ROLLBACK: ");
127:                    buffer
128:                            .append("A transaction is associated with the target object and it has been marked for rollback, perhaps as a result of a setRollbackOnly operation.");
129:                    break;
130:                case Status.STATUS_NO_TRANSACTION:
131:                    buffer.append("STATUS_NO_TRANSACTION: ");
132:                    buffer
133:                            .append("No transaction is currently associated with the target object.");
134:                    break;
135:                case Status.STATUS_PREPARED:
136:                    buffer.append("STATUS_PREPARED: ");
137:                    buffer
138:                            .append("A transaction is associated with the target object and it has been prepared, i.e.");
139:                    break;
140:                case Status.STATUS_PREPARING:
141:                    buffer.append("STATUS_PREPARING: ");
142:                    buffer
143:                            .append("A transaction is associated with the target object and it is in the process of preparing.");
144:                    break;
145:                case Status.STATUS_ROLLEDBACK:
146:                    buffer.append("STATUS_ROLLEDBACK: ");
147:                    buffer
148:                            .append("A transaction is associated with the target object and the outcome has been determined as rollback.");
149:                    break;
150:                case Status.STATUS_ROLLING_BACK:
151:                    buffer.append("STATUS_ROLLING_BACK: ");
152:                    buffer
153:                            .append("A transaction is associated with the target object and it is in the process of rolling back.");
154:                    break;
155:                default:
156:                    buffer.append("Unknown status ").append(status);
157:                    break;
158:                }
159:                return buffer.toString();
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.