1 22 23 24 package com.mchange.v2.c3p0.impl; 25 26 import java.lang.reflect.*; 27 import java.util.*; 28 import com.mchange.v2.c3p0.ConnectionTester; 29 30 public final class C3P0Defaults 33 { 34 private final static int MAX_STATEMENTS = 0; 35 private final static int MAX_STATEMENTS_PER_CONNECTION = 0; 36 private final static int INITIAL_POOL_SIZE = 3; 37 private final static int MIN_POOL_SIZE = 3; 38 private final static int MAX_POOL_SIZE = 15; 39 private final static int IDLE_CONNECTION_TEST_PERIOD = 0; private final static int MAX_IDLE_TIME = 0; private final static int PROPERTY_CYCLE = 0; private final static int ACQUIRE_INCREMENT = 3; 43 private final static int ACQUIRE_RETRY_ATTEMPTS = 30; 44 private final static int ACQUIRE_RETRY_DELAY = 1000; private final static int CHECKOUT_TIMEOUT = 0; private final static int MAX_ADMINISTRATIVE_TASK_TIME = 0; private final static int MAX_IDLE_TIME_EXCESS_CONNECTIONS = 0; private final static int MAX_CONNECTION_AGE = 0; private final static int UNRETURNED_CONNECTION_TIMEOUT = 0; 51 private final static boolean BREAK_AFTER_ACQUIRE_FAILURE = false; 52 private final static boolean TEST_CONNECTION_ON_CHECKOUT = false; 53 private final static boolean TEST_CONNECTION_ON_CHECKIN = false; 54 private final static boolean AUTO_COMMIT_ON_CLOSE = false; 55 private final static boolean FORCE_IGNORE_UNRESOLVED_TXNS = false; 56 private final static boolean USES_TRADITIONAL_REFLECTIVE_PROXIES = false; 57 private final static boolean DEBUG_UNRETURNED_CONNECTION_STACK_TRACES = false; 58 59 private final static ConnectionTester CONNECTION_TESTER = new DefaultConnectionTester(); 60 61 private final static int NUM_HELPER_THREADS = 3; 62 63 private final static String AUTOMATIC_TEST_TABLE = null; 64 private final static String CONNECTION_CUSTOMIZER_CLASS_NAME = null; 65 private final static String DRIVER_CLASS = null; 66 private final static String JDBC_URL = null; 67 private final static String OVERRIDE_DEFAULT_USER = null; 68 private final static String OVERRIDE_DEFAULT_PASSWORD = null; 69 private final static String PASSWORD = null; 70 private final static String PREFERRED_TEST_QUERY = null; 71 private final static String FACTORY_CLASS_LOCATION = null; 72 private final static String USER_OVERRIDES_AS_STRING = null; 73 private final static String USER = null; 74 75 private static Set KNOWN_PROPERTIES; 76 77 static 78 { 79 Method[] methods = C3P0Defaults.class.getMethods(); 80 Set s = new HashSet(); 81 for (int i = 0, len = methods.length; i < len; ++i) 82 { 83 Method m = methods[i]; 84 if (Modifier.isStatic( m.getModifiers() ) && m.getParameterTypes().length == 0) 85 s.add( m.getName() ); 86 } 87 KNOWN_PROPERTIES = Collections.unmodifiableSet( s ); 88 } 89 90 public static Set getKnownProperties() 91 { return KNOWN_PROPERTIES; } 92 93 public static boolean isKnownProperty( String s ) 94 { return KNOWN_PROPERTIES.contains( s ); } 95 96 public static int maxStatements() 97 { return MAX_STATEMENTS; } 98 99 public static int maxStatementsPerConnection() 100 { return MAX_STATEMENTS_PER_CONNECTION; } 101 102 public static int initialPoolSize() 103 { return INITIAL_POOL_SIZE; } 104 105 public static int minPoolSize() 106 { return MIN_POOL_SIZE; } 107 108 public static int maxPoolSize() 109 { return MAX_POOL_SIZE; } 110 111 public static int idleConnectionTestPeriod() 112 { return IDLE_CONNECTION_TEST_PERIOD; } 113 114 public static int maxIdleTime() 115 { return MAX_IDLE_TIME; } 116 117 public static int unreturnedConnectionTimeout() 118 { return UNRETURNED_CONNECTION_TIMEOUT; } 119 120 public static int propertyCycle() 121 { return PROPERTY_CYCLE; } 122 123 public static int acquireIncrement() 124 { return ACQUIRE_INCREMENT; } 125 126 public static int acquireRetryAttempts() 127 { return ACQUIRE_RETRY_ATTEMPTS; } 128 129 public static int acquireRetryDelay() 130 { return ACQUIRE_RETRY_DELAY; } 131 132 public static int checkoutTimeout() 133 { return CHECKOUT_TIMEOUT; } 134 135 public static String connectionCustomizerClassName() 136 { return CONNECTION_CUSTOMIZER_CLASS_NAME; } 137 138 public static ConnectionTester connectionTester() 139 { return CONNECTION_TESTER; } 140 141 public static String connectionTesterClassName() 142 { return CONNECTION_TESTER.getClass().getName(); } 143 144 public static String automaticTestTable() 145 { return AUTOMATIC_TEST_TABLE; } 146 147 public static String driverClass() 148 { return DRIVER_CLASS; } 149 150 public static String jdbcUrl() 151 { return JDBC_URL; } 152 153 public static int numHelperThreads() 154 { return NUM_HELPER_THREADS; } 155 156 public static boolean breakAfterAcquireFailure() 157 { return BREAK_AFTER_ACQUIRE_FAILURE; } 158 159 public static boolean testConnectionOnCheckout() 160 { return TEST_CONNECTION_ON_CHECKOUT; } 161 162 public static boolean testConnectionOnCheckin() 163 { return TEST_CONNECTION_ON_CHECKIN; } 164 165 public static boolean autoCommitOnClose() 166 { return AUTO_COMMIT_ON_CLOSE; } 167 168 public static boolean forceIgnoreUnresolvedTransactions() 169 { return FORCE_IGNORE_UNRESOLVED_TXNS; } 170 171 public static boolean debugUnreturnedConnectionStackTraces() 172 { return DEBUG_UNRETURNED_CONNECTION_STACK_TRACES; } 173 174 public static boolean usesTraditionalReflectiveProxies() 175 { return USES_TRADITIONAL_REFLECTIVE_PROXIES; } 176 177 public static String preferredTestQuery() 178 { return PREFERRED_TEST_QUERY; } 179 180 public static String userOverridesAsString() 181 { return USER_OVERRIDES_AS_STRING; } 182 183 public static String factoryClassLocation() 184 { return FACTORY_CLASS_LOCATION; } 185 186 public static String overrideDefaultUser() 187 { return OVERRIDE_DEFAULT_USER; } 188 189 public static String overrideDefaultPassword() 190 { return OVERRIDE_DEFAULT_PASSWORD; } 191 192 public static String user() 193 { return USER; } 194 195 public static String password() 196 { return PASSWORD; } 197 198 public static int maxAdministrativeTaskTime() 199 { return MAX_ADMINISTRATIVE_TASK_TIME; } 200 201 public static int maxIdleTimeExcessConnections() 202 { return MAX_IDLE_TIME_EXCESS_CONNECTIONS; } 203 204 public static int maxConnectionAge() 205 { return MAX_CONNECTION_AGE; } 206 } 207 208 | Popular Tags |