Source Code Cross Referenced for Transaction.java in  » JMX » je » com » sleepycat » je » 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 » JMX » je » com.sleepycat.je 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: Transaction.java,v 1.48.2.5 2008/02/21 08:09:02 chao Exp $
007:         */
008:
009:        package com.sleepycat.je;
010:
011:        import com.sleepycat.je.txn.Locker;
012:        import com.sleepycat.je.txn.Txn;
013:        import com.sleepycat.je.utilint.PropUtil;
014:
015:        /**
016:         * Javadoc for this public class is generated
017:         * via the doc templates in the doc_src directory.
018:         */
019:        public class Transaction {
020:
021:            private Txn txn;
022:            private Environment env;
023:            private long id;
024:            private String name;
025:
026:            /**
027:             * Creates a transaction.
028:             */
029:            Transaction(Environment env, Txn txn) {
030:                this .env = env;
031:                this .txn = txn;
032:
033:                /*
034:                 * Copy the id to this wrapper object so the id will be available
035:                 * after the transaction is closed and the txn field is nulled.
036:                 */
037:                this .id = txn.getId();
038:            }
039:
040:            /**
041:             * Javadoc for this public method is generated via
042:             * the doc templates in the doc_src directory.
043:             */
044:            public void abort() throws DatabaseException {
045:
046:                try {
047:                    checkEnv();
048:                    env.removeReferringHandle(this );
049:                    txn.abort(false); // no sync required
050:
051:                    /* Remove reference to internal txn, so we can reclaim memory. */
052:                    txn = null;
053:                } catch (Error E) {
054:                    DbInternal.envGetEnvironmentImpl(env).invalidate(E);
055:                    throw E;
056:                }
057:            }
058:
059:            /**
060:             * Javadoc for this public method is generated via
061:             * the doc templates in the doc_src directory.
062:             */
063:            public long getId() throws DatabaseException {
064:
065:                return id;
066:            }
067:
068:            /**
069:             * Javadoc for this public method is generated via
070:             * the doc templates in the doc_src directory.
071:             */
072:            public void commit() throws DatabaseException {
073:
074:                try {
075:                    checkEnv();
076:                    env.removeReferringHandle(this );
077:                    txn.commit();
078:                    /* Remove reference to internal txn, so we can reclaim memory. */
079:                    txn = null;
080:                } catch (Error E) {
081:                    DbInternal.envGetEnvironmentImpl(env).invalidate(E);
082:                    throw E;
083:                }
084:            }
085:
086:            /**
087:             * Javadoc for this public method is generated via
088:             * the doc templates in the doc_src directory.
089:             */
090:            public void commitSync() throws DatabaseException {
091:
092:                doCommit(Txn.TXN_SYNC);
093:            }
094:
095:            /**
096:             * Javadoc for this public method is generated via
097:             * the doc templates in the doc_src directory.
098:             */
099:            public void commitNoSync() throws DatabaseException {
100:
101:                doCommit(Txn.TXN_NOSYNC);
102:            }
103:
104:            /**
105:             * Javadoc for this public method is generated via
106:             * the doc templates in the doc_src directory.
107:             */
108:            public void commitWriteNoSync() throws DatabaseException {
109:
110:                doCommit(Txn.TXN_WRITE_NOSYNC);
111:            }
112:
113:            public boolean getPrepared() {
114:                return txn.getPrepared();
115:            }
116:
117:            private void doCommit(byte commitType) throws DatabaseException {
118:
119:                try {
120:                    checkEnv();
121:                    env.removeReferringHandle(this );
122:                    txn.commit(commitType);
123:
124:                    /* Remove reference to internal txn, so we can reclaim memory. */
125:                    txn = null;
126:                } catch (Error E) {
127:                    DbInternal.envGetEnvironmentImpl(env).invalidate(E);
128:                    throw E;
129:                }
130:            }
131:
132:            /**
133:             * Javadoc for this public method is generated via
134:             * the doc templates in the doc_src directory.
135:             */
136:            public void setTxnTimeout(long timeout)
137:                    throws IllegalArgumentException, DatabaseException {
138:
139:                checkEnv();
140:                txn.setTxnTimeout(PropUtil.microsToMillis(timeout));
141:            }
142:
143:            /**
144:             * Javadoc for this public method is generated via
145:             * the doc templates in the doc_src directory.
146:             */
147:            public void setLockTimeout(long timeout)
148:                    throws IllegalArgumentException, DatabaseException {
149:
150:                checkEnv();
151:                txn.setLockTimeout(PropUtil.microsToMillis(timeout));
152:            }
153:
154:            /**
155:             * Javadoc for this public method is generated via
156:             * the doc templates in the doc_src directory.
157:             */
158:            public void setName(String name) {
159:                this .name = name;
160:            }
161:
162:            /**
163:             * Javadoc for this public method is generated via
164:             * the doc templates in the doc_src directory.
165:             */
166:            public String getName() {
167:                return name;
168:            }
169:
170:            public int hashCode() {
171:                return (int) id;
172:            }
173:
174:            public boolean equals(Object o) {
175:                if (o == null) {
176:                    return false;
177:                }
178:
179:                if (!(o instanceof  Transaction)) {
180:                    return false;
181:                }
182:
183:                if (((Transaction) o).id == id) {
184:                    return true;
185:                }
186:
187:                return false;
188:            }
189:
190:            public String toString() {
191:                StringBuffer sb = new StringBuffer();
192:                sb.append("<Transaction id=\"");
193:                sb.append(id).append("\"");
194:                if (name != null) {
195:                    sb.append(" name=\"");
196:                    sb.append(name).append("\"");
197:                }
198:                sb.append(">");
199:                return sb.toString();
200:            }
201:
202:            /**
203:             * This method should only be called by the LockerFactory.getReadableLocker
204:             * and getWritableLocker methods.  The locker returned does not enforce the
205:             * readCommitted isolation setting.
206:             */
207:            Locker getLocker() throws DatabaseException {
208:
209:                if (txn == null) {
210:                    throw new DatabaseException("Transaction " + id
211:                            + " has been closed and is no longer" + " usable.");
212:                } else {
213:                    return txn;
214:                }
215:            }
216:
217:            /*
218:             * Helpers
219:             */
220:
221:            Txn getTxn() {
222:                return txn;
223:            }
224:
225:            /**
226:             * @throws RunRecoveryException if the underlying environment is invalid.
227:             */
228:            private void checkEnv() throws RunRecoveryException {
229:
230:                env.getEnvironmentImpl().checkIfInvalid();
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.