Source Code Cross Referenced for MappingFile.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ws » deployment » api » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_ws.deployment.api 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial Developer : Delplanque Xavier & Sauthier Guillaume
022:         * --------------------------------------------------------------------------
023:         * $Id: MappingFile.java 5766 2004-11-19 09:23:01Z sauthieg $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas_ws.deployment.api;
026:
027:        import java.util.Hashtable;
028:        import java.util.Iterator;
029:        import java.util.List;
030:        import java.util.Map;
031:
032:        import javax.xml.namespace.QName;
033:
034:        import org.objectweb.jonas_lib.deployment.xml.Qname;
035:
036:        import org.objectweb.jonas_ws.deployment.xml.JavaWsdlMapping;
037:        import org.objectweb.jonas_ws.deployment.xml.JavaXmlTypeMapping;
038:        import org.objectweb.jonas_ws.deployment.xml.PackageMapping;
039:
040:        /**
041:         * this Class is used to manipulate jaxrpc-mapping-file. This file contains
042:         * informations for mapping between XML namespaces and java packages. We
043:         * actually support just a few part of this file. According with JSR 921, this
044:         * file must contain class mapping information (exceptions/faults,
045:         * types/classes, portTypes/interfaces ...).
046:         *
047:         * @author Guillaume Sauthier
048:         * @author Xavier Delplanque
049:         * @author Helene Joanin
050:         */
051:        public class MappingFile {
052:
053:            /** Associates a namespace to its package. It's the cache. */
054:            private Map namespacePackageMapping;
055:
056:            /** Associates an XML QName to its java classname */
057:            private Map xmlType2javaClassname;
058:
059:            /** parsed object */
060:            private JavaWsdlMapping javaWSDLMapping;
061:
062:            /**
063:             * Constructor : creates a MappingFile object.
064:             *
065:             * @param jwMapping XML Element java-wsdl-mapping
066:             */
067:            public MappingFile(JavaWsdlMapping jwMapping) {
068:
069:                javaWSDLMapping = jwMapping;
070:
071:                // init vars
072:                namespacePackageMapping = new Hashtable();
073:                xmlType2javaClassname = new Hashtable();
074:
075:                fillPackageMapping(jwMapping);
076:                fillXmlTypeMapping(jwMapping);
077:
078:            }
079:
080:            /**
081:             * Fill up the package mapping hashtable
082:             *
083:             * @param mapping jaxrpc-mapping-file root element.
084:             */
085:            private void fillPackageMapping(JavaWsdlMapping mapping) {
086:                List pml = mapping.getPackageMappingList();
087:
088:                for (Iterator i = pml.iterator(); i.hasNext();) {
089:                    // get each mapping file package mappings
090:                    PackageMapping pm = (PackageMapping) i.next();
091:
092:                    String pt = pm.getPackageType();
093:                    String nuri = pm.getNamespaceURI();
094:
095:                    //add in the hashtable the namespace to package relation (cache)
096:                    namespacePackageMapping.put(nuri, pt);
097:                }
098:            }
099:
100:            /**
101:             * Fill up the xml type to java class map
102:             *
103:             * @param mapping jaxrpc-mapping-file root element.
104:             */
105:            private void fillXmlTypeMapping(JavaWsdlMapping mapping) {
106:
107:                List jxml = mapping.getJavaXmlTypeMappingList();
108:                for (Iterator i = jxml.iterator(); i.hasNext();) {
109:                    // get each java -> xml type mapping
110:                    JavaXmlTypeMapping jxtm = (JavaXmlTypeMapping) i.next();
111:
112:                    QName xmlName = null;
113:                    String javaName = jxtm.getJavaType();
114:                    Qname rootType = jxtm.getRootTypeQname();
115:                    if (rootType != null) {
116:                        xmlName = rootType.getQName();
117:                    } else {
118:                        xmlName = jxtm.getAnonymousTypeQname().getQName();
119:                    }
120:
121:                    xmlType2javaClassname.put(xmlName, javaName);
122:                }
123:            }
124:
125:            /**
126:             * @return Returns the XML Element representing this MappingFile (use only for Test).
127:             */
128:            public JavaWsdlMapping getXmlJavaWsdlMapping() {
129:                return javaWSDLMapping;
130:            }
131:
132:            /**
133:             * return the mapping between XML namespaces and Java packages defined in
134:             * the jaxrpc-mapping file.
135:             *
136:             * @return the mapping between XML namespaces and Java packages
137:             */
138:            public Map getMappings() {
139:                return namespacePackageMapping;
140:            }
141:
142:            /**
143:             * Return the package associated with the specified namespaceURI (can be
144:             * null).
145:             *
146:             * @param namespaceURI the namespace key to retrieve the package name
147:             *
148:             * @return the package associated with the specified namespaceURI. (null if
149:             *         namespace not present).
150:             */
151:            public String getMapping(String namespaceURI) {
152:                return (String) namespacePackageMapping.get(namespaceURI);
153:            }
154:
155:            /**
156:             * Return the Java classname representing the xml type.
157:             *
158:             * @param xmlType the QName of the xml type
159:             *
160:             * @return the Java classname representing the xml type.
161:             */
162:            public String getClassname(QName xmlType) {
163:                return (String) xmlType2javaClassname.get(xmlType);
164:            }
165:
166:            /**
167:             * Return an iterator traversing the list of xmlType mappings.
168:             *
169:             * @return an iterator traversing the list of xmlType mappings.
170:             */
171:            public Iterator getXmlTypeMappings() {
172:                return xmlType2javaClassname.keySet().iterator();
173:            }
174:
175:            /**
176:             * Build a string representation of MappingFile
177:             *
178:             * @return String representation of the mapping file.
179:             */
180:            public String toString() {
181:                StringBuffer ret = new StringBuffer();
182:
183:                ret.append("\n" + getClass().getName()); //$NON-NLS-1$
184:                ret.append("\ngetMappings()=" + namespacePackageMapping); //$NON-NLS-1$
185:                ret.append("\ngetXmlTypeMappings()=" + xmlType2javaClassname); //$NON-NLS-1$
186:
187:                return ret.toString();
188:            }
189:
190:            /**
191:             * @see java.lang.Object#hashCode()
192:             */
193:            public int hashCode() {
194:                return this .namespacePackageMapping.hashCode()
195:                        + this .xmlType2javaClassname.hashCode();
196:            }
197:
198:            /**
199:             * Return true if the 2 objects are equals in value.
200:             *
201:             * @param other the object to compare.
202:             *
203:             * @return true if objects are equals in value, else false.
204:             */
205:            public boolean equals(Object other) {
206:                if (this  == other) {
207:                    return true;
208:                }
209:                if (other == null) {
210:                    return false;
211:                }
212:                if (!(other instanceof  MappingFile)) {
213:                    return false;
214:                }
215:                MappingFile ref = (MappingFile) other;
216:                if (!namespacePackageMapping.equals(ref.getMappings())) {
217:                    return false;
218:                }
219:                // After all theses tests, the 2 objects are equals in value
220:                return true;
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.