Source Code Cross Referenced for WSDLToJava.java in  » Web-Services-apache-cxf-2.0.1 » tools-wsdlto » org » apache » cxf » tools » wsdlto » 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 apache cxf 2.0.1 » tools wsdlto » org.apache.cxf.tools.wsdlto 
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:         */package org.apache.cxf.tools.wsdlto;
019:
020:        import java.io.InputStream;
021:        import java.util.Arrays;
022:        import java.util.List;
023:
024:        import org.apache.cxf.common.util.StringUtils;
025:        import org.apache.cxf.tools.common.ToolConstants;
026:        import org.apache.cxf.tools.common.ToolContext;
027:        import org.apache.cxf.tools.common.ToolException;
028:        import org.apache.cxf.tools.common.toolspec.ToolContainer;
029:        import org.apache.cxf.tools.common.toolspec.ToolRunner;
030:        import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
031:        import org.apache.cxf.tools.wsdlto.core.FrontEndProfile;
032:        import org.apache.cxf.tools.wsdlto.core.PluginLoader;
033:
034:        public class WSDLToJava {
035:
036:            public static final String DEFAULT_FRONTEND_NAME = "jaxws";
037:            public static final String DEFAULT_DATABINDING_NAME = "jaxb";
038:
039:            private String[] args;
040:
041:            private PluginLoader pluginLoader = PluginLoader.getInstance();
042:
043:            public WSDLToJava() {
044:                args = new String[0];
045:            }
046:
047:            public WSDLToJava(String pargs[]) {
048:                args = pargs;
049:            }
050:
051:            private FrontEndProfile loadFrontEnd(String name) {
052:                if (StringUtils.isEmpty(name)) {
053:                    name = DEFAULT_FRONTEND_NAME;
054:                }
055:                if (isVerbose()) {
056:                    System.out.println("Loading FrontEnd " + name + " ...");
057:                }
058:                return pluginLoader.getFrontEndProfile(name);
059:            }
060:
061:            private DataBindingProfile loadDataBinding(String name) {
062:                if (StringUtils.isEmpty(name)) {
063:                    name = DEFAULT_DATABINDING_NAME;
064:                }
065:                if (isVerbose()) {
066:                    System.out.println("Loading DataBinding " + name + " ...");
067:                }
068:                return pluginLoader.getDataBindingProfile(name);
069:            }
070:
071:            private boolean isExitOnFinish() {
072:                String exit = System.getProperty("exitOnFinish");
073:                if (StringUtils.isEmpty(exit)) {
074:                    return false;
075:                }
076:                return "YES".equalsIgnoreCase(exit)
077:                        || "TRUE".equalsIgnoreCase(exit);
078:            }
079:
080:            public void run(ToolContext context) throws Exception {
081:                FrontEndProfile frontend = null;
082:                if (args != null) {
083:                    context.put(ToolConstants.CFG_CMD_ARG, args);
084:                    frontend = loadFrontEnd(getFrontEndName(args));
085:                } else {
086:                    frontend = loadFrontEnd("");
087:                }
088:
089:                context.put(FrontEndProfile.class, frontend);
090:
091:                DataBindingProfile databinding = loadDataBinding(getDataBindingName(args));
092:
093:                context.put(DataBindingProfile.class, databinding);
094:
095:                Class<? extends ToolContainer> containerClass = frontend
096:                        .getContainerClass();
097:
098:                InputStream toolspecStream = getResourceAsStream(
099:                        containerClass, frontend.getToolspec());
100:
101:                ToolRunner.runTool(containerClass, toolspecStream, false, args,
102:                        isExitOnFinish(), context);
103:            }
104:
105:            protected boolean isVerbose() {
106:                return isSet(new String[] { "-V", "-verbose" });
107:            }
108:
109:            private boolean isSet(String[] keys) {
110:                if (args == null) {
111:                    return false;
112:                }
113:                List<String> pargs = Arrays.asList(args);
114:
115:                for (String key : keys) {
116:                    if (pargs.contains(key)) {
117:                        return true;
118:                    }
119:                }
120:                return false;
121:            }
122:
123:            private String parseArguments(String[] pargs, String key) {
124:                if (pargs == null) {
125:                    return null;
126:                }
127:                List<String> largs = Arrays.asList(pargs);
128:
129:                int index = 0;
130:                if (largs.contains(key)) {
131:                    index = largs.indexOf(key);
132:                    if (index + 1 < largs.size()) {
133:                        return largs.get(index + 1);
134:                    }
135:                }
136:                return null;
137:            }
138:
139:            private String getOptionValue(String[] pargs, String[] keys) {
140:                for (String key : keys) {
141:                    String value = parseArguments(pargs, key);
142:                    if (!StringUtils.isEmpty(value)) {
143:                        return value.trim();
144:                    }
145:                }
146:                return null;
147:            }
148:
149:            protected String getFrontEndName(String[] pargs) {
150:                return getOptionValue(pargs,
151:                        new String[] { "-frontend", "-fe" });
152:            }
153:
154:            protected String getDataBindingName(String[] pargs) {
155:                return getOptionValue(pargs, new String[] { "-databinding",
156:                        "-db" });
157:            }
158:
159:            public void setArguments(String[] pargs) {
160:                args = pargs;
161:            }
162:
163:            public static void main(String[] pargs) {
164:
165:                WSDLToJava w2j = new WSDLToJava(pargs);
166:                try {
167:
168:                    w2j.run(new ToolContext());
169:
170:                } catch (ToolException ex) {
171:                    System.err.println();
172:                    System.err.println("WSDLToJava Error : " + ex.getMessage());
173:                    System.err.println();
174:                    if (w2j.isVerbose()) {
175:                        ex.printStackTrace();
176:                    }
177:                    if (w2j.isExitOnFinish()) {
178:                        System.exit(1);
179:                    }
180:                } catch (Exception ex) {
181:                    System.err.println("WSDLToJava Error : " + ex.getMessage());
182:                    System.err.println();
183:                    if (w2j.isVerbose()) {
184:                        ex.printStackTrace();
185:                    }
186:                    if (w2j.isExitOnFinish()) {
187:                        System.exit(1);
188:                    }
189:                }
190:                if (w2j.isExitOnFinish()) {
191:                    System.exit(0);
192:                }
193:            }
194:
195:            private static InputStream getResourceAsStream(Class clz,
196:                    String file) {
197:                return clz.getResourceAsStream(file);
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.