Source Code Cross Referenced for JDOTransactionImpl.java in  » Database-ORM » Speedo_1.4.5 » org » objectweb » speedo » workingset » jdo » lib » 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 ORM » Speedo_1.4.5 » org.objectweb.speedo.workingset.jdo.lib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) 2001-2004 France Telecom R&D
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */package org.objectweb.speedo.workingset.jdo.lib;
018:
019:        import org.objectweb.perseus.persistence.api.PersistenceException;
020:        import org.objectweb.speedo.api.ExceptionHelper;
021:        import org.objectweb.speedo.api.SpeedoProperties;
022:        import org.objectweb.speedo.api.SpeedoRuntimeException;
023:        import org.objectweb.speedo.pm.jdo.api.JDOPOManagerItf;
024:        import org.objectweb.speedo.workingset.jdo.api.JDOTransactionItf;
025:        import org.objectweb.speedo.workingset.lib.AbstractTransaction;
026:        import org.objectweb.util.monolog.api.BasicLevel;
027:
028:        import javax.jdo.JDOException;
029:        import javax.jdo.JDOFatalException;
030:        import javax.jdo.JDOUserException;
031:        import javax.jdo.PersistenceManager;
032:        import javax.naming.InitialContext;
033:        import javax.transaction.Synchronization;
034:        import javax.transaction.TransactionManager;
035:
036:        /**
037:         * Is a working set assocaited to a POManagerItf. The working set can be
038:         * transactional or not. It contains the list of reached instances.
039:         *
040:         * @see javax.jdo.Transaction
041:         * @see org.objectweb.speedo.workingset.jdo.api.JDOTransactionItf
042:         * @see org.objectweb.perseus.persistence.api.WorkingSet
043:         * @see org.objectweb.perseus.persistence.lib.BasicWorkingSet
044:         *
045:         * @author S.Chassande-Barrioz
046:         */
047:        public class JDOTransactionImpl extends AbstractTransaction implements 
048:                JDOTransactionItf {
049:
050:            // IMPLEMENTATION OF THE JDOTransactionItf INTERFACE //
051:            //-----------------------------------------------------//
052:
053:            public RuntimeException rollBackOnInternalError(Exception _e) {
054:                Exception ie = ExceptionHelper.getNested(_e);
055:                if (isActive()) {
056:                    if (managedEnv) {
057:                        logger.log(BasicLevel.INFO, ".");
058:                        String tmName = ((JDOPOManagerItf) pm)
059:                                .getPersistenceManagerFactory().getProperties()
060:                                .getProperty(SpeedoProperties.TM_NAME);
061:                        if (tmName == null) {
062:                            return new JDOFatalException(
063:                                    "No transaction manager jndi name found in initialisation properties");
064:                        }
065:                        try {
066:                            Object o = new InitialContext().lookup(tmName);
067:                            if (o == null) {
068:                                String msg = "The transaction must be marked as rollbackOnly: JNDI retrieves a null transaction manager for the name '"
069:                                        + tmName + "'.";
070:                                logger.log(BasicLevel.ERROR, msg);
071:                                return new JDOFatalException(msg);
072:                            }
073:                            if (!(o instanceof  TransactionManager)) {
074:                                String msg = "The transaction must be marked as rollbackOnly: JNDI retrieves an object which is not a javax.transaction.TransactionManager (JNDI name: "
075:                                        + tmName + "): " + o;
076:                                logger.log(BasicLevel.ERROR, msg);
077:                                return new JDOFatalException(msg);
078:                            }
079:                            javax.transaction.Transaction t = ((TransactionManager) o)
080:                                    .getTransaction();
081:                            if (t == null) {
082:                                String msg = "Impossible to rollback an unexisting transaction (TM.getTransaction()=null)";
083:                                logger.log(BasicLevel.ERROR, msg);
084:                                return new JDOFatalException(msg);
085:                            }
086:                            t.setRollbackOnly();
087:                        } catch (Exception e) {
088:                            String msg = "The transaction must be marked as rollbackOnly: Error when lookup the transaction manager in JNDI with the name '"
089:                                    + tmName + "'";
090:                            logger.log(BasicLevel.ERROR, msg, e);
091:                            return new JDOFatalException(msg);
092:                        }
093:                    } else {
094:                        rollback();
095:                    }
096:                    return new JDOFatalException(
097:                            "The current transaction has been rolledback, please retry",
098:                            ie);
099:                } else {
100:                    return new JDOFatalException(
101:                            "The current working set occrurs an error, please retry",
102:                            ie);
103:                }
104:            }
105:
106:            public void beforeWSPrepare() throws PersistenceException {
107:                try {
108:                    super .beforeWSPrepare();
109:                } catch (SpeedoRuntimeException e) {
110:                    Exception ne;
111:                    if (e.causes != null) {
112:                        ne = new JDOUserException(e.getMessage(), e.causes);
113:                    } else if (e.getCause() != null) {
114:                        ne = new JDOUserException(e.getMessage(), e.getCause());
115:                    } else {
116:                        ne = new JDOUserException(e.getMessage());
117:                    }
118:                    throw new PersistenceException(ne);
119:                }
120:            }
121:
122:            public void onWSEnd() {
123:                try {
124:                    super .onWSEnd();
125:                } catch (SpeedoRuntimeException e) {
126:                    if (e.causes != null) {
127:                        throw new JDOUserException(e.getMessage(), e.causes);
128:                    } else if (e.getCause() != null) {
129:                        throw new JDOUserException(e.getMessage(), e.getCause());
130:                    } else {
131:                        throw new JDOUserException(e.getMessage());
132:                    }
133:                }
134:            }
135:
136:            // IMPLEMENTATION OF THE javax.jdo.Transactionn INTERFACE //
137:            //--------------------------------------------------------//
138:
139:            public void begin() {
140:                logger.log(BasicLevel.INFO, "Begin the transaction");
141:                try {
142:                    super .begin();
143:                } catch (SpeedoRuntimeException e) {
144:                    throw new JDOException(e.getMessage(), e.getCause());
145:                }
146:            }
147:
148:            public void commit() {
149:                try {
150:                    super .commit();
151:                } catch (SpeedoRuntimeException e) {
152:                    if (e.causes != null && e.causes.length == 1
153:                            && e.causes[0] instanceof  JDOException) {
154:                        throw (JDOException) e.causes[0];
155:                    }
156:                    throw new JDOFatalException(e.getMessage(), e);
157:                }
158:            }
159:
160:            public void rollback() {
161:                try {
162:                    super .rollback();
163:                } catch (SpeedoRuntimeException e) {
164:                    throw new JDOException(e.getMessage(), e);
165:                }
166:            }
167:
168:            public void setNontransactionalRead(boolean b) {
169:                nontransactionalRead = b;
170:            }
171:
172:            public boolean getNontransactionalRead() {
173:                return nontransactionalRead;
174:            }
175:
176:            public void setNontransactionalWrite(boolean b) {
177:                nontransactionalWrite = b;
178:            }
179:
180:            public boolean getNontransactionalWrite() {
181:                return nontransactionalWrite;
182:            }
183:
184:            public void setRetainValues(boolean b) {
185:                setWSRetainValues(b);
186:            }
187:
188:            public boolean getRetainValues() {
189:                return getWSRetainValues();
190:            }
191:
192:            public void setRestoreValues(boolean b) {
193:                setWSRestoreValues(b);
194:            }
195:
196:            public boolean getRestoreValues() {
197:                return getWSRestoreValues();
198:            }
199:
200:            public void setOptimistic(boolean b) {
201:                optimistic = b;
202:            }
203:
204:            public boolean getOptimistic() {
205:                return optimistic;
206:            }
207:
208:            public void setSynchronization(Synchronization s) {
209:                synchronization = s;
210:            }
211:
212:            public Synchronization getSynchronization() {
213:                return synchronization;
214:            }
215:
216:            public PersistenceManager getPersistenceManager() {
217:                return (JDOPOManagerItf) pm;
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.