Source Code Cross Referenced for XAResourceImpl.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:         * XAResourceImpl.java is used to test the J2EE Connector
005:         * as implemented by JOnAS. This class implements the XAResource Interface
006:         *  
007:         */
008:        package fictional.resourceadapter;
009:
010:        import javax.resource.spi.ManagedConnection;
011:        import javax.transaction.xa.XAResource;
012:        import javax.transaction.xa.Xid;
013:        import javax.transaction.xa.XAException;
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 XAResourceImpl implements  XAResource, java.io.Serializable {
028:            private ManagedConnection mc;
029:            private Logger logger = null;
030:            String cName = "XAResourceImpl";
031:            int timeout = 0;
032:            Xid currentXid;
033:
034:            public XAResourceImpl(ManagedConnection MC) { // constructor for XAResource
035:                if (logger == null) {
036:                    logger = Log.getLogger("fictional.resourceadapter");
037:                }
038:                logger.log(BasicLevel.DEBUG, impl(this ) + ".constructor");
039:                this .mc = MC;
040:                xidState = RESET;
041:            }
042:
043:            private String impl(Object obj) {
044:                if (obj instanceof  XAResource) {
045:                    return "XAResource";
046:                } else if (obj instanceof  XAResourceImpl) {
047:                    return "XAResourceImpl";
048:                } else
049:                    return "XAResourceImpl. Is this an error";
050:            }
051:
052:            //
053:            // *****************
054:            //    XAResource    methods
055:            // *****************
056:            //
057:            protected Xid xidArray[];
058:            // This XAResourceImpl instance STATE
059:            final private int RESET = 0;
060:            final private int STARTED = 1;
061:            final private int ENDED = 2;
062:            final private int PREPARED = 3;
063:            final private int FORGOT = 4;
064:            final private int COMMITTED = 5;
065:            final private int ROLLEDBACK = 6;
066:
067:            int xFlags;
068:            int recoverFlag;
069:            int xidState;
070:
071:            public int getXidState() {
072:                return xidState;
073:            }
074:
075:            public Xid getCurrentXid() {
076:                return currentXid;
077:            }
078:
079:            public ManagedConnection getCurrentMc() {
080:                return mc;
081:            }
082:
083:            public void commit(Xid xid, boolean onePhase) throws XAException {
084:                int curState = xidState;
085:                if (xidState > RESET) {
086:                    xidState = COMMITTED;
087:                    logger.log(BasicLevel.DEBUG, impl(this )
088:                            + ".commit From State=" + curState + " to State="
089:                            + xidState + " xid=" + xid + " onePhase="
090:                            + onePhase);
091:                } else {
092:                    logger.log(BasicLevel.DEBUG, impl(this )
093:                            + ".commit error: State=" + xidState
094:                            + " should be=" + STARTED + "or more. xid=" + xid
095:                            + " onePhase=" + onePhase);
096:                }
097:            }
098:
099:            public void end(Xid xid, int flags) throws XAException {
100:                int curState = xidState;
101:                xidState = ENDED;
102:                JtestResourceAdapter jmc = (JtestResourceAdapter) mc;
103:                jmc.resetXar();
104:                logger.log(BasicLevel.DEBUG, impl(this ) + ".end From State="
105:                        + curState + " to State=" + xidState + " for xid="
106:                        + xid + " flags=" + flags);
107:            }
108:
109:            public void forget(Xid xid) throws XAException {
110:                logger.log(BasicLevel.DEBUG, impl(this ) + ".forget State="
111:                        + xidState);
112:                xidState = FORGOT;
113:            }
114:
115:            public int prepare(Xid xid) throws XAException {
116:                logger.log(BasicLevel.DEBUG, impl(this ) + ".prepare State="
117:                        + xidState);
118:                xidState = PREPARED;
119:                //return 1;
120:                return XA_OK;
121:            }
122:
123:            /**
124:             *  Obtain a list of prepared transaction branches from a resource manager. 
125:             */
126:            public Xid[] recover(int flag) throws XAException {
127:                recoverFlag = flag;
128:                logger.log(BasicLevel.DEBUG, impl(this ) + ".recover State="
129:                        + xidState);
130:                return xidArray;
131:            }
132:
133:            public void rollback(Xid xid) throws XAException {
134:                int curState = xidState;
135:                if (xidState >= STARTED) {
136:                    xidState = ROLLEDBACK;
137:                    logger.log(BasicLevel.DEBUG, impl(this )
138:                            + ".rollback From State=" + curState + " to State="
139:                            + xidState + " xid=" + xid);
140:                } else {
141:                    logger.log(BasicLevel.DEBUG, impl(this )
142:                            + ".rollback error: State=" + xidState
143:                            + " should be=" + STARTED + "or more. xid=" + xid);
144:                }
145:            }
146:
147:            public void start(Xid xid, int flags) throws XAException {
148:                currentXid = xid;
149:                xFlags = flags;
150:                int curState = xidState;
151:                if (xidState == RESET) {
152:                    xidState = STARTED;
153:                    logger.log(BasicLevel.DEBUG, impl(this )
154:                            + ".start From State=" + curState + " to State="
155:                            + xidState + " xid=" + xid + " flags=" + flags);
156:                } else {
157:                    logger.log(BasicLevel.DEBUG, impl(this )
158:                            + ".start error: State=" + xidState + " should be="
159:                            + RESET + " xid=" + xid + " flags=" + flags);
160:                }
161:            }
162:
163:            public int getTransactionTimeout() throws XAException {
164:                logger.log(BasicLevel.DEBUG, impl(this )
165:                        + ".getTransactionTimeout timeout=" + timeout);
166:                return timeout;
167:            }
168:
169:            public boolean setTransactionTimeout(int seconds)
170:                    throws XAException {
171:                timeout = seconds;
172:                logger.log(BasicLevel.DEBUG, impl(this )
173:                        + ".setTransactionTimeout seconds=" + seconds);
174:                return true;
175:            }
176:
177:            /**
178:             *  Determine if the resource manager instance represented by the target object is the 
179:             *  same as the resource manager instance represented by the parameter xares  
180:             */
181:            public boolean isSameRM(XAResource xares) throws XAException {
182:                boolean a = true;
183:                logger.log(BasicLevel.DEBUG, impl(this ) + ".isSameRM xares="
184:                        + xares + " return=" + a);
185:                return a;
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.