Source Code Cross Referenced for ConnectionInfo.java in  » Database-ORM » XORM » org » xorm » datastore » 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 ORM » XORM » org.xorm.datastore 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            $Header: /cvsroot/xorm/xorm/src/org/xorm/datastore/ConnectionInfo.java,v 1.8 2003/09/26 20:23:54 wbiggs Exp $
003:
004:            This file is part of XORM.
005:
006:            XORM is free software; you can redistribute it and/or modify
007:            it under the terms of the GNU General Public License as published by
008:            the Free Software Foundation; either version 2 of the License, or
009:            (at your option) any later version.
010:
011:            XORM is distributed in the hope that it will be useful,
012:            but WITHOUT ANY WARRANTY; without even the implied warranty of
013:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:            GNU General Public License for more details.
015:
016:            You should have received a copy of the GNU General Public License
017:            along with XORM; if not, write to the Free Software
018:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:        package org.xorm.datastore;
021:
022:        import java.util.Properties;
023:        import java.util.Iterator;
024:        import java.util.Map;
025:
026:        import javax.jdo.JDOFatalUserException;
027:
028:        import javax.naming.InitialContext;
029:
030:        import org.xorm.Configurable;
031:        import org.xorm.InterfaceManagerFactory;
032:
033:        /**
034:         * This is the base class for connection information.  A ConnectionInfo
035:         * object is used to acquire a DatastoreDriver instance.  The attributes
036:         * of this class may or may not be useful to subclasses, but they reflect
037:         * the configuration detail that is standard in JDO.
038:         */
039:        public abstract class ConnectionInfo implements  Configurable {
040:            protected String connectionUserName;
041:            protected String connectionPassword;
042:            protected String connectionURL;
043:            protected String connectionDriverName;
044:            protected String connectionFactoryName;
045:            protected String connectionFactory2Name;
046:
047:            protected Object connectionFactory;
048:            protected Object connectionFactory2;
049:
050:            protected int minPool;
051:            protected int maxPool;
052:            protected int msWait;
053:
054:            protected Properties properties;
055:            protected InterfaceManagerFactory factory;
056:
057:            public void setFactory(InterfaceManagerFactory factory) {
058:                this .factory = factory;
059:            }
060:
061:            public Properties getProperties() {
062:                return properties;
063:            }
064:
065:            public void setProperties(Properties properties) {
066:                this .properties = properties;
067:
068:                // iterate through properties
069:                Iterator i = properties.entrySet().iterator();
070:                while (i.hasNext()) {
071:                    Map.Entry entry = (Map.Entry) i.next();
072:                    String key = (String) entry.getKey();
073:                    String value = (String) entry.getValue();
074:                    if ("javax.jdo.option.ConnectionURL".equals(key)) {
075:                        setConnectionURL(value);
076:                    } else if ("javax.jdo.option.ConnectionUserName"
077:                            .equals(key)) {
078:                        setConnectionUserName(value);
079:                    } else if ("javax.jdo.option.ConnectionPassword"
080:                            .equals(key)) {
081:                        setConnectionPassword(value);
082:                    } else if ("javax.jdo.option.ConnectionDriverName"
083:                            .equals(key)) {
084:                        setConnectionDriverName(value);
085:                    } else if ("javax.jdo.option.ConnectionFactoryName"
086:                            .equals(key)) {
087:                        setConnectionFactoryName(value);
088:                    } else if ("javax.jdo.option.ConnectionFactory2Name"
089:                            .equals(key)) {
090:                        setConnectionFactory2Name(value);
091:                    } else if ("javax.jdo.option.MinPool".equals(key)) {
092:                        setMinPool(Integer.parseInt(value));
093:                    } else if ("javax.jdo.option.MaxPool".equals(key)) {
094:                        setMaxPool(Integer.parseInt(value));
095:                    }
096:                }
097:            }
098:
099:            public void setConnectionUserName(String s) {
100:                connectionUserName = s;
101:            }
102:
103:            public String getConnectionUserName() {
104:                return connectionUserName;
105:            }
106:
107:            public void setConnectionPassword(String s) {
108:                connectionPassword = s;
109:            }
110:
111:            public void setConnectionURL(String s) {
112:                connectionURL = s;
113:            }
114:
115:            public String getConnectionURL() {
116:                return connectionURL;
117:            }
118:
119:            public void setConnectionDriverName(String s) {
120:                connectionDriverName = s;
121:            }
122:
123:            public String getConnectionDriverName() {
124:                return connectionDriverName;
125:            }
126:
127:            public int getMaxPool() {
128:                return maxPool;
129:            }
130:
131:            public void setMaxPool(int i) {
132:                maxPool = i;
133:            }
134:
135:            public int getMinPool() {
136:                return minPool;
137:            }
138:
139:            public void setMinPool(int i) {
140:                minPool = i;
141:            }
142:
143:            public int getMsWait() {
144:                return msWait;
145:            }
146:
147:            public void setMsWait(int i) {
148:                msWait = i;
149:            }
150:
151:            public void setConnectionFactoryName(String s) {
152:                connectionFactoryName = s;
153:                connectionFactory = resolveJNDI(s);
154:            }
155:
156:            public String getConnectionFactoryName() {
157:                return connectionFactoryName;
158:            }
159:
160:            public void setConnectionFactory(Object o) {
161:                connectionFactory = o;
162:            }
163:
164:            public Object getConnectionFactory() {
165:                return connectionFactory;
166:            }
167:
168:            public void setConnectionFactory2Name(String s) {
169:                connectionFactory2Name = s;
170:                connectionFactory2 = resolveJNDI(s);
171:            }
172:
173:            public String getConnectionFactory2Name() {
174:                return connectionFactory2Name;
175:            }
176:
177:            public void setConnectionFactory2(Object o) {
178:                connectionFactory2 = o;
179:            }
180:
181:            public Object getConnectionFactory2() {
182:                return connectionFactory2;
183:            }
184:
185:            public static Object resolveJNDI(String name) {
186:                try {
187:                    InitialContext initCtx = new InitialContext();
188:                    return initCtx.lookup(name);
189:                } catch (Exception e) {
190:                    throw new JDOFatalUserException("Cannot resolve JNDI name "
191:                            + name, e);
192:                }
193:            }
194:
195:            /**
196:             * Returns a new DatastoreDriver that interacts with the datastore
197:             * described by this ConnectionInfo object.  This method must
198:             * be implemented by subclasses.
199:             */
200:            public abstract DatastoreDriver getDriver();
201:
202:            public Table describeTable(String tableName) {
203:                throw new JDOFatalUserException(
204:                        "No driver support for runtime metadata");
205:            }
206:
207:            /** Release resources.  Default implementation of this does nothing. */
208:            public void close() {
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.