1 20 package com.lutris.appserver.server.sql; 21 22 import org.enhydra.dods.CommonConstants; 23 import org.enhydra.dods.DODS; 24 import org.enhydra.dods.cache.CacheConstants; 25 26 import com.lutris.appserver.server.sql.standard.DriverSpecificConstants; 27 import com.lutris.util.Config; 28 29 36 37 public class DatabaseManagerConfiguration implements CacheConstants, DriverSpecificConstants { 38 39 40 41 42 47 private boolean lazyLoading = CacheConstants.DEFAULT_LAZY_LOADING; 48 49 50 51 56 private boolean caseSensitive = CacheConstants.DEFAULT_CASE_SENSITIVE; 57 58 59 60 65 private int maxExecuteTime = CacheConstants.DEFAULT_MAX_EXECUTE_TIME; 66 67 private double reserveFactor = CacheConstants.DEFAULT_RESERVE_FACTOR; 68 69 private double cachePercentage = CacheConstants.DEFAULT_CACHE_PERCENTAGE; 70 71 private int maxCacheSize = CacheConstants.DEFAULT_MAX_CACHE_SIZE; 72 73 private int maxSimpleCacheSize = CacheConstants.DEFAULT_MAX_SIMPLE_QUERY_CACHE_SIZE; 74 75 private int maxComplexCacheSize = CacheConstants.DEFAULT_MAX_COMPLEX_QUERY_CACHE_SIZE; 76 77 private int maxMultiJoinCacheSize = CacheConstants.DEFAULT_MAX_MULTI_JOIN_QUERY_CACHE_SIZE; 78 79 private boolean transactionCheck = CacheConstants.DEFAULT_TRANSACTION_CHECK; 80 81 private boolean deleteCheckVersion = CacheConstants.DEFAULT_DELETE_CHECK_VERSION; 82 83 private boolean autoSave = CacheConstants.DEFAULT_AUTO_SAVE; 84 85 private boolean autoSaveCreateVirgin = CacheConstants.DEFAULT_AUTO_SAVE_CREATE_VIRGIN; 86 87 private boolean autoWrite = CacheConstants.DEFAULT_AUTO_WRITE; 88 89 private boolean transactionCaches = CacheConstants.DEFAULT_TRANSACTION_CACHES; 90 91 private int deadlockWaitTime = CacheConstants.DEFAULT_DEADLOCK_READ_TIME; 92 93 private int deadlockRetryCount = CacheConstants.DEFAULT_DEADLOCK_RETRY_NUMBER; 94 95 private int queryTimeout = CacheConstants.DEFAULT_QUERY_TIMEOUT; 96 97 private boolean selectOids = CacheConstants.DEFAULT_SELECT_OIDS; 98 99 private boolean incrementVersions = CacheConstants.DEFAULT_INCREMENT_VERSIONS; 100 101 private int defaultFetchSize = CacheConstants.DEFAULT_DEFAULT_FETCH_SIZE; 102 103 private boolean initialAllCaches = CacheConstants.DEFAULT_INITIAL_ALL_CACHES; 104 105 private boolean allReadOnly = CacheConstants.DEFAULT_All_READONLY; 106 107 private Boolean useCursorName = null; 108 109 private String userConfigWildcard = null; 110 111 private String userConfigSingleWildcard = null; 112 113 private String userConfigSingleWildcardEscape = null; 114 115 private String userConfigWildcardEscape = null; 116 117 private String DBTransactionFactoryName = null; 118 119 private String connectionAllocatorName = null; 120 121 private String DBConnectionFactoryName = null; 122 123 private int fullCacheCountLimit = CacheConstants.DEFAULT_FULL_CACHE_COUNT_LIMIT; 124 125 private int initialCacheFetchSize = CacheConstants.DEFAULT_INITIAL_CACHE_FETCH_SIZE; 126 127 private int initialDSCacheSize = CacheConstants.DEFAULT_INITIAL_DS_CACHE_SIZE; 128 129 private String queryCacheImplClass = null; 130 131 private String initCachesResultSetType = null; 132 133 private String initCachesResultSetConcurrency = null; 134 135 private boolean sqlBatch = CommonConstants.DEFAULT_SQL_BATCH; 136 137 private boolean caseInsensitiveDatabase = CommonConstants.DEFAULT_CASE_INSENSITIVE_DATABASE; 138 139 private Integer queryTimeLimit = CommonConstants.DEFAULT_QUERY_TIME_LIMIT; 140 141 142 144 private int xaDefaultTimeout = CommonConstants.DEFAULT_XA_DEFAULT_TIMEOUT; 145 146 private int xaUsageCase = CommonConstants.DEFAULT_XA_USAGE_CASE; 147 148 private String xaTransactonManagerLookupName = CommonConstants.DEFAULT_XA_TM_LOOKUP_NAME; 149 150 private String xaUserTransactonLookupName = CommonConstants.DEFAULT_XA_USER_TRANSACTION_LOOKUP_NAME; 151 152 private String xaWrappedTransImplFactory = CommonConstants.DEFAULT_XA_WRAPPED_TRANS_IMPL_FACTORY; 153 154 private String xaJtaSupport = CommonConstants.DEFAULT_XA_JTA_SUPPORT; 155 156 158 private String dodsCacheFactory = CacheConstants.DEFAULT_DODS_CACHE_FACTORY; 159 160 165 public boolean isLazyLoading() { 166 return lazyLoading; 167 } 168 169 174 public boolean getCaseSensitive() { 175 return caseSensitive; 176 } 177 178 183 public void setCaseSensitive(boolean newValue) { 184 caseSensitive = newValue; 185 } 186 187 188 193 protected void setLazyLoading(boolean newlazyLoading) { 194 lazyLoading = newlazyLoading; 195 } 196 197 202 public int getMaxExecuteTime() { 203 return maxExecuteTime; 204 } 205 206 211 protected void setMaxExecuteTime(int newMaxExecuteTime) { 212 maxExecuteTime = newMaxExecuteTime; 213 } 214 215 220 public int getMaxCacheSize() { 221 return maxCacheSize; 222 } 223 224 229 protected void setMaxCacheSize(int newMaxCacheSize) { 230 maxCacheSize = newMaxCacheSize; 231 } 232 233 238 public double getReserveFactor() { 239 return reserveFactor; 240 } 241 242 247 protected void setReserveFactor(double newReserveFactor) { 248 reserveFactor = newReserveFactor; 249 } 250 251 254 protected void setCachePercentage(double percent) { 255 cachePercentage = percent; 256 } 257 258 261 public double getCachePercentage() { 262 return cachePercentage; 263 } 264 265 270 public int getMaxComplexCacheSize() { 271 return maxComplexCacheSize; 272 } 273 274 279 protected void setMaxComplexCacheSize(int newMaxCacheSize) { 280 maxComplexCacheSize = newMaxCacheSize; 281 } 282 283 288 public int getMaxMultiJoinCacheSize() { 289 return maxMultiJoinCacheSize; 290 } 291 292 297 protected void setMaxMultiJoinCacheSize(int newMaxCacheSize) { 298 maxMultiJoinCacheSize = newMaxCacheSize; 299 } 300 301 306 public int getMaxSimpleCacheSize() { 307 return maxSimpleCacheSize; 308 } 309 310 315 protected void setMaxSimpleCacheSize(int newMaxCacheSize) { 316 maxSimpleCacheSize = newMaxCacheSize; 317 } 318 319 324 public boolean getTransactionCheck() { 325 return transactionCheck; 326 } 327 328 333 protected void setTransactionCheck(boolean newCheck) { 334 transactionCheck = newCheck; 335 } 336 337 342 public boolean getDeleteCheckVersion() { 343 return deleteCheckVersion; 344 } 345 346 351 protected void setDeleteCheckVersion(boolean newCheck) { 352 deleteCheckVersion = newCheck; 353 } 354 355 360 public boolean getAutoSave() { 361 return autoSave; 362 } 363 364 369 protected void setAutoSave(boolean newCheck) { 370 autoSave = newCheck; 371 } 372 373 378 public boolean getAutoSaveCreateVirgin() { 379 return autoSaveCreateVirgin; 380 } 381 382 387 protected void setAutoSaveCreateVirgin(boolean newCheck) { 388 autoSaveCreateVirgin = newCheck; 389 } 390 391 396 public boolean getAutoWrite() { 397 return autoWrite; 398 } 399 400 405 protected void setAutoWrite(boolean newCheck) { 406 autoWrite = newCheck; 407 } 408 409 414 public boolean getTransactionCaches() { 415 return transactionCaches; 416 } 417 418 423 protected void setTransactionCaches(boolean newCheck) { 424 transactionCaches = newCheck; 425 } 426 427 432 public int getDeadlockWaitTime() { 433 return deadlockWaitTime; 434 } 435 436 441 protected void setDeadlockWaitTime(int waitTime) { 442 deadlockWaitTime = waitTime; 443 } 444 445 450 public int getDeadlockRetryCount() { 451 return deadlockRetryCount; 452 } 453 454 459 protected void setDeadlockRetryCount(int newValue) { 460 deadlockRetryCount = newValue; 461 } 462 463 468 public int getQueryTimeout() { 469 return queryTimeout; 470 } 471 472 477 protected void setQueryTimeout(int newValue) { 478 queryTimeout = newValue; 479 } 480 481 486 public boolean getSelectOids() { 487 return selectOids; 488 } 489 490 495 protected void setSelectOids(boolean newValue) { 496 selectOids = newValue; 497 } 498 499 500 501 506 public boolean getIncrementVersions() { 507 return incrementVersions; 508 } 509 510 515 protected void setIncrementVersions(boolean newValue) { 516 incrementVersions = newValue; 517 } 518 523 public int getDefaultFetchSize() { 524 return defaultFetchSize; 525 } 526 527 532 protected void setDefaultFetchSize(int newValue) { 533 defaultFetchSize = newValue; 534 } 535 536 541 public boolean getInitAllCaches() { 542 return initialAllCaches; 543 } 544 545 550 protected void setInitAllCaches(boolean newValue) { 551 initialAllCaches = newValue; 552 } 553 554 555 560 public Boolean getUseCursorName() { 561 return useCursorName; 562 } 563 564 569 public void setUseCursorName(boolean newValue) { 570 useCursorName =new Boolean (newValue); 571 } 572 573 578 public void setUseCursorName(Boolean newValue) { 579 useCursorName =newValue; 580 } 581 582 587 public String getUserConfigSingleWildcard() { 588 return userConfigSingleWildcard; 589 } 590 591 596 public String getUserConfigSingleWildcardEscape() { 597 return userConfigSingleWildcardEscape; 598 } 599 600 605 public String getUserConfigWildcard() { 606 return userConfigWildcard; 607 } 608 609 614 public String getUserConfigWildcardEscape() { 615 return userConfigWildcardEscape; 616 } 617 618 622 public void setUserConfigSingleWildcard(String newValue) { 623 userConfigSingleWildcard = newValue; 624 } 625 626 630 public void setUserConfigSingleWildcardEscape(String newValue) { 631 userConfigSingleWildcardEscape = newValue; 632 } 633 634 638 public void setUserConfigWildcard(String newValue) { 639 userConfigWildcard = newValue; 640 } 641 642 646 public void setUserConfigWildcardEscape(String newValue) { 647 userConfigWildcardEscape = newValue; 648 } 649 650 655 public boolean isAllReadOnly() { 656 return allReadOnly; 657 } 658 659 663 664 public void setAllReadOnly(boolean newValue) { 665 allReadOnly = newValue; 666 } 667 668 669 672 public String getDBTransactionFactoryName() { 673 return DBTransactionFactoryName; 674 } 675 676 677 680 public void setDBTransactionFactoryName(String string) { 681 DBTransactionFactoryName = string; 682 } 683 684 685 686 689 public String getConnectionAllocatorName() { 690 return connectionAllocatorName; 691 } 692 693 694 697 public void setConnectionAllocatorName(String string) { 698 connectionAllocatorName = string; 699 } 700 701 public int getFullCacheCountLimit() { 702 return fullCacheCountLimit; 703 } 704 705 708 public void setFullCacheCountLimit(int i) { 709 fullCacheCountLimit = i; 710 } 711 712 713 717 public void readDatabaseManagerConfiguration() { 718 Config databaseConfig = null; 719 720 Config userConfig = null; 721 try { 722 userConfig = (Config) DODS.getDatabaseManager().getConfig().getSection("DB.User"); 723 }catch(Exception e){} 724 725 if (userConfig != null) { 726 try{ 727 userConfigWildcard=userConfig.getString("userWildcard"); 728 }catch(Exception e){} 729 try{ 730 userConfigSingleWildcard=userConfig.getString("userSingleWildcard"); 731 }catch(Exception e){} 732 733 try{ 734 userConfigSingleWildcardEscape=userConfig.getString("userSingleWildcardEscape"); 735 }catch(Exception e){} 736 737 try{ 738 userConfigWildcardEscape=userConfig.getString("userWildcardEscape"); 739 }catch(Exception e){} 740 741 } 742 743 try { 744 databaseConfig = (Config) DODS.getDatabaseManager().getConfig().getSection("defaults"); 745 } catch (Exception ex) {} 746 if (databaseConfig != null) { 747 try { 748 allReadOnly = databaseConfig.getBoolean(PARAMNAME_ALL_READ_ONLY); 749 } catch (Exception e) {} 750 try { 751 lazyLoading = databaseConfig.getBoolean(PARAMNAME_LAZY_LOADING); 752 } catch (Exception e) {} 753 try { 754 caseSensitive = databaseConfig.getBoolean(PARAMNAME_CASE_SENSITIVE); 755 } catch (Exception e) {} 756 try { 757 maxExecuteTime = databaseConfig.getInt(PARAMNAME_MAX_EXECUTE_TIME); 758 } catch (Exception e) {} 759 try { 760 transactionCheck = databaseConfig.getBoolean(PARAMNAME_TRANSACTION_CHECK); 761 } catch (Exception e) {} 762 try { 763 deleteCheckVersion = databaseConfig.getBoolean(PARAMNAME_DELETE_CHECK_VERSION); 764 } catch (Exception e) {} 765 try { 766 autoSave = databaseConfig.getBoolean(PARAMNAME_AUTO_SAVE); 767 } catch (Exception e) {} 768 try { 769 autoSaveCreateVirgin = databaseConfig.getBoolean(PARAMNAME_AUTO_SAVE_CREATE_VIRGIN); 770 } catch (Exception e) {} 771 try { 772 autoWrite = databaseConfig.getBoolean(PARAMNAME_AUTO_WRITE); 773 } catch (Exception e) {} 774 try { 775 transactionCaches = databaseConfig.getBoolean(PARAMNAME_TRANSACTION_CACHES); 776 } catch (Exception e) {} 777 try { 778 deadlockWaitTime = databaseConfig.getInt(PARAMNAME_DEADLOCK_READ_TIME); 779 } catch (Exception e) {} 780 try { 781 deadlockRetryCount = databaseConfig.getInt(PARAMNAME_DEADLOCK_RETRY_NUMBER); 782 } catch (Exception e) {} 783 try { 784 queryTimeout = databaseConfig.getInt(PARAMNAME_QUERY_TIMEOUT); 785 } catch (Exception e) {} 786 try { 787 selectOids = databaseConfig.getBoolean(PARAMNAME_SELECT_OIDS); 788 } catch (Exception e) {} 789 try { 790 incrementVersions = databaseConfig.getBoolean(PARAMNAME_INCREMENT_VERSIONS); 791 } catch (Exception e) {} 792 try { 793 defaultFetchSize = databaseConfig.getInt(PARAMNAME_DEFAULT_FETCH_SIZE); 794 } catch (Exception e) {} 795 try { 796 boolean tmpUCrN = databaseConfig.getBoolean(PARAMNAME_USE_CURSOR_NAME); 797 useCursorName = new Boolean (tmpUCrN); 798 } catch (Exception e) { 799 useCursorName = null; 800 } 801 try { 802 DBTransactionFactoryName = databaseConfig.getString(CommonConstants.TRANSACTION_FACTORY); 803 } catch (Exception e) { 804 DBTransactionFactoryName = null; 805 } 806 try { 807 queryCacheImplClass = databaseConfig.getString(CommonConstants.QUERY_CACAHE_IMPL_CLASS); 808 } catch (Exception e) { 809 queryCacheImplClass = null; 810 } 811 try { 812 connectionAllocatorName = databaseConfig.getString(CommonConstants.CONNECTION_ALLOCATOR); 813 } catch (Exception e) { 814 connectionAllocatorName = null; 815 } 816 try { 817 DBConnectionFactoryName = databaseConfig.getString(CommonConstants.CONNECTION_FACTORY); 818 } catch (Exception e) { 819 DBConnectionFactoryName = null; 820 } 821 try { 822 fullCacheCountLimit = databaseConfig.getInt(CacheConstants.FULL_CACHE_COUNT_LIMIT); 823 } catch (Exception e) { } 824 try { 825 initCachesResultSetType = databaseConfig.getString(CommonConstants.INIT_CACHES_RESULT_SET_TYPE); 826 } catch (Exception e) { } 827 828 try { 829 initCachesResultSetConcurrency = databaseConfig.getString(CommonConstants.INIT_CACHES_RESULT_SET_CONCURRENCY); 830 } catch (Exception e) { } 831 try { 832 sqlBatch = databaseConfig.getBoolean(CommonConstants.SQL_BATCH); 833 } catch (Exception e) { } 834 try { 835 caseInsensitiveDatabase = databaseConfig.getBoolean(CommonConstants.CASE_INSENSITIVE_DATABASE); 836 } catch (Exception e) {} 837 838 try { 839 queryTimeLimit = new Integer (databaseConfig.getInt(CommonConstants.QUERY_TIME_LIMIT)); 840 } catch (Exception e) { 841 queryTimeLimit = null; 842 } 843 try { 845 xaDefaultTimeout = databaseConfig.getInt(CommonConstants.XA_DEFAULT_TIMEOUT); 846 } catch (Exception e) { } 847 try { 848 xaTransactonManagerLookupName = databaseConfig.getString(CommonConstants.XA_TM_LOOKUP_NAME); 849 } catch (Exception e) { } 850 try { 851 xaUsageCase = databaseConfig.getInt(CommonConstants.XA_USAGE_CASE); 852 } catch (Exception e) { } 853 try { 854 xaWrappedTransImplFactory = databaseConfig.getString(CommonConstants.XA_WRAPPED_TRANS_IMPL_FACTORY); 855 } catch (Exception e) { } 856 try { 857 xaUserTransactonLookupName = databaseConfig.getString(CommonConstants.XA_USER_TRANSACTION_LOOKUP_NAME); 858 } catch (Exception e) { } 859 try { 860 xaJtaSupport = databaseConfig.getString(CommonConstants.XA_JTA_SUPPORT); 861 } catch (Exception e) { } 862 864 } 865 try { 866 databaseConfig = (Config) DODS.getDatabaseManager().getConfig().getSection("defaults.cache"); 867 } catch (Exception ex) {} 868 if (databaseConfig != null) { 869 try { 870 reserveFactor = databaseConfig.getDouble(PARAMNAME_RESERVE_FACTOR); 871 } catch (Exception e) {} 872 try { 873 cachePercentage = databaseConfig.getDouble(PARAMNAME_CACHE_PERCENTAGE); 874 } catch (Exception e) {} 875 try { 876 maxCacheSize = databaseConfig.getInt(PARAMNAME_MAX_CACHE_SIZE); 877 } catch (Exception e) {} 878 try { 879 maxSimpleCacheSize = databaseConfig.getInt(PARAMNAME_MAX_SIMPLE_CACHE_SIZE); 880 } catch (Exception e) {} 881 try { 882 maxComplexCacheSize = databaseConfig.getInt(PARAMNAME_MAX_COMPLEX_CACHE_SIZE); 883 } catch (Exception e) {} 884 try { 885 maxMultiJoinCacheSize = databaseConfig.getInt(PARAMNAME_MAX_MULTI_JOIN_CACHE_SIZE); 886 } catch (Exception e) {} 887 try { 888 initialAllCaches = databaseConfig.getBoolean(PARAMNAME_INITIAL_ALL_CACHES); 889 } catch (Exception e) {} 890 try { 891 initialCacheFetchSize = databaseConfig.getInt(PARAMNAME_INITIAL_CACHE_FETCH_SIZE); 892 } catch (Exception e) {} 893 try { 894 initialDSCacheSize = databaseConfig.getInt(PARAMNAME_INITIAL_DS_CACHE_SIZE); 895 } catch (Exception e) {} 896 try { 897 dodsCacheFactory = databaseConfig.getString(PARAMNAME_DODS_CACHE_FACTORY); 898 } catch (Exception e) { } 899 } 900 } 901 902 905 public String getDBConnectionFactoryName() { 906 return DBConnectionFactoryName; 907 } 908 909 912 public void setDBConnectionFactoryName(String string) { 913 DBConnectionFactoryName = string; 914 } 915 916 919 public int getInitialCacheFetchSize() { 920 return initialCacheFetchSize; 921 } 922 923 926 public int getInitialDSCacheSize() { 927 return initialDSCacheSize; 928 } 929 930 933 public void setInitialCacheFetchSize(int i) { 934 initialCacheFetchSize = i; 935 } 936 937 940 public void setInitialDSCacheSize(int i) { 941 initialDSCacheSize = i; 942 } 943 944 947 public String getQueryCacheImplClass() { 948 return queryCacheImplClass; 949 } 950 951 954 public void setQueryCacheImplClass(String string) { 955 queryCacheImplClass = string; 956 } 957 958 961 public String getInitCachesResultSetConcurrency() { 962 return initCachesResultSetConcurrency; 963 } 964 965 968 public String getInitCachesResultSetType() { 969 return initCachesResultSetType; 970 } 971 972 975 public void setInitCachesResultSetConcurrency(String string) { 976 initCachesResultSetConcurrency = string; 977 } 978 979 982 public void setInitCachesResultSetType(String string) { 983 initCachesResultSetType = string; 984 } 985 986 989 public boolean isSqlBatch() { 990 return sqlBatch; 991 } 992 993 996 public void setSqlBatch(boolean b) { 997 sqlBatch = b; 998 } 999 1000 1003 public boolean isCaseInsensitiveDatabase() { 1004 return caseInsensitiveDatabase; 1005 } 1006 1009 public void setCaseInsensitiveDatabase(boolean caseInsensitiveDatabase) { 1010 this.caseInsensitiveDatabase = caseInsensitiveDatabase; 1011 } 1012 1013 1014 1017 public Integer getQueryTimeLimit() { 1018 return queryTimeLimit; 1019 } 1020 1021 1024 public void setQueryTimeLimit(Integer queryTimeLimit) { 1025 this.queryTimeLimit = queryTimeLimit; 1026 } 1027 1028 1031 public int getXaDefaultTimeout() { 1032 return xaDefaultTimeout; 1033 } 1034 1035 1038 public void setXaDefaultTimeout(int xaDefaultTimeout) { 1039 this.xaDefaultTimeout = xaDefaultTimeout; 1040 } 1041 1042 1045 public String getXaTransactonManagerLookupName() { 1046 return xaTransactonManagerLookupName; 1047 } 1048 1049 1052 public void setXaTransactonManagerLookupName( 1053 String xaTransactonManagerLookupName) { 1054 this.xaTransactonManagerLookupName = xaTransactonManagerLookupName; 1055 } 1056 1057 1060 public int getXaUsageCase() { 1061 return xaUsageCase; 1062 } 1063 1064 1067 public void setXaUsageCase(int xaUsageCase) { 1068 this.xaUsageCase = xaUsageCase; 1069 } 1070 1071 1074 public String getXaWrappedTransImplFactory() { 1075 return xaWrappedTransImplFactory; 1076 } 1077 1078 1081 public void setXaWrappedTransImplFactory(String xaWrappedTransImplFactory) { 1082 this.xaWrappedTransImplFactory = xaWrappedTransImplFactory; 1083 } 1084 1085 1088 public String getXaUserTransactonLookupName() { 1089 return xaUserTransactonLookupName; 1090 } 1091 1092 1095 public void setXaUserTransactonLookupName(String xaUserTransactonLookupName) { 1096 this.xaUserTransactonLookupName = xaUserTransactonLookupName; 1097 } 1098 1099 1102 public String getXaJtaSupport() { 1103 return xaJtaSupport; 1104 } 1105 1106 1109 public void setXaJtaSupport(String xaJtaSupport) { 1110 this.xaJtaSupport = xaJtaSupport; 1111 } 1112 1113 1116 public String getDodsCacheFactory() { 1117 return this.dodsCacheFactory; 1118 } 1119 1122 public void setDodsCacheFactory(String dodsCacheFactory) { 1123 this.dodsCacheFactory = dodsCacheFactory; 1124 } 1125} 1126 | Popular Tags |