Source Code Cross Referenced for MappingFileManager.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ws » deployment » lib » 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.lib 
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: MappingFileManager.java 7467 2005-10-04 12:53:14Z sauthieg $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas_ws.deployment.lib;
026:
027:        import java.io.File;
028:        import java.io.FileInputStream;
029:        import java.io.IOException;
030:        import java.io.InputStream;
031:        import java.io.InputStreamReader;
032:        import java.io.Reader;
033:        import java.util.jar.JarFile;
034:
035:        import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
036:        import org.objectweb.jonas_lib.deployment.digester.JDigester;
037:
038:        import org.objectweb.jonas_ws.deployment.api.JaxrpcMappingSchemas;
039:        import org.objectweb.jonas_ws.deployment.api.MappingFile;
040:        import org.objectweb.jonas_ws.deployment.api.WSDeploymentDescException;
041:        import org.objectweb.jonas_ws.deployment.rules.JavaWsdlMappingRuleSet;
042:        import org.objectweb.jonas_ws.deployment.xml.JavaWsdlMapping;
043:
044:        import org.objectweb.jonas.common.Log;
045:
046:        import org.objectweb.util.monolog.api.BasicLevel;
047:        import org.objectweb.util.monolog.api.Logger;
048:
049:        /**
050:         * this Class is used to manipulate jaxrpc-mapping-file. This file contains
051:         * informations for mapping between XML namespaces and java packages. We
052:         * actually support just a few part of this file. According with JSR 921, this
053:         * file must contain class mapping information (exceptions/faults,
054:         * types/classes, portTypes/interfaces ...).
055:         *
056:         * @author Guillaume Sauthier
057:         * @author Xavier Delplanque
058:         * @author Helene Joanin
059:         */
060:        public class MappingFileManager {
061:
062:            /**
063:             * Digester used to parse jaxrpc_mapping.xml
064:             */
065:            private static JDigester mfDigester = null;
066:
067:            /**
068:             * Rules to parse the jaxrpc_mapping.xml
069:             */
070:            private static JavaWsdlMappingRuleSet mfRuleSet = new JavaWsdlMappingRuleSet();
071:
072:            /**
073:             * Flag for parser validation
074:             */
075:            private static boolean parsingWithValidation = true;
076:
077:            /**
078:             * logger
079:             */
080:            private static Logger logger = Log.getLogger(Log.JONAS_WS_PREFIX);
081:
082:            /**
083:             * Private empty constructor for Utility class.
084:             */
085:            private MappingFileManager() {
086:            }
087:
088:            /**
089:             * Returns an instance of jaxrpc-mapping-file
090:             *
091:             * @param module module File containing mapping
092:             * @param filename jaxrpc-mapping-file filename
093:             *
094:             * @return Returns an instance of jaxrpc-mapping-file
095:             *
096:             * @throws WSDeploymentDescException when MappingFile cannot be loader or instanciated
097:             */
098:            public static MappingFile getInstance(File module, String filename)
099:                    throws WSDeploymentDescException {
100:                InputStream is = openStream(module, filename);
101:                return new MappingFile(loadMappingFile(
102:                        new InputStreamReader(is), filename));
103:            }
104:
105:            /**
106:             * Returns an instance of jaxrpc-mapping-file
107:             *
108:             * @param r mapping file reader
109:             * @param filename mapping filename
110:             * @param validate validate flag
111:             *
112:             * @return Returns an instance of jaxrpc-mapping-file
113:             *
114:             * @throws WSDeploymentDescException when MappingFile cannot be loader or instanciated
115:             */
116:            public static MappingFile getInstance(Reader r, String filename,
117:                    boolean validate) throws WSDeploymentDescException {
118:                parsingWithValidation = validate;
119:                return new MappingFile(loadMappingFile(r, filename));
120:            }
121:
122:            /**
123:             * Returns an instance of jaxrpc-mapping-file
124:             *
125:             * @param is jaxrpc-mapping-file InputStream
126:             * @param filename jaxrpc-mapping-file filename
127:             *
128:             * @return Returns an instance of jaxrpc-mapping-file
129:             *
130:             * @throws WSDeploymentDescException when MappingFile cannot be loader or instanciated
131:             */
132:            public static MappingFile getInstance(InputStream is,
133:                    String filename) throws WSDeploymentDescException {
134:                return new MappingFile(loadMappingFile(
135:                        new InputStreamReader(is), filename));
136:            }
137:
138:            /**
139:             * Open the InputStream of the given jaxrpc filename inside module.
140:             *
141:             * @param module module filename containing jaxrpc mapping file
142:             * @param filename jaxrpc mappinf file filename
143:             *
144:             * @return Returns the InputStream of the mapping file
145:             *
146:             * @throws WSDeploymentDescException When InputStream cannot be open (not found, ioexceptions)
147:             */
148:            private static InputStream openStream(File module, String filename)
149:                    throws WSDeploymentDescException {
150:
151:                InputStream isMapping = null;
152:
153:                // If we have file stored in Jar
154:                if (module.exists()) {
155:                    // If we have file stored in Jar
156:                    if (module.isFile()) {
157:                        JarFile jf = null;
158:
159:                        // Get the Mapping file of the jar as InputStream
160:                        try {
161:                            jf = new JarFile(module.getAbsolutePath());
162:                            isMapping = jf
163:                                    .getInputStream(jf.getEntry(filename));
164:                        } catch (Exception e) {
165:                            if (jf != null) {
166:                                try {
167:                                    jf.close();
168:                                } catch (IOException i) {
169:                                    logger.log(BasicLevel.WARN, "Can't close '"
170:                                            + module + "'");
171:                                }
172:                            }
173:
174:                            throw new WSDeploymentDescException(
175:                                    "Cannot read the jaxrpc-mapping-file "
176:                                            + filename + " in "
177:                                            + module.getAbsolutePath(), e);
178:                        }
179:                    } else {
180:                        // filename is a Directory
181:                        try {
182:                            isMapping = new FileInputStream(new File(module,
183:                                    filename));
184:                        } catch (IOException ioe) {
185:                            throw new WSDeploymentDescException(
186:                                    "Cannot read the jaxrpc-mapping-file "
187:                                            + filename + " in "
188:                                            + module.getAbsolutePath(), ioe);
189:                        }
190:                    }
191:
192:                } else {
193:                    // try laoding from ClassLoader
194:                    ClassLoader loader = Thread.currentThread()
195:                            .getContextClassLoader();
196:                    isMapping = loader.getResourceAsStream(filename);
197:                }
198:
199:                return isMapping;
200:            }
201:
202:            /**
203:             * Load the MappingFile file
204:             *
205:             * @param reader The mapping file InputStream
206:             * @param fileName mapping filename
207:             *
208:             * @return Zeus Root Element of the xml file.
209:             *
210:             * @throws WSDeploymentDescException When parsing fails.
211:             */
212:            private static JavaWsdlMapping loadMappingFile(Reader reader,
213:                    String fileName) throws WSDeploymentDescException {
214:
215:                JavaWsdlMapping jwm = new JavaWsdlMapping();
216:
217:                // Create if mfDigester is null
218:                if (mfDigester == null) {
219:                    try {
220:                        // Create and initialize the digester
221:                        mfDigester = new JDigester(mfRuleSet,
222:                                parsingWithValidation, true, null,
223:                                new JaxrpcMappingSchemas());
224:                    } catch (DeploymentDescException e) {
225:                        throw new WSDeploymentDescException(e);
226:                    }
227:                }
228:
229:                try {
230:                    mfDigester.parse(reader, fileName, jwm);
231:                } catch (DeploymentDescException e) {
232:                    throw new WSDeploymentDescException(e);
233:                } finally {
234:                    mfDigester.push(null);
235:                }
236:
237:                return jwm;
238:            }
239:
240:            /**
241:             * @return Returns the parsingWithValidation.
242:             */
243:            public static boolean isParsingWithValidation() {
244:                return parsingWithValidation;
245:            }
246:
247:            /**
248:             * @param parsingWithValidation The parsingWithValidation to set.
249:             */
250:            public static void setParsingWithValidation(
251:                    boolean parsingWithValidation) {
252:                MappingFileManager.parsingWithValidation = parsingWithValidation;
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.