Source Code Cross Referenced for TransactionProvider.java in  » Web-Framework » makumba » org » makumba » providers » 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 » Web Framework » makumba » org.makumba.providers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.makumba.providers;
002:
003:        import java.util.Enumeration;
004:        import java.util.Properties;
005:
006:        import org.makumba.Transaction;
007:        import org.makumba.commons.ClassResource;
008:        import org.makumba.commons.NamedResourceFactory;
009:        import org.makumba.commons.NamedResources;
010:        import org.makumba.commons.RuntimeWrappedException;
011:
012:        /**
013:         * This class is a facade for creating different kinds of TransactionProviders. Its constructor knows from a
014:         * Configuration (or in the future maybe through other means) which implementation to use, and provides this
015:         * implementation methods to its client, without revealing the implementation used.
016:         * 
017:         * TODO this is not the best way of doing things, needs refactoring (TransactionProvider as superclass for the other guys)
018:
019:         * @author Manuel Gay
020:         * @version $Id: TransactionProvider.java,v 1.1 28.09.2007 15:49:55 Manuel Exp $
021:         */
022:        public class TransactionProvider implements 
023:                TransactionProviderInterface {
024:
025:            private TransactionProviderInterface transactionProviderImplementation;
026:
027:            public TransactionProvider() {
028:                this (new Configuration());
029:            }
030:
031:            public TransactionProvider(TransactionProviderInterface tpi) {
032:                this .transactionProviderImplementation = tpi;
033:            }
034:
035:            public TransactionProvider(Configuration config) {
036:                try {
037:                    this .transactionProviderImplementation = (TransactionProviderInterface) Class
038:                            .forName(config.getTransactionProviderClass())
039:                            .newInstance();
040:                } catch (InstantiationException e) {
041:                    // TODO Auto-generated catch block
042:                    e.printStackTrace();
043:                } catch (IllegalAccessException e) {
044:                    // TODO Auto-generated catch block
045:                    e.printStackTrace();
046:                } catch (ClassNotFoundException e) {
047:                    // TODO Auto-generated catch block
048:                    e.printStackTrace();
049:                }
050:            }
051:
052:            public Transaction getConnectionTo(String name) {
053:                return transactionProviderImplementation.getConnectionTo(name);
054:            }
055:
056:            public String getDefaultDataSourceName() {
057:                return transactionProviderImplementation
058:                        .getDefaultDataSourceName();
059:            }
060:
061:            public String getDatabaseProperty(String name, String propName) {
062:                return transactionProviderImplementation.getDatabaseProperty(
063:                        name, propName);
064:            }
065:
066:            public void _copy(String sourceDB, String destinationDB,
067:                    String[] typeNames, boolean ignoreDbsv) {
068:                transactionProviderImplementation._copy(sourceDB,
069:                        destinationDB, typeNames, ignoreDbsv);
070:            }
071:
072:            public void _delete(String whereDB, String provenienceDB,
073:                    String[] typeNames, boolean ignoreDbsv) {
074:                transactionProviderImplementation._delete(whereDB,
075:                        provenienceDB, typeNames, ignoreDbsv);
076:            }
077:
078:            public String getDataSourceName(String lookupFile) {
079:                return transactionProviderImplementation
080:                        .getDataSourceName(lookupFile);
081:            }
082:
083:            public boolean supportsUTF8() {
084:                return transactionProviderImplementation.supportsUTF8();
085:            }
086:
087:            public CRUDOperationProvider getCRUD() {
088:                return transactionProviderImplementation.getCRUD();
089:            }
090:
091:            public static String findInHostProperties(Properties p, String str) {
092:                for (Enumeration e = p.keys(); e.hasMoreElements();) {
093:                    String s = (String) e.nextElement();
094:                    int i = s.indexOf('#');
095:                    try {
096:                        if ((i == -1 || java.net.InetAddress.getByName(
097:                                s.substring(0, i)).equals(
098:                                java.net.InetAddress.getLocalHost()))
099:                                && str.endsWith(s.substring(i + 1)))
100:                            return p.getProperty(s);
101:                    } catch (java.net.UnknownHostException uhe) {
102:                    }
103:                }
104:                return null;
105:            }
106:
107:            /**
108:             * finds the database name of the server according to the host name and current directory. If none is specified, a
109:             * default is used, if available
110:             */
111:            public static String findDatabaseName(Properties p) {
112:                String userDir = System.getProperty("user.dir");
113:                String n;
114:                java.net.URL u = ClassResource.get("/");
115:                String wbp = u != null ? u.toString() : null;
116:
117:                if ((n = TransactionProvider.findInHostProperties(p, userDir)) != null
118:                        || wbp != null
119:                        && ((n = TransactionProvider.findInHostProperties(p,
120:                                wbp)) != null)
121:                        || (n = TransactionProvider.findInHostProperties(p,
122:                                "default")) != null)
123:
124:                    return n;
125:
126:                return p.getProperty("default");
127:            }
128:
129:            public static String findDatabaseName(String s) {
130:                try {
131:                    return TransactionProvider
132:                            .findDatabaseName((Properties) NamedResources
133:                                    .getStaticCache(TransactionProvider.dbsel)
134:                                    .getResource(s));
135:                } catch (RuntimeWrappedException e) {
136:                    if (e.getCause() instanceof  org.makumba.MakumbaError)
137:                        throw (org.makumba.MakumbaError) e.getCause();
138:                    throw e;
139:                }
140:            }
141:
142:            public static int dbsel = NamedResources.makeStaticCache(
143:                    "Database selection files", new NamedResourceFactory() {
144:
145:                        private static final long serialVersionUID = 1L;
146:
147:                        protected Object makeResource(Object nm) {
148:                            Properties p = new Properties();
149:                            try {
150:                                java.io.InputStream input = org.makumba.commons.ClassResource
151:                                        .get((String) nm).openStream();
152:                                p.load(input);
153:                                input.close();
154:                            } catch (Exception e) {
155:                                throw new org.makumba.ConfigFileError(
156:                                        (String) nm);
157:                            }
158:                            return p;
159:                        }
160:                    });
161:
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.