Source Code Cross Referenced for OjbPlatformConfigurer.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » rice » ojb » 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 » ERP CRM Financial » Kuali Financial System » org.kuali.rice.ojb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation
003:         *
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.opensource.org/licenses/ecl1.php
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        // Created on Oct 11, 2006
017:        package org.kuali.rice.ojb;
018:
019:        import java.util.HashMap;
020:        import java.util.Map;
021:
022:        import org.apache.log4j.Logger;
023:        import org.apache.ojb.broker.PBKey;
024:        import org.apache.ojb.broker.PersistenceBroker;
025:        import org.apache.ojb.broker.PersistenceBrokerFactory;
026:        import org.springframework.beans.factory.InitializingBean;
027:
028:        /**
029:         * Utility class/bean that sets the platform OJB JDBC Connection Descriptors programmatically
030:         * at run time, so that it can be parameterized by Spring/Workflow configuration.
031:         * A map of jcdalias/datasource bean names to OJB platforms is accepted as the 'platforms' propery.
032:         * An empty key, or "DEFAULT" key is interpreted as specifying the default PersistenceBroker/jcdalias
033:         * @author Kuali Rice Team (kuali-rice@googlegroups.com)
034:         */
035:        public class OjbPlatformConfigurer implements  InitializingBean {
036:            private static final Logger LOG = Logger
037:                    .getLogger(OjbPlatformConfigurer.class);
038:
039:            /**
040:             * Literal to accept as specifying the "default" PersistenceBroker/jcdalias
041:             */
042:            private static final String DEFAULT = "DEFAULT";
043:
044:            private Map<String, String> dsToPlatform;
045:
046:            /**
047:             * Sets jcdAlias-&gt;platform string map.
048:             * @param platforms the map of jcdAlias-&gt;OJB platform string
049:             */
050:            public void setPlatforms(Map<String, String> platforms) {
051:                this .dsToPlatform = platforms;
052:            }
053:
054:            public void afterPropertiesSet() throws Exception {
055:                configureOJBConnectionDescriptors(this .dsToPlatform);
056:            }
057:
058:            /**
059:             * Configures the default OJB connection descriptor to use the specified platform
060:             * @param platform the OJB platform string
061:             */
062:            public static void configureDefaultOJBConnectionDescriptor(
063:                    String platform) {
064:                configureOJBConnectionDescriptor("", platform);
065:            }
066:
067:            /**
068:             * Configures the specified OJB connection descriptor to use the specified platform
069:             * @param jcdAlias the jcd alias
070:             * @param platform the OJB platform string
071:             */
072:            public static void configureOJBConnectionDescriptor(
073:                    String jcdAlias, String platform) {
074:                Map<String, String> platforms = new HashMap<String, String>();
075:                platforms.put(jcdAlias, platform);
076:                configureOJBConnectionDescriptors(platforms);
077:            }
078:
079:            /**
080:             * Configures the OJB connection descriptors with the platforms specified in the
081:             * given Map<String, String> which is taken as a map of jcdAlias-&gt;platform string.
082:             * The jcdAlias <code>""</code> or <code>"DEFAULT"</code> ({@link #DEFAULT}) is
083:             * interpreted as the default connection descriptor.
084:             * @param platforms the map of jcdAlias-&gt;OJB platform string
085:             */
086:            public static void configureOJBConnectionDescriptors(
087:                    Map<String, String> platforms) {
088:                int numUpdated = 0;
089:                if (platforms != null) {
090:                    // no way to obtain all possible PersistenceBroker/jcdalias keys from OJB? shame.
091:                    for (Map.Entry<String, String> entry : platforms.entrySet()) {
092:                        String key = entry.getKey();
093:                        PersistenceBroker pb;
094:                        // empty key means the default persistence broker/jcd alias
095:                        boolean deflt = key.length() == 0
096:                                || DEFAULT.equals(key);
097:                        if (deflt) {
098:                            pb = PersistenceBrokerFactory
099:                                    .defaultPersistenceBroker();
100:                        } else {
101:                            pb = PersistenceBrokerFactory
102:                                    .createPersistenceBroker(new PBKey(key));
103:                        }
104:                        // PersisenceBroker and JCD alias are one and the same I guess
105:                        LOG
106:                                .info("Setting "
107:                                        + (deflt ? "<<<default>>>" : "'" + key
108:                                                + "'")
109:                                        + " OJB connection descriptor database platform to '"
110:                                        + entry.getValue() + "'");
111:                        pb.serviceConnectionManager().getConnectionDescriptor()
112:                                .setDbms(entry.getValue());
113:                        numUpdated++;
114:                    }
115:                }
116:                if (numUpdated > 0) {
117:                    LOG.info("Updated " + numUpdated
118:                            + " OJB JDBC connection descriptors");
119:                } else {
120:                    LOG.warn("No OJB JDBC connection descriptors updated");
121:                }
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.