Source Code Cross Referenced for DataStoreInterfaceFactory.java in  » Content-Management-System » harmonise » org » openharmonise » rm » dsi » 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 » Content Management System » harmonise » org.openharmonise.rm.dsi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.rm.dsi;
020:
021:        import java.util.logging.*;
022:        import java.util.logging.Logger;
023:
024:        import org.openharmonise.commons.dsi.*;
025:        import org.openharmonise.rm.config.ConfigException;
026:
027:        /**
028:         * A factory class which creates new <code>AbstractDataStoreInterface</code>
029:         * instances appropriate to the database available to the current deployment
030:         * of Harmonise.
031:         * 
032:         * @author Michael Bell
033:         * @version $Revision: 1.2 $
034:         *
035:         */
036:        public class DataStoreInterfaceFactory {
037:
038:            /**
039:             * The configuration parameter name for class name for the concrete 
040:             * implementation of <code>AbstractDataStoreInterface</code>
041:             */
042:            public static final String DSI_PNAME = "DSI_CLASS";
043:
044:            /**
045:             * The configuration parameter name associated with the database URI.
046:             */
047:            public static final String DBURL_PNAME = "DB_URL";
048:
049:            /**
050:             * The configuration parameter name associated with the database user name.
051:             */
052:            public static final String DBUSR_PNAME = "DB_USR";
053:
054:            /**
055:             * The configuration parameter name associated with the database password.
056:             */
057:            public static final String DBPWD_PNAME = "DB_PWD";
058:
059:            /**
060:             * The configuration parameter name associated with the JDBC driver class name to be used
061:             * to connect to the database.
062:             */
063:            public static final String DBDRV_PNAME = "DB_DRIVERNAME";
064:
065:            /**
066:             * The cached value of data store interface class name
067:             */
068:            private static String m_dsi_classname = null;
069:
070:            /**
071:             * The cached data store interface
072:             */
073:            private static AbstractDataStoreInterface m_dsi = null;
074:
075:            /**
076:             * Logger for this class
077:             */
078:            private static final Logger m_logger = Logger
079:                    .getLogger(DataStoreInterfaceFactory.class.getName());
080:
081:            /**
082:             * Returns the default data store interface for this deployment of
083:             * Harmonise.
084:             * 
085:             * @return the default data store interface for this deployment of
086:             * Harmonise.
087:             * @throws DataStoreException if there is an error getting the required
088:             * configuration data or instantiating the <code>AbstractDataStoreInterface</code>
089:             */
090:            public static AbstractDataStoreInterface getDataStoreInterface()
091:                    throws DataStoreException {
092:
093:                if (m_dsi == null) {
094:
095:                    String sDriver;
096:                    String sURL;
097:                    String sUsr;
098:                    String sPwd;
099:                    try {
100:                        m_dsi_classname = DatabaseSettings.getInstance()
101:                                .getDsiClass();
102:                        sDriver = DatabaseSettings.getInstance().getDbDriver();
103:                        sURL = DatabaseSettings.getInstance().getDbUrl();
104:                        sUsr = DatabaseSettings.getInstance().getDbUser();
105:                        sPwd = DatabaseSettings.getInstance().getDbPwd();
106:                    } catch (ConfigException e) {
107:                        throw new DataStoreException(e);
108:                    }
109:
110:                    m_dsi = getDataStoreInterface(m_dsi_classname, sDriver,
111:                            sURL, sUsr, sPwd);
112:
113:                }
114:
115:                return m_dsi;
116:            }
117:
118:            /**
119:             * Returns an <code>AbstractDataStoreInterface<code> from the specified
120:             * parameters.
121:             * 
122:             * @param sDSIclass the data store interface class name
123:             * @param sDriver the JDBC driver class name
124:             * @param sURL the database URI
125:             * @param sUsr the database user name
126:             * @param sPwd the database password
127:             * @return  an <code>AbstractDataStoreInterface<code> from the specified
128:             * parameters
129:             * @throws DataStoreException if any of the given parameters are incorrect
130:             */
131:            public static AbstractDataStoreInterface getDataStoreInterface(
132:                    String sDSIclass, String sDriver, String sURL, String sUsr,
133:                    String sPwd) throws DataStoreException {
134:                AbstractDataStoreInterface dbinterf = null;
135:
136:                if (sDSIclass == null) {
137:                    throw new DataStoreException(
138:                            "No datastoreinterface class name found");
139:                }
140:
141:                try {
142:                    Class cls = Class.forName(sDSIclass);
143:
144:                    dbinterf = (AbstractDataStoreInterface) cls.newInstance();
145:
146:                    dbinterf.setDataStoreDetails(sDriver, sURL, sUsr, sPwd);
147:                    dbinterf
148:                            .initialise(AbstractDataStoreInterface.DB_CONNECTION_BROKER);
149:                } catch (Exception e) {
150:                    m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
151:                    throw new DataStoreException(
152:                            "Couldn't create new datastoreinterface");
153:                }
154:
155:                return dbinterf;
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.