KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mchange > v2 > c3p0 > impl > C3P0Defaults


1 /*
2  * Distributed as part of c3p0 v.0.9.1
3  *
4  * Copyright (C) 2005 Machinery For Change, Inc.
5  *
6  * Author: Steve Waldman <swaldman@mchange.com>
7  *
8  * This library is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License version 2.1, as
10  * published by the Free Software Foundation.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this software; see the file LICENSE. If not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */

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 // all public static methods should have the name of a c3p0 config property and
31
// return its default value
32
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; //idle connections never tested
40
private final static int MAX_IDLE_TIME = 0; //seconds, 0 means connections never expire
41
private final static int PROPERTY_CYCLE = 0; //seconds
42
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; //milliseconds
45
private final static int CHECKOUT_TIMEOUT = 0; //milliseconds
46
private final static int MAX_ADMINISTRATIVE_TASK_TIME = 0; //seconds
47
private final static int MAX_IDLE_TIME_EXCESS_CONNECTIONS = 0; //seconds
48
private final static int MAX_CONNECTION_AGE = 0; //seconds
49
private final static int UNRETURNED_CONNECTION_TIMEOUT = 0; //seconds
50

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 JavaDoc AUTOMATIC_TEST_TABLE = null;
64     private final static String JavaDoc CONNECTION_CUSTOMIZER_CLASS_NAME = null;
65     private final static String JavaDoc DRIVER_CLASS = null;
66     private final static String JavaDoc JDBC_URL = null;
67     private final static String JavaDoc OVERRIDE_DEFAULT_USER = null;
68     private final static String JavaDoc OVERRIDE_DEFAULT_PASSWORD = null;
69     private final static String JavaDoc PASSWORD = null;
70     private final static String JavaDoc PREFERRED_TEST_QUERY = null;
71     private final static String JavaDoc FACTORY_CLASS_LOCATION = null;
72     private final static String JavaDoc USER_OVERRIDES_AS_STRING = null;
73     private final static String JavaDoc 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 JavaDoc 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 JavaDoc connectionCustomizerClassName()
136     { return CONNECTION_CUSTOMIZER_CLASS_NAME; }
137
138     public static ConnectionTester connectionTester()
139     { return CONNECTION_TESTER; }
140
141     public static String JavaDoc connectionTesterClassName()
142     { return CONNECTION_TESTER.getClass().getName(); }
143
144     public static String JavaDoc automaticTestTable()
145     { return AUTOMATIC_TEST_TABLE; }
146
147     public static String JavaDoc driverClass()
148     { return DRIVER_CLASS; }
149
150     public static String JavaDoc 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 JavaDoc preferredTestQuery()
178     { return PREFERRED_TEST_QUERY; }
179
180     public static String JavaDoc userOverridesAsString()
181     { return USER_OVERRIDES_AS_STRING; }
182
183     public static String JavaDoc factoryClassLocation()
184     { return FACTORY_CLASS_LOCATION; }
185
186     public static String JavaDoc overrideDefaultUser()
187     { return OVERRIDE_DEFAULT_USER; }
188
189     public static String JavaDoc overrideDefaultPassword()
190     { return OVERRIDE_DEFAULT_PASSWORD; }
191
192     public static String JavaDoc user()
193     { return USER; }
194
195     public static String JavaDoc 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