Source Code Cross Referenced for Axis2WSDL2CodeAction.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » actions » iface » tools » axis2 » 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.axis2 
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.axis2;
014:
015:        import java.io.File;
016:        import java.util.Map;
017:
018:        import javax.wsdl.Definition;
019:        import javax.wsdl.Port;
020:        import javax.wsdl.Service;
021:        import javax.xml.namespace.QName;
022:
023:        import com.eviware.soapui.SoapUI;
024:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.AbstractToolsAction;
025:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ArgumentBuilder;
026:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.NamespaceTable;
027:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ProcessToolRunner;
028:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.ToolHost;
029:        import com.eviware.soapui.impl.wsdl.support.HelpUrls;
030:        import com.eviware.soapui.model.iface.Interface;
031:        import com.eviware.soapui.settings.ToolsSettings;
032:        import com.eviware.soapui.support.Tools;
033:        import com.eviware.soapui.support.UISupport;
034:        import com.eviware.soapui.support.types.StringToStringMap;
035:        import com.eviware.x.form.XForm;
036:        import com.eviware.x.form.XFormDialog;
037:        import com.eviware.x.form.XFormDialogBuilder;
038:        import com.eviware.x.form.XFormFactory;
039:        import com.eviware.x.form.XFormField;
040:        import com.eviware.x.form.XFormTextField;
041:
042:        /**
043:         * Invokes axis 2 WSDL2Code
044:         * 
045:         * @author Ole.Matzura
046:         */
047:
048:        public class Axis2WSDL2CodeAction extends
049:                AbstractToolsAction<Interface> {
050:            private static final String WSDL2JAVA_SCRIPT_NAME = "wsdl2java";
051:            private static final String PACKAGE = "Package";
052:            private static final String OUTPUT = "Output Directory";
053:            private static final String SERVICE_NAME = "service name";
054:            private static final String PORT_NAME = "port name";
055:            private static final String ASYNC = "async";
056:            private static final String SYNC = "sync";
057:            private static final String TESTCASE = "test-case";
058:            private static final String SERVERSIDE = "server-side";
059:            private static final String SERICEDESCRIPTOR = "service descriptor";
060:            private static final String DATABINDING = "databinding method";
061:            private static final String GENERATEALL = "generate all";
062:            private static final String UNPACK = "unpack classes";
063:            private static final String SERVERSIDEINTERFACE = "serverside-interface";
064:
065:            private static final String ADB_WRITE = "adb writeClasses";
066:            private static final String ADB_WRAP = "adb wrapClasses";
067:            private static final String NAMESPACE_MAPPING = "namespace mapping";
068:            private static final String JIBX_BINDING_FILE = "JIBX bindingfile";
069:            public static final String SOAPUI_ACTION_ID = "Axis2WSDL2CodeAction";
070:
071:            public Axis2WSDL2CodeAction() {
072:                super ("Axis 2 Artifacts",
073:                        "Generates Axis 2 artifacts using wsdl2java");
074:            }
075:
076:            protected StringToStringMap initValues(Interface modelItem) {
077:                StringToStringMap values = super .initValues(modelItem);
078:
079:                if (!values.hasValue(PORT_NAME)
080:                        || !values.hasValue(SERVICE_NAME))
081:                    initServiceAndPort(values, modelItem);
082:
083:                return values;
084:            }
085:
086:            @SuppressWarnings("unchecked")
087:            private void initServiceAndPort(StringToStringMap values,
088:                    Interface modelItem) {
089:                if (modelItem == null)
090:                    return;
091:
092:                try {
093:                    QName bindingName = modelItem.getBindingName();
094:                    Definition definition = modelItem.getWsdlContext()
095:                            .getDefinition();
096:                    Map<QName, Service> services = definition.getAllServices();
097:
098:                    for (QName serviceName : services.keySet()) {
099:                        Service service = services.get(serviceName);
100:
101:                        Map<String, Port> portMap = service.getPorts();
102:                        for (String portName : portMap.keySet()) {
103:                            Port port = portMap.get(portName);
104:                            if (port.getBinding().getQName()
105:                                    .equals(bindingName)) {
106:                                values.put(SERVICE_NAME, serviceName
107:                                        .getLocalPart());
108:                                values.put(PORT_NAME, portName);
109:
110:                                break;
111:                            }
112:                        }
113:
114:                        if (values.containsKey(PORT_NAME))
115:                            break;
116:                    }
117:                } catch (Exception e) {
118:                    SoapUI.logError(e);
119:                }
120:            }
121:
122:            protected XFormDialog buildDialog(Interface modelItem) {
123:                XFormDialogBuilder builder = XFormFactory
124:                        .createDialogBuilder("Axis2 artifacts");
125:                XForm mainForm = builder.createForm("Basic");
126:
127:                addWSDLFields(mainForm, modelItem);
128:
129:                mainForm.addTextField(OUTPUT,
130:                        "root directory for generated files.",
131:                        XForm.FieldType.PROJECT_FOLDER);
132:                mainForm.addTextField(PACKAGE, "target package nam",
133:                        XForm.FieldType.JAVA_PACKAGE);
134:
135:                XFormField dbComboBox = mainForm.addComboBox(DATABINDING,
136:                        new String[] { "xmlbeans", "adb", "jibx", "jaxme" },
137:                        "Specifies the Databinding framework.");
138:
139:                mainForm.addCheckBox(ASYNC,
140:                        "(generate code only for async style)");
141:                mainForm.addCheckBox(SYNC,
142:                        "(generate code only for sync style)");
143:                mainForm.addCheckBox(TESTCASE, "(Generate a test case)");
144:
145:                XFormField serverSideCB = mainForm.addCheckBox(SERVERSIDE,
146:                        "(Generate server side code (i.e. skeletons))");
147:
148:                XFormField ssiCB = mainForm.addCheckBox(SERVERSIDEINTERFACE,
149:                        "(Generate interface for server side)");
150:                XFormField sdCB = mainForm.addCheckBox(SERICEDESCRIPTOR,
151:                        "(Generate the service descriptor (i.e. server.xml).)");
152:                serverSideCB.addComponentEnabler(ssiCB, "true");
153:                serverSideCB.addComponentEnabler(sdCB, "true");
154:
155:                XForm advForm = builder.createForm("Advanced");
156:
157:                advForm.addCheckBox(GENERATEALL, "(Genrates all the classes)");
158:                advForm
159:                        .addCheckBox(UNPACK,
160:                                "(Unpacks the databinding classes)");
161:
162:                advForm.addTextField(SERVICE_NAME,
163:                        "the service name to be code generated",
164:                        XForm.FieldType.TEXT);
165:                advForm.addTextField(PORT_NAME,
166:                        "the port name to be code generated",
167:                        XForm.FieldType.TEXT);
168:
169:                advForm.addComponent(NAMESPACE_MAPPING, new NamespaceTable(
170:                        modelItem));
171:
172:                XFormField adbWrapCB = advForm
173:                        .addCheckBox(ADB_WRAP,
174:                                "(Sets the packing flag. if true the classes will be packed.)");
175:                XFormField adbWriteCB = advForm
176:                        .addCheckBox(ADB_WRITE,
177:                                "(Sets the write flag. If set to true the classes will be written by ADB)");
178:                XFormTextField jibxCB = advForm.addTextField(JIBX_BINDING_FILE,
179:                        "The JIBX binding file to use",
180:                        XForm.FieldType.PROJECT_FILE);
181:                dbComboBox.addComponentEnabler(adbWrapCB, "adb");
182:                dbComboBox.addComponentEnabler(adbWriteCB, "adb");
183:                dbComboBox.addComponentEnabler(jibxCB, "jibx");
184:
185:                buildArgsForm(builder, false, "WSDL2Java");
186:
187:                return builder.buildDialog(buildDefaultActions(
188:                        HelpUrls.AXIS2X_HELP_URL, modelItem),
189:                        "Specify arguments for Axis 2.X Wsdl2Java",
190:                        UISupport.TOOL_ICON);
191:            }
192:
193:            protected void generate(StringToStringMap values,
194:                    ToolHost toolHost, Interface modelItem) throws Exception {
195:                String axis2Dir = SoapUI.getSettings().getString(
196:                        ToolsSettings.AXIS_2_LOCATION, null);
197:                if (Tools.isEmpty(axis2Dir)) {
198:                    UISupport
199:                            .showErrorMessage("Axis 2 wsdl2java directory must be set in global preferences");
200:                    return;
201:                }
202:
203:                ProcessBuilder builder = new ProcessBuilder();
204:                ArgumentBuilder args = buildArgs(values, modelItem);
205:                builder.command(args.getArgs());
206:                builder.directory(new File(axis2Dir + File.separatorChar
207:                        + "bin"));
208:
209:                toolHost.run(new ProcessToolRunner(builder, "Axis2 wsdl2java",
210:                        modelItem));
211:            }
212:
213:            private ArgumentBuilder buildArgs(StringToStringMap values,
214:                    Interface modelItem) {
215:                values.put(OUTPUT, Tools.ensureDir(values.get(OUTPUT), ""));
216:
217:                ArgumentBuilder builder = new ArgumentBuilder(values);
218:                builder.startScript(WSDL2JAVA_SCRIPT_NAME);
219:                builder.addArgs("-uri", getWsdlUrl(values, modelItem));
220:                builder.addString(OUTPUT, "-o");
221:                builder.addString(PACKAGE, "p");
222:                builder.addString(DATABINDING, "-d");
223:                builder.addBoolean(ASYNC, "-a");
224:                builder.addBoolean(SYNC, "-s");
225:                builder.addBoolean(TESTCASE, "-t");
226:                builder.addBoolean(SERVERSIDE, "-ss");
227:                builder.addBoolean(SERVERSIDEINTERFACE, "-ssi");
228:                builder.addBoolean(SERICEDESCRIPTOR, "-sd");
229:                builder.addBoolean(GENERATEALL, "-g");
230:                builder.addBoolean(UNPACK, "-u");
231:
232:                builder.addString(SERVICE_NAME, "-sn");
233:                builder.addString(PORT_NAME, "-pn");
234:
235:                if ("adb".equals(values.get(DATABINDING))) {
236:                    builder.addBoolean(ADB_WRAP, "-Ew", "true", "false");
237:                    builder.addBoolean(ADB_WRITE, "-Er");
238:                }
239:
240:                if ("jibx".equals(values.get(DATABINDING))) {
241:                    builder.addString(JIBX_BINDING_FILE, "-E", "");
242:                }
243:
244:                try {
245:                    StringBuilder nsMapArg = new StringBuilder();
246:                    StringToStringMap nsMappings = StringToStringMap
247:                            .fromXml(values.get(NAMESPACE_MAPPING));
248:                    for (String namespace : nsMappings.keySet()) {
249:                        if (nsMapArg.length() > 0)
250:                            nsMapArg.append(',');
251:
252:                        nsMapArg.append(namespace).append('=').append(
253:                                nsMappings.get(namespace));
254:                    }
255:
256:                    builder.addArgs("-ns2p", nsMapArg.toString());
257:                } catch (Exception e) {
258:                    SoapUI.logError(e);
259:                }
260:
261:                addToolArgs(values, builder);
262:
263:                return builder;
264:            }
265:        }
w__ww_._j__a_v_a2s___.___c__o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.