Source Code Cross Referenced for CoreDataSource.java in  » Database-JDBC-Connection-Pool » xapool » org » enhydra » jdbc » core » 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 » xapool » org.enhydra.jdbc.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * XAPool: Open Source XA JDBC Pool
003:         * Copyright (C) 2003 Objectweb.org
004:         * Initial Developer: Lutris Technologies Inc.
005:         * Contact: xapool-public@lists.debian-sf.objectweb.org
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or any later version.
011:         *
012:         * This library 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 GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
020:         * USA
021:         */
022:        package org.enhydra.jdbc.core;
023:
024:        import org.enhydra.jdbc.util.Logger;
025:        import org.enhydra.jdbc.util.JdbcUtil;
026:
027:        import java.io.Serializable;
028:        import java.io.PrintWriter;
029:        import java.util.Hashtable;
030:        import javax.naming.Context;
031:        import javax.naming.Name;
032:        import javax.naming.NamingException;
033:        import javax.naming.Reference;
034:        import javax.naming.Referenceable;
035:        import javax.naming.StringRefAddr;
036:        import javax.naming.spi.ObjectFactory;
037:
038:        /**
039:         * Provides a Data Source which can be used to generate JDBC connections.
040:         * <P>
041:         * This class is generic in the sense that it does not rely upon anything other
042:         * than standard Java APIs. It uses java.sql.DriverManager and preconfigured
043:         * properties to construct a JDBC connection.
044:         */
045:        public class CoreDataSource extends JdbcUtil implements  Referenceable,
046:                ObjectFactory, Serializable {
047:
048:            // Standard Data Source properties
049:            private int loginTimeout; // timeout for database logins
050:            transient public PrintWriter logWriter; // the log writer
051:            public String user; // user for the database
052:            public String password; // password for the database
053:            private String description; // description of the datasource
054:            private boolean debug; // debug flag
055:            private boolean verbose; // verbose flag
056:            private JdbcThreadFactory threadFactory; // thread factory
057:
058:            /**
059:             * Constructor
060:             */
061:            public CoreDataSource() {
062:                loginTimeout = 0; // Default value for loginTimeout
063:                logWriter = null;
064:                user = null;
065:                password = null;
066:                description = null;
067:                debug = false;
068:                verbose = false;
069:                threadFactory = null;
070:            }
071:
072:            /**
073:             * Setter/Getter defined for standard properties
074:             */
075:            public String getDescription() {
076:                return description;
077:            }
078:
079:            public String getPassword() {
080:                return password;
081:            }
082:
083:            public String getUser() {
084:                return user;
085:            }
086:
087:            public JdbcThreadFactory getThreadFactory() {
088:                return threadFactory;
089:            }
090:
091:            public boolean isDebug() {
092:                return debug;
093:            }
094:
095:            public boolean isVerbose() {
096:                return verbose;
097:            }
098:
099:            public void setDescription(String description) {
100:                this .description = description;
101:            }
102:
103:            public void setPassword(String password) {
104:                this .password = password;
105:            }
106:
107:            public void setUser(String user) {
108:                this .user = user;
109:            }
110:
111:            public void setDebug(boolean debug) {
112:                this .debug = debug;
113:            }
114:
115:            public void setVerbose(boolean verbose) {
116:                this .verbose = verbose;
117:            }
118:
119:            public void setThreadFactory(JdbcThreadFactory f) {
120:                this .threadFactory = f;
121:            }
122:
123:            public PrintWriter getLogWriter() {
124:                return log;
125:            }
126:
127:            public void setLogWriter(PrintWriter out) {
128:                log = (Logger) out;
129:            }
130:
131:            /**
132:             * shutdown is a placeholder for datasources which should shut down
133:             * any pools which they maintain.
134:             */
135:            public void shutdown(boolean force) {
136:            }
137:
138:            public void setLoginTimeout(int seconds) {
139:                loginTimeout = seconds;
140:            }
141:
142:            public int getLoginTimeout() {
143:                return loginTimeout;
144:            }
145:
146:            /**
147:             * Methods inherited from referenceable
148:             */
149:            public Reference getReference() throws NamingException {
150:                // Note that we use getClass().getName() to provide the factory
151:                // class name. It is assumed that this class, and all of its
152:                // descendants are their own factories.
153:
154:                Reference ref = new Reference(getClass().getName(), getClass()
155:                        .getName(), null);
156:                ref.add(new StringRefAddr("user", getUser()));
157:                ref.add(new StringRefAddr("password", getPassword()));
158:                ref.add(new StringRefAddr("description", getDescription()));
159:                ref.add(new StringRefAddr("loginTimeout", Integer
160:                        .toString(getLoginTimeout())));
161:                log.debug("CoreDataSource:getReference object returned");
162:                return ref;
163:            }
164:
165:            /**
166:             * Methods inherited from ObjectFactory
167:             */
168:            public Object getObjectInstance(Object refObj, Name name,
169:                    Context nameCtx, Hashtable env) throws Exception {
170:                Reference ref = (Reference) refObj;
171:
172:                this .setUser((String) ref.get("user").getContent());
173:                this .setPassword((String) ref.get("password").getContent());
174:                this .setDescription((String) ref.get("description")
175:                        .getContent());
176:                this .setLoginTimeout(Integer.parseInt((String) ref.get(
177:                        "loginTimeout").getContent()));
178:                log.debug("CoreDataSource:getObjectInstance instance created");
179:                return this ;
180:            }
181:
182:            public String toString() {
183:                StringBuffer sb = new StringBuffer();
184:                sb.append("CoreDataSource :\n");
185:                sb.append("     debug =<" + this .debug + ">\n");
186:                sb.append("     description =<" + this .description + ">\n");
187:                sb.append("     login time out =<" + this .loginTimeout + ">\n");
188:                sb.append("     user =<" + this .user + ">\n");
189:                sb.append("     verbose =<" + this .verbose + ">\n");
190:
191:                return sb.toString();
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.