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


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