Source Code Cross Referenced for SoapUIToolRunner.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » tools » 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 » soapui 1.7.5 » com.eviware.soapui.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.tools;
014:
015:        import java.io.File;
016:
017:        import org.apache.commons.cli.CommandLine;
018:
019:        import com.eviware.soapui.SoapUI;
020:        import com.eviware.soapui.impl.wsdl.WsdlProject;
021:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.axis1.Axis1XWSDL2JavaAction;
022:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.axis2.Axis2WSDL2CodeAction;
023:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.dotnet.DotNetWsdlAction;
024:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.gsoap.GSoapAction;
025:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.jaxb.JaxbXjcAction;
026:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.jbossws.JBossWSConsumeAction;
027:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.jbossws.WSToolsWsdl2JavaAction;
028:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.oracle.OracleWsaGenProxyAction;
029:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.AbstractToolsAction;
030:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.RunnerContext;
031:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ToolHost;
032:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ToolRunner;
033:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.wscompile.WSCompileAction;
034:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.wsi.WSIAnalyzeAction;
035:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.wsimport.WSImportAction;
036:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.xfire.XFireAction;
037:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.xmlbeans.XmlBeans2Action;
038:        import com.eviware.soapui.model.iface.Interface;
039:
040:        /**
041:         * Standalone tool-runner used from maven-plugin, can also be used from command-line (see xdocs) or
042:         * directly from other classes.
043:         * <p>
044:         * For standalone usage, set the project file (with setProjectFile) and other desired properties before
045:         * calling run</p> 
046:         * 
047:         * @author Ole.Matzura
048:         */
049:
050:        public class SoapUIToolRunner extends AbstractSoapUIRunner implements 
051:                ToolHost, RunnerContext {
052:            private String iface;
053:            private String tool;
054:
055:            private RunnerStatus status;
056:            public static String TITLE = "soapUI " + SoapUI.SOAPUI_VERSION
057:                    + " Tool Runner";
058:
059:            /**
060:             * Runs the specified tool in the specified soapUI project file, see soapUI xdocs for details.
061:             * 
062:             * @param args
063:             * @throws Exception
064:             */
065:
066:            @SuppressWarnings("static-access")
067:            public static void main(String[] args) throws Exception {
068:                new SoapUIToolRunner().runFromCommandLine(args);
069:            }
070:
071:            /**
072:             * Sets the tool(s) to run, can be a comma-seperated list
073:             * 
074:             * @param tool the tools to run
075:             */
076:
077:            public void setTool(String tool) {
078:                this .tool = tool;
079:            }
080:
081:            public void setInterface(String iface) {
082:                this .iface = iface;
083:            }
084:
085:            public SoapUIToolRunner() {
086:                super (TITLE);
087:            }
088:
089:            public SoapUIToolRunner(String title) {
090:                super (title);
091:            }
092:
093:            public void run() throws Exception {
094:                String projectFile = getProjectFile();
095:
096:                if (!new File(projectFile).exists())
097:                    throw new Exception("soapUI project file [" + projectFile
098:                            + "] not found");
099:
100:                WsdlProject project = new WsdlProject(projectFile, null);
101:                log.info("Running tools [" + tool + "] for interface [" + iface
102:                        + "] in project [" + project.getName() + "]");
103:
104:                long startTime = System.nanoTime();
105:
106:                for (int c = 0; c < project.getInterfaceCount(); c++) {
107:                    Interface i = project.getInterfaceAt(c);
108:                    if (iface == null || i.getName().equals(iface)) {
109:                        runTool(i);
110:                    }
111:                }
112:
113:                long timeTaken = (System.nanoTime() - startTime) / 1000000;
114:                log.info("time taken: " + timeTaken + "ms");
115:            }
116:
117:            /**
118:             * Runs the configured tool(s) for the specified interface.. needs to be refactored to use
119:             * some kind of registry/factory pattern for tools
120:             * 
121:             * @param iface
122:             */
123:
124:            public void runTool(Interface iface) {
125:                AbstractToolsAction<Interface> action = null;
126:
127:                String[] tools = tool.split(",");
128:                for (String tool : tools) {
129:                    if (tool == null || tool.trim().length() == 0)
130:                        continue;
131:
132:                    if (tool.equals("axis1")) {
133:                        action = new Axis1XWSDL2JavaAction();
134:                    } else if (tool.equals("axis2")) {
135:                        action = new Axis2WSDL2CodeAction();
136:                    } else if (tool.equals("dotnet")) {
137:                        action = new DotNetWsdlAction();
138:                    } else if (tool.equals("gsoap")) {
139:                        action = new GSoapAction();
140:                    } else if (tool.equals("jaxb")) {
141:                        action = new JaxbXjcAction();
142:                    } else if (tool.equals("wstools")) {
143:                        action = new WSToolsWsdl2JavaAction();
144:                    } else if (tool.equals("wscompile")) {
145:                        action = new WSCompileAction();
146:                    } else if (tool.equals("wsimport")) {
147:                        action = new WSImportAction();
148:                    } else if (tool.equals("wsconsume")) {
149:                        action = new JBossWSConsumeAction();
150:                    } else if (tool.equals("xfire")) {
151:                        action = new XFireAction();
152:                    } else if (tool.equals("xmlbeans")) {
153:                        action = new XmlBeans2Action();
154:                    } else if (tool.equals("ora")) {
155:                        action = new OracleWsaGenProxyAction();
156:                    } else if (tool.equals("wsi")) {
157:                        action = new WSIAnalyzeAction();
158:                    }
159:
160:                    try {
161:                        log.info("Running tool [" + tool + "] for Interface ["
162:                                + iface.getName() + "]");
163:                        action.perform(iface, null);
164:                    } catch (Exception e) {
165:                        SoapUI.logError(e);
166:                    }
167:                }
168:            }
169:
170:            public void run(ToolRunner runner) throws Exception {
171:                status = RunnerStatus.RUNNING;
172:                runner.setContext(this );
173:                runner.run();
174:            }
175:
176:            public RunnerStatus getStatus() {
177:                return status;
178:            }
179:
180:            public String getTitle() {
181:                return getClass().getSimpleName();
182:            }
183:
184:            public void log(String msg) {
185:                System.out.print(msg);
186:            }
187:
188:            public void logError(String msg) {
189:                System.err.println(msg);
190:            }
191:
192:            public void setStatus(RunnerStatus status) {
193:                this .status = status;
194:            }
195:
196:            public void disposeContext() {
197:            }
198:
199:            @Override
200:            protected SoapUIOptions initCommandLineOptions() {
201:                SoapUIOptions options = new SoapUIOptions("toolrunner");
202:                options.addOption("i", true, "Sets the interface");
203:                options.addOption("t", true, "Sets the tool to run");
204:                options.addOption("s", false,
205:                        "Sets the soapui-settings.xml file to use");
206:                return options;
207:            }
208:
209:            @Override
210:            protected boolean processCommandLine(CommandLine cmd) {
211:                setTool(cmd.getOptionValue("t"));
212:
213:                if (cmd.hasOption("i"))
214:                    setInterface(cmd.getOptionValue("i"));
215:
216:                if (cmd.hasOption("s"))
217:                    SoapUI.initSettings(cmd.getOptionValue("s"));
218:
219:                return true;
220:
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.