1 22 23 24 package com.mchange.v2.c3p0; 25 26 import java.util.Properties ; 27 import java.io.InputStream ; 28 import java.io.IOException ; 29 import com.mchange.v1.io.InputStreamUtils; 30 import com.mchange.v2.c3p0.impl.C3P0Defaults; 31 import com.mchange.v2.cfg.MultiPropertiesConfig; 32 import com.mchange.v2.log.MLevel; 33 import com.mchange.v2.log.MLog; 34 import com.mchange.v2.log.MLogger; 35 36 60 public final class PoolConfig 61 { 62 final static MLogger logger; 63 64 public final static String INITIAL_POOL_SIZE = "c3p0.initialPoolSize"; 65 public final static String MIN_POOL_SIZE = "c3p0.minPoolSize"; 66 public final static String MAX_POOL_SIZE = "c3p0.maxPoolSize"; 67 public final static String IDLE_CONNECTION_TEST_PERIOD = "c3p0.idleConnectionTestPeriod"; 68 public final static String MAX_IDLE_TIME = "c3p0.maxIdleTime"; 69 public final static String PROPERTY_CYCLE = "c3p0.propertyCycle"; 70 public final static String MAX_STATEMENTS = "c3p0.maxStatements"; 71 public final static String MAX_STATEMENTS_PER_CONNECTION = "c3p0.maxStatementsPerConnection"; 72 public final static String CHECKOUT_TIMEOUT = "c3p0.checkoutTimeout"; 73 public final static String ACQUIRE_INCREMENT = "c3p0.acquireIncrement"; 74 public final static String ACQUIRE_RETRY_ATTEMPTS = "c3p0.acquireRetryAttempts"; 75 public final static String ACQUIRE_RETRY_DELAY = "c3p0.acquireRetryDelay"; 76 public final static String BREAK_AFTER_ACQUIRE_FAILURE = "c3p0.breakAfterAcquireFailure"; 77 public final static String USES_TRADITIONAL_REFLECTIVE_PROXIES = "c3p0.usesTraditionalReflectiveProxies"; 78 public final static String TEST_CONNECTION_ON_CHECKOUT = "c3p0.testConnectionOnCheckout"; 79 public final static String TEST_CONNECTION_ON_CHECKIN = "c3p0.testConnectionOnCheckin"; 80 public final static String CONNECTION_TESTER_CLASS_NAME = "c3p0.connectionTesterClassName"; 81 public final static String AUTOMATIC_TEST_TABLE = "c3p0.automaticTestTable"; 82 public final static String AUTO_COMMIT_ON_CLOSE = "c3p0.autoCommitOnClose"; 83 public final static String FORCE_IGNORE_UNRESOLVED_TRANSACTIONS = "c3p0.forceIgnoreUnresolvedTransactions"; 84 public final static String NUM_HELPER_THREADS = "c3p0.numHelperThreads"; 85 public final static String PREFERRED_TEST_QUERY = "c3p0.preferredTestQuery"; 86 public final static String FACTORY_CLASS_LOCATION = "c3p0.factoryClassLocation"; 87 88 public final static String DEFAULT_CONFIG_RSRC_PATH = "/c3p0.properties"; 89 90 final static PoolConfig DEFAULTS; 91 92 static 93 { 94 logger = MLog.getLogger( PoolConfig.class ); 95 96 Properties rsrcProps = findResourceProperties(); 97 PoolConfig rsrcDefaults = extractConfig( rsrcProps, null ); 98 99 Properties sysProps; 100 try 101 { sysProps = System.getProperties(); } 102 catch ( SecurityException e ) 103 { 104 if (logger.isLoggable(MLevel.WARNING)) 105 logger.log(MLevel.WARNING, 106 "Read of system Properties blocked -- ignoring any c3p0 configuration via System properties! " + 107 "(But any configuration via a c3p0.properties file is still okay!)", 108 e); 109 sysProps = new Properties (); } 111 DEFAULTS = extractConfig( sysProps, rsrcDefaults ); 112 } 113 114 public static int defaultNumHelperThreads() 115 { return DEFAULTS.getNumHelperThreads(); } 116 117 public static String defaultPreferredTestQuery() 118 { return DEFAULTS.getPreferredTestQuery(); } 119 120 public static String defaultFactoryClassLocation() 121 { return DEFAULTS.getFactoryClassLocation(); } 122 123 public static int defaultMaxStatements() 124 { return DEFAULTS.getMaxStatements(); } 125 126 public static int defaultMaxStatementsPerConnection() 127 { return DEFAULTS.getMaxStatementsPerConnection(); } 128 129 public static int defaultInitialPoolSize() 130 { return DEFAULTS.getInitialPoolSize(); } 131 132 public static int defaultMinPoolSize() 133 { return DEFAULTS.getMinPoolSize(); } 134 135 public static int defaultMaxPoolSize() 136 { return DEFAULTS.getMaxPoolSize(); } 137 138 public static int defaultIdleConnectionTestPeriod() 139 { return DEFAULTS.getIdleConnectionTestPeriod(); } 140 141 public static int defaultMaxIdleTime() 142 { return DEFAULTS.getMaxIdleTime(); } 143 144 public static int defaultPropertyCycle() 145 { return DEFAULTS.getPropertyCycle(); } 146 147 public static int defaultCheckoutTimeout() 148 { return DEFAULTS.getCheckoutTimeout(); } 149 150 public static int defaultAcquireIncrement() 151 { return DEFAULTS.getAcquireIncrement(); } 152 153 public static int defaultAcquireRetryAttempts() 154 { return DEFAULTS.getAcquireRetryAttempts(); } 155 156 public static int defaultAcquireRetryDelay() 157 { return DEFAULTS.getAcquireRetryDelay(); } 158 159 public static boolean defaultBreakAfterAcquireFailure() 160 { return DEFAULTS.isBreakAfterAcquireFailure(); } 161 162 public static String defaultConnectionTesterClassName() 163 { return DEFAULTS.getConnectionTesterClassName(); } 164 165 public static String defaultAutomaticTestTable() 166 { return DEFAULTS.getAutomaticTestTable(); } 167 168 public static boolean defaultTestConnectionOnCheckout() 169 { return DEFAULTS.isTestConnectionOnCheckout(); } 170 171 public static boolean defaultTestConnectionOnCheckin() 172 { return DEFAULTS.isTestConnectionOnCheckin(); } 173 174 public static boolean defaultAutoCommitOnClose() 175 { return DEFAULTS.isAutoCommitOnClose(); } 176 177 public static boolean defaultForceIgnoreUnresolvedTransactions() 178 { return DEFAULTS.isAutoCommitOnClose(); } 179 180 public static boolean defaultUsesTraditionalReflectiveProxies() 181 { return DEFAULTS.isUsesTraditionalReflectiveProxies(); } 182 183 184 int maxStatements; 185 int maxStatementsPerConnection; 186 int initialPoolSize; 187 int minPoolSize; 188 int maxPoolSize; 189 int idleConnectionTestPeriod; 190 int maxIdleTime; 191 int propertyCycle; 192 int checkoutTimeout; 193 int acquireIncrement; 194 int acquireRetryAttempts; 195 int acquireRetryDelay; 196 boolean breakAfterAcquireFailure; 197 boolean testConnectionOnCheckout; 198 boolean testConnectionOnCheckin; 199 boolean autoCommitOnClose; 200 boolean forceIgnoreUnresolvedTransactions; 201 boolean usesTraditionalReflectiveProxies; 202 String connectionTesterClassName; 203 String automaticTestTable; 204 int numHelperThreads; 205 String preferredTestQuery; 206 String factoryClassLocation; 207 208 private PoolConfig( Properties props, boolean init ) throws NumberFormatException 209 { 210 if (init) 211 extractConfig( this, props, DEFAULTS ); 212 } 213 214 public PoolConfig( Properties props ) throws NumberFormatException 215 { this( props, true ); } 216 217 public PoolConfig() throws NumberFormatException 218 { this( null, true ); } 219 220 public int getNumHelperThreads() 221 { return numHelperThreads; } 222 223 public String getPreferredTestQuery() 224 { return preferredTestQuery; } 225 226 public String getFactoryClassLocation() 227 { return factoryClassLocation; } 228 229 public int getMaxStatements() 230 { return maxStatements; } 231 232 public int getMaxStatementsPerConnection() 233 { return maxStatementsPerConnection; } 234 235 public int getInitialPoolSize() 236 { return initialPoolSize; } 237 238 public int getMinPoolSize() 239 { return minPoolSize; } 240 241 public int getMaxPoolSize() 242 { return maxPoolSize; } 243 244 public int getIdleConnectionTestPeriod() 245 { return idleConnectionTestPeriod; } 246 247 public int getMaxIdleTime() 248 { return maxIdleTime; } 249 250 public int getPropertyCycle() 251 { return propertyCycle; } 252 253 public int getAcquireIncrement() 254 { return acquireIncrement; } 255 256 public int getCheckoutTimeout() 257 { return checkoutTimeout; } 258 259 public int getAcquireRetryAttempts() 260 { return acquireRetryAttempts; } 261 262 public int getAcquireRetryDelay() 263 { return acquireRetryDelay; } 264 265 public boolean isBreakAfterAcquireFailure() 266 { return this.breakAfterAcquireFailure; } 267 268 public boolean isUsesTraditionalReflectiveProxies() 269 { return this.usesTraditionalReflectiveProxies; } 270 271 public String getConnectionTesterClassName() 272 { return connectionTesterClassName; } 273 274 public String getAutomaticTestTable() 275 { return automaticTestTable; } 276 277 280 public boolean getTestConnectionOnCheckout() 281 { return testConnectionOnCheckout; } 282 283 public boolean isTestConnectionOnCheckout() 284 { return this.getTestConnectionOnCheckout(); } 285 286 public boolean isTestConnectionOnCheckin() 287 { return testConnectionOnCheckin; } 288 289 public boolean isAutoCommitOnClose() 290 { return this.autoCommitOnClose; } 291 292 public boolean isForceIgnoreUnresolvedTransactions() 293 { return this.forceIgnoreUnresolvedTransactions; } 294 295 public void setNumHelperThreads( int numHelperThreads ) 296 { this.numHelperThreads = numHelperThreads; } 297 298 public void setPreferredTestQuery( String preferredTestQuery ) 299 { this.preferredTestQuery = preferredTestQuery; } 300 301 public void setFactoryClassLocation( String factoryClassLocation ) 302 { this.factoryClassLocation = factoryClassLocation; } 303 304 public void setMaxStatements( int maxStatements ) 305 { this.maxStatements = maxStatements; } 306 307 public void setMaxStatementsPerConnection( int maxStatementsPerConnection ) 308 { this.maxStatementsPerConnection = maxStatementsPerConnection; } 309 310 public void setInitialPoolSize( int initialPoolSize ) 311 { this.initialPoolSize = initialPoolSize; } 312 313 public void setMinPoolSize( int minPoolSize ) 314 { this.minPoolSize = minPoolSize; } 315 316 public void setMaxPoolSize( int maxPoolSize ) 317 { this.maxPoolSize = maxPoolSize; } 318 319 public void setIdleConnectionTestPeriod( int idleConnectionTestPeriod ) 320 { this.idleConnectionTestPeriod = idleConnectionTestPeriod; } 321 322 public void setMaxIdleTime( int maxIdleTime ) 323 { this.maxIdleTime = maxIdleTime; } 324 325 public void setPropertyCycle( int propertyCycle ) 326 { this.propertyCycle = propertyCycle; } 327 328 public void setCheckoutTimeout( int checkoutTimeout ) 329 { this.checkoutTimeout = checkoutTimeout; } 330 331 public void setAcquireIncrement( int acquireIncrement ) 332 { this.acquireIncrement = acquireIncrement; } 333 334 public void setAcquireRetryAttempts( int acquireRetryAttempts ) 335 { this.acquireRetryAttempts = acquireRetryAttempts; } 336 337 public void setAcquireRetryDelay( int acquireRetryDelay ) 338 { this.acquireRetryDelay = acquireRetryDelay; } 339 340 public void setConnectionTesterClassName( String connectionTesterClassName ) 341 { this.connectionTesterClassName = connectionTesterClassName; } 342 343 public void setAutomaticTestTable( String automaticTestTable ) 344 { this.automaticTestTable = automaticTestTable; } 345 346 public void setBreakAfterAcquireFailure( boolean breakAfterAcquireFailure ) 347 { this.breakAfterAcquireFailure = breakAfterAcquireFailure; } 348 349 public void setUsesTraditionalReflectiveProxies( boolean usesTraditionalReflectiveProxies ) 350 { this.usesTraditionalReflectiveProxies = usesTraditionalReflectiveProxies; } 351 352 public void setTestConnectionOnCheckout( boolean testConnectionOnCheckout ) 353 { this.testConnectionOnCheckout = testConnectionOnCheckout; } 354 355 public void setTestConnectionOnCheckin( boolean testConnectionOnCheckin ) 356 { this.testConnectionOnCheckin = testConnectionOnCheckin; } 357 358 public void setAutoCommitOnClose( boolean autoCommitOnClose ) 359 { this.autoCommitOnClose = autoCommitOnClose; } 360 361 public void setForceIgnoreUnresolvedTransactions( boolean forceIgnoreUnresolvedTransactions ) 362 { this.forceIgnoreUnresolvedTransactions = forceIgnoreUnresolvedTransactions; } 363 364 private static PoolConfig extractConfig(Properties props, PoolConfig defaults) throws NumberFormatException 365 { 366 PoolConfig pcfg = new PoolConfig(null, false); 367 extractConfig( pcfg, props, defaults ); 368 return pcfg; 369 } 370 371 private static void extractConfig(PoolConfig pcfg, Properties props, PoolConfig defaults) throws NumberFormatException 372 { 373 String maxStatementsStr = null; 374 String maxStatementsPerConnectionStr = null; 375 String initialPoolSizeStr = null; 376 String minPoolSizeStr = null; 377 String maxPoolSizeStr = null; 378 String idleConnectionTestPeriodStr = null; 379 String maxIdleTimeStr = null; 380 String propertyCycleStr = null; 381 String checkoutTimeoutStr = null; 382 String acquireIncrementStr = null; 383 String acquireRetryAttemptsStr = null; 384 String acquireRetryDelayStr = null; 385 String breakAfterAcquireFailureStr = null; 386 String usesTraditionalReflectiveProxiesStr = null; 387 String testConnectionOnCheckoutStr = null; 388 String testConnectionOnCheckinStr = null; 389 String autoCommitOnCloseStr = null; 390 String forceIgnoreUnresolvedTransactionsStr = null; 391 String connectionTesterClassName = null; 392 String automaticTestTable = null; 393 String numHelperThreadsStr = null; 394 String preferredTestQuery = null; 395 String factoryClassLocation = null; 396 397 if ( props != null ) 398 { 399 maxStatementsStr = props.getProperty(MAX_STATEMENTS); 400 maxStatementsPerConnectionStr = props.getProperty(MAX_STATEMENTS_PER_CONNECTION); 401 initialPoolSizeStr = props.getProperty(INITIAL_POOL_SIZE); 402 minPoolSizeStr = props.getProperty(MIN_POOL_SIZE); 403 maxPoolSizeStr = props.getProperty(MAX_POOL_SIZE); 404 idleConnectionTestPeriodStr = props.getProperty(IDLE_CONNECTION_TEST_PERIOD); 405 maxIdleTimeStr = props.getProperty(MAX_IDLE_TIME); 406 propertyCycleStr = props.getProperty(PROPERTY_CYCLE); 407 checkoutTimeoutStr = props.getProperty(CHECKOUT_TIMEOUT); 408 acquireIncrementStr = props.getProperty(ACQUIRE_INCREMENT); 409 acquireRetryAttemptsStr = props.getProperty(ACQUIRE_RETRY_ATTEMPTS); 410 acquireRetryDelayStr = props.getProperty(ACQUIRE_RETRY_DELAY); 411 breakAfterAcquireFailureStr = props.getProperty(BREAK_AFTER_ACQUIRE_FAILURE); 412 usesTraditionalReflectiveProxiesStr = props.getProperty(USES_TRADITIONAL_REFLECTIVE_PROXIES); 413 testConnectionOnCheckoutStr = props.getProperty(TEST_CONNECTION_ON_CHECKOUT); 414 testConnectionOnCheckinStr = props.getProperty(TEST_CONNECTION_ON_CHECKIN); 415 autoCommitOnCloseStr = props.getProperty(AUTO_COMMIT_ON_CLOSE); 416 forceIgnoreUnresolvedTransactionsStr = props.getProperty(FORCE_IGNORE_UNRESOLVED_TRANSACTIONS); 417 connectionTesterClassName = props.getProperty(CONNECTION_TESTER_CLASS_NAME); 418 automaticTestTable = props.getProperty(AUTOMATIC_TEST_TABLE); 419 numHelperThreadsStr = props.getProperty(NUM_HELPER_THREADS); 420 preferredTestQuery = props.getProperty(PREFERRED_TEST_QUERY); 421 factoryClassLocation = props.getProperty(FACTORY_CLASS_LOCATION); 422 } 423 424 if ( maxStatementsStr != null ) 426 pcfg.setMaxStatements( Integer.parseInt( maxStatementsStr.trim() ) ); 427 else if (defaults != null) 428 pcfg.setMaxStatements( defaults.getMaxStatements() ); 429 else 430 pcfg.setMaxStatements( C3P0Defaults.maxStatements() ); 431 432 if ( maxStatementsPerConnectionStr != null ) 434 pcfg.setMaxStatementsPerConnection( Integer.parseInt( maxStatementsPerConnectionStr.trim() ) ); 435 else if (defaults != null) 436 pcfg.setMaxStatementsPerConnection( defaults.getMaxStatementsPerConnection() ); 437 else 438 pcfg.setMaxStatementsPerConnection( C3P0Defaults.maxStatementsPerConnection() ); 439 440 if ( initialPoolSizeStr != null ) 442 pcfg.setInitialPoolSize( Integer.parseInt( initialPoolSizeStr.trim() ) ); 443 else if (defaults != null) 444 pcfg.setInitialPoolSize( defaults.getInitialPoolSize() ); 445 else 446 pcfg.setInitialPoolSize( C3P0Defaults.initialPoolSize() ); 447 448 if ( minPoolSizeStr != null ) 450 pcfg.setMinPoolSize( Integer.parseInt( minPoolSizeStr.trim() ) ); 451 else if (defaults != null) 452 pcfg.setMinPoolSize( defaults.getMinPoolSize() ); 453 else 454 pcfg.setMinPoolSize( C3P0Defaults.minPoolSize() ); 455 456 if ( maxPoolSizeStr != null ) 458 pcfg.setMaxPoolSize( Integer.parseInt( maxPoolSizeStr.trim() ) ); 459 else if (defaults != null) 460 pcfg.setMaxPoolSize( defaults.getMaxPoolSize() ); 461 else 462 pcfg.setMaxPoolSize( C3P0Defaults.maxPoolSize() ); 463 464 if ( idleConnectionTestPeriodStr != null ) 466 pcfg.setIdleConnectionTestPeriod( Integer.parseInt( idleConnectionTestPeriodStr.trim() ) ); 467 else if (defaults != null) 468 pcfg.setIdleConnectionTestPeriod( defaults.getIdleConnectionTestPeriod() ); 469 else 470 pcfg.setIdleConnectionTestPeriod( C3P0Defaults.idleConnectionTestPeriod() ); 471 472 if ( maxIdleTimeStr != null ) 474 pcfg.setMaxIdleTime( Integer.parseInt( maxIdleTimeStr.trim() ) ); 475 else if (defaults != null) 476 pcfg.setMaxIdleTime( defaults.getMaxIdleTime() ); 477 else 478 pcfg.setMaxIdleTime( C3P0Defaults.maxIdleTime() ); 479 480 if ( propertyCycleStr != null ) 482 pcfg.setPropertyCycle( Integer.parseInt( propertyCycleStr.trim() ) ); 483 else if (defaults != null) 484 pcfg.setPropertyCycle( defaults.getPropertyCycle() ); 485 else 486 pcfg.setPropertyCycle( C3P0Defaults.propertyCycle() ); 487 488 if ( checkoutTimeoutStr != null ) 490 pcfg.setCheckoutTimeout( Integer.parseInt( checkoutTimeoutStr.trim() ) ); 491 else if (defaults != null) 492 pcfg.setCheckoutTimeout( defaults.getCheckoutTimeout() ); 493 else 494 pcfg.setCheckoutTimeout( C3P0Defaults.checkoutTimeout() ); 495 496 if ( acquireIncrementStr != null ) 498 pcfg.setAcquireIncrement( Integer.parseInt( acquireIncrementStr.trim() ) ); 499 else if (defaults != null) 500 pcfg.setAcquireIncrement( defaults.getAcquireIncrement() ); 501 else 502 pcfg.setAcquireIncrement( C3P0Defaults.acquireIncrement() ); 503 504 if ( acquireRetryAttemptsStr != null ) 506 pcfg.setAcquireRetryAttempts( Integer.parseInt( acquireRetryAttemptsStr.trim() ) ); 507 else if (defaults != null) 508 pcfg.setAcquireRetryAttempts( defaults.getAcquireRetryAttempts() ); 509 else 510 pcfg.setAcquireRetryAttempts( C3P0Defaults.acquireRetryAttempts() ); 511 512 if ( acquireRetryDelayStr != null ) 514 pcfg.setAcquireRetryDelay( Integer.parseInt( acquireRetryDelayStr.trim() ) ); 515 else if (defaults != null) 516 pcfg.setAcquireRetryDelay( defaults.getAcquireRetryDelay() ); 517 else 518 pcfg.setAcquireRetryDelay( C3P0Defaults.acquireRetryDelay() ); 519 520 if ( breakAfterAcquireFailureStr != null ) 522 pcfg.setBreakAfterAcquireFailure( Boolean.valueOf(breakAfterAcquireFailureStr.trim()).booleanValue() ); 523 else if (defaults != null) 524 pcfg.setBreakAfterAcquireFailure( defaults.isBreakAfterAcquireFailure() ); 525 else 526 pcfg.setBreakAfterAcquireFailure( C3P0Defaults.breakAfterAcquireFailure() ); 527 528 if ( usesTraditionalReflectiveProxiesStr != null ) 530 pcfg.setUsesTraditionalReflectiveProxies( Boolean.valueOf(usesTraditionalReflectiveProxiesStr.trim()).booleanValue() ); 531 else if (defaults != null) 532 pcfg.setUsesTraditionalReflectiveProxies( defaults.isUsesTraditionalReflectiveProxies() ); 533 else 534 pcfg.setUsesTraditionalReflectiveProxies( C3P0Defaults.usesTraditionalReflectiveProxies() ); 535 536 if ( testConnectionOnCheckoutStr != null ) 538 pcfg.setTestConnectionOnCheckout( Boolean.valueOf(testConnectionOnCheckoutStr.trim()).booleanValue() ); 539 else if (defaults != null) 540 pcfg.setTestConnectionOnCheckout( defaults.isTestConnectionOnCheckout() ); 541 else 542 pcfg.setTestConnectionOnCheckout( C3P0Defaults.testConnectionOnCheckout() ); 543 544 if ( testConnectionOnCheckinStr != null ) 546 pcfg.setTestConnectionOnCheckin( Boolean.valueOf(testConnectionOnCheckinStr.trim()).booleanValue() ); 547 else if (defaults != null) 548 pcfg.setTestConnectionOnCheckin( defaults.isTestConnectionOnCheckin() ); 549 else 550 pcfg.setTestConnectionOnCheckin( C3P0Defaults.testConnectionOnCheckin() ); 551 552 if ( autoCommitOnCloseStr != null ) 554 pcfg.setAutoCommitOnClose( Boolean.valueOf(autoCommitOnCloseStr.trim()).booleanValue() ); 555 else if (defaults != null) 556 pcfg.setAutoCommitOnClose( defaults.isAutoCommitOnClose() ); 557 else 558 pcfg.setAutoCommitOnClose( C3P0Defaults.autoCommitOnClose() ); 559 560 if ( forceIgnoreUnresolvedTransactionsStr != null ) 562 pcfg.setForceIgnoreUnresolvedTransactions( Boolean.valueOf( forceIgnoreUnresolvedTransactionsStr.trim() ).booleanValue() ); 563 else if (defaults != null) 564 pcfg.setForceIgnoreUnresolvedTransactions( defaults.isForceIgnoreUnresolvedTransactions() ); 565 else 566 pcfg.setForceIgnoreUnresolvedTransactions( C3P0Defaults.forceIgnoreUnresolvedTransactions() ); 567 568 if ( connectionTesterClassName != null ) 570 pcfg.setConnectionTesterClassName( connectionTesterClassName.trim() ); 571 else if (defaults != null) 572 pcfg.setConnectionTesterClassName( defaults.getConnectionTesterClassName() ); 573 else 574 pcfg.setConnectionTesterClassName( C3P0Defaults.connectionTesterClassName() ); 575 576 if ( automaticTestTable != null ) 578 pcfg.setAutomaticTestTable( automaticTestTable.trim() ); 579 else if (defaults != null) 580 pcfg.setAutomaticTestTable( defaults.getAutomaticTestTable() ); 581 else 582 pcfg.setAutomaticTestTable( C3P0Defaults.automaticTestTable() ); 583 584 if ( numHelperThreadsStr != null ) 586 pcfg.setNumHelperThreads( Integer.parseInt( numHelperThreadsStr.trim() ) ); 587 else if (defaults != null) 588 pcfg.setNumHelperThreads( defaults.getNumHelperThreads() ); 589 else 590 pcfg.setNumHelperThreads( C3P0Defaults.numHelperThreads() ); 591 592 if ( preferredTestQuery != null ) 594 pcfg.setPreferredTestQuery( preferredTestQuery.trim() ); 595 else if (defaults != null) 596 pcfg.setPreferredTestQuery( defaults.getPreferredTestQuery() ); 597 else 598 pcfg.setPreferredTestQuery( C3P0Defaults.preferredTestQuery() ); 599 600 if ( factoryClassLocation != null ) 602 pcfg.setFactoryClassLocation( factoryClassLocation.trim() ); 603 else if (defaults != null) 604 pcfg.setFactoryClassLocation( defaults.getFactoryClassLocation() ); 605 else 606 pcfg.setFactoryClassLocation( C3P0Defaults.factoryClassLocation() ); 607 } 608 609 private static Properties findResourceProperties() 610 { return MultiPropertiesConfig.readVmConfig().getPropertiesByResourcePath(DEFAULT_CONFIG_RSRC_PATH); } 611 612 private static Properties origFindResourceProperties() 613 { 614 Properties props = new Properties (); 615 616 InputStream is = null; 617 try 618 { 619 is = PoolConfig.class.getResourceAsStream(DEFAULT_CONFIG_RSRC_PATH); 620 if ( is != null ) 621 props.load( is ); 622 } 623 catch (IOException e) 624 { 625 if ( logger.isLoggable( MLevel.WARNING ) ) 627 logger.log( MLevel.WARNING, "An IOException occurred while trying to read Pool properties!", e ); 628 props = new Properties (); 629 } 630 finally 631 { InputStreamUtils.attemptClose( is ); } 632 633 return props; 634 } 635 } 636 | Popular Tags |