Source Code Cross Referenced for WSDL2JavaGenerator.java in  » Web-Services-AXIS2 » tools » org » apache » axis2 » tool » codegen » 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 » Web Services AXIS2 » tools » org.apache.axis2.tool.codegen 
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.axis2.tool.codegen;
020:
021:        import org.apache.axis2.description.AxisService;
022:        import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
023:        import org.apache.axis2.util.CommandLineOption;
024:        import org.apache.axis2.util.CommandLineOptionConstants;
025:
026:        import javax.wsdl.WSDLException;
027:
028:        import java.io.File;
029:        import java.io.IOException;
030:        import java.net.MalformedURLException;
031:        import java.net.URL;
032:        import java.util.HashMap;
033:        import java.util.Map;
034:
035:        public class WSDL2JavaGenerator {
036:
037:            /**
038:             * Maps a string containing the name of a language to a constant defined in CommandLineOptionConstants.LanguageNames
039:             * 
040:             * @param UILangValue a string containg a language, e.g. "java", "cs", "cpp" or "vb"
041:             * @return a normalized string constant
042:             */
043:            private String mapLanguagesWithCombo(String UILangValue) {
044:                return UILangValue;
045:            }
046:
047:            /**
048:             * Creates a list of parameters for the code generator based on the decisions made by the user on the OptionsPage
049:             * (page2). For each setting, there is a Command-Line option for the Axis2 code generator.
050:             * 
051:             * @return a Map with keys from CommandLineOptionConstants with the values entered by the user on the Options Page.
052:             */
053:            public Map fillOptionMap(boolean isAyncOnly, boolean isSyncOnly,
054:                    boolean isServerSide, boolean isServerXML,
055:                    boolean isTestCase, boolean isGenerateAll,
056:                    String serviceName, String portName,
057:                    String databindingName, String WSDLURI, String packageName,
058:                    String selectedLanguage, String outputLocation,
059:                    String namespace2packageList, boolean isServerSideInterface) {
060:                Map optionMap = new HashMap();
061:                //WSDL file name
062:                optionMap
063:                        .put(
064:                                CommandLineOptionConstants.WSDL2JavaConstants.WSDL_LOCATION_URI_OPTION,
065:                                new CommandLineOption(
066:                                        CommandLineOptionConstants.WSDL2JavaConstants.WSDL_LOCATION_URI_OPTION,
067:                                        getStringArray(WSDLURI)));
068:
069:                //Async only
070:                if (isAyncOnly) {
071:                    optionMap
072:                            .put(
073:                                    CommandLineOptionConstants.WSDL2JavaConstants.CODEGEN_ASYNC_ONLY_OPTION,
074:                                    new CommandLineOption(
075:                                            CommandLineOptionConstants.WSDL2JavaConstants.CODEGEN_ASYNC_ONLY_OPTION,
076:                                            new String[0]));
077:                }
078:                //sync only
079:                if (isSyncOnly) {
080:                    optionMap
081:                            .put(
082:                                    CommandLineOptionConstants.WSDL2JavaConstants.CODEGEN_SYNC_ONLY_OPTION,
083:                                    new CommandLineOption(
084:                                            CommandLineOptionConstants.WSDL2JavaConstants.CODEGEN_SYNC_ONLY_OPTION,
085:                                            new String[0]));
086:                }
087:                //serverside
088:                if (isServerSide) {
089:                    optionMap
090:                            .put(
091:                                    CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION,
092:                                    new CommandLineOption(
093:                                            CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION,
094:                                            new String[0]));
095:                    //server xml
096:                    if (isServerXML) {
097:                        optionMap
098:                                .put(
099:                                        CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_SERVICE_DESCRIPTION_OPTION,
100:                                        new CommandLineOption(
101:                                                CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_SERVICE_DESCRIPTION_OPTION,
102:                                                new String[0]));
103:                    }
104:                    if (isGenerateAll) {
105:                        optionMap
106:                                .put(
107:                                        CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_ALL_OPTION,
108:                                        new CommandLineOption(
109:                                                CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_ALL_OPTION,
110:                                                new String[0]));
111:                    }
112:                }
113:                //test case
114:                if (isTestCase) {
115:                    optionMap
116:                            .put(
117:                                    CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_TEST_CASE_OPTION,
118:                                    new CommandLineOption(
119:                                            CommandLineOptionConstants.WSDL2JavaConstants.GENERATE_TEST_CASE_OPTION,
120:                                            new String[0]));
121:                }
122:                //package name
123:                optionMap
124:                        .put(
125:                                CommandLineOptionConstants.WSDL2JavaConstants.PACKAGE_OPTION,
126:                                new CommandLineOption(
127:                                        CommandLineOptionConstants.WSDL2JavaConstants.PACKAGE_OPTION,
128:                                        getStringArray(packageName)));
129:                //selected language
130:                optionMap
131:                        .put(
132:                                CommandLineOptionConstants.WSDL2JavaConstants.STUB_LANGUAGE_OPTION,
133:                                new CommandLineOption(
134:                                        CommandLineOptionConstants.WSDL2JavaConstants.STUB_LANGUAGE_OPTION,
135:                                        getStringArray(mapLanguagesWithCombo(selectedLanguage))));
136:                //output location
137:                optionMap
138:                        .put(
139:                                CommandLineOptionConstants.WSDL2JavaConstants.OUTPUT_LOCATION_OPTION,
140:                                new CommandLineOption(
141:                                        CommandLineOptionConstants.WSDL2JavaConstants.OUTPUT_LOCATION_OPTION,
142:                                        getStringArray(outputLocation)));
143:
144:                //databinding
145:                optionMap
146:                        .put(
147:                                CommandLineOptionConstants.WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION,
148:                                new CommandLineOption(
149:                                        CommandLineOptionConstants.WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION,
150:                                        getStringArray(databindingName)));
151:
152:                //port name
153:                if (portName != null) {
154:                    optionMap
155:                            .put(
156:                                    CommandLineOptionConstants.WSDL2JavaConstants.PORT_NAME_OPTION,
157:                                    new CommandLineOption(
158:                                            CommandLineOptionConstants.WSDL2JavaConstants.PORT_NAME_OPTION,
159:                                            getStringArray(portName)));
160:                }
161:                //service name
162:                if (serviceName != null) {
163:                    optionMap
164:                            .put(
165:                                    CommandLineOptionConstants.WSDL2JavaConstants.SERVICE_NAME_OPTION,
166:                                    new CommandLineOption(
167:                                            CommandLineOptionConstants.WSDL2JavaConstants.SERVICE_NAME_OPTION,
168:                                            getStringArray(serviceName)));
169:                }
170:                //ns2pkg mapping
171:                if (namespace2packageList != null) {
172:                    optionMap
173:                            .put(
174:                                    CommandLineOptionConstants.WSDL2JavaConstants.NAME_SPACE_TO_PACKAGE_OPTION,
175:                                    new CommandLineOption(
176:                                            CommandLineOptionConstants.WSDL2JavaConstants.NAME_SPACE_TO_PACKAGE_OPTION,
177:                                            getStringArray(namespace2packageList)));
178:                }
179:
180:                //server side interface  mapping
181:                if (isServerSideInterface) {
182:                    optionMap
183:                            .put(
184:                                    CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_INTERFACE_OPTION,
185:                                    new CommandLineOption(
186:                                            CommandLineOptionConstants.WSDL2JavaConstants.SERVER_SIDE_INTERFACE_OPTION,
187:                                            new String[0]));
188:                }
189:                return optionMap;
190:
191:            }
192:
193:            public String getBaseUri(String wsdlURI) {
194:
195:                try {
196:                    URL url;
197:                    if (wsdlURI.indexOf("://") == -1) {
198:                        url = new URL("file", "", wsdlURI);
199:                    } else {
200:                        url = new URL(wsdlURI);
201:                    }
202:
203:                    String baseUri;
204:                    if ("file".equals(url.getProtocol())) {
205:                        baseUri = new File(url.getFile()).getParentFile()
206:                                .toURL().toExternalForm();
207:                    } else {
208:                        baseUri = url.toExternalForm().substring(0,
209:                                url.toExternalForm().lastIndexOf("/"));
210:                    }
211:
212:                    return baseUri;
213:                } catch (MalformedURLException e) {
214:                    throw new RuntimeException(e);
215:                }
216:            }
217:
218:            /**
219:             * Reads the WSDL Object Model from the given location.
220:             * 
221:             * @param wsdlURI the filesystem location (full path) of the WSDL file to read in.
222:             * @return the WSDLDescription object containing the WSDL Object Model of the given WSDL file
223:             * @throws WSDLException when WSDL File is invalid
224:             * @throws IOException on errors reading the WSDL file
225:             */
226:            public AxisService getAxisService(String wsdlURI) throws Exception {
227:
228:                URL url;
229:                if (wsdlURI.indexOf("://") == -1) {
230:                    url = new URL("file", "", wsdlURI);
231:                } else {
232:                    url = new URL(wsdlURI);
233:                }
234:
235:                //FIXME @author soi - 
236:                // This quick fix assume that the wsdlURI points to a wsdl 1.1 version.
237:                // A better fix should be to determine which builder to use based on the wsdl version. 
238:                // The current implementation of the wsdl builder classes did not allow for this. I will suggest
239:                // that the determination of which builder to use should be done in the builder classes, preferably
240:                // in the parent builder class. 
241:                // Accessable through a static reference to a method like getBuilderInstance(String wsdlURI) in
242:                // the parent builder class or through a builder Abstract Factor or Abstract factory methods.
243:
244:                WSDL11ToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(
245:                        url.openConnection().getInputStream());
246:
247:                builder.setBaseUri(getBaseUri(wsdlURI));
248:                builder.setCodegen(true);
249:                return builder.populateService();
250:            }
251:
252:            /**
253:             * Converts a single String into a String Array
254:             * 
255:             * @param value a single string
256:             * @return an array containing only one element
257:             */
258:            private String[] getStringArray(String value) {
259:                String[] values = new String[1];
260:                values[0] = value;
261:                return values;
262:            }
263:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.