Source Code Cross Referenced for MappingLoaderRegistry.java in  » Database-ORM » castor » org » castor » mapping » 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 » castor » org.castor.mapping 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Ralf Joachim, Werner Guttmann
003:         *
004:         * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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:        package org.castor.mapping;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collection;
020:        import java.util.Collections;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.StringTokenizer;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.castor.util.ConfigKeys;
028:        import org.castor.util.Configuration;
029:        import org.exolab.castor.mapping.MappingException;
030:        import org.exolab.castor.mapping.MappingLoader;
031:
032:        /**
033:         * @author <a href="mailto:werner DOT guttmann AT gmx DOT net">Werner Guttmann</a>
034:         * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
035:         * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
036:         */
037:        public final class MappingLoaderRegistry {
038:
039:            /** The <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
040:             *  Logging </a> instance used for all logging. */
041:            private static final Log LOG = LogFactory
042:                    .getLog(MappingLoaderRegistry.class);
043:
044:            /** The cached mapping loader factories. */
045:            private final List _mappingLoaderFactories = new ArrayList();
046:
047:            /** Already loaded mapping loaders. */
048:            private final List _mappingLoaders = new ArrayList();
049:
050:            /**
051:             * Creates an instance of this registry, loading the mapping loader
052:             * factories from the castor.properties file. 
053:             * @param config Configuration.
054:             */
055:            public MappingLoaderRegistry(final Configuration config) {
056:                String prop = config.getProperty(
057:                        ConfigKeys.MAPPING_LOADER_FACTORIES, "");
058:                StringTokenizer tokenizer = new StringTokenizer(prop, ", ");
059:                while (tokenizer.hasMoreTokens()) {
060:                    String classname = tokenizer.nextToken();
061:                    try {
062:                        ClassLoader loader = getClass().getClassLoader();
063:                        Class cls = loader.loadClass(classname);
064:                        // Class[] types = new Class[] {ClassLoader.class};
065:                        Object obj = cls.getConstructor((Class[]) null)
066:                                .newInstance((Object[]) null);
067:                        _mappingLoaderFactories.add(obj);
068:                    } catch (Exception ex) {
069:                        LOG.error(
070:                                "Problem instantiating mapping loader factory implementation: "
071:                                        + classname, ex);
072:                    }
073:                }
074:            }
075:
076:            /**
077:             * Deletes all 'cached' mapping loader factories.
078:             */
079:            public void clear() {
080:                Iterator iter = _mappingLoaders.iterator();
081:                while (iter.hasNext()) {
082:                    ((MappingLoader) iter.next()).clear();
083:                }
084:            }
085:
086:            //--------------------------------------------------------------------------
087:
088:            /**
089:             * Returns a mapping loader for the suitable source and binding type. The engine's
090:             * specific mapping loader is used to create binding specific descriptors.
091:             * The mapping loader is cached in memory and returned in subsequent method calls.
092:             *
093:             * @param sourceType The type of the mapping source.
094:             * @param bindingType The binding type to load from mapping.
095:             * @return A mapping loader
096:             * @throws MappingException A mapping error occured preventing
097:             *         descriptors from being generated from the loaded mapping
098:             */
099:            public MappingLoader getMappingLoader(final String sourceType,
100:                    final BindingType bindingType) throws MappingException {
101:                Iterator iter = _mappingLoaderFactories.iterator();
102:                while (iter.hasNext()) {
103:                    MappingLoaderFactory loaderFactory = (MappingLoaderFactory) iter
104:                            .next();
105:                    if (loaderFactory.getSourceType().equals(sourceType)
106:                            && (loaderFactory.getBindingType() == bindingType)) {
107:                        MappingLoader mappingLoader = loaderFactory
108:                                .getMappingLoader();
109:                        _mappingLoaders.add(mappingLoader);
110:                        return mappingLoader;
111:                    }
112:                }
113:
114:                String msg = "No mapping loader/factory for: " + "SourceType="
115:                        + sourceType + " / BindingType=" + bindingType;
116:                LOG.error(msg);
117:                throw new MappingException(msg);
118:            }
119:
120:            /**
121:             * Returns a list of 'cached' mapping loader factories.
122:             * @return a list of 'cached' mapping loader factories.
123:             */
124:            public Collection getMappingLoaderFactories() {
125:                return Collections
126:                        .unmodifiableCollection(_mappingLoaderFactories);
127:            }
128:
129:            //--------------------------------------------------------------------------
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.