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


001:        package org.exolab.castor.mapping.loader;
002:
003:        import java.util.Hashtable;
004:        import java.util.Iterator;
005:        import java.util.List;
006:        import java.util.Map;
007:        import java.util.Vector;
008:
009:        import org.exolab.castor.mapping.ClassDescriptor;
010:        import org.exolab.castor.mapping.MappingException;
011:        import org.exolab.castor.mapping.MappingLoader;
012:
013:        public abstract class AbstractMappingLoader2 implements  MappingLoader {
014:            //--------------------------------------------------------------------------
015:
016:            /** The class loader to use. */
017:            private ClassLoader _loader;
018:
019:            /** A flag indicating whether or not mappings can be redefined. */
020:            private boolean _allowRedefinitions = false;
021:
022:            /** Has loadMapping been called? */
023:            private boolean _loaded = false;
024:
025:            /** All class descriptors in the original order. */
026:            private List _descriptors = new Vector();
027:
028:            /** All class descriptors added so far, keyed by classname. */
029:            private Map _descriptorsByClassname = new Hashtable();
030:
031:            //--------------------------------------------------------------------------
032:
033:            public AbstractMappingLoader2(final ClassLoader loader) {
034:                setClassLoader(loader);
035:            }
036:
037:            public final void clear() {
038:                _allowRedefinitions = false;
039:                _loaded = false;
040:                _descriptors.clear();
041:                _descriptorsByClassname.clear();
042:            }
043:
044:            //--------------------------------------------------------------------------
045:
046:            /**
047:             * @see org.exolab.castor.mapping.MappingLoader#setClassLoader(java.lang.ClassLoader)
048:             * {@inheritDoc}
049:             */
050:            public final void setClassLoader(final ClassLoader loader) {
051:                if (loader == null) {
052:                    _loader = getClass().getClassLoader();
053:                } else {
054:                    _loader = loader;
055:                }
056:            }
057:
058:            /**
059:             * @see org.exolab.castor.mapping.MappingLoader#getClassLoader()
060:             * {@inheritDoc}
061:             */
062:            public final ClassLoader getClassLoader() {
063:                return _loader;
064:            }
065:
066:            /**
067:             * Enables or disables the ability to allow the redefinition of class mappings.
068:             * 
069:             * @param allow A boolean that when true enables redefinitions.
070:             */
071:            public final void setAllowRedefinitions(boolean allow) {
072:                _allowRedefinitions = allow;
073:            }
074:
075:            /**
076:             * Is the ability to allow redefinitions enabled or disabled?
077:             * 
078:             * @return A boolean that when true enables redefinitions.
079:             */
080:            public final boolean isAllowRedefinition() {
081:                return _allowRedefinitions;
082:            }
083:
084:            //--------------------------------------------------------------------------
085:
086:            /**
087:             * Adds a class descriptor. Will throw a mapping exception if a descriptor for this class
088:             * already exists.
089:             *
090:             * @param descriptor The descriptor to add.
091:             * @throws MappingException A descriptor for this class already exists.
092:             */
093:            protected final void addDescriptor(final ClassDescriptor descriptor)
094:                    throws MappingException {
095:                String classname = descriptor.getJavaClass().getName();
096:                if (_descriptorsByClassname.containsKey(classname)) {
097:                    if (!isAllowRedefinition()) {
098:                        throw new MappingException(
099:                                "mapping.duplicateDescriptors", classname);
100:                    }
101:                } else {
102:                    _descriptors.add(descriptor);
103:                }
104:
105:                //-- if we make it here...add class
106:                _descriptorsByClassname.put(classname, descriptor);
107:            }
108:
109:            /**
110:             * @see org.exolab.castor.mapping.MappingLoader#getDescriptor(java.lang.String)
111:             * {@inheritDoc}
112:             */
113:            public final ClassDescriptor getDescriptor(final String classname) {
114:                if (classname == null) {
115:                    return null;
116:                }
117:                return (ClassDescriptor) _descriptorsByClassname.get(classname);
118:            }
119:
120:            /**
121:             * @see org.exolab.castor.mapping.MappingLoader#descriptorIterator()
122:             * {@inheritDoc}
123:             */
124:            public final Iterator descriptorIterator() {
125:                return _descriptors.iterator();
126:            }
127:
128:            //--------------------------------------------------------------------------
129:
130:            /**
131:             * Return if mapping should be loaded with this MappingLoader instance or if another
132:             * mapping have been loaded previously. If no mapping have been loaded previously
133:             * then prevent any other mapping to be loaded later on.
134:             * 
135:             * @return <code>true</code> if mapping should be loaded, <code>false</code>
136:             *         otherwise.
137:             */
138:            protected final boolean loadMapping() {
139:                if (_loaded) {
140:                    return false;
141:                }
142:                _loaded = true;
143:                return true;
144:            }
145:
146:            //--------------------------------------------------------------------------
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.