Source Code Cross Referenced for LocalTransactionImpl.java in  » J2EE » JOnAS-4.8.6 » ersatz » resourceadapter » 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 » JOnAS 4.8.6 » ersatz.resourceadapter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on December 10, 2003
003:         *
004:         * LocalTransactionImpl.java is used to test the J2EE Connector
005:         * as implemented by JOnAS. This class implements 
006:         * javax.resource.spi.LocalTransaction and 
007:         * javax.resource.cci.LocalTransaction
008:         */
009:        package ersatz.resourceadapter;
010:
011:        import javax.resource.ResourceException;
012:        import javax.resource.spi.ManagedConnection;
013:        import javax.resource.spi.ConnectionEvent;
014:
015:        /**
016:         * @author Bob Kruse
017:         *
018:         * Jtest Resource Adapter
019:         *
020:         * used to test the J2EE Connector as implemented by JOnAS.
021:         * 
022:         */
023:        public class LocalTransactionImpl implements 
024:                javax.resource.spi.LocalTransaction,
025:                javax.resource.cci.LocalTransaction {
026:            private ManagedConnection mc;
027:            String cName = "LocalTransactionImpl";
028:            private boolean sendEvent;
029:            //
030:            // This LocalTransactionImpl instance STATE
031:            final private int RESET = 0;
032:            final private int BEGUN = 1;
033:            final private int ENDED = 2;
034:            final private int PREPARED = 3;
035:            final private int FORGOT = 4;
036:            final private int COMMITTED = 5;
037:            final private int ROLLEDBACK = 6;
038:
039:            int txState;
040:
041:            public LocalTransactionImpl(ManagedConnection MC, boolean se) {
042:                Utility.log(cName + ".constructor");
043:                this .mc = MC;
044:                txState = RESET;
045:                sendEvent = se;
046:            }
047:
048:            public void setSendEvent(boolean event) {
049:                sendEvent = event;
050:            }
051:
052:            public int getTxState() {
053:                return txState;
054:            }
055:
056:            public ManagedConnection getCurrentMc() {
057:                return mc;
058:            }
059:
060:            public void begin() throws ResourceException {
061:                Utility.log(cName + ".begin (enter) txState=" + txState);
062:                int curState = txState;
063:                ManagedConnectionImpl omc = (ManagedConnectionImpl) mc;
064:                try {
065:                    if (txState == RESET) {
066:                        if (sendEvent) {
067:                            omc.sendEvent(
068:                                    ConnectionEvent.LOCAL_TRANSACTION_STARTED,
069:                                    null, omc.getCHandle());
070:                            txState = BEGUN;
071:                            Utility
072:                                    .log(cName
073:                                            + ".begin (exit) (sendEvent(LOCAL_TRANSACTION_STARTED="
074:                                            + ConnectionEvent.LOCAL_TRANSACTION_STARTED
075:                                            + "))" + " From State=" + curState
076:                                            + " to State=" + txState);
077:                        } else {
078:                            txState = BEGUN;
079:                        }
080:                        omc.inLocalTrans = true;
081:                    } else {
082:                        IllegalStateException ex = new IllegalStateException(
083:                                "LocalTransaction Already active");
084:                        Utility.log(cName + ".begin (exit) error: State="
085:                                + txState + " should be=" + RESET + ". "
086:                                + ex.getMessage());
087:                        throw ex;
088:                    }
089:
090:                } catch (Exception e) {
091:                    Utility.log(cName
092:                            + ".begin (exit) error: unable to sendEvent"
093:                            + " with 'LOCAL_TRANSACTION_STARTED' "
094:                            + e.toString());
095:                }
096:            }
097:
098:            public void commit() throws ResourceException {
099:                Utility.log(cName + ".commit (enter) txState=" + txState);
100:                int curState = txState;
101:                ManagedConnectionImpl omc = (ManagedConnectionImpl) mc;
102:                try {
103:                    if (txState == BEGUN) {
104:                        if (sendEvent) {
105:                            omc
106:                                    .sendEvent(
107:                                            ConnectionEvent.LOCAL_TRANSACTION_COMMITTED,
108:                                            null, omc.getCHandle());
109:                            txState = COMMITTED;
110:                            Utility
111:                                    .log(cName
112:                                            + ".commit (exit) (sendEvent(LOCAL_TRANSACTION_COMMITTED="
113:                                            + ConnectionEvent.LOCAL_TRANSACTION_COMMITTED
114:                                            + "))" + " From State=" + curState
115:                                            + " to State=" + txState);
116:                        } else {
117:                            txState = COMMITTED;
118:                        }
119:                    } else {
120:                        IllegalStateException ex = new IllegalStateException(
121:                                "LocalTransaction Illegal State during commit");
122:                        Utility.log(cName + ".commit (exit) error: State="
123:                                + txState + " should be=" + BEGUN + ". "
124:                                + ex.getMessage());
125:                        omc.inLocalTrans = false;
126:                        throw ex;
127:                    }
128:                } catch (Exception e) {
129:                    Utility.log(cName
130:                            + ".commit (exit) error: unable to sendEvent"
131:                            + " with 'LOCAL_TRANSACTION_COMMITTED' "
132:                            + e.toString());
133:                }
134:                omc.inLocalTrans = false;
135:            }
136:
137:            public void rollback() throws ResourceException {
138:                int curState = txState;
139:                Utility.log(cName + ".rollback (enter) txState=" + txState);
140:                ManagedConnectionImpl omc = (ManagedConnectionImpl) mc;
141:                try {
142:                    if (txState == BEGUN) {
143:                        if (sendEvent) {
144:                            omc
145:                                    .sendEvent(
146:                                            ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK,
147:                                            null, omc.getCHandle());
148:                            txState = ROLLEDBACK;
149:                            Utility
150:                                    .log(cName
151:                                            + ".rollback (exit) (sendEvent(LOCAL_TRANSACTION_ROLLEDBACK="
152:                                            + ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK
153:                                            + "))" + " From State=" + curState
154:                                            + " to State=" + txState);
155:                        } else {
156:                            txState = ROLLEDBACK;
157:                        }
158:                    } else {
159:                        IllegalStateException ex = new IllegalStateException(
160:                                "LocalTransaction Illegal State during rollback");
161:                        Utility.log(cName + ".rollback (exit) error: State="
162:                                + txState + " should be=" + BEGUN + ". "
163:                                + ex.getMessage());
164:                        omc.inLocalTrans = false;
165:                        throw ex;
166:                    }
167:                } catch (Exception e) {
168:                    Utility.log(cName
169:                            + ".rollback (exit) error: unable to sendEvent"
170:                            + " with 'LOCAL_TRANSACTION_ROLLEDBACK' "
171:                            + e.toString());
172:                }
173:                omc.inLocalTrans = false;
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.