Source Code Cross Referenced for ProxoolAdapter.java in  » Database-JDBC-Connection-Pool » proxool » org » logicalcobwebs » proxool » 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 » proxool » org.logicalcobwebs.proxool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This software is released under a licence similar to the Apache Software Licence.
003:         * See org.logicalcobwebs.proxool.package.html for details.
004:         * The latest version is available at http://proxool.sourceforge.net
005:         */
006:        package org.logicalcobwebs.proxool;
007:
008:        import org.logicalcobwebs.dbscript.ConnectionAdapterIF;
009:        import org.apache.commons.logging.Log;
010:        import org.apache.commons.logging.LogFactory;
011:
012:        import java.sql.Connection;
013:        import java.sql.DriverManager;
014:        import java.sql.SQLException;
015:        import java.util.Properties;
016:
017:        /**
018:         * Provides Proxool connections to the {@link org.logicalcobwebs.dbscript.ScriptFacade ScriptFacade}
019:         *
020:         * @version $Revision: 1.22 $, $Date: 2006/01/18 14:40:06 $
021:         * @author Bill Horsman (bill@logicalcobwebs.co.uk)
022:         * @author $Author: billhorsman $ (current maintainer)
023:         * @since Proxool 0.5
024:         */
025:        public class ProxoolAdapter implements  ConnectionAdapterIF,
026:                ConfigurationListenerIF {
027:
028:            private static final Log LOG = LogFactory
029:                    .getLog(ProxoolAdapter.class);
030:
031:            private String alias = String.valueOf(hashCode());
032:
033:            private String fullUrl;
034:
035:            private Properties changedInfo;
036:
037:            private Properties completeInfo;
038:
039:            /**
040:             * Use this constructor if you want to define the alias
041:             * @param alias the alias of the pool
042:             */
043:            public ProxoolAdapter(String alias) {
044:                this .alias = alias;
045:            }
046:
047:            /**
048:             * Default constructor. Will use the hashCode as the alias for the pool
049:             */
050:            public ProxoolAdapter() {
051:            }
052:
053:            public void definitionUpdated(
054:                    ConnectionPoolDefinitionIF connectionPoolDefinition,
055:                    Properties completeInfo, Properties changedInfo) {
056:                setCompleteInfo(completeInfo);
057:                setChangedInfo(changedInfo);
058:                LOG.debug("Definition updated "
059:                        + connectionPoolDefinition.getCompleteUrl());
060:                if (changedInfo != null && changedInfo.size() > 0) {
061:                    LOG.debug(changedInfo.size() + " properties updated");
062:                } else {
063:                    LOG.debug("No properties updated");
064:                }
065:            }
066:
067:            public Properties getChangedInfo() {
068:                return changedInfo;
069:            }
070:
071:            public void setChangedInfo(Properties changedInfo) {
072:                this .changedInfo = changedInfo;
073:            }
074:
075:            public Properties getCompleteInfo() {
076:                return completeInfo;
077:            }
078:
079:            public void setCompleteInfo(Properties completeInfo) {
080:                this .completeInfo = completeInfo;
081:            }
082:
083:            public String getName() {
084:                return "proxool";
085:            }
086:
087:            public void update(Properties info) throws SQLException,
088:                    ProxoolException {
089:                ProxoolFacade.updateConnectionPool(getFullUrl(), info);
090:            }
091:
092:            public void update(String url) throws SQLException,
093:                    ProxoolException {
094:                ProxoolFacade.updateConnectionPool(url, null);
095:            }
096:
097:            public void setup(String driver, String url, Properties info)
098:                    throws SQLException, ProxoolException {
099:
100:                try {
101:                    Class.forName(ProxoolDriver.class.getName());
102:                } catch (ClassNotFoundException e) {
103:                    throw new SQLException("Couldn't find " + driver);
104:                }
105:
106:                fullUrl = TestHelper.buildProxoolUrl(alias, driver, url);
107:                ProxoolFacade.registerConnectionPool(fullUrl, info);
108:                ProxoolFacade.addConfigurationListener(alias, this );
109:            }
110:
111:            public Connection getConnection() throws SQLException {
112:                return DriverManager.getConnection(ProxoolConstants.PROXOOL
113:                        + ProxoolConstants.ALIAS_DELIMITER + alias);
114:            }
115:
116:            public String getFullUrl() {
117:                return fullUrl;
118:            }
119:
120:            public void closeConnection(Connection connection)
121:                    throws SQLException {
122:                if (connection != null) {
123:                    connection.close();
124:                }
125:            }
126:
127:            public void tearDown() {
128:                try {
129:                    ProxoolFacade.removeConnectionPool(alias);
130:                } catch (ProxoolException e) {
131:                    LOG.error("Problem tearing down " + alias, e);
132:                }
133:            }
134:
135:        }
136:
137:        /*
138:         Revision history:
139:         $Log: ProxoolAdapter.java,v $
140:         Revision 1.22  2006/01/18 14:40:06  billhorsman
141:         Unbundled Jakarta's Commons Logging.
142:
143:         Revision 1.21  2003/03/04 10:24:40  billhorsman
144:         removed try blocks around each test
145:
146:         Revision 1.20  2003/03/03 11:12:04  billhorsman
147:         fixed licence
148:
149:         Revision 1.19  2003/03/01 15:27:24  billhorsman
150:         checkstyle
151:
152:         Revision 1.18  2003/02/26 16:05:49  billhorsman
153:         widespread changes caused by refactoring the way we
154:         update and redefine pool definitions.
155:
156:         Revision 1.17  2003/02/19 15:14:24  billhorsman
157:         fixed copyright (copy and paste error,
158:         not copyright change)
159:
160:         Revision 1.16  2003/02/07 10:09:58  billhorsman
161:         removed connectionPoolDefinition property. not needed.
162:
163:         Revision 1.15  2003/02/06 17:41:03  billhorsman
164:         now uses imported logging
165:
166:         Revision 1.14  2003/01/23 11:13:40  billhorsman
167:         use new setConfiguratorListener method
168:
169:         Revision 1.13  2003/01/18 15:13:13  billhorsman
170:         Signature changes (new ProxoolException
171:         thrown) on the ProxoolFacade API.
172:
173:         Revision 1.12  2003/01/17 00:38:12  billhorsman
174:         wide ranging changes to clarify use of alias and url -
175:         this has led to some signature changes (new exceptions
176:         thrown) on the ProxoolFacade API.
177:
178:         Revision 1.11  2002/12/16 16:41:59  billhorsman
179:         allow URL updates to pool
180:
181:         Revision 1.10  2002/12/12 10:49:43  billhorsman
182:         now includes properties in definitionChanged event
183:
184:         Revision 1.9  2002/12/04 13:20:10  billhorsman
185:         ConfigurationListenerIF test
186:
187:         Revision 1.8  2002/11/13 20:23:38  billhorsman
188:         change method name, throw exceptions differently, trivial changes
189:
190:         Revision 1.7  2002/11/09 16:09:06  billhorsman
191:         checkstyle
192:
193:         Revision 1.6  2002/11/09 16:02:05  billhorsman
194:         fix doc
195:
196:         Revision 1.5  2002/11/09 14:45:35  billhorsman
197:         only close connection if it is open
198:
199:         Revision 1.4  2002/11/07 18:56:59  billhorsman
200:         allow explicit definition of alias
201:
202:         Revision 1.3  2002/11/02 14:22:16  billhorsman
203:         Documentation
204:
205:         Revision 1.2  2002/11/02 12:46:42  billhorsman
206:         improved debug
207:
208:         Revision 1.1  2002/11/02 11:37:48  billhorsman
209:         New tests
210:
211:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.