Source Code Cross Referenced for Java2WSDLMojo.java in  » Web-Services-apache-cxf-2.0.1 » maven-plugins » org » apache » cxf » maven_plugin » 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 » maven plugins » org.apache.cxf.maven_plugin 
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.maven_plugin;
019:
020:        import java.io.File;
021:        import java.util.ArrayList;
022:        import java.util.List;
023:
024:        import org.apache.cxf.helpers.FileUtils;
025:        import org.apache.cxf.tools.java2wsdl.JavaToWSDL;
026:        import org.apache.maven.plugin.AbstractMojo;
027:        import org.apache.maven.plugin.MojoExecutionException;
028:        import org.apache.maven.project.MavenProject;
029:        import org.apache.tools.ant.ExitException;
030:        import org.apache.tools.ant.util.optional.NoExitSecurityManager;
031:
032:        /**
033:         * @goal java2wsdl
034:         * @description CXF Java To WSDL Tool
035:         */
036:        public class Java2WSDLMojo extends AbstractMojo {
037:            /**
038:             * @parameter
039:             * @required
040:             */
041:            String className;
042:
043:            /**
044:             * @parameter  expression="${project.build.outputDirectory}"
045:             * @required
046:             */
047:            String classpath;
048:
049:            /**
050:             * @parameter
051:             */
052:            String outputFile;
053:
054:            /**
055:             * @parameter
056:             */
057:            Boolean soap12;
058:
059:            /**
060:             * @parameter
061:             */
062:            String targetNamespace;
063:
064:            /**
065:             * @parameter
066:             */
067:            String serviceName;
068:
069:            /**
070:             * @parameter
071:             */
072:            Boolean verbose;
073:
074:            /**
075:             * @parameter
076:             */
077:            Boolean quiet;
078:
079:            /**
080:             * @parameter  expression="${project.compileClasspathElements}"
081:             * @required
082:             */
083:            List classpathElements;
084:
085:            /**
086:             * @parameter expression="${project}"
087:             * @required
088:             */
089:            MavenProject project;
090:
091:            public void execute() throws MojoExecutionException {
092:                File classesDir = new File(classpath);
093:                FileUtils.mkDir(classesDir);
094:
095:                StringBuffer buf = new StringBuffer();
096:                for (Object classpathElement : classpathElements) {
097:                    buf.append(classpathElement.toString());
098:                    buf.append(File.pathSeparatorChar);
099:                }
100:                String newCp = buf.toString();
101:
102:                String cp = System.getProperty("java.class.path");
103:                SecurityManager oldSm = System.getSecurityManager();
104:                try {
105:                    System.setProperty("java.class.path", newCp);
106:                    System.setSecurityManager(new NoExitSecurityManager());
107:                    processJavaClass();
108:                } finally {
109:                    System.setSecurityManager(oldSm);
110:                    System.setProperty("java.class.path", cp);
111:                }
112:
113:                System.gc();
114:            }
115:
116:            private void processJavaClass() throws MojoExecutionException {
117:                List<String> args = new ArrayList<String>();
118:
119:                // outputfile arg
120:                if (outputFile == null && project != null) {
121:                    // Put the wsdl in target/generated/wsdl
122:                    int i = className.lastIndexOf('.');
123:                    // Prone to OoBE, but then it's wrong anyway
124:                    String name = className.substring(i + 1);
125:                    outputFile = (project.getBuild().getDirectory()
126:                            + "/generated/wsdl/" + name + ".wsdl").replace("/",
127:                            File.separator);
128:                }
129:                if (outputFile != null) {
130:                    // JavaToWSDL freaks out if the directory of the outputfile doesn't exist, so lets
131:                    // create it since there's no easy way for the user to create it beforehand in maven
132:                    FileUtils.mkDir(new File(outputFile).getParentFile());
133:                    args.add("-o");
134:                    args.add(outputFile);
135:
136:                    /*
137:                      Contributor's comment:
138:                      Sometimes JavaToWSDL creates Java code for the wrappers.  I don't *think* this is
139:                      needed by the end user.
140:                     */
141:
142:                    // Commiter's comment:
143:                    // Yes, it's required, it's defined in the JAXWS spec.
144:                    if (project != null) {
145:                        project.addCompileSourceRoot(new File(outputFile)
146:                                .getParentFile().getAbsolutePath());
147:                    }
148:                }
149:
150:                // classpath arg
151:                args.add("-cp");
152:                args.add(classpath);
153:
154:                // soap12 arg
155:                if (soap12 != null && soap12.booleanValue()) {
156:                    args.add("-soap12");
157:                }
158:
159:                // target namespace arg
160:                if (targetNamespace != null) {
161:                    args.add("-t");
162:                    args.add(targetNamespace);
163:                }
164:
165:                // servicename arg
166:                if (serviceName != null) {
167:                    args.add("-servicename");
168:                    args.add(serviceName);
169:                }
170:
171:                // verbose arg
172:                if (verbose != null && verbose.booleanValue()) {
173:                    args.add("-verbose");
174:                }
175:
176:                // quiet arg
177:                if (quiet != null && quiet.booleanValue()) {
178:                    args.add("-quiet");
179:                }
180:
181:                // classname arg
182:                args.add(className);
183:
184:                String exitOnFinish = System.getProperty("exitOnFinish", "");
185:                try {
186:                    JavaToWSDL.main(args.toArray(new String[args.size()]));
187:                } catch (ExitException e) {
188:                    if (e.getStatus() != 0) {
189:                        throw e;
190:                    }
191:                } finally {
192:                    System.setProperty("exitOnFinish", exitOnFinish);
193:                }
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.