1 2 12 package com.versant.core.common.config; 13 14 import com.versant.core.util.StringListParser; 15 import com.versant.core.metadata.parser.JdoExtensionKeys; 16 import com.versant.core.metadata.parser.JdoExtension; 17 18 import java.util.*; 19 import java.io.*; 20 21 25 public class PropertyConverter { 26 27 public static final HashMap oldToNew = new HashMap(); 28 29 static { 30 String PROJECT_DESCRIPTION = "project.description"; 31 oldToNew.put(PROJECT_DESCRIPTION, ConfigParser.PROJECT_DESCRIPTION); 32 String SERVER = "server"; 33 oldToNew.put(SERVER, ConfigParser.SERVER); 34 String HOST = "host"; 35 oldToNew.put(HOST, "versant.host"); 36 String ALLOW_REMOTE_ACCESS = "remote.access"; 37 oldToNew.put(ALLOW_REMOTE_ACCESS, ConfigParser.REMOTE_ACCESS); 38 String ALLOW_REMOTE_PMS = "remote.pm"; 39 oldToNew.put(ALLOW_REMOTE_PMS, ConfigParser.ALLOW_REMOTE_PMS); 40 String REMOTE_USERNAME = "remote.username"; 41 oldToNew.put(REMOTE_USERNAME, "versant.remoteUsername"); 42 String REMOTE_PASSWORD = "remote.password"; 43 oldToNew.put(REMOTE_PASSWORD, "versant.remotePassword"); 44 String RMI_REGISTRY_PORT = "rmi.registry.port"; 45 oldToNew.put(RMI_REGISTRY_PORT, ConfigParser.RMI_REGISTRY_PORT); 46 String SERVER_PORT = "server.port"; 47 oldToNew.put(SERVER_PORT, ConfigParser.SERVER_PORT); 48 String RMI_CLIENT_SF = "rmi.client.sf"; 49 oldToNew.put(RMI_CLIENT_SF, ConfigParser.RMI_CLIENT_SF); 50 String RMI_CSF_IS_SSF = "rmi.csf.is.ssf"; 51 oldToNew.put(RMI_CSF_IS_SSF, ConfigParser.RMI_CSF_IS_SSF); 52 String RMI_SERVER_SF = "rmi.server.sf"; 53 oldToNew.put(RMI_SERVER_SF, ConfigParser.RMI_SERVER_SF); 54 String ALLOW_PM_CLOSE_WITH_OPEN_TX = "allow.pm.close.with.open.tx"; 55 oldToNew.put(ALLOW_PM_CLOSE_WITH_OPEN_TX, 56 ConfigParser.ALLOW_PM_CLOSE_WITH_OPEN_TX); 57 String PRECOMPILE_NAMED_QUERIES = "precompile.named.queries"; 58 oldToNew.put(PRECOMPILE_NAMED_QUERIES, 59 ConfigParser.PRECOMPILE_NAMED_QUERIES); 60 String CHECK_MODEL_CONSISTENCY_ON_COMMIT = "check.model.consistency.on.commit"; 61 oldToNew.put(CHECK_MODEL_CONSISTENCY_ON_COMMIT, 62 ConfigParser.CHECK_MODEL_CONSISTENCY_ON_COMMIT); 63 String INTERCEPT_DFG_FIELD_ACCESS = "intercept.dfg.field.access"; 64 oldToNew.put(INTERCEPT_DFG_FIELD_ACCESS, 65 ConfigParser.INTERCEPT_DFG_FIELD_ACCESS); 66 String PM_CACHE_REF_TYPE = "pm.cache.ref.type"; 67 oldToNew.put(PM_CACHE_REF_TYPE, ConfigParser.PM_CACHE_REF_TYPE); 68 69 String HYPERDRIVE = "hyperdrive"; 70 oldToNew.put(HYPERDRIVE, ConfigParser.HYPERDRIVE); 71 72 String PMPOOL_ENABLED = "pmpool.enabled"; 73 oldToNew.put(PMPOOL_ENABLED, ConfigParser.PMPOOL_ENABLED); 74 String PMPOOL_MAX_IDLE = "pmpool.maxIdle"; 75 oldToNew.put(PMPOOL_MAX_IDLE, ConfigParser.PMPOOL_MAX_IDLE); 76 77 String REMOTE_PMPOOL_ENABLED = "remote.pmpool.enabled"; 78 oldToNew.put(REMOTE_PMPOOL_ENABLED, ConfigParser.REMOTE_PMPOOL_ENABLED); 79 String REMOTE_PMPOOL_MAX_IDLE = "remote.pmpool.maxIdle"; 80 oldToNew.put(REMOTE_PMPOOL_MAX_IDLE, 81 ConfigParser.REMOTE_PMPOOL_MAX_IDLE); 82 String REMOTE_PMPOOL_MAX_ACTIVE = "remote.pmpool.maxActive"; 83 oldToNew.put(REMOTE_PMPOOL_MAX_ACTIVE, 84 ConfigParser.REMOTE_PMPOOL_MAX_ACTIVE); 85 86 String FLUSH_THRESHOLD = "flush.threshold"; 87 oldToNew.put(FLUSH_THRESHOLD, ConfigParser.FLUSH_THRESHOLD); 88 89 String STORE_COUNT = "storeCount"; 90 oldToNew.put(STORE_COUNT, null); 91 String STORE = "store"; 92 oldToNew.put(STORE, null); 93 String STORE_NAME = "store0.name"; 94 oldToNew.put(STORE_NAME, null); 95 String STORE_TYPE = "store0.type"; 96 oldToNew.put(STORE_TYPE, ConfigParser.STORE_TYPE); 97 String STORE_DB = "store0.db"; 98 oldToNew.put(STORE_DB, ConfigParser.STORE_DB); 99 String STORE_URL = "store0.url"; 100 oldToNew.put(STORE_URL, ConfigParser.STD_CON_URL); 101 String STORE_DRIVER = "store0.driver"; 102 oldToNew.put(STORE_DRIVER, ConfigParser.STD_CON_DRIVER_NAME); 103 String STORE_USER = "store0.user"; 104 oldToNew.put(STORE_USER, ConfigParser.STD_CON_USER_NAME); 105 String STORE_PASSWORD = "store0.password"; 106 oldToNew.put(STORE_PASSWORD, ConfigParser.STD_CON_PASSWORD); 107 String STORE_PROPERTIES = "store0.properties"; 108 oldToNew.put(STORE_PROPERTIES, ConfigParser.STORE_PROPERTIES); 109 String STORE_MAX_ACTIVE = "store0.maxActive"; 110 oldToNew.put(STORE_MAX_ACTIVE, ConfigParser.STORE_MAX_ACTIVE); 111 String STORE_MAX_IDLE = "store0.maxIdle"; 112 oldToNew.put(STORE_MAX_IDLE, ConfigParser.STORE_MAX_IDLE); 113 String STORE_MIN_IDLE = "store0.minIdle"; 114 oldToNew.put(STORE_MIN_IDLE, ConfigParser.STORE_MIN_IDLE); 115 String STORE_RESERVED = "store0.reserved"; 116 oldToNew.put(STORE_RESERVED, ConfigParser.STORE_RESERVED); 117 String STORE_TYPE_MAPPING_COUNT = "store0.jdbc.type.count"; 118 oldToNew.put(STORE_TYPE_MAPPING_COUNT, null); 119 String STORE_JAVATYPE_MAPPING_COUNT = "store0.jdbc.javatype.count"; 120 oldToNew.put(STORE_JAVATYPE_MAPPING_COUNT, null); 121 String STORE_NAMEGEN = "store0.jdbc.namegen"; 122 oldToNew.put(STORE_NAMEGEN, ConfigParser.STORE_NAMEGEN); 123 String STORE_MIGRATION_CONTROLS = "store0.jdbc.migration"; 124 oldToNew.put(STORE_MIGRATION_CONTROLS, 125 ConfigParser.STORE_MIGRATION_CONTROLS); 126 String STORE_DISABLE_BATCHING = "store0.jdbc.nobatching"; 127 oldToNew.put(STORE_DISABLE_BATCHING, 128 ConfigParser.STORE_DISABLE_BATCHING); 129 String STORE_DISABLE_PS_CACHE = "store0.jdbc.disable.pscache"; 130 oldToNew.put(STORE_DISABLE_PS_CACHE, 131 ConfigParser.STORE_DISABLE_PS_CACHE); 132 String STORE_PS_CACHE_MAX = "store0.pscache.max"; 133 oldToNew.put(STORE_PS_CACHE_MAX, ConfigParser.STORE_PS_CACHE_MAX); 134 String STORE_VALIDATE_SQL = "store0.validate.sql"; 135 oldToNew.put(STORE_VALIDATE_SQL, ConfigParser.STORE_VALIDATE_SQL); 136 String STORE_INIT_SQL = "store0.init.sql"; 137 oldToNew.put(STORE_INIT_SQL, ConfigParser.STORE_INIT_SQL); 138 String STORE_WAIT_FOR_CON_ON_STARTUP = "store0.wait.for.con.on.startup"; 139 oldToNew.put(STORE_WAIT_FOR_CON_ON_STARTUP, 140 ConfigParser.STORE_WAIT_FOR_CON_ON_STARTUP); 141 String STORE_TEST_ON_ALLOC = "store0.test.on.alloc"; 142 oldToNew.put(STORE_TEST_ON_ALLOC, ConfigParser.STORE_TEST_ON_ALLOC); 143 String STORE_TEST_ON_RELEASE = "store0.test.on.release"; 144 oldToNew.put(STORE_TEST_ON_RELEASE, ConfigParser.STORE_TEST_ON_RELEASE); 145 String STORE_TEST_ON_EXCEPTION = "store0.test.on.exception"; 146 oldToNew.put(STORE_TEST_ON_EXCEPTION, 147 ConfigParser.STORE_TEST_ON_EXCEPTION); 148 String STORE_TEST_WHEN_IDLE = "store0.test.when.idle"; 149 oldToNew.put(STORE_TEST_WHEN_IDLE, ConfigParser.STORE_TEST_WHEN_IDLE); 150 String STORE_RETRY_INTERVAL_MS = "store0.retry.interval.ms"; 151 oldToNew.put(STORE_RETRY_INTERVAL_MS, 152 ConfigParser.STORE_RETRY_INTERVAL_MS); 153 String STORE_RETRY_COUNT = "store0.retry.count"; 154 oldToNew.put(STORE_RETRY_COUNT, ConfigParser.STORE_RETRY_COUNT); 155 String STORE_VALIDATE_MAPPING_ON_STARTUP = "store0.validate.mapping.on.startup"; 156 oldToNew.put(STORE_VALIDATE_MAPPING_ON_STARTUP, 157 ConfigParser.STORE_VALIDATE_MAPPING_ON_STARTUP); 158 String STORE_CON_TIMEOUT = "store0.con.timeout"; 159 oldToNew.put(STORE_CON_TIMEOUT, ConfigParser.STORE_CON_TIMEOUT); 160 String STORE_TEST_INTERVAL = "store0.test.interval"; 161 oldToNew.put(STORE_TEST_INTERVAL, ConfigParser.STORE_TEST_INTERVAL); 162 String STORE_ISOLATION_LEVEL = "store0.isolation.level"; 163 oldToNew.put(STORE_ISOLATION_LEVEL, ConfigParser.STORE_ISOLATION_LEVEL); 164 String STORE_BLOCK_WHEN_FULL = "store0.block.when.full"; 165 oldToNew.put(STORE_BLOCK_WHEN_FULL, ConfigParser.STORE_BLOCK_WHEN_FULL); 166 String STORE_MAX_CON_AGE = "store0.max.con.age"; 167 oldToNew.put(STORE_MAX_CON_AGE, ConfigParser.STORE_MAX_CON_AGE); 168 String STORE_MANAGED_ONE_TO_MANY = "store0.managed.one.to.many"; 169 oldToNew.put(STORE_MANAGED_ONE_TO_MANY, 170 ConfigParser.STORE_MANAGED_ONE_TO_MANY); 171 String STORE_MANAGED_MANY_TO_MANY = "store0.managed.many.to.many"; 172 oldToNew.put(STORE_MANAGED_MANY_TO_MANY, 173 ConfigParser.STORE_MANAGED_MANY_TO_MANY); 174 String STORE_SCO_FACTORY_COUNT = "store0.sco.factory.count"; 175 oldToNew.put(STORE_SCO_FACTORY_COUNT, null); 176 String STORE_OID_BATCH_SIZE = "store0.OID.batch.size"; 177 oldToNew.put(STORE_OID_BATCH_SIZE, ConfigParser.VDS_OID_BATCH_SIZE); 178 String STORE_SCHEMA_DEFINITION = "store0.schema.define"; 179 oldToNew.put(STORE_SCHEMA_DEFINITION, 180 ConfigParser.VDS_SCHEMA_DEFINITION); 181 String STORE_SCHEMA_EVOLUTION = "store0.schema.evolve"; 182 oldToNew.put(STORE_SCHEMA_EVOLUTION, ConfigParser.VDS_SCHEMA_EVOLUTION); 183 184 String MDEDIT_SRC_PATH = "mdedit.srcPath"; 185 oldToNew.put(MDEDIT_SRC_PATH, ConfigParser.MDEDIT_SRC_PATH); 186 String MDEDIT_CP_COUNT = "mdedit.classPathCount"; 187 oldToNew.put(MDEDIT_CP_COUNT, null); 188 189 String JDO_FILE_COUNT = "jdoFileCount"; 190 oldToNew.put(JDO_FILE_COUNT, null); 191 192 String EVENT_LOGGING = "event.logging"; 193 oldToNew.put(EVENT_LOGGING, ConfigParser.EVENT_LOGGING); 194 195 String DATASTORE_TX_LOCKING = "datastore.tx.locking"; 196 oldToNew.put(DATASTORE_TX_LOCKING, ConfigParser.DATASTORE_TX_LOCKING); 197 198 String CACHE_ENABLED = "cache.enabled"; 199 oldToNew.put(CACHE_ENABLED, ConfigParser.CACHE_ENABLED); 200 String CACHE_MAX_OBJECTS = "cache.maxobjects"; 201 oldToNew.put(CACHE_MAX_OBJECTS, ConfigParser.CACHE_MAX_OBJECTS); 202 String CACHE_LISTENER = "cache.listener"; 203 oldToNew.put(CACHE_LISTENER, ConfigParser.CACHE_LISTENER); 204 String CACHE_CLUSTER_TRANSPORT = "cache.cluster.transport"; 205 oldToNew.put(CACHE_CLUSTER_TRANSPORT, 206 ConfigParser.CACHE_CLUSTER_TRANSPORT); 207 208 String QUERY_CACHE_ENABLED = "query.cache.enabled"; 209 oldToNew.put(QUERY_CACHE_ENABLED, ConfigParser.QUERY_CACHE_ENABLED); 210 String QUERY_CACHE_MAX_QUERIES = "query.cache.max.queries"; 211 oldToNew.put(QUERY_CACHE_MAX_QUERIES, 212 ConfigParser.QUERY_CACHE_MAX_QUERIES); 213 214 String ANT_DISABLED = "ant.disabled"; 215 oldToNew.put(ANT_DISABLED, ConfigParser.ANT_DISABLED); 216 String ANT_BUILDFILE = "ant.buildfile"; 217 oldToNew.put(ANT_BUILDFILE, ConfigParser.ANT_BUILDFILE); 218 String ANT_RUN_TARGET = "ant.run.target"; 219 oldToNew.put(ANT_RUN_TARGET, ConfigParser.ANT_RUN_TARGET); 220 String ANT_COMPILE = "ant.compile"; 221 oldToNew.put(ANT_COMPILE, ConfigParser.ANT_COMPILE); 222 String ANT_ARGS = "ant.args"; 223 oldToNew.put(ANT_ARGS, ConfigParser.ANT_ARGS); 224 String ANT_SHOW_ALL_TARGETS = "ant.show.all.targets"; 225 oldToNew.put(ANT_SHOW_ALL_TARGETS, ConfigParser.ANT_SHOW_ALL_TARGETS); 226 227 String SCRIPT_DIR = "script.dir"; 228 oldToNew.put(SCRIPT_DIR, ConfigParser.SCRIPT_DIR); 229 230 String METRIC_SNAPSHOT_INTERVAL_MS = "metric.snapshot.interval.ms"; 231 oldToNew.put(METRIC_SNAPSHOT_INTERVAL_MS, 232 ConfigParser.METRIC_SNAPSHOT_INTERVAL_MS); 233 String METRIC_STORE_CAPACITY = "metric.store.capacity"; 234 oldToNew.put(METRIC_STORE_CAPACITY, ConfigParser.METRIC_STORE_CAPACITY); 235 236 String LOG_DOWNLOADER = "log.downloader"; 237 oldToNew.put(LOG_DOWNLOADER, ConfigParser.LOG_DOWNLOADER); 238 239 String EXTERNALIZER_COUNT = "externalizer.count"; 240 oldToNew.put(EXTERNALIZER_COUNT, null); 241 242 String TESTING = "testing"; 243 oldToNew.put(TESTING, ConfigParser.TESTING); 244 245 } 246 247 248 public static void main(String [] args) { 249 String src = null; 250 String dest = null; 251 for (int i = 0; i < args.length; i++) { 252 if (i == 0) src = args[i]; 253 if (i == 1) dest = args[i]; 254 } 255 if (src == null) { 256 printHelp(); 257 } 258 File srcFile = new File(src); 259 if (!srcFile.exists()) { 260 System.out.println("Input file " + src + " does not exist."); 261 printHelp(); 262 System.exit(-1); 263 } 264 File destFile = null; 265 if (dest == null) { 266 int last = src.lastIndexOf('.'); 267 dest = src.substring(0, last) + ".properties"; 268 destFile = new File(dest); 269 if (destFile.exists()) { 270 System.out.println( 271 "File " + dest + " will be created by this tool,"); 272 System.out.println( 273 "but it already exists. (we do not want to overide existing files) "); 274 System.exit(-1); 275 276 } 277 } 278 if (dest != null) { 279 destFile = new File(dest); 280 if (!destFile.exists()) { 281 try { 282 destFile.createNewFile(); 283 } catch (IOException e) { 284 System.out.println("Could not create file " + dest); 285 System.exit(-1); 286 } 287 } 288 } 289 Properties p = new Properties(); 290 try { 291 InputStream in = null; 292 try { 293 in = new FileInputStream(src); 294 295 try { 296 p.load(in); 297 } catch (IOException e) { 298 e.printStackTrace(); 299 } 300 } finally { 301 if (in != null) in.close(); 302 } 303 } catch (IOException e) { 304 e.printStackTrace(); 305 } 306 307 try { 308 ArrayList lines = new ArrayList(); 309 BufferedReader reader = null; 310 BufferedWriter writer = null; 311 try { 312 reader = new BufferedReader(new FileReader(srcFile)); 313 String [] newLines = null; 314 while (true) { 316 String line = reader.readLine(); 317 if (line == null) { 318 break; 319 } 320 newLines = getConvertedLine(line); 321 for (int i = 0; i < newLines.length; i++) { 322 lines.add(newLines[i]); 323 } 324 } 325 } finally { 326 try { 327 reader.close(); 328 } catch (IOException ex) { 329 } 330 } 331 try { 332 writer = new BufferedWriter(new FileWriter(destFile, false)); 333 Iterator iter = lines.iterator(); 335 while (iter.hasNext()) { 336 writer.write((String )iter.next()); 337 writer.newLine(); 338 } 339 } finally { 340 try { 341 writer.close(); 342 } catch (IOException ex) { 343 } 345 } 346 } catch (IOException e) { 347 e.printStackTrace(); 348 } 349 } 350 351 352 private static String [] getConvertedLine(String line) { 353 if (line.trim().equals("")) { 354 return new String []{line}; 355 } else if (line.trim().startsWith("#")) { 356 return new String []{line}; 357 } else { 358 return getPropLines(line); 359 } 360 } 361 362 private static String [] getPropLines(String line) { 363 int first = line.indexOf('='); 364 Properties p = new Properties(); 365 p.setProperty(line.substring(0, first), 366 line.substring(first + 1, line.length())); 367 convert(p, true); 368 Set set = p.keySet(); 369 String [] props = new String [set.size()]; 370 StringBuffer newLine = null; 371 int i = 0; 372 for (Iterator iter = set.iterator(); iter.hasNext();) { 373 String s = (String )iter.next(); 374 newLine = new StringBuffer (); 375 newLine.append(s); 376 newLine.append("="); 377 newLine.append(p.getProperty(s)); 378 props[i++] = newLine.toString(); 379 } 380 return props; 381 } 382 383 private static void printHelp() { 384 System.out.println( 385 "usage: com.versant.core.common.config.PropertyConverter <inputFile> [<outputFile>]"); 386 System.out.println( 387 " <inputFile> The old *.jdogenie file to be converted."); 388 System.out.println( 389 " If output file is not specified then the output"); 390 System.out.println( 391 " file will be <inputFile>.properties"); 392 System.out.println(" <outputFile> The new file .properties file."); 393 System.exit(-1); 394 } 395 396 402 public static boolean convert(Properties original) { 403 return convert(original, false); 404 } 405 406 412 private static boolean convert(Properties original, boolean converted) { 413 Properties oldProps = (Properties)original.clone(); 414 Properties newProps = new Properties(); 415 ArrayList list = new ArrayList(oldProps.keySet()); 416 Collections.sort(list); 417 for (Iterator iter = list.iterator(); iter.hasNext();) { 418 String key = (String )iter.next(); 419 if (oldToNew.containsKey(key)) { 420 if (oldToNew.get(key) != null) { 421 newProps.setProperty((String )oldToNew.get(key), 422 oldProps.getProperty(key)); 423 } 424 converted = true; 426 } else { 427 String STORE_EXT = "store0.ext."; 428 String STORE_TYPE_MAPPING = "store0.jdbc.type."; 429 String STORE_JAVATYPE_MAPPING = "store0.jdbc.javatype."; 430 String STORE_SCO_FACTORY_MAPPING = "store0.sco.factory.mapping"; 431 String JDO = "jdo"; 432 String METRIC_USER = "metric.user."; 433 String EXTERNALIZER = "externalizer."; 434 String DIAGRAM = "diagram"; 435 String MDEDIT_CP = "mdedit.cp"; 436 if (key.startsWith(STORE_EXT)) { 437 String newKey = ConfigParser.STORE_EXT + 438 key.substring(STORE_EXT.length(), key.length()); 439 newProps.setProperty(newKey, oldProps.getProperty(key)); 440 converted = true; 441 } else if (key.startsWith(STORE_TYPE_MAPPING)) { 442 String newKey = ConfigParser.STORE_TYPE_MAPPING + 443 key.substring(STORE_TYPE_MAPPING.length(), 444 key.length()); 445 newProps.setProperty(newKey, oldProps.getProperty(key)); 446 converted = true; 447 } else if (key.startsWith(STORE_JAVATYPE_MAPPING)) { 448 String newKey = ConfigParser.STORE_JAVATYPE_MAPPING + 449 key.substring(STORE_JAVATYPE_MAPPING.length(), 450 key.length()); 451 newProps.setProperty(newKey, oldProps.getProperty(key)); 452 converted = true; 453 } else if (key.startsWith(STORE_SCO_FACTORY_MAPPING)) { 454 String newKey = ConfigParser.STORE_SCO_FACTORY_MAPPING + 455 key.substring(STORE_SCO_FACTORY_MAPPING.length(), 456 key.length()); 457 newProps.setProperty(newKey, oldProps.getProperty(key)); 458 } else if (key.startsWith(JDO)) { 459 String newKey = ConfigParser.JDO + 460 key.substring(JDO.length(), 461 key.length()); 462 newProps.setProperty(newKey, oldProps.getProperty(key)); 463 converted = true; 464 } else if (key.startsWith(METRIC_USER)) { 465 String newKey = ConfigParser.METRIC_USER + 466 key.substring(METRIC_USER.length(), 467 key.length()); 468 newProps.setProperty(newKey, oldProps.getProperty(key)); 469 converted = true; 470 } else if (key.startsWith(EXTERNALIZER)) { 471 String newKey = ConfigParser.EXTERNALIZER + 472 key.substring(EXTERNALIZER.length(), 473 key.length()); 474 newProps.setProperty(newKey, oldProps.getProperty(key)); 475 converted = true; 476 } else if (key.startsWith(DIAGRAM)) { 477 String newKey = ConfigParser.DIAGRAM + 478 key.substring(DIAGRAM.length(), 479 key.length()); 480 newProps.setProperty(newKey, oldProps.getProperty(key)); 481 converted = true; 482 } else if (key.startsWith(MDEDIT_CP)) { 483 String newKey = ConfigParser.MDEDIT_CP + 484 key.substring(MDEDIT_CP.length(), 485 key.length()); 486 newProps.setProperty(newKey, oldProps.getProperty(key)); 487 converted = true; 488 } else { 489 490 newProps.put(key, oldProps.get(key)); 491 } 493 } 494 } 495 if (converted) { 496 fillAsProps(newProps, ConfigParser.EVENT_LOGGING); fillAsProps(newProps, ConfigParser.RMI_CLIENT_SF); fillAsProps(newProps, ConfigParser.RMI_SERVER_SF); fillAsProps(newProps, ConfigParser.CACHE_CLUSTER_TRANSPORT); fillAsProps(newProps, ConfigParser.CACHE_LISTENER); 501 fillAsProps(newProps, ConfigParser.STORE_NAMEGEN); fillAsProps(newProps, ConfigParser.STORE_MIGRATION_CONTROLS); fillAsProps(newProps, 504 ConfigParser.STORE_EXT + 505 JdoExtension.toKeyString( 506 JdoExtensionKeys.JDBC_KEY_GENERATOR)); fillAsProps(newProps, ConfigParser.LOG_DOWNLOADER); fillExternalizer(newProps); 509 } 510 511 original.clear(); 512 original.putAll(newProps); 513 if ("za.co.hemtech.jdo.client.BootstrapPMF".equals(original.getProperty( 514 ConfigParser.PMF_CLASS))) { 515 original.setProperty(ConfigParser.PMF_CLASS, 516 "com.versant.core.jdo.BootstrapPMF"); 517 } 518 return converted; 519 } 520 521 526 private static void fillAsProps(Properties newProps, String lookup) { 527 String s = newProps.getProperty(lookup); 528 if (s != null) { 529 HashMap logging = new HashMap(17); 530 StringListParser lp = new StringListParser(s); 531 String name = null; try { 533 name = lp.nextQuotedString(); } catch (IllegalStateException e) { 535 return; 536 } 537 lp.nextProperties(logging); 538 Set names = logging.keySet(); 539 for (Iterator iter = names.iterator(); iter.hasNext();) { 540 String key = (String )iter.next(); 541 newProps.setProperty(lookup + "." + key, 542 (String )logging.get(key)); 543 } 544 newProps.remove(lookup); 545 if (name != null) { 546 newProps.setProperty(lookup, name); 547 } 548 } 549 } 550 551 556 private static void fillExternalizer(Properties newProps) { 557 String s; 558 for (int i = 0; i < ConfigParser.MAX_EXTERNALIZER_COUNT; i++) { 559 String key = ConfigParser.EXTERNALIZER + i; 560 s = newProps.getProperty(key); 561 if (s != null) { 562 StringListParser lp = new StringListParser(s); 563 Object o = newProps.setProperty(key + ConfigParser.EXTERNALIZER_TYPE, 564 lp.nextString()); 565 if (o != null) { 566 newProps.setProperty(key + ConfigParser.EXTERNALIZER_TYPE, 567 (String )o); 568 continue; 569 } 570 boolean enabled = lp.nextBoolean(); 571 newProps.setProperty(key + ConfigParser.EXTERNALIZER_ENABLED, 572 (enabled ? "true" : "false")); 573 String externalizerName = lp.nextQuotedString(); 574 if (externalizerName != null) { 575 newProps.setProperty(key + ConfigParser.EXTERNALIZER_CLASS, 576 externalizerName); 577 } 578 579 HashMap typeKeys = new HashMap(17); 580 lp.nextProperties(typeKeys); 581 Set names = typeKeys.keySet(); 582 for (Iterator iter = names.iterator(); iter.hasNext();) { 583 String typeKey = (String )iter.next(); 584 newProps.setProperty(key + 585 ConfigParser.EXTERNALIZER_CLASS + "." + typeKey, 586 (String )typeKeys.get(typeKey)); 587 } 588 newProps.remove(key); 589 } 590 } 591 } 592 593 } 594 595 | Popular Tags |