Source Code Cross Referenced for WSToolsRegenerateJava2WsdlAction.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » actions » iface » tools » jbossws » 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.impl.wsdl.actions.iface.tools.jbossws 
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.impl.wsdl.actions.iface.tools.jbossws;
014:
015:        import java.io.File;
016:        import java.io.IOException;
017:
018:        import org.jboss.jbosswsTools.ConfigurationDocument;
019:        import org.jboss.jbosswsTools.ConfigurationType;
020:        import org.jboss.jbosswsTools.JavaToWsdlType;
021:        import org.jboss.jbosswsTools.MappingType;
022:        import org.jboss.jbosswsTools.NamespacesType;
023:        import org.jboss.jbosswsTools.ServiceType;
024:        import org.jboss.jbosswsTools.WsxmlType;
025:        import org.jboss.jbosswsTools.ServiceType.ParameterStyle;
026:        import org.jboss.jbosswsTools.ServiceType.Style;
027:
028:        import com.eviware.soapui.SoapUI;
029:        import com.eviware.soapui.impl.wsdl.WsdlInterface;
030:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.AbstractToolsAction;
031:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ArgumentBuilder;
032:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ProcessToolRunner;
033:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.RunnerContext;
034:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ShowConfigFileAction;
035:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ToolHost;
036:        import com.eviware.soapui.impl.wsdl.support.HelpUrls;
037:        import com.eviware.soapui.settings.ToolsSettings;
038:        import com.eviware.soapui.support.Tools;
039:        import com.eviware.soapui.support.UISupport;
040:        import com.eviware.soapui.support.action.swing.ActionList;
041:        import com.eviware.soapui.support.types.StringToStringMap;
042:        import com.eviware.x.form.XForm;
043:        import com.eviware.x.form.XFormDialog;
044:        import com.eviware.x.form.XFormDialogBuilder;
045:        import com.eviware.x.form.XFormFactory;
046:
047:        /**
048:         * Invokes jbossws java2wsdl tools
049:         * 
050:         * @author Ole.Matzura
051:         */
052:
053:        public class WSToolsRegenerateJava2WsdlAction extends
054:                AbstractToolsAction<WsdlInterface> {
055:            private static final String CLASSPATH = "Classpath";
056:            private static final String OUTPUT = "Output Directory";
057:            private static final String ENDPOINT = "Endpoint";
058:            private static final String MAPPING = "Mapping file";
059:            private static final String SERVICE_NAME = "Service Name";
060:            private static final String STYLE = "Style";
061:            private static final String PARAMETER_STYLE = "Parameter Style";
062:            private static final String TARGET_NAMESPACE = "Target NS";
063:            private static final String TYPES_NAMESPACE = "Types NS";
064:            private static final String EJB_LINK = "ejb-link";
065:            private static final String SERVLET_LINK = "servlet-link";
066:            public static final String SOAPUI_ACTION_ID = "WSToolsRegenerateJava2WsdlAction";
067:
068:            public WSToolsRegenerateJava2WsdlAction() {
069:                super ("Regenerate with JBossWS",
070:                        "Regenerates WSDL with the jbossws wstools utility");
071:            }
072:
073:            protected XFormDialog buildDialog(WsdlInterface modelItem) {
074:                XFormDialogBuilder builder = XFormFactory
075:                        .createDialogBuilder("Regenerate JBossWS WSDL Artifacts");
076:
077:                XForm mainForm = builder.createForm("Basic");
078:
079:                mainForm.addTextField(ENDPOINT, "Serice Endpoint Interface",
080:                        XForm.FieldType.JAVA_CLASS);
081:                mainForm.addTextField(SERVICE_NAME,
082:                        "The name of the generated Service",
083:                        XForm.FieldType.TEXT);
084:                mainForm.addComboBox(STYLE, new String[] {
085:                        Style.DOCUMENT.toString(), Style.RPC.toString() },
086:                        "The style to use");
087:                mainForm
088:                        .addComboBox(PARAMETER_STYLE, new String[] {
089:                                ParameterStyle.BARE.toString(),
090:                                ParameterStyle.WRAPPED.toString() },
091:                                "The style to use");
092:                mainForm.addTextField(CLASSPATH, "Classpath to use",
093:                        XForm.FieldType.PROJECT_FOLDER);
094:                mainForm.addTextField(OUTPUT,
095:                        "The root directory for all emitted files.",
096:                        XForm.FieldType.PROJECT_FOLDER);
097:                mainForm.addTextField(MAPPING, "mapping file to generate",
098:                        XForm.FieldType.PROJECT_FILE);
099:                mainForm.addTextField(TARGET_NAMESPACE,
100:                        "The target namespace for the generated WSDL",
101:                        XForm.FieldType.TEXT);
102:                mainForm.addTextField(TYPES_NAMESPACE,
103:                        "The namespace for the generated types",
104:                        XForm.FieldType.TEXT);
105:                mainForm.addTextField(EJB_LINK,
106:                        "The name of the source EJB to link to",
107:                        XForm.FieldType.TEXT);
108:                mainForm.addTextField(SERVLET_LINK,
109:                        "The name of the source Servlet to link to",
110:                        XForm.FieldType.TEXT);
111:
112:                buildArgsForm(builder, false, "wstools");
113:
114:                ActionList actions = buildDefaultActions(
115:                        HelpUrls.WSTOOLS_HELP_URL, modelItem);
116:                actions.addAction(new ShowConfigFileAction("JBossWS Wsdl2Java",
117:                        "Contents of generated wsconfig.xml file") {
118:                    protected String getConfigFile() {
119:                        ConfigurationDocument configDocument = createConfigFile(dialog
120:                                .getValues());
121:                        return configDocument.toString();
122:                    }
123:                });
124:
125:                return builder
126:                        .buildDialog(
127:                                actions,
128:                                "Specify arguments for JBossWS wstools java2wsdl functionality",
129:                                UISupport.TOOL_ICON);
130:            }
131:
132:            protected void generate(StringToStringMap values,
133:                    ToolHost toolHost, WsdlInterface modelItem)
134:                    throws Exception {
135:                String wstoolsDir = SoapUI.getSettings().getString(
136:                        ToolsSettings.JBOSSWS_WSTOOLS_LOCATION, null);
137:                if (Tools.isEmpty(wstoolsDir)) {
138:                    UISupport
139:                            .showErrorMessage("wstools directory must be set in global preferences");
140:                    return;
141:                }
142:
143:                String wsToolsExtension = UISupport.isWindows() ? ".bat"
144:                        : ".sh";
145:
146:                File wstoolsFile = new File(wstoolsDir + File.separatorChar
147:                        + "wstools" + wsToolsExtension);
148:                if (!wstoolsFile.exists()) {
149:                    UISupport
150:                            .showErrorMessage("Could not find wstools script at ["
151:                                    + wstoolsFile + "]");
152:                    return;
153:                }
154:
155:                ProcessBuilder builder = new ProcessBuilder();
156:                ArgumentBuilder args = buildArgs(UISupport.isWindows());
157:                builder.command(args.getArgs());
158:                builder.directory(new File(wstoolsDir));
159:
160:                toolHost.run(new ToolRunner(builder, new File(values
161:                        .get(OUTPUT)), values.get(SERVICE_NAME), modelItem));
162:            }
163:
164:            private ArgumentBuilder buildArgs(boolean isWindows)
165:                    throws IOException {
166:                StringToStringMap values = dialog.getValues();
167:                values.put(OUTPUT, Tools.ensureDir(values.get(OUTPUT), ""));
168:
169:                ArgumentBuilder builder = new ArgumentBuilder(values);
170:                builder.startScript("wstools");
171:
172:                builder.addString(CLASSPATH, "-cp");
173:                builder.addArgs("-config", buildConfigFile(values));
174:                builder.addString(OUTPUT, "-dest");
175:                addToolArgs(values, builder);
176:                return builder;
177:            }
178:
179:            private String buildConfigFile(StringToStringMap values)
180:                    throws IOException {
181:                File file = File.createTempFile("wstools-config", ".xml",
182:                        new File(SoapUI.getSettings().getString(
183:                                ToolsSettings.JBOSSWS_WSTOOLS_LOCATION, null)));
184:                ConfigurationDocument configDocument = createConfigFile(values);
185:                configDocument.save(file);
186:                return file.getName();
187:            }
188:
189:            private ConfigurationDocument createConfigFile(
190:                    StringToStringMap values) {
191:                ConfigurationDocument configDocument = ConfigurationDocument.Factory
192:                        .newInstance();
193:                ConfigurationType config = configDocument.addNewConfiguration();
194:
195:                JavaToWsdlType java2Wsdl = config.addNewJavaWsdl();
196:                ServiceType service = java2Wsdl.addNewService();
197:                service.setEndpoint(values.get(ENDPOINT));
198:                service.setStyle(Style.Enum.forString(values.get(STYLE)));
199:                service.setParameterStyle(ParameterStyle.Enum.forString(values
200:                        .get(PARAMETER_STYLE)));
201:                service.setName(values.get(SERVICE_NAME));
202:
203:                MappingType mapping = java2Wsdl.addNewMapping();
204:                mapping.setFile(values.get(MAPPING));
205:
206:                NamespacesType namespaces = java2Wsdl.addNewNamespaces();
207:                namespaces.setTargetNamespace(values.get(TARGET_NAMESPACE));
208:                namespaces.setTypeNamespace(values.get(TYPES_NAMESPACE));
209:
210:                WsxmlType webservices = java2Wsdl.addNewWebservices();
211:                if (values.get(EJB_LINK) != null
212:                        && values.get(EJB_LINK).length() > 0)
213:                    webservices.setEjbLink(values.get(EJB_LINK));
214:                if (values.get(SERVLET_LINK) != null
215:                        && values.get(SERVLET_LINK).length() > 0)
216:                    webservices.setServletLink(values.get(SERVLET_LINK));
217:                return configDocument;
218:            }
219:
220:            private class ToolRunner extends ProcessToolRunner {
221:                private final File outDir;
222:                private final String serviceName;
223:                private final WsdlInterface modelItem;
224:
225:                public ToolRunner(ProcessBuilder builder, File outDir,
226:                        String serviceName, WsdlInterface modelItem) {
227:                    super (builder, "JBossWS wstools", modelItem);
228:                    this .outDir = outDir;
229:                    this .serviceName = serviceName;
230:                    this .modelItem = modelItem;
231:                }
232:
233:                protected void afterRun(RunnerContext context) {
234:                    if (context.getStatus() != RunnerContext.RunnerStatus.FINISHED)
235:                        return;
236:
237:                    try {
238:                        boolean ifaces = modelItem.updateDefinition("file:"
239:                                + outDir.getAbsolutePath() + File.separatorChar
240:                                + "wsdl" + File.separatorChar + serviceName
241:                                + ".wsdl", true);
242:
243:                        if (ifaces) {
244:                            context.log("Updated Interface ["
245:                                    + modelItem.getName() + "]");
246:                            UISupport.select(modelItem);
247:                        } else {
248:                            UISupport
249:                                    .showErrorMessage("Failed to update Interface from generated WSDL");
250:                        }
251:                    } catch (Exception e) {
252:                        SoapUI.logError(e);
253:                    }
254:                }
255:            }
256:        }
w___w__w.___j__a_v__a_2___s.___c___om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.