Source Code Cross Referenced for ConfigParser.java in  » Testing » PolePosition-0.20 » com » versant » core » common » config » 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 » Testing » PolePosition 0.20 » com.versant.core.common.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998 - 2005 Versant Corporation
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         * Versant Corporation - initial API and implementation
010:         */
011:        package com.versant.core.common.config;
012:
013:        import com.versant.core.jdo.VersantPersistenceManager;
014:        import com.versant.core.metadata.MDStatics;
015:        import com.versant.core.metadata.parser.JdoExtension;
016:        import com.versant.core.metadata.parser.JdoRoot;
017:        import com.versant.core.util.StringListParser;
018:
019:        import java.io.File;
020:        import java.io.FileInputStream;
021:        import java.io.IOException;
022:        import java.io.InputStream;
023:        import java.util.*;
024:
025:        import com.versant.core.common.BindingSupportImpl;
026:        import com.versant.core.common.Utils;
027:
028:        /**
029:         * Parser for our property files. This will parse a file and return a Config
030:         * instance.
031:         */
032:        public class ConfigParser {
033:
034:            public static final String VERSANT_JDO_META_DATA = "versant.jdoMetaData";
035:
036:            public static final String META_DATA_PRE_PROCESSOR = "versant.metadata.preprocessor";
037:
038:            public static final String PROJECT_DESCRIPTION = "versant.workbench.projectDescription";
039:            public static final String PROPERTIES_FILE_MODE = "versant.workbench.propertiesFile";
040:            public static final String PROPERTIES_SPLIT_FILE = "versant.workbench.splitPropertiesFiles";
041:            public static final String SERVER = "versant.server";
042:            public static final String REMOTE_ACCESS = "versant.remoteAccess";
043:            public static final String ALLOW_REMOTE_PMS = "versant.remotePMs";
044:            public static final String RMI_REGISTRY_PORT = "versant.rmiRegistryPort";
045:            public static final String SERVER_PORT = "versant.serverPort";
046:            public static final String RMI_CLIENT_SF = "versant.rmiClientSocketFactory";
047:            public static final String RMI_CSF_IS_SSF = "versant.rmiClientSocketFactoryIsServerSF";
048:            public static final String RMI_SERVER_SF = "versant.rmiServerSocketFactory";
049:            public static final String ALLOW_PM_CLOSE_WITH_OPEN_TX = "versant.allowPmCloseWithOpenTx";
050:            public static final String PRECOMPILE_NAMED_QUERIES = "versant.precompileNamedQueries";
051:            public static final String CHECK_MODEL_CONSISTENCY_ON_COMMIT = "versant.checkModelConsistencyOnCommit";
052:            public static final String INTERCEPT_DFG_FIELD_ACCESS = "versant.interceptDfgFieldAccess";
053:            public static final String PM_CACHE_REF_TYPE = "versant.pmCacheRefType";
054:
055:            public static final String PMF_CLASS = "javax.jdo.PersistenceManagerFactoryClass";
056:            public static final String OPTION_OPTIMISTIC = "javax.jdo.option.Optimistic";
057:            public static final String OPTION_RETAINVALUES = "javax.jdo.option.RetainValues";
058:            public static final String OPTION_RESTORE_VALUES = "javax.jdo.option.RestoreValues";
059:            public static final String OPTION_NON_TRANSACTIONAL_READ = "javax.jdo.option.NontransactionalRead";
060:            public static final String OPTION_NON_TRANSACTIONAL_WRITE = "javax.jdo.option.NontransactionalWrite";
061:            public static final String OPTION_MULTITHREADED = "javax.jdo.option.Multithreaded";
062:            public static final String OPTION_IGNORE_CACHE = "javax.jdo.option.IgnoreCache";
063:            public static final String OPTION_CONNECTION_FACTORY_NAME = "javax.jdo.option.ConnectionFactoryName";
064:            public static final String OPTION_CONNECTION_FACTORY2_NAME = "javax.jdo.option.ConnectionFactory2Name";
065:
066:            public static final boolean PARALLEL_COLLECTION_FETCH_DEFAULT = true;
067:            public static final boolean DEFAULT_ALLOW_PM_CLOSE_WITH_OPEN_TX = false;
068:            public static final boolean DEFAULT_ALLOW_REMOTE_ACCESS = true;
069:            public static final boolean DEFAULT_ALLOW_REMOTE_PMS = true;
070:            public static final boolean DEFAULT_RMI_CSF_IS_SSF = false;
071:            public static final boolean DEFAULT_HYPERDRIVE = true;
072:            public static final boolean DEFAULT_PMPOOL_ENABLED = true;
073:            public static final boolean DEFAULT_REMOTE_PMPOOL_ENABLED = true;
074:            public static final boolean DEFAULT_PRECOMPILE_NAMED_QUERIES = true;
075:            public static final boolean DEFAULT_CHECK_MODEL_CONSISTENCY_ON_COMMIT = false;
076:            public static final boolean DEFAULT_ANT_DISABLED = false;
077:            public static final boolean DEFAULT_OPTION_OPTIMISTIC = true;
078:            public static final boolean DEFAULT_OPTION_RETAINVALUES = false;
079:            public static final boolean DEFAULT_OPTION_RESTORE_VALUES = false;
080:            public static final boolean DEFAULT_OPTION_IGNORE_CACHE = false;
081:            public static final boolean DEFAULT_OPTION_NON_TRANSACTIONAL_READ = false;
082:            public static final boolean DEFAULT_OPTION_NON_TRANSACTIONAL_WRITE = false;
083:            public static final boolean DEFAULT_OPTION_MULTITHREADED = false;
084:            public static final boolean DEFAULT_CACHE_ENABLED = true;
085:            public static final boolean DEFAULT_QUERY_CACHE_ENABLED = true;
086:            public static final boolean DEFAULT_ANT_SHOW_ALL_TARGETS = false;
087:            public static final int DEFAULT_STORE_MAX_ACTIVE = 10;
088:            public static final int DEFAULT_STORE_MAX_IDLE = 10;
089:            public static final int DEFAULT_STORE_MIN_IDLE = 2;
090:            public static final int DEFAULT_STORE_RESERVED = 1;
091:            public static final boolean DEFAULT_STORE_WAIT_FOR_CON_ON_STARTUP = false;
092:            public static final boolean DEFAULT_STORE_TEST_ON_ALLOC = false;
093:            public static final boolean DEFAULT_STORE_TEST_ON_RELEASE = false;
094:            public static final boolean DEFAULT_STORE_TEST_ON_EXCEPTION = true;
095:            public static final int DEFAULT_STORE_RETRY_INTERVAL_MS = 1000;
096:            public static final int DEFAULT_STORE_RETRY_COUNT = 30;
097:            public static final boolean DEFAULT_STORE_MANAGED_ONE_TO_MANY = false;
098:            public static final boolean DEFAULT_STORE_MANAGED_MANY_TO_MANY = false;
099:
100:            public static final int DEFAULT_RMI_REGISTRY_PORT = 2388;
101:
102:            public static final String HYPERDRIVE = "versant.hyperdrive";
103:            public static final String HYPERDRIVE_SRC_DIR = "versant.hyperdriveSrcDir";
104:            public static final String HYPERDRIVE_CLASS_DIR = "versant.hyperdriveClassDir";
105:
106:            public static final String PMPOOL_ENABLED = "versant.pmpoolEnabled";
107:            public static final String PMPOOL_MAX_IDLE = "versant.pmpoolMaxIdle";
108:
109:            public static final int DEFAULT_PMPOOL_MAX_IDLE = 8;
110:
111:            public static final String REMOTE_PMPOOL_ENABLED = "versant.remotePmpoolEnabled";
112:            public static final String REMOTE_PMPOOL_MAX_IDLE = "versant.remotePmpoolMaxIdle";
113:            public static final String REMOTE_PMPOOL_MAX_ACTIVE = "versant.remotePmpoolMaxActive";
114:
115:            public static final int DEFAULT_REMOTE_PMPOOL_MAX_IDLE = 2;
116:            public static final int DEFAULT_REMOTE_PMPOOL_MAX_ACTIVE = 5;
117:
118:            public static final String FLUSH_THRESHOLD = "versant.flushThreshold";
119:
120:            public static final int DEFAULT_FLUSH_THRESHOLD = 0;
121:
122:            public static final String STORE_TYPE = "versant.type";
123:            public static final String STORE_DB = "versant.db";
124:            public static final String STORE_PROPERTIES = "versant.properties";
125:            public static final String STORE_MAX_ACTIVE = "versant.maxActive";
126:            public static final String STORE_MAX_IDLE = "versant.maxIdle";
127:            public static final String STORE_MIN_IDLE = "versant.minIdle";
128:            public static final String STORE_RESERVED = "versant.reserved";
129:            public static final String STORE_EXT = "versant.ext.";
130:            public static final int MAX_STORE_TYPE_MAPPING_COUNT = 100;
131:            public static final String STORE_TYPE_MAPPING = "versant.jdbcType.";
132:            public static final int MAX_STORE_JAVATYPE_MAPPING_COUNT = 100;
133:            public static final String STORE_JAVATYPE_MAPPING = "versant.jdbcJavaType.";
134:            public static final String STORE_NAMEGEN = "versant.jdbcNamegen";
135:            public static final String STORE_MIGRATION_CONTROLS = "versant.jdbcMigration";
136:            public static final String STORE_DISABLE_BATCHING = "versant.jdbcNobatching";
137:            public static final String STORE_DISABLE_PS_CACHE = "versant.jdbcDisablePsCache";
138:            public static final String STORE_PS_CACHE_MAX = "versant.psCacheMax";
139:            public static final String STORE_VALIDATE_SQL = "versant.validateSql";
140:            public static final String STORE_INIT_SQL = "versant.initSql";
141:            public static final String STORE_WAIT_FOR_CON_ON_STARTUP = "versant.waitForConOnStartup";
142:            public static final String STORE_TEST_ON_ALLOC = "versant.testOnAlloc";
143:            public static final String STORE_TEST_ON_RELEASE = "versant.testOnRelease";
144:            public static final String STORE_TEST_ON_EXCEPTION = "versant.testOnException";
145:            public static final String STORE_TEST_WHEN_IDLE = "versant.testWhenIdle";
146:            public static final String STORE_RETRY_INTERVAL_MS = "versant.retryIntervalMs";
147:            public static final String STORE_RETRY_COUNT = "versant.retryCount";
148:            public static final String STORE_VALIDATE_MAPPING_ON_STARTUP = "versant.validateMappingOnStartup";
149:            public static final String STORE_CON_TIMEOUT = "versant.conTimeout";
150:            public static final String STORE_TEST_INTERVAL = "versant.testInterval";
151:            public static final String STORE_ISOLATION_LEVEL = "versant.isolationLevel";
152:            public static final String STORE_BLOCK_WHEN_FULL = "versant.blockWhenFull";
153:            public static final String STORE_MAX_CON_AGE = "versant.maxConAge";
154:            public static final String STORE_MANAGED_ONE_TO_MANY = "versant.managedOneToMany";
155:            public static final String STORE_MANAGED_MANY_TO_MANY = "versant.managedManyToMany";
156:            public static final int MAX_STORE_SCO_FACTORY_COUNT = 100;
157:            public static final String STORE_SCO_FACTORY_MAPPING = "versant.scoFactoryMapping.";
158:            public static final String VDS_OID_BATCH_SIZE = "versant.vdsOidBatchSize";
159:            public static final String VDS_SCHEMA_DEFINITION = "versant.vdsSchemaDefine";
160:            public static final String VDS_SCHEMA_EVOLUTION = "versant.vdsSchemaEvolve";
161:            public static final String VDS_NAMING_POLICY = "versant.vdsNamingPolicy";
162:
163:            // standard connection properties
164:            public static final String STD_CON_DRIVER_NAME = "javax.jdo.option.ConnectionDriverName";
165:            public static final String STD_CON_USER_NAME = "javax.jdo.option.ConnectionUserName";
166:            public static final String STD_CON_PASSWORD = "javax.jdo.option.ConnectionPassword";
167:            public static final String STD_CON_URL = "javax.jdo.option.ConnectionURL";
168:            public static final String STD_CON_FACTORY_NAME = "javax.jdo.option.ConnectionFactoryName";
169:            public static final String STD_CON2_FACTORY_NAME = "javax.jdo.option.ConnectionFactory2Name";
170:
171:            // 2de connection properties
172:            public static final String CON2_DRIVER_NAME = "versant.Connection2DriverName";
173:            public static final String CON2_USER_NAME = "versant.Connection2UserName";
174:            public static final String CON2_PASSWORD = "versant.Connection2Password";
175:            public static final String CON2_URL = "versant.Connection2URL";
176:            public static final String CON2_PROPERTIES = "versant.properties2";
177:
178:            public static final int DEFAULT_MAX_CON_AGE = 1000;
179:
180:            public static final String ISOLATION_LEVEL_READ_UNCOMMITTED = "READ_UNCOMMITTED";
181:            public static final String ISOLATION_LEVEL_READ_COMMITTED = "READ_COMMITTED";
182:            public static final String ISOLATION_LEVEL_REPEATABLE_READ = "REPEATABLE_READ";
183:            public static final String ISOLATION_LEVEL_SERIALIZABLE = "SERIALIZABLE";
184:
185:            public static final int MAX_JDO_FILE_COUNT = 1000;
186:            public static final String JDO = "versant.metadata.";
187:
188:            public static final String EVENT_LOGGING = "versant.logging";
189:
190:            public static final String DATASTORE_TX_LOCKING = "versant.datastoreTxLocking";
191:
192:            public static final String DATASTORE_TX_LOCKING_NONE = "LOCKING_NONE";
193:            public static final String DATASTORE_TX_LOCKING_FIRST = "LOCKING_FIRST";
194:            public static final String DATASTORE_TX_LOCKING_ALL = "LOCKING_ALL";
195:
196:            public static final String RETAIN_CONNECTION_IN_OPT_TX = "versant.retainConnectionInOptTx";
197:
198:            public static final String CACHE_ENABLED = "versant.l2CacheEnabled";
199:            public static final String CACHE_MAX_OBJECTS = "versant.l2CacheMaxObjects";
200:            public static final String CACHE_LISTENER = "versant.l2CacheListener";
201:            public static final String CACHE_CLUSTER_TRANSPORT = "versant.l2CacheClusterTransport";
202:            public static final String CLUSTER_JGROUPS = "JGROUPS";
203:            public static final String CLUSTER_TANGOSOL_COHERENCE = "TANGOSOL_COHERENCE";
204:
205:            public static final String QUERY_CACHE_ENABLED = "versant.l2QueryCacheEnabled";
206:            public static final String QUERY_CACHE_MAX_QUERIES = "versant.l2QueryCacheMaxQueries";
207:            public static final String COMPILED_QUERY_CACHE_SIZE = "versant.compiledQueryCacheSize";
208:
209:            public static final int DEFAULT_CACHE_MAX_OBJECTS = 10000;
210:            public static final int DEFAULT_CACHE_MAX_QUERIES = 1000;
211:
212:            public static final int DEFAULT_METRIC_SNAPSHOT_INTERVAL_MS = 1000;
213:            public static final int DEFAULT_METRIC_STORE_CAPACITY = 60 * 60;
214:
215:            public static final String METRIC_USER = "versant.userMetric.";
216:            public static final int MAX_METRIC_USER_COUNT = 100;
217:
218:            public static final String METRIC_SNAPSHOT_INTERVAL_MS = "versant.metricSnapshotIntervalMs";
219:            public static final String METRIC_STORE_CAPACITY = "versant.metricStoreCapacity";
220:
221:            public static final String LOG_DOWNLOADER = "versant.logDownloader";
222:            public static final String NAMING_POLICY_CLASS_NAME = "versant.namingPolicy";
223:
224:            // This is no longer used - the Workbench will automatically convert
225:            // it to ext.jdbc-class-id instead on load
226:            public static final String JDBC_INHERITANCE_NO_CLASSID = "jdbc-inheritance-no-classid";
227:
228:            public static final String PM_CACHE_REF_TYPE_STRONG = "STRONG";
229:            public static final String PM_CACHE_REF_TYPE_SOFT = "SOFT";
230:            public static final String PM_CACHE_REF_TYPE_WEAK = "WEAK";
231:
232:            public static final int MAX_EXTERNALIZER_COUNT = 100;
233:            public static final String EXTERNALIZER = "versant.externalizer.";
234:
235:            public static final String TESTING = "versant.testing";
236:
237:            // workbench specefic properties
238:            public static final String MDEDIT_SRC_PATH = "versant.workbench.srcPath";
239:            public static final int MAX_MDEDIT_CP_COUNT = 1000;
240:            public static final String MDEDIT_CP = "versant.workbench.classpath.";
241:
242:            public static final String ANT_DISABLED = "versant.workbench.antDisabled";
243:            public static final String ANT_BUILDFILE = "versant.workbench.antBuildfile";
244:            public static final String ANT_RUN_TARGET = "versant.workbench.antRunTarget";
245:            public static final String ANT_COMPILE = "versant.workbench.antCompile";
246:            public static final String ANT_ARGS = "versant.workbench.antArgs";
247:            public static final String ANT_SHOW_ALL_TARGETS = "versant.workbench.antShowAllTargets";
248:
249:            public static final String SCRIPT_DIR = "versant.workbench.scriptDir";
250:
251:            public static final String DIAGRAM = "versant.workbench.diagram";
252:            public static final String DIAGRAM_COUNT = ".count";
253:            public static final String DIAGRAM_CLASS = ".class";
254:            public static final String DIAGRAM_NAME = ".name";
255:            public static final String DIAGRAM_LEGEND = ".legend";
256:
257:            public static final String EXTERNALIZER_TYPE = ".type";
258:            public static final String EXTERNALIZER_ENABLED = ".enabled";
259:            public static final String EXTERNALIZER_CLASS = ".class";
260:
261:            public ConfigParser() {
262:            }
263:
264:            /**
265:             * Parse the supplied properties file and create a Config instance.
266:             */
267:            public ConfigInfo parse(String filename) {
268:                try {
269:                    InputStream in = null;
270:                    try {
271:                        in = new FileInputStream(filename);
272:                        return parse(in);
273:                    } finally {
274:                        if (in != null)
275:                            in.close();
276:                    }
277:                } catch (IOException e) {
278:                    handleException(e);
279:                    return null;
280:                }
281:            }
282:
283:            private void handleException(Throwable t) {
284:                throw BindingSupportImpl.getInstance().runtime(
285:                        t.getClass().getName() + ": " + t.getMessage(), t);
286:            }
287:
288:            /**
289:             * Parse the supplied properties resoutce and create a Config instance.
290:             */
291:            public ConfigInfo parseResource(String filename, ClassLoader cl) {
292:                try {
293:                    InputStream in = null;
294:                    try {
295:                        if (filename.startsWith("/"))
296:                            filename = filename.substring(1);
297:                        in = cl.getResourceAsStream(filename);
298:                        if (in == null) {
299:                            throw BindingSupportImpl.getInstance().runtime(
300:                                    "Resource not found: " + filename);
301:                        }
302:                        return parse(in);
303:                    } finally {
304:                        if (in != null)
305:                            in.close();
306:                    }
307:                } catch (IOException e) {
308:                    handleException(e);
309:                    return null;
310:                }
311:            }
312:
313:            public ConfigInfo parseResource(File file) {
314:                try {
315:                    InputStream in = new FileInputStream(file);
316:                    try {
317:                        return parse(in);
318:                    } finally {
319:                        if (in != null)
320:                            in.close();
321:                    }
322:                } catch (IOException e) {
323:                    handleException(e);
324:                    return null;
325:                }
326:            }
327:
328:            /**
329:             * Parse the supplied properties resoutce and create a Config instance.
330:             */
331:            public ConfigInfo parseResource(String filename) {
332:                try {
333:                    InputStream in = null;
334:                    try {
335:                        in = getClass().getResourceAsStream(filename);
336:                        if (in == null) {
337:                            throw BindingSupportImpl.getInstance().runtime(
338:                                    "Resource not found: " + filename);
339:                        }
340:                        return parse(in);
341:                    } finally {
342:                        if (in != null)
343:                            in.close();
344:                    }
345:                } catch (IOException e) {
346:                    handleException(e);
347:                    return null;
348:                }
349:            }
350:
351:            /**
352:             * Parse the supplied config stream and create a Config instance.
353:             */
354:            public ConfigInfo parse(InputStream in) {
355:                Properties p = new Properties();
356:                try {
357:                    p.load(in);
358:                } catch (IOException e) {
359:                    throw BindingSupportImpl.getInstance().runtime(
360:                            e.getClass() + ": " + e.getMessage(), e);
361:                }
362:                return parse(p);
363:            }
364:
365:            /**
366:             * Parse the supplied config properties and create a Config instance.
367:             */
368:            public ConfigInfo parse(Properties p) {
369:                PropertyConverter.convert(p);
370:                String s;
371:                ConfigInfo c = new ConfigInfo();
372:                c.metaDataPreProcessor = p.getProperty(META_DATA_PRE_PROCESSOR);
373:                c.props = p;
374:                c.jdoMetaData = (JdoRoot[]) p.get(VERSANT_JDO_META_DATA);
375:                c.serverName = p.getProperty(SERVER, "versant");
376:                c.hyperdrive = getBoolean(p, HYPERDRIVE, DEFAULT_HYPERDRIVE);
377:                c.hyperdriveSrcDir = p.getProperty(HYPERDRIVE_SRC_DIR);
378:                c.hyperdriveClassDir = p.getProperty(HYPERDRIVE_CLASS_DIR);
379:                c.flushThreshold = getInt(p, FLUSH_THRESHOLD,
380:                        DEFAULT_FLUSH_THRESHOLD);
381:                c.allowPmCloseWithOpenTx = getBoolean(p,
382:                        ALLOW_PM_CLOSE_WITH_OPEN_TX,
383:                        DEFAULT_ALLOW_PM_CLOSE_WITH_OPEN_TX);
384:                c.precompileNamedQueries = getBoolean(p,
385:                        PRECOMPILE_NAMED_QUERIES,
386:                        DEFAULT_PRECOMPILE_NAMED_QUERIES);
387:                c.checkModelConsistencyOnCommit = getBoolean(p,
388:                        CHECK_MODEL_CONSISTENCY_ON_COMMIT,
389:                        DEFAULT_CHECK_MODEL_CONSISTENCY_ON_COMMIT);
390:                c.interceptDfgFieldAccess = getBoolean(p,
391:                        INTERCEPT_DFG_FIELD_ACCESS, false);
392:                c.testing = getBoolean(p, TESTING, false);
393:                c.remoteAccess = p.getProperty(REMOTE_ACCESS);
394:
395:                s = p.getProperty(PM_CACHE_REF_TYPE, PM_CACHE_REF_TYPE_SOFT);
396:                if (s.equals(PM_CACHE_REF_TYPE_SOFT)) {
397:                    c.pmCacheRefType = VersantPersistenceManager.PM_CACHE_REF_TYPE_SOFT;
398:                } else if (s.equals(PM_CACHE_REF_TYPE_WEAK)) {
399:                    c.pmCacheRefType = VersantPersistenceManager.PM_CACHE_REF_TYPE_WEAK;
400:                } else if (s.equals(PM_CACHE_REF_TYPE_STRONG)) {
401:                    c.pmCacheRefType = VersantPersistenceManager.PM_CACHE_REF_TYPE_STRONG;
402:                } else {
403:                    throw BindingSupportImpl.getInstance().runtime(
404:                            "Invalid " + PM_CACHE_REF_TYPE + ": '" + s
405:                                    + "', expected " + PM_CACHE_REF_TYPE_SOFT
406:                                    + ", " + PM_CACHE_REF_TYPE_WEAK + " or "
407:                                    + PM_CACHE_REF_TYPE_STRONG);
408:                }
409:
410:                c.retainValues = getBoolean(p, OPTION_RETAINVALUES,
411:                        DEFAULT_OPTION_RETAINVALUES);
412:                c.restoreValues = getBoolean(p, OPTION_RESTORE_VALUES,
413:                        DEFAULT_OPTION_RESTORE_VALUES);
414:                c.optimistic = getBoolean(p, OPTION_OPTIMISTIC,
415:                        DEFAULT_OPTION_OPTIMISTIC);
416:                c.nontransactionalRead = getBoolean(p,
417:                        OPTION_NON_TRANSACTIONAL_READ,
418:                        DEFAULT_OPTION_NON_TRANSACTIONAL_READ);
419:                c.nontransactionalWrite = getBoolean(p,
420:                        OPTION_NON_TRANSACTIONAL_WRITE,
421:                        DEFAULT_OPTION_NON_TRANSACTIONAL_WRITE);
422:                c.ignoreCache = getBoolean(p, OPTION_IGNORE_CACHE,
423:                        DEFAULT_OPTION_IGNORE_CACHE);
424:                c.multithreaded = getBoolean(p, OPTION_MULTITHREADED,
425:                        DEFAULT_OPTION_MULTITHREADED);
426:                c.connectionFactoryName = p
427:                        .getProperty(OPTION_CONNECTION_FACTORY_NAME);
428:                c.connectionFactory2Name = p
429:                        .getProperty(OPTION_CONNECTION_FACTORY2_NAME);
430:
431:                // datastore tx locking
432:                s = p.getProperty(DATASTORE_TX_LOCKING);
433:                if (s == null) {
434:                    c.datastoreTxLocking = VersantPersistenceManager.LOCKING_FIRST;
435:                } else {
436:                    if (s.equals(DATASTORE_TX_LOCKING_ALL)) {
437:                        c.datastoreTxLocking = VersantPersistenceManager.LOCKING_ALL;
438:                    } else if (s.equals(DATASTORE_TX_LOCKING_FIRST)) {
439:                        c.datastoreTxLocking = VersantPersistenceManager.LOCKING_FIRST;
440:                    } else if (s.equals(DATASTORE_TX_LOCKING_NONE)) {
441:                        c.datastoreTxLocking = VersantPersistenceManager.LOCKING_NONE;
442:                    } else {
443:                        throw BindingSupportImpl.getInstance().runtime(
444:                                "Invalid datastore.tx.locking: '" + s
445:                                        + "', expected none, first or all.");
446:                    }
447:                }
448:
449:                s = p.getProperty(RETAIN_CONNECTION_IN_OPT_TX);
450:                if ("true".equals(s)) {
451:                    c.retainConnectionInOptTx = MDStatics.TRUE;
452:                } else if ("false".equals(s)) {
453:                    c.retainConnectionInOptTx = MDStatics.FALSE;
454:                } else {
455:                    c.retainConnectionInOptTx = MDStatics.NOT_SET;
456:                }
457:
458:                // pm pool settings
459:                c.pmpoolEnabled = getBoolean(p, PMPOOL_ENABLED,
460:                        DEFAULT_PMPOOL_ENABLED);
461:                c.pmpoolMaxIdle = getInt(p, PMPOOL_MAX_IDLE,
462:                        DEFAULT_PMPOOL_MAX_IDLE);
463:                c.remotePmpoolEnabled = getBoolean(p, REMOTE_PMPOOL_ENABLED,
464:                        DEFAULT_REMOTE_PMPOOL_ENABLED);
465:                c.remotePmpoolMaxIdle = getInt(p, REMOTE_PMPOOL_MAX_IDLE,
466:                        DEFAULT_REMOTE_PMPOOL_MAX_IDLE);
467:                c.remotePmpoolMaxActive = getInt(p, REMOTE_PMPOOL_MAX_ACTIVE,
468:                        DEFAULT_REMOTE_PMPOOL_MAX_ACTIVE);
469:
470:                c.queryCacheEnabled = getBoolean(p, QUERY_CACHE_ENABLED,
471:                        DEFAULT_QUERY_CACHE_ENABLED);
472:                c.maxQueriesToCache = getInt(p, QUERY_CACHE_MAX_QUERIES,
473:                        DEFAULT_CACHE_MAX_QUERIES);
474:                c.compiledQueryCacheSize = getInt(p, COMPILED_QUERY_CACHE_SIZE,
475:                        0);
476:
477:                // initialize the cache settings
478:                c.useCache = getBoolean(p, CACHE_ENABLED, DEFAULT_CACHE_ENABLED);
479:                c.cacheMaxObjects = getInt(p, CACHE_MAX_OBJECTS,
480:                        DEFAULT_CACHE_MAX_OBJECTS);
481:
482:                c.cacheListenerClass = getClassAndProps(p,
483:                        CACHE_CLUSTER_TRANSPORT,
484:                        c.cacheListenerProps = new HashMap());
485:                if (c.cacheListenerClass == null
486:                        && c.cacheListenerProps == null) {
487:                    c.cacheListenerClass = getClassAndProps(p, CACHE_LISTENER,
488:                            c.cacheListenerProps = new HashMap());
489:                }
490:
491:                // read externalizers
492:                readExternalizers(p, c);
493:
494:                // read SCO factories
495:                readSCOFactoryMappings(p, c.scoFactoryRegistryMappings);
496:
497:                // create store
498:                String db = p.getProperty(STORE_DB);
499:                if (Utils.isVersantDatabaseType(db)) {
500:                    db = "versant";
501:                    p.put(STORE_DB, db);
502:                }
503:                c.db = p.getProperty(STORE_DB);
504:                c.url = p.getProperty(STD_CON_URL);
505:
506:                getClassAndProps(p, EVENT_LOGGING, c.perfProps = new HashMap());
507:
508:                c.logDownloaderClass = getClassAndProps(p, LOG_DOWNLOADER,
509:                        c.logDownloaderProps = new HashMap());
510:
511:                c.metricStoreCapacity = getInt(p, METRIC_STORE_CAPACITY,
512:                        DEFAULT_METRIC_STORE_CAPACITY);
513:                c.metricSnapshotIntervalMs = getInt(p,
514:                        METRIC_SNAPSHOT_INTERVAL_MS,
515:                        DEFAULT_METRIC_SNAPSHOT_INTERVAL_MS);
516:
517:                // parse user defined base metrics
518:                for (int i = 0; i < MAX_METRIC_USER_COUNT; i++) {
519:                    s = p.getProperty(METRIC_USER + i);
520:                    if (s == null)
521:                        continue;
522:                    StringListParser lp = new StringListParser(s);
523:                    ConfigInfo.UserBaseMetric u = new ConfigInfo.UserBaseMetric();
524:                    u.name = lp.nextString();
525:                    u.displayName = lp.nextQuotedString();
526:                    u.category = lp.nextQuotedString();
527:                    u.description = lp.nextQuotedString();
528:                    u.defaultCalc = lp.nextInt();
529:                    u.decimals = lp.nextInt();
530:                    c.userBaseMetrics.add(u);
531:                }
532:
533:                // find all .jdo and .jdoql files
534:                int n = MAX_JDO_FILE_COUNT;
535:                for (int i = 0; i < n; i++) {
536:                    String base = JDO + i;
537:                    String f = p.getProperty(base);
538:                    if (f == null)
539:                        continue;
540:                    c.jdoResources.add(f);
541:                }
542:
543:                return c;
544:            }
545:
546:            private void readSCOFactoryMappings(Properties p, Map map) {
547:                String s;
548:                for (int x = 0; x < MAX_STORE_SCO_FACTORY_COUNT; x++) {
549:                    s = p.getProperty(STORE_SCO_FACTORY_MAPPING + x);
550:                    if (s != null) {
551:                        StringListParser lp = new StringListParser(s);
552:                        String javaClassName = lp.nextString();
553:                        String factoryName = lp.nextString();
554:                        map.put(javaClassName, factoryName);
555:                    }
556:                }
557:            }
558:
559:            private void readExternalizers(Properties p, ConfigInfo c) {
560:                String s;
561:                String ext = null;
562:                for (int i = 0; i < MAX_EXTERNALIZER_COUNT; i++) {
563:                    ext = EXTERNALIZER + i;
564:                    s = p.getProperty(ext + EXTERNALIZER_TYPE);
565:                    if (s != null) { // we have an externalizer
566:                        ConfigInfo.ExternalizerInfo ei = new ConfigInfo.ExternalizerInfo();
567:                        ei.typeName = s;
568:                        ei.enabled = getBoolean(p, ext + EXTERNALIZER_ENABLED,
569:                                false);
570:                        ei.externalizerName = p.getProperty(ext
571:                                + EXTERNALIZER_CLASS);
572:                        Set all = p.keySet();
573:                        String extProps = ext + EXTERNALIZER_CLASS + ".";
574:                        for (Iterator iter = all.iterator(); iter.hasNext();) {
575:                            String key = (String) iter.next();
576:                            if (key.startsWith(extProps)) {
577:                                String newKey = key
578:                                        .substring(extProps.length() + 1);
579:                                ei.args.put(newKey, p.getProperty(key));
580:                            }
581:                        }
582:                        c.externalizers.add(ei);
583:                    }
584:                }
585:            }
586:
587:            public static String trim(String s) {
588:                if (s == null)
589:                    return s;
590:                s = s.trim();
591:                if (s.length() == 0)
592:                    return null;
593:                return s;
594:            }
595:
596:            public static int getExtEnum(Properties p, String be, int ext,
597:                    Map map, int def) {
598:                JdoExtension e = getExt(p, be, ext);
599:                if (e == null)
600:                    return def;
601:                return e.getEnum(map);
602:            }
603:
604:            public static boolean getExtBoolean(Properties p, String be,
605:                    int ext, boolean def) {
606:                JdoExtension e = getExt(p, be, ext);
607:                if (e == null)
608:                    return def;
609:                return e.getBoolean();
610:            }
611:
612:            public static JdoExtension getExt(Properties p, String be, int ext) {
613:                String s = p.getProperty(be + JdoExtension.toKeyString(ext));
614:                if (s == null)
615:                    return null;
616:                JdoExtension e = new JdoExtension();
617:                e.key = ext;
618:                e.value = s;
619:                return e;
620:            }
621:
622:            public static String getReq(Properties p, String s, String alt) {
623:                String v = p.getProperty(s);
624:                if (v == null && alt != null)
625:                    v = p.getProperty(alt);
626:                if (v == null) {
627:                    if (alt == null) {
628:                        throw BindingSupportImpl.getInstance().runtime(
629:                                "Expected property: '" + s + "'");
630:                    } else {
631:                        throw BindingSupportImpl.getInstance().runtime(
632:                                "Expected property: '" + s + "' or '" + alt
633:                                        + "'");
634:                    }
635:                }
636:                return v;
637:            }
638:
639:            public static String getReq(Properties p, String s) {
640:                return getReq(p, s, null);
641:            }
642:
643:            public static int getInt(Properties p, String s, int def) {
644:                String v = p.getProperty(s);
645:                if (v == null || v.equals("null") || v.length() == 0)
646:                    return def;
647:                try {
648:                    return Integer.parseInt(v);
649:                } catch (NumberFormatException e) {
650:                    throw BindingSupportImpl.getInstance().runtime(
651:                            "Expected int: " + s);
652:                }
653:            }
654:
655:            public static boolean getBoolean(Properties p, String s, boolean def) {
656:                String v = p.getProperty(s);
657:                if (v == null)
658:                    return def;
659:                return v.equals("true") || v.equals("on");
660:            }
661:
662:            public static String getClassAndProps(Properties p, String key,
663:                    Map map) {
664:                Set all = p.keySet();
665:                String nextKey = key + ".";
666:                for (Iterator iter = all.iterator(); iter.hasNext();) {
667:                    String s = (String) iter.next();
668:                    if (s.startsWith(nextKey)) {
669:                        String newKey = s.substring(nextKey.length());
670:                        map.put(newKey, p.getProperty(s));
671:                    }
672:                }
673:                return p.getProperty(key);
674:            }
675:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.