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


0001:        /**
0002:         * perseus/connector: this is an implementation of some JCA-related technologies
0003:         * (resource adapters and managers) for the ObjectWeb consortium.
0004:         * Copyright (C) 2001-2004 France Telecom R&D
0005:         *
0006:         * This library is free software; you can redistribute it and/or
0007:         * modify it under the terms of the GNU Lesser General Public
0008:         * License as published by the Free Software Foundation; either
0009:         * version 2 of the License, or (at your option) any later version.
0010:         *
0011:         * This library is distributed in the hope that it will be useful,
0012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014:         * Lesser General Public License for more details.
0015:         *
0016:         * You should have received a copy of the GNU Lesser General Public
0017:         * License along with this library; if not, write to the Free Software
0018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0019:         *
0020:         * Contact: speedo@objectweb.org
0021:         *
0022:         */package org.objectweb.speedo.jca.jdo;
0023:
0024:        import org.objectweb.util.monolog.api.BasicLevel;
0025:        import org.objectweb.util.monolog.api.Logger;
0026:        import org.objectweb.speedo.api.Debug;
0027:        import org.objectweb.speedo.api.SpeedoProperties;
0028:        import org.objectweb.speedo.jca.SpeedoManagedConnection;
0029:        import org.objectweb.speedo.jca.SpeedoConnection;
0030:        import org.objectweb.speedo.pm.jdo.api.JDOPOManagerItf;
0031:
0032:        import java.util.Collection;
0033:
0034:        import javax.naming.Context;
0035:        import javax.naming.InitialContext;
0036:        import javax.resource.ResourceException;
0037:        import javax.resource.cci.Connection;
0038:        import javax.resource.cci.ConnectionMetaData;
0039:        import javax.resource.cci.Interaction;
0040:        import javax.resource.cci.LocalTransaction;
0041:        import javax.resource.cci.ResultSetInfo;
0042:        import javax.transaction.Synchronization;
0043:        import javax.transaction.UserTransaction;
0044:        import javax.jdo.datastore.JDOConnection;
0045:        import javax.jdo.datastore.Sequence;
0046:        import javax.jdo.listener.InstanceLifecycleListener;
0047:        import javax.jdo.FetchPlan;
0048:        import javax.jdo.PersistenceManager;
0049:        import javax.jdo.JDOException;
0050:        import javax.jdo.Transaction;
0051:        import javax.jdo.Query;
0052:        import javax.jdo.Extent;
0053:        import javax.jdo.PersistenceManagerFactory;
0054:
0055:        /**
0056:         * @author	P. Dechamboux
0057:         */
0058:        public class JDOConnectionImpl extends SpeedoConnection implements 
0059:                Connection, ConnectionMetaData, PersistenceManager, Transaction {
0060:            /**
0061:             * The logger into which traces about JDOConnectionImpl are produced.
0062:             */
0063:            private Logger logger;
0064:            /**
0065:             * The name of this storage sub-system.
0066:             */
0067:            private final static String EISPRODUCTNAME = "JDO Connector";
0068:            /**
0069:             * The ConnectionFactory that have requested the allocation of this
0070:             * Connection.
0071:             */
0072:            private JDOConnectionFactory connectionFactory;
0073:            /**
0074:             * The LocalTransaction allocated by this connection if any.
0075:             */
0076:            private LocalTransaction localTransaction = null;
0077:
0078:            /**
0079:             * The UserTransaction of JTA
0080:             */
0081:            private UserTransaction userTransaction = null;
0082:
0083:            /**
0084:             * Constructs a JDOConnectionImpl.
0085:             * @param el	The logger into which to produce Connection-related traces.
0086:             * @param fcf	The ConnectionFactory that has requested the Connection
0087:             * 				creation.
0088:             */
0089:            JDOConnectionImpl(Logger el, JDOConnectionFactory fcf) {
0090:                logger = el;
0091:                connectionFactory = fcf;
0092:            }
0093:
0094:            /**
0095:             * Initializes a Connection to be linked with a ManagedConnection.
0096:             * @param mc	The ManagedConnection to be linked to.
0097:             */
0098:            void initialize(SpeedoManagedConnection mc) {
0099:                managedConnection = mc;
0100:            }
0101:
0102:            // IMPLEMENTATION OF METHODS FROM THE (cci)Connection INTERFACE
0103:
0104:            /**
0105:             * No support for Interaction.
0106:             */
0107:            public Interaction createInteraction() throws ResourceException {
0108:                throw new ResourceException(
0109:                        "JDO Connector: no support for Interaction.");
0110:            }
0111:
0112:            public LocalTransaction getLocalTransaction()
0113:                    throws ResourceException {
0114:                if (managedConnection == null) {
0115:                    throw new ResourceException(
0116:                            "JDO Connector: cannot get a LocalTransaction with no associated ManagedConnection.");
0117:                }
0118:                localTransaction = managedConnection;
0119:                return managedConnection;
0120:            }
0121:
0122:            /**
0123:             * The JDOConnectionImpl manages the metadata on its own.
0124:             */
0125:            public ConnectionMetaData getMetaData() throws ResourceException {
0126:                return this ;
0127:            }
0128:
0129:            /**
0130:             * No support for ResultSet.
0131:             */
0132:            public ResultSetInfo getResultSetInfo() throws ResourceException {
0133:                throw new ResourceException(
0134:                        "JDO Connector: no support for ResultSet.");
0135:            }
0136:
0137:            /**
0138:             * Closes this Connection. Dissociates from the ManagedConnection to which
0139:             * it is linked.
0140:             */
0141:            public void close() {
0142:                if (Debug.ON)
0143:                    logger.log(BasicLevel.DEBUG, "Closes Connection: " + this );
0144:                if (managedConnection == null) {
0145:                    // The connection is already closed
0146:                    return;
0147:                }
0148:                if (localTransaction != null) {
0149:                    if (!managedConnection.localTransactionTerminated()) {
0150:                        throw new JDOException(
0151:                                "JDO Connector: cannot close connection while a LocalTransaction is still active.");
0152:                    }
0153:                }
0154:                try {
0155:                    managedConnection.dissociateConnection(this );
0156:                } catch (ResourceException e) {
0157:                    throw new JDOException(
0158:                            "JDO Connector: problem while closing a connection.",
0159:                            e);
0160:                } finally {
0161:                    localTransaction = null;
0162:                    managedConnection = null;
0163:                }
0164:            }
0165:
0166:            /**
0167:             * Sets the connection to the relevant auto-commit mode.
0168:             */
0169:            public void setAutoCommit(boolean b) throws ResourceException {
0170:                throw new ResourceException("No sense for a JDO connector.");
0171:            }
0172:
0173:            /**
0174:             * Gets the connection auto-commit mode.
0175:             */
0176:            public boolean getAutoCommit() throws ResourceException {
0177:                throw new ResourceException("No sense for a JDO connector.");
0178:            }
0179:
0180:            // IMPLEMENTATION OF METHODS FROM THE (cci)ConnectionMetaData INTERFACE
0181:
0182:            /**
0183:             * Returns the name of this storage sub-system.
0184:             * @return	The storage sub-system name.
0185:             */
0186:            public String getEISProductName() throws ResourceException {
0187:                return EISPRODUCTNAME;
0188:            }
0189:
0190:            /**
0191:             * This is the same version number as the adapter.
0192:             * @return	The storage sub-system version.
0193:             */
0194:            public String getEISProductVersion() throws ResourceException {
0195:                return connectionFactory.getAdapterVersion();
0196:            }
0197:
0198:            /**
0199:             * No support for user name.
0200:             * @return	The empty string.
0201:             */
0202:            public String getUserName() throws ResourceException {
0203:                return "";
0204:            }
0205:
0206:            // IMPLEMENTATION OF METHODS FROM THE PersistenceManager INTERFACE
0207:            // Delegates execution to the associated ManagedConnection.
0208:
0209:            public boolean isClosed() {
0210:                return managedConnection == null;
0211:            }
0212:
0213:            public Transaction currentTransaction() {
0214:                if (managedConnection == null) {
0215:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0216:                }
0217:                //if transaction mode is not normal, return this
0218:                if (connectionFactory.getTransactionMode() != SpeedoProperties.TRANSACTION_BMODE_NORMAL) {
0219:                    if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) {
0220:                        try {
0221:                            if (userTransaction == null) {
0222:                                Context ic = new InitialContext();
0223:                                userTransaction = (UserTransaction) ic
0224:                                        .lookup("javax.transaction.UserTransaction");
0225:                            }
0226:                            logger.log(BasicLevel.DEBUG,
0227:                                    "UserTransaction is used.");
0228:                        } catch (Exception e) {
0229:                            throw new JDOException(
0230:                                    "Error with JTA UserTransaction", e);
0231:                        }
0232:                    }
0233:                    return this ;
0234:                } else {
0235:                    return ((JDOPOManagerItf) managedConnection.getPOManager())
0236:                            .currentTransaction();
0237:                }
0238:            }
0239:
0240:            public void evict(Object o) {
0241:                if (managedConnection == null) {
0242:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0243:                }
0244:                ((JDOPOManagerItf) managedConnection.getPOManager()).evict(o);
0245:            }
0246:
0247:            public void evictAll(Object[] objects) {
0248:                if (managedConnection == null) {
0249:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0250:                }
0251:                ((JDOPOManagerItf) managedConnection.getPOManager())
0252:                        .evictAll(objects);
0253:            }
0254:
0255:            public void evictAll(Collection collection) {
0256:                if (managedConnection == null) {
0257:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0258:                }
0259:                ((JDOPOManagerItf) managedConnection.getPOManager())
0260:                        .evictAll(collection);
0261:            }
0262:
0263:            public void evictAll() {
0264:                if (managedConnection == null) {
0265:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0266:                }
0267:                ((JDOPOManagerItf) managedConnection.getPOManager()).evictAll();
0268:            }
0269:
0270:            public void refresh(Object o) {
0271:                if (managedConnection == null) {
0272:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0273:                }
0274:                ((JDOPOManagerItf) managedConnection.getPOManager()).refresh(o);
0275:            }
0276:
0277:            public void refreshAll(Object[] objects) {
0278:                if (managedConnection == null) {
0279:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0280:                }
0281:                ((JDOPOManagerItf) managedConnection.getPOManager())
0282:                        .refreshAll(objects);
0283:            }
0284:
0285:            public void refreshAll(Collection collection) {
0286:                if (managedConnection == null) {
0287:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0288:                }
0289:                ((JDOPOManagerItf) managedConnection.getPOManager())
0290:                        .refreshAll(collection);
0291:            }
0292:
0293:            public void refreshAll() {
0294:                if (managedConnection == null) {
0295:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0296:                }
0297:                ((JDOPOManagerItf) managedConnection.getPOManager())
0298:                        .refreshAll();
0299:            }
0300:
0301:            public Query newQuery() {
0302:                if (managedConnection == null) {
0303:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0304:                }
0305:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0306:                        .newQuery();
0307:            }
0308:
0309:            public Query newQuery(String q) {
0310:                if (managedConnection == null) {
0311:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0312:                }
0313:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0314:                        .newQuery(q);
0315:            }
0316:
0317:            public Query newQuery(Object o) {
0318:                if (managedConnection == null) {
0319:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0320:                }
0321:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0322:                        .newQuery(o);
0323:            }
0324:
0325:            public Query newQuery(String s, Object o) {
0326:                if (managedConnection == null) {
0327:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0328:                }
0329:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0330:                        .newQuery(s, o);
0331:            }
0332:
0333:            public Query newQuery(Class aClass) {
0334:                if (managedConnection == null) {
0335:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0336:                }
0337:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0338:                        .newQuery(aClass);
0339:            }
0340:
0341:            public Query newQuery(Extent extent) {
0342:                if (managedConnection == null) {
0343:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0344:                }
0345:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0346:                        .newQuery(extent);
0347:            }
0348:
0349:            public Query newQuery(Class aClass, Collection collection) {
0350:                if (managedConnection == null) {
0351:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0352:                }
0353:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0354:                        .newQuery(aClass, collection);
0355:            }
0356:
0357:            public Query newQuery(Class aClass, String s) {
0358:                if (managedConnection == null) {
0359:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0360:                }
0361:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0362:                        .newQuery(aClass, s);
0363:            }
0364:
0365:            public Query newQuery(Class aClass, Collection collection, String s) {
0366:                if (managedConnection == null) {
0367:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0368:                }
0369:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0370:                        .newQuery(aClass, collection, s);
0371:            }
0372:
0373:            public Query newQuery(Extent extent, String s) {
0374:                if (managedConnection == null) {
0375:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0376:                }
0377:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0378:                        .newQuery(extent, s);
0379:            }
0380:
0381:            public Extent getExtent(Class aClass, boolean b) {
0382:                if (managedConnection == null) {
0383:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0384:                }
0385:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0386:                        .getExtent(aClass, b);
0387:            }
0388:
0389:            public Object getObjectById(Object o, boolean b) {
0390:                if (managedConnection == null) {
0391:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0392:                }
0393:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0394:                        .getObjectById(o, b);
0395:            }
0396:
0397:            public Collection getObjectsById(Collection arg0, boolean arg1) {
0398:                if (managedConnection == null) {
0399:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0400:                }
0401:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0402:                        .getObjectsById(arg0, arg1);
0403:            }
0404:
0405:            public Collection getObjectsById(Collection arg0) {
0406:                if (managedConnection == null) {
0407:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0408:                }
0409:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0410:                        .getObjectsById(arg0);
0411:            }
0412:
0413:            public Object[] getObjectsById(Object[] arg0, boolean arg1) {
0414:                if (managedConnection == null) {
0415:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0416:                }
0417:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0418:                        .getObjectsById(arg0, arg1);
0419:            }
0420:
0421:            public Object[] getObjectsById(Object[] arg0) {
0422:                if (managedConnection == null) {
0423:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0424:                }
0425:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0426:                        .getObjectsById(arg0);
0427:            }
0428:
0429:            public Sequence getSequence(String arg0) {
0430:                if (managedConnection == null) {
0431:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0432:                }
0433:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0434:                        .getSequence(arg0);
0435:            }
0436:
0437:            public Object getUserObject(Object arg0) {
0438:                if (managedConnection == null) {
0439:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0440:                }
0441:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0442:                        .getUserObject(arg0);
0443:            }
0444:
0445:            public Object newInstance(Class arg0) {
0446:                if (managedConnection == null) {
0447:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0448:                }
0449:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0450:                        .newInstance(arg0);
0451:            }
0452:
0453:            public Object putUserObject(Object arg0, Object arg1) {
0454:                if (managedConnection == null) {
0455:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0456:                }
0457:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0458:                        .putUserObject(arg0, arg1);
0459:            }
0460:
0461:            public Object removeUserObject(Object arg0) {
0462:                if (managedConnection == null) {
0463:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0464:                }
0465:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0466:                        .removeUserObject(arg0);
0467:            }
0468:
0469:            public Object getObjectId(Object o) {
0470:                if (managedConnection == null) {
0471:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0472:                }
0473:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0474:                        .getObjectId(o);
0475:            }
0476:
0477:            public Object getObjectById(Class clazz, Object o) {
0478:                if (managedConnection == null) {
0479:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0480:                }
0481:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0482:                        .getObjectById(clazz, o);
0483:            }
0484:
0485:            public Object getObjectById(Object o) {
0486:                if (managedConnection == null) {
0487:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0488:                }
0489:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0490:                        .getObjectById(o);
0491:            }
0492:
0493:            public Object getTransactionalObjectId(Object o) {
0494:                if (managedConnection == null) {
0495:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0496:                }
0497:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0498:                        .getTransactionalObjectId(o);
0499:            }
0500:
0501:            public Object newObjectIdInstance(Class aClass, Object s) {
0502:                if (managedConnection == null) {
0503:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0504:                }
0505:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0506:                        .newObjectIdInstance(aClass, s);
0507:            }
0508:
0509:            public Object makePersistent(Object o) {
0510:                if (managedConnection == null) {
0511:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0512:                }
0513:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0514:                        .makePersistent(o);
0515:            }
0516:
0517:            public Object[] makePersistentAll(Object[] objects) {
0518:                if (managedConnection == null) {
0519:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0520:                }
0521:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0522:                        .makePersistentAll(objects);
0523:            }
0524:
0525:            public Collection makePersistentAll(Collection collection) {
0526:                if (managedConnection == null) {
0527:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0528:                }
0529:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0530:                        .makePersistentAll(collection);
0531:            }
0532:
0533:            public void deletePersistent(Object o) {
0534:                if (managedConnection == null) {
0535:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0536:                }
0537:                ((JDOPOManagerItf) managedConnection.getPOManager())
0538:                        .deletePersistent(o);
0539:            }
0540:
0541:            public void deletePersistentAll(Object[] objects) {
0542:                if (managedConnection == null) {
0543:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0544:                }
0545:                ((JDOPOManagerItf) managedConnection.getPOManager())
0546:                        .deletePersistentAll(objects);
0547:            }
0548:
0549:            public void deletePersistentAll(Collection collection) {
0550:                if (managedConnection == null) {
0551:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0552:                }
0553:                ((JDOPOManagerItf) managedConnection.getPOManager())
0554:                        .deletePersistentAll(collection);
0555:            }
0556:
0557:            public void makeTransient(Object o) {
0558:                if (managedConnection == null) {
0559:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0560:                }
0561:                ((JDOPOManagerItf) managedConnection.getPOManager())
0562:                        .makeTransient(o);
0563:            }
0564:
0565:            public void makeTransientAll(Object[] objects) {
0566:                if (managedConnection == null) {
0567:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0568:                }
0569:                ((JDOPOManagerItf) managedConnection.getPOManager())
0570:                        .makeTransientAll(objects);
0571:            }
0572:
0573:            public void makeTransientAll(Collection collection) {
0574:                if (managedConnection == null) {
0575:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0576:                }
0577:                ((JDOPOManagerItf) managedConnection.getPOManager())
0578:                        .makeTransientAll(collection);
0579:            }
0580:
0581:            public void makeTransactional(Object o) {
0582:                if (managedConnection == null) {
0583:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0584:                }
0585:                ((JDOPOManagerItf) managedConnection.getPOManager())
0586:                        .makeTransactional(o);
0587:            }
0588:
0589:            public void makeTransactionalAll(Object[] objects) {
0590:                if (managedConnection == null) {
0591:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0592:                }
0593:                ((JDOPOManagerItf) managedConnection.getPOManager())
0594:                        .makeTransactionalAll(objects);
0595:            }
0596:
0597:            public void makeTransactionalAll(Collection collection) {
0598:                if (managedConnection == null) {
0599:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0600:                }
0601:                ((JDOPOManagerItf) managedConnection.getPOManager())
0602:                        .makeTransactionalAll(collection);
0603:            }
0604:
0605:            public void makeNontransactional(Object o) {
0606:                if (managedConnection == null) {
0607:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0608:                }
0609:                ((JDOPOManagerItf) managedConnection.getPOManager())
0610:                        .makeNontransactional(o);
0611:            }
0612:
0613:            public void makeNontransactionalAll(Object[] objects) {
0614:                if (managedConnection == null) {
0615:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0616:                }
0617:                makeNontransactionalAll(objects);
0618:            }
0619:
0620:            public void makeNontransactionalAll(Collection collection) {
0621:                if (managedConnection == null) {
0622:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0623:                }
0624:                ((JDOPOManagerItf) managedConnection.getPOManager())
0625:                        .makeNontransactionalAll(collection);
0626:            }
0627:
0628:            public void retrieve(Object o) {
0629:                if (managedConnection == null) {
0630:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0631:                }
0632:                ((JDOPOManagerItf) managedConnection.getPOManager())
0633:                        .retrieve(o);
0634:            }
0635:
0636:            public void retrieveAll(Collection collection) {
0637:                if (managedConnection == null) {
0638:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0639:                }
0640:                ((JDOPOManagerItf) managedConnection.getPOManager())
0641:                        .retrieveAll(collection);
0642:            }
0643:
0644:            public void retrieveAll(Object[] objects) {
0645:                if (managedConnection == null) {
0646:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0647:                }
0648:                ((JDOPOManagerItf) managedConnection.getPOManager())
0649:                        .retrieveAll(objects);
0650:            }
0651:
0652:            public void retrieveAll(Collection collection, boolean b) {
0653:                if (managedConnection == null) {
0654:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0655:                }
0656:                ((JDOPOManagerItf) managedConnection.getPOManager())
0657:                        .retrieveAll(collection, b);
0658:            }
0659:
0660:            public void retrieveAll(Object[] objects, boolean b) {
0661:                if (managedConnection == null) {
0662:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0663:                }
0664:                ((JDOPOManagerItf) managedConnection.getPOManager())
0665:                        .retrieveAll(objects, b);
0666:            }
0667:
0668:            public void setUserObject(Object o) {
0669:                if (managedConnection == null) {
0670:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0671:                }
0672:                ((JDOPOManagerItf) managedConnection.getPOManager())
0673:                        .setUserObject(o);
0674:            }
0675:
0676:            public Object getUserObject() {
0677:                if (managedConnection == null) {
0678:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0679:                }
0680:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0681:                        .getUserObject();
0682:            }
0683:
0684:            public PersistenceManagerFactory getPersistenceManagerFactory() {
0685:                if (managedConnection == null) {
0686:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0687:                }
0688:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0689:                        .getPersistenceManagerFactory();
0690:            }
0691:
0692:            public Class getObjectIdClass(Class aClass) {
0693:                if (managedConnection == null) {
0694:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0695:                }
0696:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0697:                        .getObjectIdClass(aClass);
0698:            }
0699:
0700:            public void setMultithreaded(boolean b) {
0701:                if (managedConnection == null) {
0702:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0703:                }
0704:                ((JDOPOManagerItf) managedConnection.getPOManager())
0705:                        .setMultithreaded(b);
0706:            }
0707:
0708:            public boolean getMultithreaded() {
0709:                if (managedConnection == null) {
0710:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0711:                }
0712:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0713:                        .getMultithreaded();
0714:            }
0715:
0716:            public void setIgnoreCache(boolean b) {
0717:                if (managedConnection == null) {
0718:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0719:                }
0720:                ((JDOPOManagerItf) managedConnection.getPOManager())
0721:                        .setIgnoreCache(b);
0722:            }
0723:
0724:            public boolean getIgnoreCache() {
0725:                if (managedConnection == null) {
0726:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0727:                }
0728:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0729:                        .getIgnoreCache();
0730:            }
0731:
0732:            public void addInstanceLifecycleListener(
0733:                    InstanceLifecycleListener arg0, Class[] arg1) {
0734:                if (managedConnection == null) {
0735:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0736:                }
0737:                ((JDOPOManagerItf) managedConnection.getPOManager())
0738:                        .addInstanceLifecycleListener(arg0, arg1);
0739:            }
0740:
0741:            public Object attachCopy(Object arg0, boolean arg1) {
0742:                if (managedConnection == null) {
0743:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0744:                }
0745:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0746:                        .makePersistent(arg0);
0747:            }
0748:
0749:            public Collection attachCopyAll(Collection arg0, boolean arg1) {
0750:                if (managedConnection == null) {
0751:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0752:                }
0753:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0754:                        .makePersistentAll(arg0);
0755:            }
0756:
0757:            public Object[] attachCopyAll(Object[] arg0, boolean arg1) {
0758:                if (managedConnection == null) {
0759:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0760:                }
0761:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0762:                        .makePersistentAll(arg0);
0763:            }
0764:
0765:            public Object detachCopy(Object arg0) {
0766:                if (managedConnection == null) {
0767:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0768:                }
0769:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0770:                        .detachCopy(arg0);
0771:            }
0772:
0773:            public Collection detachCopyAll(Collection arg0) {
0774:                if (managedConnection == null) {
0775:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0776:                }
0777:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0778:                        .detachCopyAll(arg0);
0779:            }
0780:
0781:            public Object[] detachCopyAll(Object[] arg0) {
0782:                if (managedConnection == null) {
0783:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0784:                }
0785:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0786:                        .detachCopyAll(arg0);
0787:            }
0788:
0789:            public void flush() {
0790:                if (managedConnection == null) {
0791:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0792:                }
0793:                ((JDOPOManagerItf) managedConnection.getPOManager()).flush();
0794:            }
0795:
0796:            public void checkConsistency() {
0797:                if (managedConnection == null) {
0798:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0799:                }
0800:                ((JDOPOManagerItf) managedConnection.getPOManager())
0801:                        .checkConsistency();
0802:            }
0803:
0804:            public JDOConnection getDataStoreConnection() {
0805:                if (managedConnection == null) {
0806:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0807:                }
0808:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0809:                        .getDataStoreConnection();
0810:            }
0811:
0812:            public Extent getExtent(Class arg0) {
0813:                if (managedConnection == null) {
0814:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0815:                }
0816:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0817:                        .getExtent(arg0);
0818:            }
0819:
0820:            public FetchPlan getFetchPlan() {
0821:                if (managedConnection == null) {
0822:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0823:                }
0824:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0825:                        .getFetchPlan();
0826:            }
0827:
0828:            public Query newNamedQuery(Class arg0, String arg1) {
0829:                if (managedConnection == null) {
0830:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0831:                }
0832:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0833:                        .newNamedQuery(arg0, arg1);
0834:            }
0835:
0836:            public void refreshAll(JDOException arg0) {
0837:                if (managedConnection == null) {
0838:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0839:                }
0840:                ((JDOPOManagerItf) managedConnection.getPOManager())
0841:                        .refreshAll(arg0);
0842:            }
0843:
0844:            public void removeInstanceLifecycleListener(
0845:                    InstanceLifecycleListener arg0) {
0846:                if (managedConnection == null) {
0847:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0848:                }
0849:                ((JDOPOManagerItf) managedConnection.getPOManager())
0850:                        .removeInstanceLifecycleListener(arg0);
0851:            }
0852:
0853:            //
0854:            //	IMPLEMENTATION OF JDO.TRANSACTION INTERFACE
0855:            //
0856:
0857:            public void begin() {
0858:                if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) {
0859:                    try {
0860:                        userTransaction.begin();
0861:                    } catch (Exception e) {
0862:                        throw new JDOException(
0863:                                "Error with JTA UserTransaction.begin().", e);
0864:                    }
0865:                } else {
0866:                    //do nothing
0867:                    logger
0868:                            .log(BasicLevel.INFO,
0869:                                    "Nothing is done on begin. The property ignoreJDOTransaction is activated.");
0870:                }
0871:            }
0872:
0873:            public void commit() {
0874:                if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) {
0875:                    try {
0876:                        userTransaction.commit();
0877:                        logger.log(BasicLevel.DEBUG, "UserTransaction commit.");
0878:                    } catch (Exception e) {
0879:                        throw new JDOException(
0880:                                "Error with JTA UserTransaction.commit().", e);
0881:                    }
0882:                } else {
0883:                    // do nothing
0884:                    logger
0885:                            .log(BasicLevel.INFO,
0886:                                    "Nothing is done on commit. The property ignoreJDOTransaction is activated.");
0887:                }
0888:            }
0889:
0890:            public void rollback() {
0891:                if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) {
0892:                    try {
0893:                        userTransaction.rollback();
0894:                    } catch (Exception e) {
0895:                        throw new JDOException(
0896:                                "Error with JTA UserTransaction.rollback().", e);
0897:                    }
0898:                } else {
0899:                    // do nothing
0900:                    logger
0901:                            .log(BasicLevel.INFO,
0902:                                    "Nothing is done on rollback. The property ignoreJDOTransaction is activated.");
0903:                }
0904:            }
0905:
0906:            public boolean isActive() {
0907:                // delegate
0908:                if (managedConnection == null) {
0909:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0910:                }
0911:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0912:                        .currentTransaction().isActive();
0913:            }
0914:
0915:            public boolean getRollbackOnly() {
0916:                //delegate
0917:                if (managedConnection == null) {
0918:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0919:                }
0920:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0921:                        .currentTransaction().getRollbackOnly();
0922:            }
0923:
0924:            public void setRollbackOnly() {
0925:                //delegate
0926:                if (managedConnection == null) {
0927:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0928:                }
0929:                ((JDOPOManagerItf) managedConnection.getPOManager())
0930:                        .currentTransaction().setRollbackOnly();
0931:
0932:            }
0933:
0934:            public void setNontransactionalRead(boolean nontransactionalRead) {
0935:                //delegate
0936:                if (managedConnection == null) {
0937:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0938:                }
0939:                ((JDOPOManagerItf) managedConnection.getPOManager())
0940:                        .currentTransaction().setNontransactionalRead(
0941:                                nontransactionalRead);
0942:            }
0943:
0944:            public boolean getNontransactionalRead() {
0945:                //delegate
0946:                if (managedConnection == null) {
0947:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0948:                }
0949:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0950:                        .currentTransaction().getNontransactionalRead();
0951:
0952:            }
0953:
0954:            public void setNontransactionalWrite(boolean nontransactionalWrite) {
0955:                //delegate
0956:                if (managedConnection == null) {
0957:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0958:                }
0959:                ((JDOPOManagerItf) managedConnection.getPOManager())
0960:                        .currentTransaction().setNontransactionalWrite(
0961:                                nontransactionalWrite);
0962:
0963:            }
0964:
0965:            public boolean getNontransactionalWrite() {
0966:                //delegate
0967:                if (managedConnection == null) {
0968:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0969:                }
0970:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0971:                        .currentTransaction().getNontransactionalWrite();
0972:            }
0973:
0974:            public void setRetainValues(boolean retainValues) {
0975:                //delegate
0976:                if (managedConnection == null) {
0977:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0978:                }
0979:                ((JDOPOManagerItf) managedConnection.getPOManager())
0980:                        .currentTransaction().setRetainValues(retainValues);
0981:
0982:            }
0983:
0984:            public boolean getRetainValues() {
0985:                //delegate
0986:                if (managedConnection == null) {
0987:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0988:                }
0989:                return ((JDOPOManagerItf) managedConnection.getPOManager())
0990:                        .currentTransaction().getRetainValues();
0991:            }
0992:
0993:            public void setRestoreValues(boolean restoreValues) {
0994:                //delegate
0995:                if (managedConnection == null) {
0996:                    throw new JDOException(NO_ACTIVE_CONNECTION);
0997:                }
0998:                ((JDOPOManagerItf) managedConnection.getPOManager())
0999:                        .currentTransaction().setRestoreValues(restoreValues);
1000:            }
1001:
1002:            public boolean getRestoreValues() {
1003:                //delegate
1004:                if (managedConnection == null) {
1005:                    throw new JDOException(NO_ACTIVE_CONNECTION);
1006:                }
1007:                return ((JDOPOManagerItf) managedConnection.getPOManager())
1008:                        .currentTransaction().getRestoreValues();
1009:            }
1010:
1011:            public void setOptimistic(boolean optimistic) {
1012:                //delegate
1013:                if (managedConnection == null) {
1014:                    throw new JDOException(NO_ACTIVE_CONNECTION);
1015:                }
1016:                ((JDOPOManagerItf) managedConnection.getPOManager())
1017:                        .currentTransaction().setOptimistic(optimistic);
1018:            }
1019:
1020:            public boolean getOptimistic() {
1021:                //delegate
1022:                if (managedConnection == null) {
1023:                    throw new JDOException(NO_ACTIVE_CONNECTION);
1024:                }
1025:                return ((JDOPOManagerItf) managedConnection.getPOManager())
1026:                        .currentTransaction().getOptimistic();
1027:            }
1028:
1029:            public void setSynchronization(Synchronization sync) {
1030:                //delegate
1031:                if (managedConnection == null) {
1032:                    throw new JDOException(NO_ACTIVE_CONNECTION);
1033:                }
1034:                ((JDOPOManagerItf) managedConnection.getPOManager())
1035:                        .currentTransaction().setSynchronization(sync);
1036:            }
1037:
1038:            public Synchronization getSynchronization() {
1039:                //delegate
1040:                if (managedConnection == null) {
1041:                    throw new JDOException(NO_ACTIVE_CONNECTION);
1042:                }
1043:                return ((JDOPOManagerItf) managedConnection.getPOManager())
1044:                        .currentTransaction().getSynchronization();
1045:            }
1046:
1047:            public PersistenceManager getPersistenceManager() {
1048:                //delegate
1049:                if (managedConnection == null) {
1050:                    throw new JDOException(NO_ACTIVE_CONNECTION);
1051:                }
1052:                return ((JDOPOManagerItf) managedConnection.getPOManager())
1053:                        .currentTransaction().getPersistenceManager();
1054:            }
1055:
1056:            /* (non-Javadoc)
1057:             * @see javax.jdo.PersistenceManager#makeTransient(java.lang.Object, boolean)
1058:             */
1059:            public void makeTransient(Object o, boolean useFetchPlan) {
1060:                if (!useFetchPlan) {
1061:                    makeTransient(o);
1062:                } else {
1063:                    //TODO: implement
1064:                }
1065:            }
1066:
1067:            /* (non-Javadoc)
1068:             * @see javax.jdo.PersistenceManager#makeTransientAll(java.lang.Object[], boolean)
1069:             */
1070:            public void makeTransientAll(Object[] os, boolean useFetchPlan) {
1071:                if (!useFetchPlan) {
1072:                    makeTransientAll(os);
1073:                } else {
1074:                    //TODO: implement
1075:                }
1076:            }
1077:
1078:            /* (non-Javadoc)
1079:             * @see javax.jdo.PersistenceManager#makeTransientAll(java.util.Collection, boolean)
1080:             */
1081:            public void makeTransientAll(Collection os, boolean useFetchPlan) {
1082:                if (!useFetchPlan) {
1083:                    makeTransientAll(os);
1084:                } else {
1085:                    //TODO: implement
1086:                }
1087:            }
1088:
1089:            /* (non-Javadoc)
1090:             * @see javax.jdo.PersistenceManager#retrieve(java.lang.Object, boolean)
1091:             */
1092:            public void retrieve(Object o, boolean FGOnly) {
1093:                if (!FGOnly) {
1094:                    retrieve(o);
1095:                } else {
1096:                    //TODO: implement
1097:                }
1098:            }
1099:
1100:            /* (non-Javadoc)
1101:             * @see javax.jdo.PersistenceManager#getDetachAllOnCommit()
1102:             */
1103:            public boolean getDetachAllOnCommit() {
1104:                // TODO Auto-generated method stub
1105:                return false;
1106:            }
1107:
1108:            /* (non-Javadoc)
1109:             * @see javax.jdo.PersistenceManager#setDetachAllOnCommit(boolean)
1110:             */
1111:            public void setDetachAllOnCommit(boolean arg0) {
1112:                // TODO Auto-generated method stub
1113:
1114:            }
1115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.