Source Code Cross Referenced for MappingFactoryValue.java in  » Database-ORM » openjpa » org » apache » openjpa » jdbc » conf » 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 » openjpa » org.apache.openjpa.jdbc.conf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.    
018:         */
019:        package org.apache.openjpa.jdbc.conf;
020:
021:        import org.apache.commons.lang.StringUtils;
022:        import org.apache.openjpa.jdbc.meta.MetaDataPlusMappingFactory;
023:        import org.apache.openjpa.lib.conf.Configuration;
024:        import org.apache.openjpa.lib.conf.Configurations;
025:        import org.apache.openjpa.lib.conf.PluginValue;
026:        import org.apache.openjpa.lib.log.Log;
027:        import org.apache.openjpa.lib.util.Localizer;
028:        import org.apache.openjpa.meta.MetaDataFactory;
029:
030:        /**
031:         * Handles the complex logic of creating a {@link MetaDataFactory} for
032:         * combined metadata and mapping.
033:         *
034:         * @author Abe White
035:         * @nojavadoc
036:         */
037:        public class MappingFactoryValue extends PluginValue {
038:
039:            private static final Localizer _loc = Localizer
040:                    .forPackage(MappingFactoryValue.class);
041:
042:            private String[] _metaFactoryDefaults = null;
043:            private String[] _mappedMetaFactoryDefaults = null;
044:
045:            public MappingFactoryValue(String prop) {
046:                super (prop, false);
047:            }
048:
049:            /**
050:             * Default setting for a given <code>MetaDataFactory</code> alias setting.
051:             * If a <code>MappingFactory</code> value is not supplied, we check these
052:             * defaults against the <code>MetaDataFactory</code> setting. If the
053:             * <code>MetaDataFactory</code> does not have a default, we assume it
054:             * handles both metadata and mapping factory.
055:             */
056:            public void setMetaDataFactoryDefault(String metaAlias,
057:                    String mappingAlias) {
058:                _metaFactoryDefaults = setAlias(metaAlias, mappingAlias,
059:                        _metaFactoryDefaults);
060:            }
061:
062:            /**
063:             * If the <code>Mapping</code> property is set, we check these defaults
064:             * before checking metadata factory defaults.
065:             */
066:            public void setMappedMetaDataFactoryDefault(String metaAlias,
067:                    String mappingAlias) {
068:                _mappedMetaFactoryDefaults = setAlias(metaAlias, mappingAlias,
069:                        _mappedMetaFactoryDefaults);
070:            }
071:
072:            /**
073:             * Intantiate a {@link MetaDataFactory} responsible for both metadata and
074:             * mapping.
075:             */
076:            public MetaDataFactory instantiateMetaDataFactory(
077:                    Configuration conf, PluginValue metaPlugin, String mapping) {
078:                return instantiateMetaDataFactory(conf, metaPlugin, mapping,
079:                        true);
080:            }
081:
082:            /**
083:             * Intantiate a {@link MetaDataFactory} responsible for both metadata and
084:             * mapping.
085:             */
086:            public MetaDataFactory instantiateMetaDataFactory(
087:                    Configuration conf, PluginValue metaPlugin, String mapping,
088:                    boolean fatal) {
089:                String clsName = getClassName();
090:                String props = getProperties();
091:                String metaClsName = metaPlugin.getClassName();
092:                String metaProps = metaPlugin.getProperties();
093:
094:                // if no mapping factory set, check for default for this factory
095:                if (StringUtils.isEmpty(clsName)) {
096:                    String def;
097:                    if (!StringUtils.isEmpty(mapping)) {
098:                        def = unalias(metaPlugin.alias(metaClsName),
099:                                _mappedMetaFactoryDefaults, true);
100:                        if (def != null)
101:                            clsName = unalias(def);
102:                    }
103:                    if (StringUtils.isEmpty(clsName)) {
104:                        def = unalias(metaPlugin.alias(metaClsName),
105:                                _metaFactoryDefaults, true);
106:                        if (def != null)
107:                            clsName = unalias(def);
108:                    }
109:                }
110:
111:                // if mapping factory and metadata factory the same, combine
112:                // into metadata factory
113:                if (clsName != null && clsName.equals(metaClsName)) {
114:                    if (props != null && metaProps == null)
115:                        metaProps = props;
116:                    else if (props != null)
117:                        metaProps += "," + props;
118:                    clsName = null;
119:                    props = null;
120:                }
121:
122:                // instantiate factories
123:                MetaDataFactory map = (MetaDataFactory) newInstance(clsName,
124:                        MetaDataFactory.class, conf, fatal);
125:                MetaDataFactory meta;
126:                if (map != null
127:                        && map.getClass().getName().indexOf("Deprecated") != -1) {
128:                    // deprecated mapping factories take over metadata too, so we have
129:                    // to special-case them to treat them like metadata factory only
130:                    meta = map;
131:                    map = null;
132:                } else {
133:                    meta = (MetaDataFactory) metaPlugin.newInstance(
134:                            metaClsName, MetaDataFactory.class, conf, fatal);
135:                }
136:
137:                // configure factories.  if only meta factory, allow user to specify
138:                // its mapping properties in the mapping factory setting
139:                if (map == null && props != null) {
140:                    if (metaProps == null)
141:                        metaProps = props;
142:                    else
143:                        metaProps += ", " + props;
144:                }
145:                Configurations.configureInstance(map, conf, props,
146:                        (fatal) ? getProperty() : null);
147:                Configurations.configureInstance(meta, conf, metaProps,
148:                        (fatal) ? metaPlugin.getProperty() : null);
149:
150:                Log log = conf.getLog(JDBCConfiguration.LOG_METADATA);
151:                if (log.isTraceEnabled()) {
152:                    log.trace(_loc.get("meta-factory", meta));
153:                    if (map != null)
154:                        log.trace(_loc.get("map-factory", map));
155:                }
156:
157:                // if no mapping setting, return meta factory alone, assuming it handles
158:                // both metadata and mapping
159:                MetaDataFactory ret = (map == null) ? meta
160:                        : new MetaDataPlusMappingFactory(meta, map);
161:                return ret;
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.