1 6 package org.logicalcobwebs.proxool; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 11 import java.sql.Driver ; 12 import java.sql.DriverManager ; 13 import java.sql.SQLException ; 14 import java.util.HashSet ; 15 import java.util.Iterator ; 16 import java.util.Properties ; 17 import java.util.Set ; 18 import java.util.StringTokenizer ; 19 import java.lang.reflect.Modifier ; 20 21 28 class ConnectionPoolDefinition implements ConnectionPoolDefinitionIF { 29 30 32 private static final Log LOG = LogFactory.getLog(ConnectionPoolDefinition.class); 33 34 37 private Log poolLog = LOG;; 38 39 private String alias; 40 41 43 private String jndiName; 44 45 private String initialContextFactory; 46 47 private String providerUrl; 48 49 private String securityAuthentication; 50 51 private String securityPrincipal; 52 53 private String securityCredentials; 54 55 private Properties delegateProperties = new Properties (); 56 57 private Properties completeInfo = new Properties (); 58 59 private Properties changedInfo = new Properties (); 60 61 66 private boolean connectionPropertiesChanged; 67 68 private String url; 69 70 private String completeUrl; 71 72 private String driver; 73 74 private int maximumConnectionLifetime;; 75 76 private int prototypeCount; 77 78 private int minimumConnectionCount; 79 80 private int maximumConnectionCount; 81 82 private int houseKeepingSleepTime; 83 84 private int simultaneousBuildThrottle; 85 86 private int recentlyStartedThreshold; 87 88 private int overloadWithoutRefusalLifetime; 89 90 private int maximumActiveTime; 91 92 private boolean verbose; 93 94 private boolean trace; 95 96 private String statistics; 97 98 private String statisticsLogLevel; 99 100 private Set fatalSqlExceptions = new HashSet (); 101 102 106 private String fatalSqlExceptionsAsString; 107 108 private String fatalSqlExceptionWrapper = null; 109 110 private String houseKeepingTestSql; 111 112 private boolean testBeforeUse; 113 114 private boolean testAfterUse; 115 116 private boolean jmx; 117 118 private String jmxAgentId; 119 120 private Class injectableConnectionInterface; 121 122 private Class injectableStatementInterface; 123 124 private Class injectablePreparedStatementInterface; 125 126 private Class injectableCallableStatementInterface; 127 128 131 public ConnectionPoolDefinition() { 132 } 133 134 143 protected ConnectionPoolDefinition(String url, Properties info, boolean explicitRegister) throws ProxoolException { 144 this.alias = ProxoolFacade.getAlias(url); 145 poolLog = LogFactory.getLog("org.logicalcobwebs.proxool." + alias); 146 reset(); 147 doChange(url, info, false, !explicitRegister); 148 } 149 150 158 protected void update(String url, Properties info) throws ProxoolException { 159 changedInfo.clear(); 160 connectionPropertiesChanged = false; 161 poolLog.debug("Updating definition"); 162 doChange(url, info, false, false); 163 if (connectionPropertiesChanged) { 164 poolLog.info("Mercifully killing all current connections because of definition changes"); 165 ProxoolFacade.killAllConnections(alias, "of definition changes", true); 166 } 167 } 168 169 177 protected void redefine(String url, Properties info) throws ProxoolException { 178 reset(); 179 changedInfo.clear(); 180 connectionPropertiesChanged = false; 181 poolLog.debug("Redefining definition"); 182 doChange(url, info, false, false); 183 184 if (getUrl() == null || getDriver() == null) { 186 throw new ProxoolException("The URL is not defined properly: " + getCompleteUrl()); 187 } 188 189 if (connectionPropertiesChanged) { 190 LOG.info("Mercifully killing all current connections because of definition changes"); 191 ProxoolFacade.killAllConnections(alias, "definition has changed", true); 192 } 193 } 194 195 private boolean doChange(String url, Properties info, boolean pretend, boolean implicitRegister) throws ProxoolException { 196 197 boolean changed = false; 198 199 try { 200 int endOfPrefix = url.indexOf(':'); 201 int endOfDriver = url.indexOf(':', endOfPrefix + 1); 202 203 if (endOfPrefix > -1 && endOfDriver > -1) { 204 final String driver = url.substring(endOfPrefix + 1, endOfDriver); 205 if (isChanged(getDriver(), driver)) { 206 changed = true; 207 if (!pretend) { 208 logChange(true, ProxoolConstants.DELEGATE_DRIVER_PROPERTY, driver); 209 setDriver(driver); 210 } 211 } 212 213 final String delegateUrl = url.substring(endOfDriver + 1); 214 if (isChanged(getUrl(), delegateUrl)) { 215 changed = true; 216 if (!pretend) { 217 logChange(true, ProxoolConstants.DELEGATE_URL_PROPERTY, delegateUrl); 218 setUrl(delegateUrl); 219 } 220 } 221 } else { 222 } 224 } catch (IndexOutOfBoundsException e) { 225 LOG.error("Invalid URL: '" + url + "'", e); 226 throw new ProxoolException("Invalid URL: '" + url + "'"); 227 } 228 229 if (!pretend) { 230 setCompleteUrl(url); 231 } 232 233 if (info != null) { 234 Iterator i = info.keySet().iterator(); 235 while (i.hasNext()) { 236 String key = (String ) i.next(); 237 String value = info.getProperty(key); 238 changed = changed | setAnyProperty(key, value, pretend); 239 if (!pretend) { 240 completeInfo.setProperty(key, value); 241 } 242 } 243 } 244 245 if (!pretend) { 246 ProxoolFacade.definitionUpdated(getAlias(), this, completeInfo, changedInfo); 247 } 248 249 if ((getDriver() == null || getUrl() == null) && implicitRegister) { 250 throw new ProxoolException("Attempt to refer to a unregistered pool by its alias '" + getAlias() + "'"); 251 } 252 253 return changed; 254 } 255 256 private void logChange(boolean proxoolProperty, String key, String value) { 257 if (poolLog.isDebugEnabled()) { 258 String displayValue = value; 259 if (key.toLowerCase().indexOf("password") > -1) { 260 displayValue = "********"; 261 } 262 poolLog.debug((proxoolProperty ? "Recognised proxool property: " : "Delegating property to driver: ") + key + "=" + displayValue); 263 } 264 } 265 266 private boolean setAnyProperty(String key, String value, boolean pretend) throws ProxoolException { 267 boolean proxoolProperty = true; 268 boolean changed = false; 269 270 changed = changed || setHouseKeeperProperty(key, value, pretend); 272 changed = changed || setLoggingProperty(key, value, pretend); 273 changed = changed || setInjectableProperty(key, value, pretend); 274 changed = changed || setJndiProperty(key, value, pretend); 275 276 if (key.equals(ProxoolConstants.USER_PROPERTY)) { 277 proxoolProperty = false; 278 if (isChanged(getUser(), value)) { 279 changed = true; 280 if (!pretend) { 281 setUser(value); 282 } 283 } 284 } else if (key.equals(ProxoolConstants.PASSWORD_PROPERTY)) { 285 proxoolProperty = false; 286 if (isChanged(getPassword(), value)) { 287 changed = true; 288 if (!pretend) { 289 setPassword(value); 290 } 291 } 292 } else if (key.equals(ProxoolConstants.DELEGATE_DRIVER_PROPERTY)) { 293 if (isChanged(getDriver(), value)) { 294 changed = true; 295 if (!pretend) { 296 setDriver(value); 297 } 298 } 299 } else if (key.equals(ProxoolConstants.DELEGATE_URL_PROPERTY)) { 300 if (isChanged(getUrl(), value)) { 301 changed = true; 302 if (!pretend) { 303 setUrl(value); 304 } 305 } 306 } else if (key.equals(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY)) { 307 if (getMaximumConnectionCount() != getInt(key, value)) { 308 changed = true; 309 if (!pretend) { 310 setMaximumConnectionCount(getInt(key, value)); 311 } 312 } 313 } else if (key.equals(ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME_PROPERTY)) { 314 if (getMaximumConnectionLifetime() != getInt(key, value)) { 315 changed = true; 316 if (!pretend) { 317 setMaximumConnectionLifetime(getInt(key, value)); 318 } 319 } 320 } else if (key.equals(ProxoolConstants.MAXIMUM_NEW_CONNECTIONS_PROPERTY)) { 321 poolLog.warn("Use of " + ProxoolConstants.MAXIMUM_NEW_CONNECTIONS_PROPERTY + " is deprecated. Use more descriptive " + ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE_PROPERTY + " instead."); 322 if (getSimultaneousBuildThrottle() != getInt(key, value)) { 323 changed = true; 324 if (!pretend) { 325 setSimultaneousBuildThrottle(getInt(key, value)); 326 } 327 } 328 } else if (key.equals(ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE_PROPERTY)) { 329 if (getSimultaneousBuildThrottle() != getInt(key, value)) { 330 changed = true; 331 setSimultaneousBuildThrottle(getInt(key, value)); 332 } 333 } else if (key.equals(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY)) { 334 if (getMinimumConnectionCount() != getInt(key, value)) { 335 changed = true; 336 if (!pretend) { 337 setMinimumConnectionCount(getInt(key, value)); 338 } 339 } 340 } else if (key.equals(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY)) { 341 if (getPrototypeCount() != getInt(key, value)) { 342 changed = true; 343 if (!pretend) { 344 setPrototypeCount(getInt(key, value)); 345 } 346 } 347 } else if (key.equals(ProxoolConstants.RECENTLY_STARTED_THRESHOLD_PROPERTY)) { 348 if (getRecentlyStartedThreshold() != getInt(key, value)) { 349 changed = true; 350 if (!pretend) { 351 setRecentlyStartedThreshold(getInt(key, value)); 352 } 353 } 354 } else if (key.equals(ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME_PROPERTY)) { 355 if (getOverloadWithoutRefusalLifetime() != getInt(key, value)) { 356 changed = true; 357 if (!pretend) { 358 setOverloadWithoutRefusalLifetime(getInt(key, value)); 359 } 360 } 361 } else if (key.equals(ProxoolConstants.MAXIMUM_ACTIVE_TIME_PROPERTY)) { 362 if (getMaximumActiveTime() != getInt(key, value)) { 363 changed = true; 364 if (!pretend) { 365 setMaximumActiveTime(getInt(key, value)); 366 } 367 } 368 } else if (key.equals(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY)) { 369 if (isChanged(fatalSqlExceptionsAsString, value)) { 370 changed = true; 371 if (!pretend) { 372 setFatalSqlExceptionsAsString(value.length() > 0 ? value : null); 373 } 374 } 375 } else if (key.equals(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY)) { 376 if (isChanged(fatalSqlExceptionWrapper, value)) { 377 changed = true; 378 if (!pretend) { 379 setFatalSqlExceptionWrapper(value.length() > 0 ? value : null); 380 } 381 } 382 } else if (key.equals(ProxoolConstants.STATISTICS_PROPERTY)) { 383 if (isChanged(getStatistics(), value)) { 384 changed = true; 385 if (!pretend) { 386 setStatistics(value.length() > 0 ? value : null); 387 } 388 } 389 } else if (key.equals(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY)) { 390 if (isChanged(getStatisticsLogLevel(), value)) { 391 changed = true; 392 if (!pretend) { 393 setStatisticsLogLevel(value.length() > 0 ? value : null); 394 } 395 } 396 } 397 398 if (!key.startsWith(ProxoolConstants.PROPERTY_PREFIX)) { 399 if (isChanged(getDelegateProperty(key), value)) { 400 changed = true; 401 if (!pretend) { 402 setDelegateProperty(key, value); 403 } 404 } 405 proxoolProperty = false; 406 } 407 408 if (changed && !pretend) { 409 logChange(proxoolProperty, key, value); 410 changedInfo.setProperty(key, value); 411 } 412 return changed; 413 } 414 415 419 private boolean setLoggingProperty(String key, String value, boolean pretend) { 420 boolean changed = false; 421 if (key.equals(ProxoolConstants.DEBUG_LEVEL_PROPERTY)) { 422 if (value != null && value.equals("1")) { 423 poolLog.warn("Use of " + ProxoolConstants.DEBUG_LEVEL_PROPERTY + "=1 is deprecated. Use " + ProxoolConstants.VERBOSE_PROPERTY + "=true instead."); 424 if (!isVerbose()) { 425 changed = true; 426 if (!pretend) { 427 setVerbose(true); 428 } 429 } 430 } else { 431 poolLog.warn("Use of " + ProxoolConstants.DEBUG_LEVEL_PROPERTY + "=0 is deprecated. Use " + ProxoolConstants.VERBOSE_PROPERTY + "=false instead."); 432 if (isVerbose()) { 433 changed = true; 434 if (!pretend) { 435 setVerbose(false); 436 } 437 } 438 } 439 } else if (key.equals(ProxoolConstants.VERBOSE_PROPERTY)) { 440 final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue(); 441 if (isVerbose() != valueAsBoolean) { 442 changed = true; 443 if (!pretend) { 444 setVerbose(valueAsBoolean); 445 } 446 } 447 } else if (key.equals(ProxoolConstants.TRACE_PROPERTY)) { 448 final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue(); 449 if (isTrace() != valueAsBoolean) { 450 changed = true; 451 if (!pretend) { 452 setTrace(valueAsBoolean); 453 } 454 } 455 } 456 return changed; 457 } 458 459 463 private boolean setInjectableProperty(String key, String value, boolean pretend) { 464 boolean changed = false; 465 if (key.equals(ProxoolConstants.INJECTABLE_CONNECTION_INTERFACE_NAME_PROPERTY)) { 466 if (isChanged(getInjectableConnectionInterfaceName(), value)) { 467 changed = true; 468 if (!pretend) { 469 setInjectableConnectionInterfaceName(value.length() > 0 ? value : null); 470 } 471 } 472 } else if (key.equals(ProxoolConstants.INJECTABLE_STATEMENT_INTERFACE_NAME_PROPERTY)) { 473 if (isChanged(getInjectableStatementInterfaceName(), value)) { 474 changed = true; 475 if (!pretend) { 476 setInjectableStatementInterfaceName(value.length() > 0 ? value : null); 477 } 478 } 479 } else if (key.equals(ProxoolConstants.INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME_PROPERTY)) { 480 if (isChanged(getInjectablePreparedStatementInterfaceName(), value)) { 481 changed = true; 482 if (!pretend) { 483 setInjectablePreparedStatementInterfaceName(value.length() > 0 ? value : null); 484 } 485 } 486 } else if (key.equals(ProxoolConstants.INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME_PROPERTY)) { 487 if (isChanged(getInjectableCallableStatememtInterfaceName(), value)) { 488 changed = true; 489 if (!pretend) { 490 setInjectableCallableStatementInterfaceName(value.length() > 0 ? value : null); 491 } 492 } 493 } 494 return changed; 495 } 496 497 501 private boolean setHouseKeeperProperty(String key, String value, boolean pretend) throws ProxoolException { 502 boolean changed = false; 503 if (key.equals(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY)) { 504 if (getHouseKeepingSleepTime() != getInt(key, value)) { 505 changed = true; 506 if (!pretend) { 507 setHouseKeepingSleepTime(getInt(key, value)); 508 } 509 } 510 } else if (key.equals(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY)) { 511 if (isChanged(getHouseKeepingTestSql(), value)) { 512 changed = true; 513 if (!pretend) { 514 setHouseKeepingTestSql(value.length() > 0 ? value : null); 515 } 516 } 517 } else if (key.equals(ProxoolConstants.TEST_BEFORE_USE_PROPERTY)) { 518 final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue(); 519 if (isTestBeforeUse() != valueAsBoolean) { 520 changed = true; 521 if (!pretend) { 522 setTestBeforeUse(valueAsBoolean); 523 } 524 } 525 } else if (key.equals(ProxoolConstants.TEST_AFTER_USE_PROPERTY)) { 526 final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue(); 527 if (isTestAfterUse() != valueAsBoolean) { 528 changed = true; 529 if (!pretend) { 530 setTestAfterUse(valueAsBoolean); 531 } 532 } 533 } 534 return changed; 535 } 536 537 541 private boolean setJndiProperty(String key, String value, boolean pretend) { 542 boolean changed = false; 543 if (key.equals(ProxoolConstants.JNDI_NAME_PROPERTY)) { 544 if (isChanged(getJndiName(), value)) { 545 changed = true; 546 if (!pretend) { 547 setJndiName(value.length() > 0 ? value : null); 548 } 549 } 550 } else { 551 552 } 553 return changed; 554 } 555 private int getInt(String key, String value) throws ProxoolException { 556 try { 557 return Integer.parseInt(value); 558 } catch (NumberFormatException e) { 559 throw new ProxoolException("'" + key + "' property must be an integer. Found '" + value + "' instead."); 560 } 561 } 562 563 private static boolean isChanged(String oldValue, String newValue) { 564 boolean changed = false; 565 if (oldValue == null) { 566 if (newValue != null) { 567 changed = true; 568 } 569 } else if (newValue == null) { 570 changed = true; 571 } else if (!oldValue.equals(newValue)) { 572 changed = true; 573 } 574 return changed; 575 } 576 577 582 protected Object clone() throws CloneNotSupportedException { 583 ConnectionPoolDefinition clone = new ConnectionPoolDefinition(); 584 585 clone.setCompleteUrl(completeUrl); 586 clone.setDelegateProperties((Properties ) delegateProperties.clone()); 587 clone.setCompleteInfo((Properties ) completeInfo.clone()); 588 clone.clearChangedInfo(); 589 590 clone.setAlias(alias); 591 clone.setUrl(url); 592 clone.setDriver(driver); 593 clone.setMaximumConnectionLifetime(maximumConnectionLifetime); 594 clone.setPrototypeCount(prototypeCount); 595 clone.setMinimumConnectionCount(minimumConnectionCount); 596 clone.setMaximumConnectionCount(maximumConnectionCount); 597 clone.setHouseKeepingSleepTime(houseKeepingSleepTime); 598 clone.setHouseKeepingTestSql(houseKeepingTestSql); 599 clone.setTestAfterUse(testAfterUse); 600 clone.setTestBeforeUse(testBeforeUse); 601 clone.setSimultaneousBuildThrottle(simultaneousBuildThrottle); 602 clone.setRecentlyStartedThreshold(recentlyStartedThreshold); 603 clone.setOverloadWithoutRefusalLifetime(overloadWithoutRefusalLifetime); 604 clone.setMaximumActiveTime(maximumActiveTime); 605 clone.setVerbose(verbose); 606 clone.setTrace(trace); 607 clone.setStatistics(statistics); 608 clone.setStatisticsLogLevel(statisticsLogLevel); 609 clone.setFatalSqlExceptionsAsString(fatalSqlExceptionsAsString); 610 try { 611 clone.setFatalSqlExceptionWrapper(fatalSqlExceptionWrapper); 612 } catch (ProxoolException e) { 613 throw new IllegalArgumentException ("Problem cloning fatalSqlExceptionWrapper: " + fatalSqlExceptionWrapper); 614 } 615 return clone; 616 } 617 618 private void clearChangedInfo() { 619 changedInfo.clear(); 620 } 621 622 625 private void reset() { 626 completeUrl = null; 627 delegateProperties.clear(); 628 completeInfo.clear(); 629 changedInfo.clear(); 630 631 url = null; 632 driver = null; 633 maximumConnectionLifetime = DEFAULT_MAXIMUM_CONNECTION_LIFETIME; 634 prototypeCount = DEFAULT_PROTOTYPE_COUNT; 635 minimumConnectionCount = DEFAULT_MINIMUM_CONNECTION_COUNT; 636 maximumConnectionCount = DEFAULT_MAXIMUM_CONNECTION_COUNT; 637 houseKeepingSleepTime = DEFAULT_HOUSE_KEEPING_SLEEP_TIME; 638 houseKeepingTestSql = null; 639 testAfterUse = false; 640 testBeforeUse = false; 641 simultaneousBuildThrottle = DEFAULT_SIMULTANEOUS_BUILD_THROTTLE; 642 recentlyStartedThreshold = DEFAULT_RECENTLY_STARTED_THRESHOLD; 643 overloadWithoutRefusalLifetime = DEFAULT_OVERLOAD_WITHOUT_REFUSAL_THRESHOLD; 644 maximumActiveTime = DEFAULT_MAXIMUM_ACTIVE_TIME; 645 verbose = false; 646 trace = false; 647 statistics = null; 648 statisticsLogLevel = null; 649 fatalSqlExceptions.clear(); 650 fatalSqlExceptionWrapper = null; 651 } 652 653 657 protected Properties getCompleteInfo() { 658 return completeInfo; 659 } 660 661 666 public void setCompleteInfo(Properties completeInfo) { 667 this.completeInfo = completeInfo; 668 } 669 670 673 public String getUser() { 674 return getDelegateProperty(USER_PROPERTY); 675 } 676 677 680 public void setUser(String user) { 681 setDelegateProperty(USER_PROPERTY, user); 682 } 683 684 687 public String getPassword() { 688 return getDelegateProperty(PASSWORD_PROPERTY); 689 } 690 691 694 public void setPassword(String password) { 695 setDelegateProperty(PASSWORD_PROPERTY, password); 696 } 697 698 701 public String getJdbcDriverVersion() { 702 703 try { 704 Driver driver = DriverManager.getDriver(getUrl()); 705 return driver.getMajorVersion() + "." + driver.getMinorVersion(); 706 } catch (SQLException e) { 707 return "Trying to locate driver version for '" + getUrl() + "' caused: " + e.toString(); 708 } catch (NullPointerException e) { 709 return "Couldn't locate driver for '" + getUrl() + "'!"; 710 } 711 712 } 713 714 717 public String toString() { 718 return getCompleteUrl(); 719 } 720 721 725 public String getName() { 726 return alias; 727 } 728 729 732 public String getAlias() { 733 return alias; 734 } 735 736 739 public void setAlias(String alias) { 740 this.alias = alias; 741 } 742 743 746 public int getMaximumConnectionLifetime() { 747 return maximumConnectionLifetime; 748 } 749 750 753 public void setMaximumConnectionLifetime(int maximumConnectionLifetime) { 754 this.maximumConnectionLifetime = maximumConnectionLifetime; 755 } 756 757 760 public int getPrototypeCount() { 761 return prototypeCount; 762 } 763 764 767 public void setPrototypeCount(int prototypeCount) { 768 this.prototypeCount = prototypeCount; 769 } 770 771 774 public int getMinimumConnectionCount() { 775 return minimumConnectionCount; 776 } 777 778 781 public void setMinimumConnectionCount(int minimumConnectionCount) { 782 this.minimumConnectionCount = minimumConnectionCount; 783 } 784 785 788 public int getMaximumConnectionCount() { 789 return maximumConnectionCount; 790 } 791 792 795 public void setMaximumConnectionCount(int maximumConnectionCount) { 796 this.maximumConnectionCount = maximumConnectionCount; 797 } 798 799 802 public int getHouseKeepingSleepTime() { 803 return houseKeepingSleepTime; 804 } 805 806 809 public void setHouseKeepingSleepTime(int houseKeepingSleepTime) { 810 this.houseKeepingSleepTime = houseKeepingSleepTime; 811 } 812 813 817 public int getMaximumNewConnections() { 818 return simultaneousBuildThrottle; 819 } 820 821 825 public void setMaximumNewConnections(int maximumNewConnections) { 826 this.simultaneousBuildThrottle = maximumNewConnections; 827 } 828 829 832 public int getSimultaneousBuildThrottle() { 833 return simultaneousBuildThrottle; 834 } 835 836 839 public void setSimultaneousBuildThrottle(int simultaneousBuildThrottle) { 840 this.simultaneousBuildThrottle = simultaneousBuildThrottle; 841 } 842 843 847 public Properties getProperties() { 848 return delegateProperties; 849 } 850 851 854 public Properties getDelegateProperties() { 855 return delegateProperties; 856 } 857 858 863 public String getDelegateProperty(String name) { 864 return getDelegateProperties().getProperty(name); 865 } 866 867 873 public void setDelegateProperty(String name, String value) { 874 connectionPropertiesChanged = true; 875 getDelegateProperties().setProperty(name, value); 876 } 877 878 883 public void setDelegateProperties(Properties delegateProperties) { 884 this.delegateProperties = delegateProperties; 885 } 886 887 890 public String getUrl() { 891 return url; 892 } 893 894 897 public void setUrl(String url) { 898 this.url = url; 899 connectionPropertiesChanged = true; 900 } 901 902 905 public String getDriver() { 906 return driver; 907 } 908 909 912 public void setDriver(String driver) { 913 this.driver = driver; 914 connectionPropertiesChanged = true; 915 } 916 917 920 public int getRecentlyStartedThreshold() { 921 return recentlyStartedThreshold; 922 } 923 924 927 public void setRecentlyStartedThreshold(int recentlyStartedThreshold) { 928 this.recentlyStartedThreshold = recentlyStartedThreshold; 929 } 930 931 934 public int getOverloadWithoutRefusalLifetime() { 935 return overloadWithoutRefusalLifetime; 936 } 937 938 941 public void setOverloadWithoutRefusalLifetime(int overloadWithoutRefusalLifetime) { 942 this.overloadWithoutRefusalLifetime = overloadWithoutRefusalLifetime; 943 } 944 945 948 public int getMaximumActiveTime() { 949 return maximumActiveTime; 950 } 951 952 955 public void setMaximumActiveTime(int maximumActiveTime) { 956 this.maximumActiveTime = maximumActiveTime; 957 } 958 959 963 public int getDebugLevel() { 964 return (verbose ? 1 : 0); 965 } 966 967 970 public boolean isVerbose() { 971 return verbose; 972 } 973 974 977 public void setVerbose(boolean verbose) { 978 this.verbose = verbose; 979 } 980 981 984 public boolean isTrace() { 985 return trace; 986 } 987 988 991 public void setTrace(boolean trace) { 992 this.trace = trace; 993 } 994 995 998 public String getCompleteUrl() { 999 return completeUrl; 1000 } 1001 1002 1005 public void setCompleteUrl(String completeUrl) { 1006 this.completeUrl = completeUrl; 1007 } 1008 1009 1012 public void setFatalSqlExceptionsAsString(String fatalSqlExceptionsAsString) { 1013 this.fatalSqlExceptionsAsString = fatalSqlExceptionsAsString; 1014 fatalSqlExceptions.clear(); 1015 if (fatalSqlExceptionsAsString != null) { 1016 StringTokenizer st = new StringTokenizer (fatalSqlExceptionsAsString, FATAL_SQL_EXCEPTIONS_DELIMITER); 1017 while (st.hasMoreTokens()) { 1018 fatalSqlExceptions.add(st.nextToken().trim()); 1019 } 1020 } 1021 } 1022 1023 1026 public Set getFatalSqlExceptions() { 1027 return fatalSqlExceptions; 1028 } 1029 1030 1033 public String getFatalSqlExceptionWrapper() { 1034 return fatalSqlExceptionWrapper; 1035 } 1036 1037 1040 public void setFatalSqlExceptionWrapper(String fatalSqlExceptionWrapper) throws ProxoolException { 1041 1042 try { 1044 FatalSqlExceptionHelper.throwFatalSQLException(fatalSqlExceptionWrapper, new SQLException ("Test")); 1045 } catch (SQLException e) { 1046 } catch (RuntimeException e) { 1048 } 1050 1051 this.fatalSqlExceptionWrapper = fatalSqlExceptionWrapper; 1052 } 1053 1054 1057 public String getHouseKeepingTestSql() { 1058 return houseKeepingTestSql; 1059 } 1060 1061 1064 public void setHouseKeepingTestSql(String houseKeepingTestSql) { 1065 this.houseKeepingTestSql = houseKeepingTestSql; 1066 } 1067 1068 1071 public boolean isTestBeforeUse() { 1072 return testBeforeUse; 1073 } 1074 1075 1078 public void setTestBeforeUse(boolean testBeforeUse) { 1079 this.testBeforeUse = testBeforeUse; 1080 } 1081 1082 1085 public boolean isTestAfterUse() { 1086 return testAfterUse; 1087 } 1088 1089 1092 public void setTestAfterUse(boolean testAfterUse) { 1093 this.testAfterUse = testAfterUse; 1094 } 1095 1096 1099 public String getStatistics() { 1100 return statistics; 1101 } 1102 1103 1106 public void setStatistics(String statistics) { 1107 this.statistics = statistics; 1108 } 1109 1110 1113 public String getStatisticsLogLevel() { 1114 return statisticsLogLevel; 1115 } 1116 1117 1120 public void setStatisticsLogLevel(String statisticsLogLevel) { 1121 this.statisticsLogLevel = statisticsLogLevel; 1122 } 1123 1124 public String getJndiName() { 1126 return jndiName; 1127 } 1128 1129 public void setJndiName(String jndiName) { 1130 this.jndiName = jndiName; 1131 } 1132 1133 public String getInitialContextFactory() { 1134 return initialContextFactory; 1135 } 1136 1137 public void setInitialContextFactory(String initialContextFactory) { 1138 this.initialContextFactory = initialContextFactory; 1139 } 1140 1141 public String getProviderUrl() { 1142 return providerUrl; 1143 } 1144 1145 public void setProviderUrl(String providerUrl) { 1146 this.providerUrl = providerUrl; 1147 } 1148 1149 public String getSecurityAuthentication() { 1150 return securityAuthentication; 1151 } 1152 1153 public void setSecurityAuthentication(String securityAuthentication) { 1154 this.securityAuthentication = securityAuthentication; 1155 } 1156 1157 public String getSecurityPrincipal() { 1158 return securityPrincipal; 1159 } 1160 1161 public void setSecurityPrincipal(String securityPrincipal) { 1162 this.securityPrincipal = securityPrincipal; 1163 } 1164 1165 public String getSecurityCredentials() { 1166 return securityCredentials; 1167 } 1168 1169 public void setSecurityCredentials(String securityCredentials) { 1170 this.securityCredentials = securityCredentials; 1171 } 1172 1174 1177 public boolean isJmx() { 1178 return jmx; 1179 } 1180 1181 1184 public void setJmx(boolean jmx) { 1185 this.jmx = jmx; 1186 } 1187 1188 1191 public String getJmxAgentId() { 1192 return jmxAgentId; 1193 } 1194 1195 1198 public void setJmxAgentId(String jmxAgentId) { 1199 this.jmxAgentId = jmxAgentId; 1200 } 1201 1202 1205 public Class getInjectableConnectionInterface() { 1206 return injectableConnectionInterface; 1207 } 1208 1209 1212 public String getInjectableConnectionInterfaceName() { 1213 if (getInjectableConnectionInterface() != null) { 1214 return getInjectableConnectionInterface().getName(); 1215 } else { 1216 return null; 1217 } 1218 } 1219 1220 1224 public void setInjectableConnectionInterfaceName(String injectableConnectionInterfaceName) { 1225 this.injectableConnectionInterface = getInterface(injectableConnectionInterfaceName); 1226 } 1227 1228 1231 public Class getInjectableStatementInterface() { 1232 return injectableStatementInterface; 1233 } 1234 1235 1238 public String getInjectableStatementInterfaceName() { 1239 if (getInjectableStatementInterface() != null) { 1240 return getInjectableStatementInterface().getName(); 1241 } else { 1242 return null; 1243 } 1244 } 1245 1246 1250 public void setInjectableStatementInterfaceName(String injectableStatementInterfaceName) { 1251 this.injectableStatementInterface = getInterface(injectableStatementInterfaceName); 1252 } 1253 1254 1257 public Class getInjectablePreparedStatementInterface() { 1258 return injectablePreparedStatementInterface; 1259 } 1260 1261 1264 public String getInjectablePreparedStatementInterfaceName() { 1265 if (getInjectablePreparedStatementInterface() != null) { 1266 return getInjectablePreparedStatementInterface().getName(); 1267 } else { 1268 return null; 1269 } 1270 } 1271 1272 1276 public void setInjectablePreparedStatementInterfaceName(String injectablePreparedStatementInterfaceName) { 1277 this.injectablePreparedStatementInterface = getInterface(injectablePreparedStatementInterfaceName); 1278 } 1279 1280 1283 public String getInjectableCallableStatememtInterfaceName() { 1284 if (getInjectableCallableStatementInterface() != null) { 1285 return getInjectableCallableStatementInterface().getName(); 1286 } else { 1287 return null; 1288 } 1289 } 1290 1291 1294 public Class getInjectableCallableStatementInterface() { 1295 return injectableCallableStatementInterface; 1296 } 1297 1298 1302 public void setInjectableCallableStatementInterfaceName(String injectableCallableStatementInterfaceName) { 1303 this.injectableCallableStatementInterface = getInterface(injectableCallableStatementInterfaceName); 1304 } 1305 1306 private Class getInterface(String className) { 1307 try { 1308 Class clazz = null; 1309 if (className != null && className.length() > 0) { 1310 clazz = Class.forName(className); 1311 if (!clazz.isInterface()) { 1312 throw new IllegalArgumentException (className + " is a class. It must be an interface."); 1313 } 1314 if (!Modifier.isPublic(clazz.getModifiers())) { 1315 throw new IllegalArgumentException (className + " is a protected interface. It must be public."); 1316 } 1317 } 1318 return clazz; 1319 } catch (ClassNotFoundException e) { 1320 throw new IllegalArgumentException (className + " couldn't be found"); 1321 } 1322 } 1323 1324 1334 public boolean isEqual(String url, Properties info) { 1335 try { 1336 return !doChange(url, info, true, false); 1337 } catch (ProxoolException e) { 1338 LOG.error("Problem checking equality", e); 1339 return false; 1340 } 1341 1356 } 1357 1358} 1359 1360 1495 | Popular Tags |