Source Code Cross Referenced for XactContext.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » store » raw » xact » 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 » Database DBMS » db derby 10.2 » org.apache.derby.impl.store.raw.xact 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.store.raw.xact.XactContext
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.store.raw.xact;
023:
024:        import org.apache.derby.iapi.reference.SQLState;
025:
026:        // This is the recommended super-class for all contexts.
027:        import org.apache.derby.iapi.services.context.ContextImpl;
028:        import org.apache.derby.iapi.services.context.ContextManager;
029:
030:        import org.apache.derby.iapi.services.sanity.SanityManager;
031:
032:        import org.apache.derby.iapi.store.raw.RawStoreFactory;
033:        import org.apache.derby.iapi.store.raw.xact.RawTransaction;
034:
035:        import org.apache.derby.iapi.error.StandardException;
036:
037:        import org.apache.derby.iapi.error.ExceptionSeverity;
038:
039:        /**
040:         The context associated with the transaction.
041:
042:         This object stores the context associated with the raw store transaction
043:         on the stack.  It stores info about the transaction opened within a 
044:         context manager (ie. typically a single user) for a single RawStoreFactory.
045:
046:         **/
047:
048:        final class XactContext extends ContextImpl {
049:
050:            private RawTransaction xact;
051:            private RawStoreFactory factory;
052:            private boolean abortAll; // true if any exception causes this transaction to be aborted.
053:
054:            XactContext(ContextManager cm, String name, Xact xact,
055:                    boolean abortAll, RawStoreFactory factory) {
056:                super (cm, name);
057:
058:                this .xact = xact;
059:                this .abortAll = abortAll;
060:                this .factory = factory;
061:                xact.xc = this ; // double link between transaction and myself
062:            }
063:
064:            /*
065:             ** Context methods (most are implemented by super-class)
066:             */
067:
068:            /**
069:            	@exception StandardException Standard Cloudscape error policy
070:             */
071:            public void cleanupOnError(Throwable error)
072:                    throws StandardException {
073:
074:                if (SanityManager.DEBUG) {
075:                    SanityManager.ASSERT(getContextManager() != null);
076:                }
077:
078:                boolean throwAway = false;
079:
080:                if (error instanceof  StandardException) {
081:                    StandardException se = (StandardException) error;
082:
083:                    if (abortAll) {
084:                        // any error aborts an internal/nested xact and its transaction
085:
086:                        if (se.getSeverity() < ExceptionSeverity.TRANSACTION_SEVERITY) {
087:                            throw StandardException
088:                                    .newException(
089:                                            SQLState.XACT_INTERNAL_TRANSACTION_EXCEPTION,
090:                                            error);
091:                        }
092:
093:                        throwAway = true;
094:
095:                    } else {
096:
097:                        // If the severity is lower than a transaction error then do nothing.
098:                        if (se.getSeverity() < ExceptionSeverity.TRANSACTION_SEVERITY) {
099:                            return;
100:                        }
101:
102:                        // If the session is going to disappear then we want to close this
103:                        // transaction, not just abort it.
104:                        if (se.getSeverity() >= ExceptionSeverity.SESSION_SEVERITY)
105:                            throwAway = true;
106:                    }
107:                } else {
108:                    // some java* error, throw away the transaction.
109:                    throwAway = true;
110:                }
111:
112:                try {
113:
114:                    if (xact != null) {
115:                        // abort the transaction
116:                        xact.abort();
117:                    }
118:
119:                } catch (StandardException se) {
120:                    // if we get an error during abort then shut the system down
121:                    throwAway = true;
122:
123:                    // if the system was being shut down anyway, do nothing
124:                    if ((se.getSeverity() <= ExceptionSeverity.SESSION_SEVERITY)
125:                            && (se.getSeverity() >= ((StandardException) error)
126:                                    .getSeverity())) {
127:
128:                        throw factory
129:                                .markCorrupt(StandardException.newException(
130:                                        SQLState.XACT_ABORT_EXCEPTION, se));
131:                    }
132:
133:                } finally {
134:
135:                    if (throwAway) {
136:                        // xact close will pop this context out of the context
137:                        // stack 
138:                        xact.close();
139:                        xact = null;
140:                    }
141:                }
142:
143:            }
144:
145:            RawTransaction getTransaction() {
146:                return xact;
147:            }
148:
149:            RawStoreFactory getFactory() {
150:                return factory;
151:            }
152:
153:            void substituteTransaction(Xact newTran) {
154:                // disengage old tran from this xact context
155:                Xact oldTran = (Xact) xact;
156:                if (oldTran.xc == this )
157:                    oldTran.xc = null;
158:
159:                // set up double link between new transaction and myself
160:                xact = newTran;
161:                ((Xact) xact).xc = this;
162:            }
163:
164:        }
w_w___w___.___j_a__va__2_s___.__c__o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.