Source Code Cross Referenced for PersistenceManagerFactoryImpl.java in  » Database-ORM » db-ojb » org » apache » ojb » 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 » db ojb » org.apache.ojb.jdo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.ojb.jdo;
002:
003:        /* Copyright 2003-2005 The Apache Software Foundation
004:         *
005:         * Licensed under the Apache License, Version 2.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        import javax.jdo.PersistenceManager;
019:        import javax.jdo.PersistenceManagerFactory;
020:        import java.util.Arrays;
021:        import java.util.Collection;
022:        import java.util.Collections;
023:        import java.util.Properties;
024:
025:        import org.apache.commons.lang.BooleanUtils;
026:
027:        /**
028:         * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
029:         */
030:
031:        public class PersistenceManagerFactoryImpl implements 
032:                PersistenceManagerFactory {
033:            /**
034:             * flags
035:             */
036:            private boolean m_optimistic = true;
037:            private boolean m_retainValues = true;
038:            private boolean m_restoreValues = true;
039:            private boolean m_nonTransactionalRead = true;
040:            private boolean m_nonTransactionalWrite = false;
041:            private boolean m_ignoreCache = true;
042:            private boolean m_multiThreaded = false;
043:
044:            /**
045:             * pool information
046:             */
047:            private int m_minPool = 1;
048:            private int m_maxPool = 1;
049:            private int m_msWait = 0;
050:
051:            /**
052:             * connection factory information
053:             */
054:            private Object m_connectionFactory;
055:            private String m_connectionFactoryName;
056:
057:            private Object m_connectionFactory2;
058:            private String m_connectionFactory2Name;
059:
060:            private String m_connectionDriverName;
061:            private String m_connectionURL;
062:
063:            private String m_connectionPassword;
064:            private String m_connectionName;
065:
066:            private String m_alias;
067:
068:            /**
069:             * support options
070:             */
071:            private final String[] m_implementedOptions = new String[] {
072:                    "javax.jdo.option.TransientTransactional",
073:                    "javax.jdo.option.NontransactionalRead",
074:                    "javax.jdo.option.NontransactionalWrite",
075:                    "javax.jdo.option.RetainValues",
076:                    "javax.jdo.option.RestoreValues",
077:                    "javax.jdo.option.Optimistic",
078:                    "javax.jdo.option.ApplicationIdentity",
079:                    "javax.jdo.option.DatastoreIdentity",
080:                    "javax.jdo.option.NonDatastoreIdentity",
081:                    "javax.jdo.option.ArrayList", "javax.jdo.option.HashMap",
082:                    "javax.jdo.option.Hashtable",
083:                    "javax.jdo.option.LinkedList", "javax.jdo.option.TreeMap",
084:                    "javax.jdo.option.TreeSet", "javax.jdo.option.Vector",
085:                    "javax.jdo.option.Map", "javax.jdo.option.List",
086:                    "javax.jdo.option.Array",
087:                    "javax.jdo.option.NullCollection", "javax.jdo.query.JDOQL" };
088:
089:            /**
090:             * properties
091:             */
092:            private static Properties PROPERTIES = new Properties();
093:
094:            static {
095:                PROPERTIES.put("VendorName", "Apache ObjectRelationalBridge");
096:                PROPERTIES.put("VersionNumber", "1.0");
097:            }
098:
099:            /**
100:             * This method returns an instance of PersistenceManagerFactory based on the properties
101:             * in the parameter. It is used by JDOHelper to construct an instance of PersistenceManagerFactory
102:             * based on user-specified properties.
103:             * The following are standard key values for the Properties:
104:             * Java Data Objects1.0
105:             * javax.jdo.PersistenceManagerFactoryClass --> Ignored, we only have one and that is PersistenceManagerFactoryImpl
106:             * javax.jdo.option.Optimistic
107:             * javax.jdo.option.RetainValues
108:             * javax.jdo.option.RestoreValues
109:             * javax.jdo.option.IgnoreCache
110:             * javax.jdo.option.NontransactionalRead
111:             * javax.jdo.option.NontransactionalWrite
112:             * javax.jdo.option.Multithreaded
113:             *
114:             * javax.jdo.option.ConnectionUserName
115:             * javax.jdo.option.ConnectionPassword
116:             * javax.jdo.option.ConnectionURL
117:             * javax.jdo.option.ConnectionFactoryName
118:             * javax.jdo.option.ConnectionFactory2Name
119:             * @see JDOConstants
120:             * @param props
121:             * @return the PersistenceManagerFactory instance with the appropriate Properties.
122:             */
123:            public static PersistenceManagerFactory getPersistenceManagerFactory(
124:                    Properties props) {
125:                PersistenceManagerFactoryImpl retval = new PersistenceManagerFactoryImpl();
126:                // parse and set the properties
127:                // boolean props
128:                retval.setOptimistic(Boolean.getBoolean(props.getProperty(
129:                        JDOConstants.OPTIMISTIC, BooleanUtils
130:                                .toStringTrueFalse(retval.getOptimistic()))));
131:                retval.setRetainValues(Boolean.getBoolean(props.getProperty(
132:                        JDOConstants.RETAIN_VALUES, BooleanUtils
133:                                .toStringTrueFalse(retval.getRetainValues()))));
134:                retval
135:                        .setRestoreValues(Boolean.getBoolean(props.getProperty(
136:                                JDOConstants.RESTORE_VALUES, BooleanUtils
137:                                        .toStringTrueFalse(retval
138:                                                .getRestoreValues()))));
139:                retval.setIgnoreCache(Boolean.getBoolean(props.getProperty(
140:                        JDOConstants.IGNORE_CACHE, BooleanUtils
141:                                .toStringTrueFalse(retval.getIgnoreCache()))));
142:                retval.setNontransactionalRead(Boolean.getBoolean(props
143:                        .getProperty(JDOConstants.NON_TRANSACTIONAL_READ,
144:                                BooleanUtils.toStringTrueFalse(retval
145:                                        .getNontransactionalRead()))));
146:                retval
147:                        .setMultithreaded(Boolean.getBoolean(props.getProperty(
148:                                JDOConstants.MULTI_THREADED, BooleanUtils
149:                                        .toStringTrueFalse(retval
150:                                                .getMultithreaded()))));
151:                retval.setOptimistic(Boolean.getBoolean(props.getProperty(
152:                        JDOConstants.OPTIMISTIC, BooleanUtils
153:                                .toStringTrueFalse(retval.getOptimistic()))));
154:                retval.setOptimistic(Boolean.getBoolean(props.getProperty(
155:                        JDOConstants.OPTIMISTIC, BooleanUtils
156:                                .toStringTrueFalse(retval.getOptimistic()))));
157:
158:                // string props
159:                retval.setConnectionUserName(props.getProperty(
160:                        JDOConstants.CONNECTION_USER_NAME, retval
161:                                .getConnectionUserName()));
162:                retval.setConnectionPassword(props.getProperty(
163:                        JDOConstants.CONNECTION_PASSWORD, null));
164:                retval
165:                        .setConnectionURL(props.getProperty(
166:                                JDOConstants.CONNECTION_URL, retval
167:                                        .getConnectionURL()));
168:                retval.setConnectionFactoryName(props.getProperty(
169:                        JDOConstants.CONNECTION_FACTORY_NAME, retval
170:                                .getConnectionFactoryName()));
171:                retval.setConnectionFactory2Name(props.getProperty(
172:                        JDOConstants.CONNECTION_FACTORY_2_NAME, retval
173:                                .getConnectionFactory2Name()));
174:                retval.setAlias(props.getProperty(JDOConstants.ALIAS, retval
175:                        .getAlias()));
176:                return retval;
177:            }
178:
179:            public PersistenceManager getPersistenceManager() {
180:                return getPersistenceManager(null, null, null);
181:            }
182:
183:            public PersistenceManager getPersistenceManager(String userid,
184:                    String password) {
185:                return getPersistenceManager(null, userid, password);
186:            }
187:
188:            public PersistenceManager getPersistenceManager(String alias,
189:                    String userid, String password) {
190:                return new PersistenceManagerImpl(this , alias, userid, password);
191:            }
192:
193:            public String getAlias() {
194:                return m_alias;
195:            }
196:
197:            public void setAlias(String alias) {
198:                m_alias = alias;
199:            }
200:
201:            public void setConnectionUserName(String s) {
202:                m_connectionName = s;
203:            }
204:
205:            public String getConnectionUserName() {
206:                return m_connectionName;
207:            }
208:
209:            public void setConnectionPassword(String s) {
210:                m_connectionPassword = s;
211:            }
212:
213:            public void setConnectionURL(String s) {
214:                m_connectionURL = s;
215:            }
216:
217:            public String getConnectionURL() {
218:                return m_connectionURL;
219:            }
220:
221:            public void setConnectionDriverName(String s) {
222:                m_connectionDriverName = s;
223:            }
224:
225:            public String getConnectionDriverName() {
226:                return m_connectionDriverName;
227:            }
228:
229:            public void setConnectionFactoryName(String s) {
230:                m_connectionFactoryName = s;
231:            }
232:
233:            public String getConnectionFactoryName() {
234:                return m_connectionFactoryName;
235:            }
236:
237:            public void setConnectionFactory(Object o) {
238:                m_connectionFactory = o;
239:            }
240:
241:            public Object getConnectionFactory() {
242:                return m_connectionFactory;
243:            }
244:
245:            public void setConnectionFactory2Name(String s) {
246:                m_connectionFactory2Name = s;
247:            }
248:
249:            public String getConnectionFactory2Name() {
250:                return m_connectionFactory2Name;
251:            }
252:
253:            public void setConnectionFactory2(Object o) {
254:                m_connectionFactory2 = o;
255:            }
256:
257:            public Object getConnectionFactory2() {
258:                return m_connectionFactory2;
259:            }
260:
261:            public void setMultithreaded(boolean b) {
262:                m_multiThreaded = b;
263:            }
264:
265:            public boolean getMultithreaded() {
266:                return m_multiThreaded;
267:            }
268:
269:            public void setOptimistic(boolean b) {
270:                m_optimistic = b;
271:            }
272:
273:            public boolean getOptimistic() {
274:                return m_optimistic;
275:            }
276:
277:            public void setRetainValues(boolean b) {
278:                m_retainValues = b;
279:            }
280:
281:            public boolean getRetainValues() {
282:                return m_retainValues;
283:            }
284:
285:            public void setRestoreValues(boolean b) {
286:                m_restoreValues = b;
287:            }
288:
289:            public boolean getRestoreValues() {
290:                return m_restoreValues;
291:            }
292:
293:            public void setNontransactionalRead(boolean b) {
294:                m_nonTransactionalRead = b;
295:            }
296:
297:            public boolean getNontransactionalRead() {
298:                return m_nonTransactionalRead;
299:            }
300:
301:            public void setNontransactionalWrite(boolean b) {
302:                m_nonTransactionalWrite = b;
303:            }
304:
305:            public boolean getNontransactionalWrite() {
306:                return m_nonTransactionalWrite;
307:            }
308:
309:            public void setIgnoreCache(boolean b) {
310:                m_ignoreCache = b;
311:            }
312:
313:            public boolean getIgnoreCache() {
314:                return m_ignoreCache;
315:            }
316:
317:            public int getMaxPool() {
318:                return m_maxPool;
319:            }
320:
321:            public void setMaxPool(int i) {
322:                m_maxPool = i;
323:            }
324:
325:            public int getMinPool() {
326:                return m_minPool;
327:            }
328:
329:            public void setMinPool(int i) {
330:                m_minPool = i;
331:            }
332:
333:            public int getMsWait() {
334:                return m_msWait;
335:            }
336:
337:            public void setMsWait(int i) {
338:                m_msWait = i;
339:            }
340:
341:            /**
342:             * Return "static" properties of this PersistenceManagerFactory.
343:             * Properties with keys VendorName and VersionNumber are required.  Other
344:             * keys are optional.
345:             * @return the non-operational properties of this PersistenceManagerFactory.
346:             */
347:            public Properties getProperties() {
348:                return PROPERTIES;
349:            }
350:
351:            /** The application can determine from the results of this
352:             * method which optional features are supported by the
353:             * JDO implementation.
354:             * <P>Each supported JDO optional feature is represented by a
355:             * String with one of the following values:
356:             *
357:             * <P>javax.jdo.option.TransientTransactional
358:             * <P>javax.jdo.option.NontransactionalRead
359:             * <P>javax.jdo.option.NontransactionalWrite
360:             * <P>javax.jdo.option.RetainValues
361:             * <P>javax.jdo.option.RestoreValues
362:             * <P>javax.jdo.option.Optimistic
363:             * <P>javax.jdo.option.ApplicationIdentity
364:             * <P>javax.jdo.option.DatastoreIdentity
365:             * <P>javax.jdo.option.NonDatastoreIdentity
366:             * <P>javax.jdo.option.ArrayList
367:             * <P>javax.jdo.option.HashMap
368:             * <P>javax.jdo.option.Hashtable
369:             * <P>javax.jdo.option.LinkedList
370:             * <P>javax.jdo.option.TreeMap
371:             * <P>javax.jdo.option.TreeSet
372:             * <P>javax.jdo.option.Vector
373:             * <P>javax.jdo.option.Map
374:             * <P>javax.jdo.option.List
375:             * <P>javax.jdo.option.Array
376:             * <P>javax.jdo.option.NullCollection
377:             *
378:             *<P>The standard JDO query language is represented by a String:
379:             *<P>javax.jdo.query.JDOQL
380:             * @return the Set of String representing the supported Options
381:             */
382:            public Collection supportedOptions() {
383:                return Collections.unmodifiableCollection(Arrays
384:                        .asList(m_implementedOptions));
385:            }
386:
387:            /* (non-Javadoc)
388:             * @see javax.jdo.PersistenceManagerFactory#close()
389:             */
390:            public void close() {
391:                // TODO Auto-generated method stub
392:
393:            }
394:
395:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.