Source Code Cross Referenced for C3P0PooledDataSource.java in  » Database-JDBC-Connection-Pool » c3p0 » com » mchange » v2 » c3p0 » mbean » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » c3p0 » com.mchange.v2.c3p0.mbean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Distributed as part of c3p0 v.0.9.1.2
003:         *
004:         * Copyright (C) 2005 Machinery For Change, Inc.
005:         *
006:         * Author: Steve Waldman <swaldman@mchange.com>
007:         *
008:         * This library is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU Lesser General Public License version 2.1, as 
010:         * published by the Free Software Foundation.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public License
018:         * along with this software; see the file LICENSE.  If not, write to the
019:         * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020:         * Boston, MA 02111-1307, USA.
021:         */
022:
023:        package com.mchange.v2.c3p0.mbean;
024:
025:        import com.mchange.v2.c3p0.*;
026:        import com.mchange.v2.log.*;
027:        import java.beans.PropertyVetoException;
028:        import java.sql.Connection;
029:        import java.sql.SQLException;
030:        import java.io.PrintWriter;
031:        import java.util.Properties;
032:        import javax.sql.DataSource;
033:        import javax.naming.InitialContext;
034:        import javax.naming.Name;
035:        import javax.naming.Context;
036:        import javax.naming.NameAlreadyBoundException;
037:        import javax.naming.NamingException;
038:
039:        /**
040:         * @deprecated Please use com.mchange.v2.c3p0.jboss.C3P0PooledDataSource
041:         */
042:        public class C3P0PooledDataSource implements  C3P0PooledDataSourceMBean {
043:            private final static MLogger logger = MLog
044:                    .getLogger(C3P0PooledDataSource.class);
045:
046:            String jndiName;
047:
048:            ComboPooledDataSource combods = new ComboPooledDataSource();
049:
050:            private void rebind() throws NamingException {
051:                rebind(null);
052:            }
053:
054:            private void rebind(String unbindName) throws NamingException {
055:                InitialContext ictx = new InitialContext();
056:                if (unbindName != null)
057:                    ictx.unbind(unbindName);
058:
059:                if (jndiName != null) {
060:                    // Thanks to David D. Kilzer for this code to auto-create
061:                    // subcontext paths!
062:                    Name name = ictx.getNameParser(jndiName).parse(jndiName);
063:                    Context ctx = ictx;
064:                    for (int i = 0, max = name.size() - 1; i < max; i++) {
065:                        try {
066:                            ctx = ctx.createSubcontext(name.get(i));
067:                        } catch (NameAlreadyBoundException ignore) {
068:                            ctx = (Context) ctx.lookup(name.get(i));
069:                        }
070:                    }
071:
072:                    ictx.rebind(jndiName, combods);
073:                }
074:
075:            }
076:
077:            // Jndi Setup Names
078:            public void setJndiName(String jndiName) throws NamingException {
079:                String unbindName = this .jndiName;
080:                this .jndiName = jndiName;
081:                rebind(unbindName);
082:            }
083:
084:            public String getJndiName() {
085:                return jndiName;
086:            }
087:
088:            // DriverManagerDataSourceProperties  (count: 4)
089:            public String getDescription() {
090:                return combods.getDescription();
091:            }
092:
093:            public void setDescription(String description)
094:                    throws NamingException {
095:                combods.setDescription(description);
096:                rebind();
097:            }
098:
099:            public String getDriverClass() {
100:                return combods.getDriverClass();
101:            }
102:
103:            public void setDriverClass(String driverClass)
104:                    throws PropertyVetoException, NamingException {
105:                combods.setDriverClass(driverClass);
106:                rebind();
107:            }
108:
109:            public String getJdbcUrl() {
110:                return combods.getJdbcUrl();
111:            }
112:
113:            public void setJdbcUrl(String jdbcUrl) throws NamingException {
114:                combods.setJdbcUrl(jdbcUrl);
115:                rebind();
116:            }
117:
118:            // DriverManagerDataSource "virtual properties" based on properties
119:            public String getUser() {
120:                return combods.getUser();
121:            }
122:
123:            public void setUser(String user) throws NamingException {
124:                combods.setUser(user);
125:                rebind();
126:            }
127:
128:            public String getPassword() {
129:                return combods.getPassword();
130:            }
131:
132:            public void setPassword(String password) throws NamingException {
133:                combods.setPassword(password);
134:                rebind();
135:            }
136:
137:            // WrapperConnectionPoolDataSource properties (count: 21)
138:            public int getCheckoutTimeout() {
139:                return combods.getCheckoutTimeout();
140:            }
141:
142:            public void setCheckoutTimeout(int checkoutTimeout)
143:                    throws NamingException {
144:                combods.setCheckoutTimeout(checkoutTimeout);
145:                rebind();
146:            }
147:
148:            public int getAcquireIncrement() {
149:                return combods.getAcquireIncrement();
150:            }
151:
152:            public void setAcquireIncrement(int acquireIncrement)
153:                    throws NamingException {
154:                combods.setAcquireIncrement(acquireIncrement);
155:                rebind();
156:            }
157:
158:            public int getAcquireRetryAttempts() {
159:                return combods.getAcquireRetryAttempts();
160:            }
161:
162:            public void setAcquireRetryAttempts(int acquireRetryAttempts)
163:                    throws NamingException {
164:                combods.setAcquireRetryAttempts(acquireRetryAttempts);
165:                rebind();
166:            }
167:
168:            public int getAcquireRetryDelay() {
169:                return combods.getAcquireRetryDelay();
170:            }
171:
172:            public void setAcquireRetryDelay(int acquireRetryDelay)
173:                    throws NamingException {
174:                combods.setAcquireRetryDelay(acquireRetryDelay);
175:                rebind();
176:            }
177:
178:            public boolean isAutoCommitOnClose() {
179:                return combods.isAutoCommitOnClose();
180:            }
181:
182:            public void setAutoCommitOnClose(boolean autoCommitOnClose)
183:                    throws NamingException {
184:                combods.setAutoCommitOnClose(autoCommitOnClose);
185:                rebind();
186:            }
187:
188:            public String getConnectionTesterClassName() {
189:                return combods.getConnectionTesterClassName();
190:            }
191:
192:            public void setConnectionTesterClassName(
193:                    String connectionTesterClassName)
194:                    throws PropertyVetoException, NamingException {
195:                combods.setConnectionTesterClassName(connectionTesterClassName);
196:                rebind();
197:            }
198:
199:            public String getAutomaticTestTable() {
200:                return combods.getAutomaticTestTable();
201:            }
202:
203:            public void setAutomaticTestTable(String automaticTestTable)
204:                    throws NamingException {
205:                combods.setAutomaticTestTable(automaticTestTable);
206:                rebind();
207:            }
208:
209:            public boolean isForceIgnoreUnresolvedTransactions() {
210:                return combods.isForceIgnoreUnresolvedTransactions();
211:            }
212:
213:            public void setForceIgnoreUnresolvedTransactions(
214:                    boolean forceIgnoreUnresolvedTransactions)
215:                    throws NamingException {
216:                combods
217:                        .setForceIgnoreUnresolvedTransactions(forceIgnoreUnresolvedTransactions);
218:                rebind();
219:            }
220:
221:            public int getIdleConnectionTestPeriod() {
222:                return combods.getIdleConnectionTestPeriod();
223:            }
224:
225:            public void setIdleConnectionTestPeriod(int idleConnectionTestPeriod)
226:                    throws NamingException {
227:                combods.setIdleConnectionTestPeriod(idleConnectionTestPeriod);
228:                rebind();
229:            }
230:
231:            public int getInitialPoolSize() {
232:                return combods.getInitialPoolSize();
233:            }
234:
235:            public void setInitialPoolSize(int initialPoolSize)
236:                    throws NamingException {
237:                combods.setInitialPoolSize(initialPoolSize);
238:                rebind();
239:            }
240:
241:            public int getMaxIdleTime() {
242:                return combods.getMaxIdleTime();
243:            }
244:
245:            public void setMaxIdleTime(int maxIdleTime) throws NamingException {
246:                combods.setMaxIdleTime(maxIdleTime);
247:                rebind();
248:            }
249:
250:            public int getMaxPoolSize() {
251:                return combods.getMaxPoolSize();
252:            }
253:
254:            public void setMaxPoolSize(int maxPoolSize) throws NamingException {
255:                combods.setMaxPoolSize(maxPoolSize);
256:                rebind();
257:            }
258:
259:            public int getMaxStatements() {
260:                return combods.getMaxStatements();
261:            }
262:
263:            public void setMaxStatements(int maxStatements)
264:                    throws NamingException {
265:                combods.setMaxStatements(maxStatements);
266:                rebind();
267:            }
268:
269:            public int getMaxStatementsPerConnection() {
270:                return combods.getMaxStatementsPerConnection();
271:            }
272:
273:            public void setMaxStatementsPerConnection(
274:                    int maxStatementsPerConnection) throws NamingException {
275:                combods
276:                        .setMaxStatementsPerConnection(maxStatementsPerConnection);
277:                rebind();
278:            }
279:
280:            public int getMinPoolSize() {
281:                return combods.getMinPoolSize();
282:            }
283:
284:            public void setMinPoolSize(int minPoolSize) throws NamingException {
285:                combods.setMinPoolSize(minPoolSize);
286:                rebind();
287:            }
288:
289:            public int getPropertyCycle() {
290:                return combods.getPropertyCycle();
291:            }
292:
293:            public void setPropertyCycle(int propertyCycle)
294:                    throws NamingException {
295:                combods.setPropertyCycle(propertyCycle);
296:                rebind();
297:            }
298:
299:            public boolean isBreakAfterAcquireFailure() {
300:                return combods.isBreakAfterAcquireFailure();
301:            }
302:
303:            public void setBreakAfterAcquireFailure(
304:                    boolean breakAfterAcquireFailure) throws NamingException {
305:                combods.setBreakAfterAcquireFailure(breakAfterAcquireFailure);
306:                rebind();
307:            }
308:
309:            public boolean isTestConnectionOnCheckout() {
310:                return combods.isTestConnectionOnCheckout();
311:            }
312:
313:            public void setTestConnectionOnCheckout(
314:                    boolean testConnectionOnCheckout) throws NamingException {
315:                combods.setTestConnectionOnCheckout(testConnectionOnCheckout);
316:                rebind();
317:            }
318:
319:            public boolean isTestConnectionOnCheckin() {
320:                return combods.isTestConnectionOnCheckin();
321:            }
322:
323:            public void setTestConnectionOnCheckin(
324:                    boolean testConnectionOnCheckin) throws NamingException {
325:                combods.setTestConnectionOnCheckin(testConnectionOnCheckin);
326:                rebind();
327:            }
328:
329:            public boolean isUsesTraditionalReflectiveProxies() {
330:                return combods.isUsesTraditionalReflectiveProxies();
331:            }
332:
333:            public void setUsesTraditionalReflectiveProxies(
334:                    boolean usesTraditionalReflectiveProxies)
335:                    throws NamingException {
336:                combods
337:                        .setUsesTraditionalReflectiveProxies(usesTraditionalReflectiveProxies);
338:                rebind();
339:            }
340:
341:            public String getPreferredTestQuery() {
342:                return combods.getPreferredTestQuery();
343:            }
344:
345:            public void setPreferredTestQuery(String preferredTestQuery)
346:                    throws NamingException {
347:                combods.setPreferredTestQuery(preferredTestQuery);
348:                rebind();
349:            }
350:
351:            // PoolBackedDataSource properties (count: 2)
352:            public String getDataSourceName() {
353:                return combods.getDataSourceName();
354:            }
355:
356:            public void setDataSourceName(String name) throws NamingException {
357:                combods.setDataSourceName(name);
358:                rebind();
359:            }
360:
361:            public int getNumHelperThreads() {
362:                return combods.getNumHelperThreads();
363:            }
364:
365:            public void setNumHelperThreads(int numHelperThreads)
366:                    throws NamingException {
367:                combods.setNumHelperThreads(numHelperThreads);
368:                rebind();
369:            }
370:
371:            // shared properties (count: 1)
372:            public String getFactoryClassLocation() {
373:                return combods.getFactoryClassLocation();
374:            }
375:
376:            public void setFactoryClassLocation(String factoryClassLocation)
377:                    throws NamingException {
378:                combods.setFactoryClassLocation(factoryClassLocation);
379:                rebind();
380:            }
381:
382:            // PooledDataSource statistics
383:
384:            public int getNumUserPools() throws SQLException {
385:                return combods.getNumUserPools();
386:            }
387:
388:            public int getNumConnectionsDefaultUser() throws SQLException {
389:                return combods.getNumConnectionsDefaultUser();
390:            }
391:
392:            public int getNumIdleConnectionsDefaultUser() throws SQLException {
393:                return combods.getNumIdleConnectionsDefaultUser();
394:            }
395:
396:            public int getNumBusyConnectionsDefaultUser() throws SQLException {
397:                return combods.getNumBusyConnectionsDefaultUser();
398:            }
399:
400:            public int getNumUnclosedOrphanedConnectionsDefaultUser()
401:                    throws SQLException {
402:                return combods.getNumUnclosedOrphanedConnectionsDefaultUser();
403:            }
404:
405:            public int getNumConnections(String username, String password)
406:                    throws SQLException {
407:                return combods.getNumConnections(username, password);
408:            }
409:
410:            public int getNumIdleConnections(String username, String password)
411:                    throws SQLException {
412:                return combods.getNumIdleConnections(username, password);
413:            }
414:
415:            public int getNumBusyConnections(String username, String password)
416:                    throws SQLException {
417:                return combods.getNumBusyConnections(username, password);
418:            }
419:
420:            public int getNumUnclosedOrphanedConnections(String username,
421:                    String password) throws SQLException {
422:                return combods.getNumUnclosedOrphanedConnections(username,
423:                        password);
424:            }
425:
426:            public int getNumConnectionsAllUsers() throws SQLException {
427:                return combods.getNumConnectionsAllUsers();
428:            }
429:
430:            public int getNumIdleConnectionsAllUsers() throws SQLException {
431:                return combods.getNumIdleConnectionsAllUsers();
432:            }
433:
434:            public int getNumBusyConnectionsAllUsers() throws SQLException {
435:                return combods.getNumBusyConnectionsAllUsers();
436:            }
437:
438:            public int getNumUnclosedOrphanedConnectionsAllUsers()
439:                    throws SQLException {
440:                return combods.getNumUnclosedOrphanedConnectionsAllUsers();
441:            }
442:
443:            // PooledDataSource operations
444:            public void softResetDefaultUser() throws SQLException {
445:                combods.softResetDefaultUser();
446:            }
447:
448:            public void softReset(String username, String password)
449:                    throws SQLException {
450:                combods.softReset(username, password);
451:            }
452:
453:            public void softResetAllUsers() throws SQLException {
454:                combods.softResetAllUsers();
455:            }
456:
457:            public void hardReset() throws SQLException {
458:                combods.hardReset();
459:            }
460:
461:            public void close() throws SQLException {
462:                combods.close();
463:            }
464:
465:            //JBoss only... (but these methods need not be called for the mbean to work)
466:            public void create() throws Exception {
467:            }
468:
469:            // the mbean works without this, but if called we start populating the pool early
470:            public void start() throws Exception {
471:                //System.err.println("Bound C3P0 PooledDataSource to name '" + jndiName + "'. Starting..."); 
472:                logger
473:                        .log(
474:                                MLevel.INFO,
475:                                "Bound C3P0 PooledDataSource to name ''{0}''. Starting...",
476:                                jndiName);
477:                combods.getNumBusyConnectionsDefaultUser(); //just touch the datasource to start it up.
478:            }
479:
480:            public void stop() {
481:            }
482:
483:            public void destroy() {
484:            }
485:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.