Source Code Cross Referenced for JDOConnectionFactory.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) 


001:        /**
002:         * perseus/connector: this is an implementation of some JCA-related technologies
003:         * (resource adapters and managers) for the ObjectWeb consortium.
004:         * Copyright (C) 2001-2004 France Telecom R&D
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2 of the License, or (at your option) any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * Contact: speedo@objectweb.org
021:         *
022:         */package org.objectweb.speedo.jca.jdo;
023:
024:        import org.objectweb.util.monolog.api.BasicLevel;
025:        import org.objectweb.util.monolog.api.Logger;
026:        import org.objectweb.speedo.api.Debug;
027:        import org.objectweb.speedo.api.SpeedoProperties;
028:        import org.objectweb.speedo.jca.SpeedoConnectionFactory;
029:        import org.objectweb.speedo.jca.SpeedoConnectionSpec;
030:        import org.objectweb.speedo.jca.SpeedoManagedConnectionFactory;
031:        import org.objectweb.speedo.pm.jdo.api.JDOPOManagerFactoryItf;
032:
033:        import javax.naming.NamingException;
034:        import javax.naming.Reference;
035:        import javax.resource.NotSupportedException;
036:        import javax.resource.ResourceException;
037:        import javax.resource.cci.Connection;
038:        import javax.resource.cci.ConnectionFactory;
039:        import javax.resource.cci.ConnectionSpec;
040:        import javax.resource.cci.RecordFactory;
041:        import javax.resource.cci.ResourceAdapterMetaData;
042:        import javax.resource.spi.ConnectionManager;
043:        import javax.resource.spi.ConnectionRequestInfo;
044:        import javax.jdo.datastore.DataStoreCache;
045:        import javax.jdo.listener.InstanceLifecycleListener;
046:        import javax.jdo.PersistenceManagerFactory;
047:        import javax.jdo.PersistenceManager;
048:        import javax.jdo.JDOException;
049:        import java.util.Properties;
050:        import java.util.Collection;
051:
052:        /**
053:         * @author	P. Dechamboux
054:         */
055:        public class JDOConnectionFactory extends SpeedoConnectionFactory
056:                implements  ConnectionFactory, ResourceAdapterMetaData,
057:                PersistenceManagerFactory {
058:            /**
059:             * The JDO Adapter Version.
060:             */
061:            private final static String JDOADAPTERVERSION = "1.00";
062:            /**
063:             * The JDO Adapter Vendor Name (i.e. ObjectWeb !!).
064:             */
065:            private final static String JDOADAPTERVENDORNAME = "The ObjectWeb Consortium";
066:            /**
067:             * The JDO Adapter Name.
068:             */
069:            private final static String JDOADAPTERNAME = "OW Java Data Object (JDO) Adapter";
070:            /**
071:             * A short description of the JDO Adapter.
072:             */
073:            private final static String JDOADAPTERSHORTDESCRIPTION = "It provides a JCA wrapper to any JDO compliant implementation.";
074:            /**
075:             * The JDO Spec Version (none yet).
076:             */
077:            private final static String JDOSPECVERSION = "1.00";
078:
079:            /**
080:             * The JNDI Reference associated to this adapter.
081:             */
082:            private Reference jndiReference = null;
083:            /**
084:             * The ManagedConnectionFactory associated to this ConnectionFactory.
085:             */
086:            private SpeedoManagedConnectionFactory mcf;
087:
088:            /**
089:             * The transaction mode within a j2ee context.
090:             */
091:            private byte transactionMode = SpeedoProperties.TRANSACTION_BMODE_NORMAL;
092:
093:            /**
094:             * Constructs a JDOConnectionFactory. Associates a ConnectionManager with
095:             * it, or creates a default one (if null).
096:             * @param fmcf	The ManagedConnectionFactory to be associated with this
097:             * 				ConnectionFactory.
098:             * @param cm	The ConnectionManager to be associated with this
099:             * 				ConnectionFactory. It may be null.
100:             * @param transactionMode the mode of transaction chosen for the application.
101:             */
102:            JDOConnectionFactory(Logger logger,
103:                    SpeedoManagedConnectionFactory fmcf, ConnectionManager cm,
104:                    byte transactionMode) throws ResourceException {
105:                this .logger = logger;
106:                if (Debug.ON)
107:                    logger.log(BasicLevel.DEBUG,
108:                            "Constructs a new JDOConnectionFactory.");
109:                mcf = fmcf;
110:                setConnectionManager(cm);
111:                this .transactionMode = transactionMode;
112:            }
113:
114:            /**
115:             * Creates a new JDOConnectionImpl.
116:             */
117:            public Object createConnection() throws ResourceException {
118:                JDOConnectionImpl res = new JDOConnectionImpl(logger, this );
119:                if (Debug.ON)
120:                    logger.log(BasicLevel.DEBUG,
121:                            "New JDOConnectionImpl created: " + res);
122:                return res;
123:            }
124:
125:            private void checkMCFStarted() {
126:                if (!mcf.started) {
127:                    try {
128:                        mcf.start();
129:                    } catch (ResourceException e) {
130:                        throw new JDOException(
131:                                "JDO Connector: cannot initialize the ManagedConnectionFactory.",
132:                                e);
133:                    }
134:                }
135:            }
136:
137:            // IMPLEMENTATION OF METHODS FROM THE (cci)ConnectionFactory INTERFACE
138:
139:            /**
140:             * Connection allocation is delegated to the ConnectionManager assigned to
141:             * this factory.
142:             */
143:            public Connection getConnection() throws ResourceException {
144:                if (!mcf.started) {
145:                    mcf.start();
146:                }
147:                PersistenceManager pm = (PersistenceManager) connectionManager
148:                        .allocateConnection(mcf, null);
149:                pm.currentTransaction();
150:                return (Connection) pm;
151:            }
152:
153:            /**
154:             * Connection allocation is delegated to the ConnectionManager assigned to
155:             * this factory.
156:             * @param spec	The connection is not taken into account within JDO.
157:             */
158:            public Connection getConnection(ConnectionSpec spec)
159:                    throws ResourceException {
160:                if (!mcf.started) {
161:                    mcf.start();
162:                }
163:                ConnectionRequestInfo cri = null;
164:                if (spec instanceof  ConnectionRequestInfo) {
165:                    cri = (ConnectionRequestInfo) spec;
166:                }
167:                PersistenceManager pm = (PersistenceManager) connectionManager
168:                        .allocateConnection(mcf, cri);
169:                pm.currentTransaction();
170:                return (Connection) pm;
171:            }
172:
173:            /**
174:             * Assigns a JNDI Reference to the adapter.
175:             * @param reference	The JNDI Reference to be assigned.
176:             */
177:            public void setReference(Reference reference) {
178:                jndiReference = reference;
179:            }
180:
181:            /**
182:             * Returns the JNDI Reference.
183:             * @return	The JNDI Reference.
184:             */
185:            public Reference getReference() throws NamingException {
186:                return jndiReference;
187:            }
188:
189:            /**
190:             * No support for record.
191:             */
192:            public RecordFactory getRecordFactory() throws ResourceException {
193:                throw new NotSupportedException(
194:                        "JDO Connector: no support for record.");
195:            }
196:
197:            /**
198:             * The JDOConnectionFactory manages its metadata on its own.
199:             */
200:            public ResourceAdapterMetaData getMetaData()
201:                    throws ResourceException {
202:                return this ;
203:            }
204:
205:            // IMPLEMENTATION OF METHODS FROM THE (cci)ResourceAdapaterMetaData INTERFACE
206:
207:            /**
208:             * Gives access to the adapter version metadata for the JDO.
209:             * @return	The JDO adapter version.
210:             */
211:            public String getAdapterVersion() {
212:                return JDOADAPTERVERSION;
213:            }
214:
215:            /**
216:             * Gives access to the adapter vendor name metadata for the JDO.
217:             * @return	The JDO adapter vendor name.
218:             */
219:            public String getAdapterVendorName() {
220:                return JDOADAPTERVENDORNAME;
221:            }
222:
223:            /**
224:             * Gives access to the adapter name metadata for the JDO.
225:             * @return	The JDO adapter name.
226:             */
227:            public String getAdapterName() {
228:                return JDOADAPTERNAME;
229:            }
230:
231:            /**
232:             * Gives access to a short description of the JDO adapter.
233:             * @return	The JDO short description.
234:             */
235:            public String getAdapterShortDescription() {
236:                return JDOADAPTERSHORTDESCRIPTION;
237:            }
238:
239:            /**
240:             * Gives access to the specification version of the JDO.
241:             * @return	The JDO specification version.
242:             */
243:            public String getSpecVersion() {
244:                return JDOSPECVERSION;
245:            }
246:
247:            /**
248:             * No interaction is supported by the JDO adapter.
249:             */
250:            public String[] getInteractionSpecsSupported() {
251:                return new String[0];
252:            }
253:
254:            /**
255:             * No support for record.
256:             */
257:            public boolean supportsExecuteWithInputAndOutputRecord() {
258:                return false;
259:            }
260:
261:            /**
262:             * No support for record.
263:             */
264:            public boolean supportsExecuteWithInputRecordOnly() {
265:                return false;
266:            }
267:
268:            /**
269:             * Yes, it does support local transaction demarcation.
270:             */
271:            public boolean supportsLocalTransactionDemarcation() {
272:                return true;
273:            }
274:
275:            // IMPLEMENTATION OF METHODS FROM THE PersistenceManagerFactory INTERFACE
276:
277:            public PersistenceManager getPersistenceManager() {
278:                try {
279:                    return (PersistenceManager) getConnection();
280:                } catch (ResourceException e) {
281:                    throw new JDOException(
282:                            "JDO Connector: problem while getting a PersistenceManager.",
283:                            e);
284:                }
285:            }
286:
287:            public PersistenceManager getPersistenceManager(String s, String s1) {
288:                try {
289:                    PersistenceManager pm = (PersistenceManager) getConnection(new SpeedoConnectionSpec(
290:                            s, s1));
291:                    pm.currentTransaction();
292:                    return pm;
293:                } catch (ResourceException e) {
294:                    throw new JDOException(
295:                            "JDO Connector: problem while getting a PersistenceManager.",
296:                            e);
297:                }
298:            }
299:
300:            public void setConnectionUserName(String s) {
301:                checkMCFStarted();
302:                ((JDOPOManagerFactoryItf) mcf.pmf).setConnectionUserName(s);
303:            }
304:
305:            public String getConnectionUserName() {
306:                checkMCFStarted();
307:                return ((JDOPOManagerFactoryItf) mcf.pmf)
308:                        .getConnectionUserName();
309:            }
310:
311:            public void setConnectionPassword(String s) {
312:                checkMCFStarted();
313:                ((JDOPOManagerFactoryItf) mcf.pmf).setConnectionPassword(s);
314:            }
315:
316:            public void setConnectionURL(String s) {
317:                checkMCFStarted();
318:                ((JDOPOManagerFactoryItf) mcf.pmf).setConnectionURL(s);
319:            }
320:
321:            public String getConnectionURL() {
322:                checkMCFStarted();
323:                return ((JDOPOManagerFactoryItf) mcf.pmf).getConnectionURL();
324:            }
325:
326:            public void setConnectionDriverName(String s) {
327:                checkMCFStarted();
328:                ((JDOPOManagerFactoryItf) mcf.pmf).setConnectionDriverName(s);
329:            }
330:
331:            public String getConnectionDriverName() {
332:                checkMCFStarted();
333:                return ((JDOPOManagerFactoryItf) mcf.pmf)
334:                        .getConnectionDriverName();
335:            }
336:
337:            public void setConnectionFactoryName(String s) {
338:                checkMCFStarted();
339:                ((JDOPOManagerFactoryItf) mcf.pmf).setConnectionFactoryName(s);
340:            }
341:
342:            public String getConnectionFactoryName() {
343:                checkMCFStarted();
344:                return ((JDOPOManagerFactoryItf) mcf.pmf)
345:                        .getConnectionFactoryName();
346:            }
347:
348:            public void setConnectionFactory(Object o) {
349:                checkMCFStarted();
350:                ((JDOPOManagerFactoryItf) mcf.pmf).setConnectionFactory(o);
351:            }
352:
353:            public Object getConnectionFactory() {
354:                checkMCFStarted();
355:                return ((JDOPOManagerFactoryItf) mcf.pmf)
356:                        .getConnectionFactory();
357:            }
358:
359:            public void setConnectionFactory2Name(String s) {
360:                checkMCFStarted();
361:                ((JDOPOManagerFactoryItf) mcf.pmf).setConnectionFactory2Name(s);
362:            }
363:
364:            public String getConnectionFactory2Name() {
365:                checkMCFStarted();
366:                return ((JDOPOManagerFactoryItf) mcf.pmf)
367:                        .getConnectionFactory2Name();
368:            }
369:
370:            public void setConnectionFactory2(Object o) {
371:                checkMCFStarted();
372:                ((JDOPOManagerFactoryItf) mcf.pmf).setConnectionFactory2(o);
373:            }
374:
375:            public Object getConnectionFactory2() {
376:                checkMCFStarted();
377:                return ((JDOPOManagerFactoryItf) mcf.pmf)
378:                        .getConnectionFactory2();
379:            }
380:
381:            public void setMultithreaded(boolean b) {
382:                checkMCFStarted();
383:                ((JDOPOManagerFactoryItf) mcf.pmf).setMultithreaded(b);
384:            }
385:
386:            public boolean getMultithreaded() {
387:                checkMCFStarted();
388:                return ((JDOPOManagerFactoryItf) mcf.pmf).getMultithreaded();
389:            }
390:
391:            public void setOptimistic(boolean b) {
392:                checkMCFStarted();
393:                ((JDOPOManagerFactoryItf) mcf.pmf).setOptimistic(b);
394:            }
395:
396:            public boolean getOptimistic() {
397:                checkMCFStarted();
398:                return ((JDOPOManagerFactoryItf) mcf.pmf).getOptimistic();
399:            }
400:
401:            public void setRetainValues(boolean b) {
402:                checkMCFStarted();
403:                ((JDOPOManagerFactoryItf) mcf.pmf).setRetainValues(b);
404:            }
405:
406:            public boolean getRetainValues() {
407:                checkMCFStarted();
408:                return ((JDOPOManagerFactoryItf) mcf.pmf).getRetainValues();
409:            }
410:
411:            public void setRestoreValues(boolean b) {
412:                checkMCFStarted();
413:                ((JDOPOManagerFactoryItf) mcf.pmf).setRestoreValues(b);
414:            }
415:
416:            public boolean getRestoreValues() {
417:                checkMCFStarted();
418:                return ((JDOPOManagerFactoryItf) mcf.pmf).getRestoreValues();
419:            }
420:
421:            public void setNontransactionalRead(boolean b) {
422:                checkMCFStarted();
423:                ((JDOPOManagerFactoryItf) mcf.pmf).setNontransactionalRead(b);
424:            }
425:
426:            public boolean getNontransactionalRead() {
427:                checkMCFStarted();
428:                return ((JDOPOManagerFactoryItf) mcf.pmf)
429:                        .getNontransactionalRead();
430:            }
431:
432:            public void setNontransactionalWrite(boolean b) {
433:                checkMCFStarted();
434:                ((JDOPOManagerFactoryItf) mcf.pmf).setNontransactionalWrite(b);
435:            }
436:
437:            public boolean getNontransactionalWrite() {
438:                checkMCFStarted();
439:                return ((JDOPOManagerFactoryItf) mcf.pmf)
440:                        .getNontransactionalWrite();
441:            }
442:
443:            public void setIgnoreCache(boolean b) {
444:                checkMCFStarted();
445:                ((JDOPOManagerFactoryItf) mcf.pmf).setIgnoreCache(b);
446:            }
447:
448:            public boolean getIgnoreCache() {
449:                checkMCFStarted();
450:                return ((JDOPOManagerFactoryItf) mcf.pmf).getIgnoreCache();
451:            }
452:
453:            public Properties getProperties() {
454:                checkMCFStarted();
455:                return ((JDOPOManagerFactoryItf) mcf.pmf).getProperties();
456:            }
457:
458:            public Collection supportedOptions() {
459:                checkMCFStarted();
460:                return ((JDOPOManagerFactoryItf) mcf.pmf).supportedOptions();
461:            }
462:
463:            public void close() {
464:                checkMCFStarted();
465:                ((JDOPOManagerFactoryItf) mcf.pmf).close();
466:            }
467:
468:            public DataStoreCache getDataStoreCache() {
469:                checkMCFStarted();
470:                return ((JDOPOManagerFactoryItf) mcf.pmf).getDataStoreCache();
471:            }
472:
473:            public String getMapping() {
474:                checkMCFStarted();
475:                return ((JDOPOManagerFactoryItf) mcf.pmf).getMapping();
476:            }
477:
478:            public boolean isClosed() {
479:                checkMCFStarted();
480:                return ((JDOPOManagerFactoryItf) mcf.pmf).isClosed();
481:            }
482:
483:            public void setMapping(String arg0) {
484:                checkMCFStarted();
485:                ((JDOPOManagerFactoryItf) mcf.pmf).setMapping(arg0);
486:            }
487:
488:            public void addInstanceLifecycleListener(
489:                    InstanceLifecycleListener arg0, Class[] arg1) {
490:                checkMCFStarted();
491:                ((JDOPOManagerFactoryItf) mcf.pmf)
492:                        .addInstanceLifecycleListener(arg0, arg1);
493:            }
494:
495:            public void removeInstanceLifecycleListener(
496:                    InstanceLifecycleListener arg0) {
497:                checkMCFStarted();
498:                ((JDOPOManagerFactoryItf) mcf.pmf)
499:                        .removeInstanceLifecycleListener(arg0);
500:            }
501:
502:            public byte getTransactionMode() {
503:                return transactionMode;
504:            }
505:
506:            /* (non-Javadoc)
507:             * @see javax.jdo.PersistenceManagerFactory#getDetachAllOnCommit()
508:             */
509:            public boolean getDetachAllOnCommit() {
510:                // TODO Auto-generated method stub
511:                return false;
512:            }
513:
514:            /* (non-Javadoc)
515:             * @see javax.jdo.PersistenceManagerFactory#setDetachAllOnCommit(boolean)
516:             */
517:            public void setDetachAllOnCommit(boolean arg0) {
518:                // TODO Auto-generated method stub
519:
520:            }
521:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.