You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-dev@ws.apache.org by an...@apache.org on 2003/03/10 21:18:07 UTC
cvs commit: xml-axis-wsif/java/src/org/apache/wsif/wsdl WSDL2Java.java
antelder 2003/03/10 12:18:07
Added: java/src/org/apache/wsif/wsdl/gen
WSIFJavaGeneratorFactory.java WSIFEmitter.java
WSIFJavaBindingWriter.java
WSIFJavaServiceWriter.java
WSIFJavaTestCaseWriter.java
java/src/org/apache/wsif/wsdl WSDL2Java.java
Log:
WSIF specific version of the WSDL2Java tool
Revision Changes Path
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/gen/WSIFJavaGeneratorFactory.java
Index: WSIFJavaGeneratorFactory.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.gen;
import javax.wsdl.Binding;
import javax.wsdl.Service;
import org.apache.axis.wsdl.gen.Generator;
import org.apache.axis.wsdl.symbolTable.BindingEntry;
import org.apache.axis.wsdl.symbolTable.ServiceEntry;
import org.apache.axis.wsdl.symbolTable.SymbolTable;
import org.apache.axis.wsdl.toJava.JavaGeneratorFactory;
import org.apache.axis.wsdl.toJava.JavaServiceWriter;
/**
* WSIFJavaGeneratorFactory
*
* WSIF version of the AXIS JavaGeneratorFactory that overrides
* the service and binding generators to use the WSIF
* versions of the JavaServiceWriter and JavaBindingWriter.
*
* @author <a href="mailto:ant.elder@uk.ibm.com">Ant Elder</a>
*/
public class WSIFJavaGeneratorFactory extends JavaGeneratorFactory {
public Generator getGenerator(Service service, SymbolTable symbolTable) {
Generator writer =
new WSIFJavaServiceWriter(emitter, service, symbolTable);
ServiceEntry sEntry = symbolTable.getServiceEntry(service.getQName());
serviceWriters.addStuff(writer, sEntry, symbolTable);
return serviceWriters;
} // getGenerator
public Generator getGenerator(Binding binding, SymbolTable symbolTable) {
Generator writer =
new WSIFJavaBindingWriter(emitter, binding, symbolTable);
BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
bindingWriters.addStuff(writer, bEntry, symbolTable);
return bindingWriters;
} // getGenerator
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/gen/WSIFEmitter.java
Index: WSIFEmitter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.gen;
import org.apache.axis.wsdl.toJava.Emitter;
/**
* WSIFEmitter
*
* WSIF version of the AXIS Emitter that uses the WSIF
* version of JavaGeneratorFactory.
*
* @author <a href="mailto:ant.elder@uk.ibm.com">Ant Elder</a>
*/
public class WSIFEmitter extends Emitter {
protected boolean testcaseGenDII = false;
protected boolean testcaseGenStubs = true;
/**
* Constructor
*/
public WSIFEmitter() {
WSIFJavaGeneratorFactory factory = new WSIFJavaGeneratorFactory();
setFactory(factory);
factory.setEmitter(this);
}
/**
* Returns the testcaseGenDII.
* @return boolean
*/
public boolean isTestcaseGenDII() {
return testcaseGenDII;
}
/**
* Returns the testcaseGenStubs.
* @return boolean
*/
public boolean isTestcaseGenStubs() {
return testcaseGenStubs;
}
/**
* Sets the testcaseGenDII.
* @param testcaseGenDII The testcaseGenDII to set
*/
public void setTestcaseGenDII(boolean testcaseGenDII) {
this.testcaseGenDII = testcaseGenDII;
}
/**
* Sets the testcaseGenStubs.
* @param testcaseGenStubs The testcaseGenStubs to set
*/
public void setTestcaseGenStubs(boolean testcaseGenStubs) {
this.testcaseGenStubs = testcaseGenStubs;
}
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/gen/WSIFJavaBindingWriter.java
Index: WSIFJavaBindingWriter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.gen;
import java.io.IOException;
import javax.wsdl.Binding;
import org.apache.axis.wsdl.symbolTable.SymbolTable;
import org.apache.axis.wsdl.toJava.Emitter;
import org.apache.axis.wsdl.toJava.JavaBindingWriter;
/**
* WSIFJavaBindingWriter
*
* WSIF version of the AXIS JavaBindingWriter that overrides
* the generate method to only generate the interface. The
* AXIS version also generates stub, skeleton, and implementation
* files which are not required by WSIF.
*
* @author <a href="mailto:ant.elder@uk.ibm.com">Ant Elder</a>
*/
public class WSIFJavaBindingWriter extends JavaBindingWriter {
/**
* Constructor.
*/
public WSIFJavaBindingWriter(
Emitter emitter,
Binding binding,
SymbolTable symbolTable) {
super(emitter, binding, symbolTable);
} // ctor
/**
* Write all the binding bindings:
* - interfaceWriter only
* (but only if required by stub testcase)
*/
public void generate() throws IOException {
setGenerators();
if (interfaceWriter != null) {
if (((WSIFEmitter)emitter).isTestcaseGenStubs()) {
interfaceWriter.generate();
}
}
} // generate
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/gen/WSIFJavaServiceWriter.java
Index: WSIFJavaServiceWriter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.gen;
import javax.wsdl.Service;
import org.apache.axis.wsdl.symbolTable.ServiceEntry;
import org.apache.axis.wsdl.symbolTable.SymbolTable;
import org.apache.axis.wsdl.toJava.Emitter;
import org.apache.axis.wsdl.toJava.JavaServiceWriter;
/**
* WSIFJavaServiceWriter
*
* WSIF version of the AXIS JavaServiceWriter that suppresses
* the use of the serviceIfaceWritter and serviceImpWriter as
* these are not required by WSIF, and use the WSIF version
* of the JavaTestCaseWriter.
*
* @author <a href="mailto:ant.elder@uk.ibm.com">Ant Elder</a>
*/
public class WSIFJavaServiceWriter extends JavaServiceWriter {
/**
* Constructor.
*/
public WSIFJavaServiceWriter(
Emitter emitter,
Service service,
SymbolTable symbolTable) {
super(emitter, service, symbolTable);
ServiceEntry sEntry = symbolTable.getServiceEntry(service.getQName());
if (sEntry.isReferenced()) {
serviceIfaceWriter = null;
serviceImplWriter = null;
if (emitter.isTestCaseWanted()) {
testCaseWriter =
new WSIFJavaTestCaseWriter(emitter, sEntry, symbolTable);
}
}
} // ctor
}
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/gen/WSIFJavaTestCaseWriter.java
Index: WSIFJavaTestCaseWriter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl.gen;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.wsdl.Binding;
import javax.wsdl.Definition;
import javax.wsdl.Input;
import javax.wsdl.Operation;
import javax.wsdl.Output;
import javax.wsdl.Part;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.xml.namespace.QName;
import org.apache.axis.utils.JavaUtils;
import org.apache.axis.wsdl.symbolTable.BindingEntry;
import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
import org.apache.axis.wsdl.symbolTable.ServiceEntry;
import org.apache.axis.wsdl.symbolTable.SymbolTable;
import org.apache.axis.wsdl.toJava.Emitter;
import org.apache.axis.wsdl.toJava.JavaClassWriter;
import org.apache.axis.wsdl.toJava.Utils;
import org.apache.wsif.WSIFException;
import org.apache.wsif.providers.ProviderUtils;
import org.apache.wsif.util.WSIFUtils;
/**
* WSIFJavaTestCaseWriter
*
* WSIF version of the AXIS JavaTestCaseWriter that
* generates a WSIF JUnit testcase program source.
*
* @author <a href="mailto:ant.elder@uk.ibm.com">Ant Elder</a>
*/
public class WSIFJavaTestCaseWriter extends JavaClassWriter {
protected ServiceEntry sEntry;
protected SymbolTable symbolTable;
protected String indent;
protected static final String TAB = " ";
/**
* Constructor.
*/
protected WSIFJavaTestCaseWriter(
Emitter emitter,
ServiceEntry sEntry,
SymbolTable symbolTable) {
super(emitter, sEntry.getName() + "TestCase", "testCase");
this.sEntry = sEntry;
this.symbolTable = symbolTable;
}
/**
* Write the body of the TestCase file.
* For each port in the service get the portType
* and call writePortTypeTestCode.
*/
protected void writeFileBody(PrintWriter pw) throws IOException {
indent = TAB;
writeTestConstructor(pw);
skipLines(pw, 1);
writeTestSuite(pw);
ArrayList donePortTypes = new ArrayList();
Service service = sEntry.getService();
Map portMap = service.getPorts();
HashMap diiPortTypeMethods = new HashMap();
HashMap stubPortTypeMethods = new HashMap();
/* for each port in the service, get the portType
* used by its binding, and if hasn't already been
* done for another port then write a portType method */
for (Iterator i = portMap.values().iterator(); i.hasNext();) {
Port p = (Port) i.next();
Binding binding = p.getBinding();
BindingEntry bEntry =
symbolTable.getBindingEntry(binding.getQName());
PortType portType = binding.getPortType();
if (donePortTypes.contains(portType)) {
continue;
}
donePortTypes.add(portType);
String portName = p.getName();
if (!JavaUtils.isJavaId(portName)) {
portName = Utils.xmlNameToJavaClass(portName);
}
PortTypeEntry ptEntry =
symbolTable.getPortTypeEntry(portType.getQName());
if (((WSIFEmitter) emitter).isTestcaseGenDII()) {
writeComment(pw, p.getDocumentationElement());
String methodName =
writeDIITestPortType(
pw,
service,
portName,
portType,
ptEntry);
diiPortTypeMethods.put(portType, methodName);
}
if (((WSIFEmitter) emitter).isTestcaseGenStubs()) {
writeComment(pw, p.getDocumentationElement());
String methodName =
writeStubTestPortType(
pw,
service,
portName,
portType,
ptEntry);
stubPortTypeMethods.put(portType, methodName);
}
}
/* for each port in the service write a JUnit test
* method to call the portType method for the port. */
for (Iterator i = portMap.values().iterator(); i.hasNext();) {
Port p = (Port) i.next();
Binding binding = p.getBinding();
PortType portType = binding.getPortType();
if (((WSIFEmitter) emitter).isTestcaseGenDII()) {
writeTestMethod(
pw,
(String) diiPortTypeMethods.get(portType),
p.getName());
}
if (((WSIFEmitter) emitter).isTestcaseGenStubs()) {
writeTestMethod(
pw,
(String) stubPortTypeMethods.get(portType),
p.getName());
}
}
writeMainMethod(pw);
} // writeFileBody
/**
* Write the header comments.
* (Overriden to make WSIF specific)
*/
protected void writeHeaderComments(PrintWriter pw) throws IOException {
String localFile = getFileName();
int lastSepChar = localFile.lastIndexOf(File.separatorChar);
if (lastSepChar >= 0) {
localFile = localFile.substring(lastSepChar + 1);
}
pw.println("/**");
pw.println(" * " + localFile);
pw.println(" *");
pw.println(" * This file was auto-generated from WSDL");
pw.println(" * by the Apache WSIF WSDL2Java emitter.");
pw.println(" */");
pw.println();
} // writeHeaderComments
/**
* Write the package declaration statement.
* (Overriden so it can add the imports as well)
*/
protected void writePackage(PrintWriter pw) throws IOException {
if (getPackage() != null) {
pw.println("package " + getPackage() + ";");
pw.println();
}
writeImports(pw);
skipLines(pw, 1);
} // writePackage
/**
* Write the import statements.
*/
protected void writeImports(PrintWriter pw) throws IOException {
pw.println("import java.rmi.RemoteException;");
pw.println("import java.util.Iterator;");
skipLines(pw, 1);
pw.println("import junit.framework.Test;");
pw.println("import junit.framework.TestCase;");
pw.println("import junit.framework.TestSuite;");
pw.println("import junit.textui.TestRunner;");
skipLines(pw, 1);
pw.println("import org.apache.wsif.WSIFConstants;");
pw.println("import org.apache.wsif.WSIFException;");
pw.println("import org.apache.wsif.WSIFMessage;");
pw.println("import org.apache.wsif.WSIFOperation;");
pw.println("import org.apache.wsif.WSIFPort;");
pw.println("import org.apache.wsif.WSIFService;");
pw.println("import org.apache.wsif.WSIFServiceFactory;");
}
/**
* Returns "extends junit.framework.TestCase ".
*/
protected String getExtendsText() {
return "extends TestCase ";
} // getExtendsText
/**
* Write the constructor.
*/
protected void writeTestConstructor(PrintWriter pw) throws IOException {
addNewCodeLine(pw, "public " + getClassName() + "(String name) {");
tabIn();
addNewCodeLine(pw, "super(name);");
tabOut();
addNewCodeLine(pw, "}");
}
/**
* Write the JUnit suite method.
*/
protected void writeTestSuite(PrintWriter pw) throws IOException {
addNewCodeLine(pw, "public static Test suite() {");
tabIn();
addNewCodeLine(
pw,
"return new TestSuite(" + getClassName() + ".class);");
tabOut();
addNewCodeLine(pw, "}");
}
/**
* Write the testPortType method using stubs
*/
protected String writeStubTestPortType(
PrintWriter pw,
Service service,
String portName,
PortType portType,
PortTypeEntry ptEntry)
throws IOException {
QName serviceName = service.getQName();
QName portTypeName = portType.getQName();
String methodName = "doit" + "Stub" + portTypeName.getLocalPart();
addNewCodeLine(
pw,
"protected void " + methodName + "(String portName) {");
tabIn();
addNewCodeLine(pw, "try {");
tabIn();
addNewCodeLine(
pw,
"WSIFServiceFactory factory = WSIFServiceFactory.newInstance();");
skipLines(pw, 1);
addNewCodeLine(pw, "WSIFService service =");
tabIn();
addNewCodeLine(pw, "factory.getService(");
tabIn();
addNewCodeLine(
pw,
"\"" + emitter.getWSDLURI().replace('\\', '/') + "\",");
addNewCodeLine(pw, "\"" + serviceName.getNamespaceURI() + "\",");
addNewCodeLine(pw, "\"" + serviceName.getLocalPart() + "\",");
addNewCodeLine(pw, "\"" + portTypeName.getNamespaceURI() + "\",");
addNewCodeLine(pw, "\"" + portTypeName.getLocalPart() + "\");");
tabOut();
tabOut();
skipLines(pw, 1);
String seiName = getSEIName(portType);
addNewCodeLine(pw, seiName);
addCode(pw, " stub =");
tabIn();
addNewCodeLine(pw, "(");
addCode(pw, seiName);
addCode(pw, ") service.getStub(portName, ");
addCode(pw, seiName);
addCode(pw, ".class);");
tabOut();
skipLines(pw, 1);
for (Iterator i = portType.getOperations().iterator(); i.hasNext();) {
Operation op = (Operation) i.next();
String javaOpName = Utils.xmlNameToJavaClass(op.getName());
String opMethodName = "executeOp" + javaOpName;
if (isOverloaded(portType, op)) {
opMethodName += getInMsgName(op);
}
addNewCodeLine(pw, opMethodName + "(stub);");
}
skipLines(pw, 1);
tabOut();
addNewCodeLine(pw, "} catch (Exception ex) {");
tabIn();
addNewCodeLine(pw, "ex.printStackTrace();");
addNewCodeLine(pw, "assertTrue(\"");
addCode(pw, methodName);
addCode(pw, " got exception: \" + ex.getLocalizedMessage(), false);");
tabOut();
addNewCodeLine(pw, "}");
tabOut();
addNewCodeLine(pw, "}");
skipLines(pw, 1);
for (Iterator i = portType.getOperations().iterator(); i.hasNext();) {
Operation op = (Operation) i.next();
writeStubOperationMethod(pw, seiName, portType, op);
}
return methodName;
}
/**
* Write the executeOp method using stubs
*/
protected void writeStubOperationMethod(
PrintWriter pw,
String seiName,
PortType portType,
Operation op) {
addNewCodeLine(pw, "protected void ");
String javaOpName = Utils.xmlNameToJavaClass(op.getName());
String opMethodName = "executeOp" + javaOpName;
if (isOverloaded(portType, op)) {
opMethodName += getInMsgName(op);
}
addCode(pw, opMethodName);
addCode(pw, "(");
addCode(pw, seiName);
addCode(pw, " stub) throws RemoteException {");
skipLines(pw, 1);
tabIn();
ArrayList params = new ArrayList();
Input in = op.getInput();
if (in != null && in.getMessage() != null) {
List parts = in.getMessage().getOrderedParts(null);
unwrapIfWrapped(
emitter.getCurrentDefinition(),
parts,
op.getName());
addNewCodeLine(
pw,
"// TODO: change these params to required values");
int parameterCounter = 0;
for (Iterator i = parts.iterator(); i.hasNext();) {
Part p = (Part) i.next();
QName type = ProviderUtils.getPartType(p);
String className = Utils.getJavaLocalName(getClassName(type));
String paramName = "p" + parameterCounter++;
params.add(paramName);
addNewCodeLine(
pw,
className
+ " "
+ paramName
+ " = "
+ getTypeInitialiser(type)
+ ";");
}
skipLines(pw, 1);
}
String returnPartName = null;
String returnClassName = "";
Output out = op.getOutput();
if (out != null
&& out.getMessage() != null
&& out.getMessage().getParts().size() > 0) {
List parts = out.getMessage().getOrderedParts(null);
unwrapIfWrapped(
emitter.getCurrentDefinition(),
parts,
op.getName() + "Response");
Part p = (Part) parts.get(0);
returnPartName = p.getName();
QName type = ProviderUtils.getPartType(p);
returnClassName = Utils.getJavaLocalName(getClassName(type));
addNewCodeLine(pw, returnClassName);
addCode(pw, " ");
addCode(pw, returnPartName);
addCode(pw, " = stub.");
addCode(pw, op.getName());
addCode(pw, "(");
} else {
addNewCodeLine(pw, "stub.");
addCode(pw, op.getName());
addCode(pw, "(");
}
for (Iterator i = params.iterator(); i.hasNext();) {
String paramName = (String) i.next();
addCode(pw, paramName);
if (i.hasNext()) {
addCode(pw, ", ");
}
}
addCode(pw, ");");
skipLines(pw, 1);
if (returnPartName != null) {
addNewCodeLine(pw, "System.out.println(\"operation '");
addCode(pw, op.getName());
addCode(pw, "' returned: \" + ");
addCode(pw, returnPartName);
addCode(pw, ");");
skipLines(pw, 1);
addNewCodeLine(pw, "// TODO: test return parts here");
if (Character.isLowerCase(returnClassName.charAt(0))) {
addNewCodeLine(pw, "// assertTrue(\"operation ");
} else {
addNewCodeLine(pw, "assertTrue(\"operation ");
}
addCode(pw, op.getName());
addCode(pw, " returned null!!\", ");
addCode(pw, returnPartName);
addCode(pw, " != null);");
}
tabOut();
addNewCodeLine(pw, "}");
skipLines(pw, 1);
}
/**
* Write the testPortType method using the WSIF DII
*/
protected String writeDIITestPortType(
PrintWriter pw,
Service service,
String portName,
PortType portType,
PortTypeEntry ptEntry)
throws IOException {
QName serviceName = service.getQName();
QName portTypeName = portType.getQName();
String methodName = "doit" + "DII" + portTypeName.getLocalPart();
skipLines(pw, 1);
addNewCodeLine(pw, "protected void ");
addCode(pw, methodName);
addCode(pw, "(String portName) {");
tabIn();
addNewCodeLine(pw, "try {");
tabIn();
addNewCodeLine(
pw,
"WSIFServiceFactory factory = WSIFServiceFactory.newInstance();");
addNewCodeLine(pw, "factory.setFeature(");
tabIn();
addNewCodeLine(pw, "WSIFConstants.WSIF_FEATURE_AUTO_MAP_TYPES,");
addNewCodeLine(pw, "new Boolean(true));");
tabOut();
skipLines(pw, 1);
addNewCodeLine(pw, "WSIFService service =");
tabIn();
addNewCodeLine(pw, "factory.getService(");
tabIn();
addNewCodeLine(
pw,
"\"" + emitter.getWSDLURI().replace('\\', '/') + "\",");
addNewCodeLine(pw, "\"" + serviceName.getNamespaceURI() + "\",");
addNewCodeLine(pw, "\"" + serviceName.getLocalPart() + "\",");
addNewCodeLine(pw, "\"" + portTypeName.getNamespaceURI() + "\",");
addNewCodeLine(pw, "\"" + portTypeName.getLocalPart() + "\");");
tabOut();
tabOut();
skipLines(pw, 1);
addNewCodeLine(pw, "WSIFPort port = service.getPort(portName);");
skipLines(pw, 1);
for (Iterator i = portType.getOperations().iterator(); i.hasNext();) {
Operation op = (Operation) i.next();
String opMethodName = "executeOp" + capitalizeFirst(op.getName());
if (isOverloaded(portType, op)) {
opMethodName += getInMsgName(op);
}
addNewCodeLine(pw, opMethodName + "(port);");
}
skipLines(pw, 1);
tabOut();
addNewCodeLine(pw, "} catch (Exception ex) {");
tabIn();
addNewCodeLine(pw, "ex.printStackTrace();");
addNewCodeLine(pw, "assertTrue(\"");
addCode(pw, methodName);
addCode(pw, " got exception: \" + ex.getLocalizedMessage(), false);");
tabOut();
addNewCodeLine(pw, "}");
tabOut();
addNewCodeLine(pw, "}");
skipLines(pw, 1);
for (Iterator i = portType.getOperations().iterator(); i.hasNext();) {
Operation op = (Operation) i.next();
writeDIIOperationMethod(pw, portType, op);
}
return methodName;
}
/**
* Write the executeOp method using the WSIF DII
*/
protected void writeDIIOperationMethod(
PrintWriter pw,
PortType portType,
Operation op) {
addNewCodeLine(pw, "protected void ");
String opMethodName = "executeOp" + capitalizeFirst(op.getName());
boolean overloaded = isOverloaded(portType, op);
if (overloaded) {
opMethodName += getInMsgName(op);
}
addCode(pw, opMethodName);
addCode(pw, "(WSIFPort wsifPort) throws WSIFException {");
skipLines(pw, 1);
tabIn();
addNewCodeLine(pw, "WSIFOperation op = wsifPort.createOperation(");
if (overloaded) {
tabIn();
addNewCodeLine(pw, "\"");
addCode(pw, op.getName());
addCode(pw, "\",");
addNewCodeLine(pw, "\"");
addCode(pw, getInMsgName(op));
addCode(pw, "\",");
addNewCodeLine(pw, "null);");
tabOut();
} else {
addCode(pw, "\"");
addCode(pw, op.getName());
addCode(pw, "\");");
}
skipLines(pw, 1);
addNewCodeLine(pw, "WSIFMessage inMsg = op.createInputMessage();");
addNewCodeLine(pw, "WSIFMessage outMsg = op.createOutputMessage();");
addNewCodeLine(pw, "WSIFMessage faultMsg = op.createFaultMessage();");
skipLines(pw, 1);
Input in = op.getInput();
if (in != null && in.getMessage() != null) {
List parts = in.getMessage().getOrderedParts(null);
unwrapIfWrapped(
emitter.getCurrentDefinition(),
parts,
op.getName());
addNewCodeLine(pw, "// TODO: change these parameter values");
int parameterCounter = 0;
for (Iterator i = parts.iterator(); i.hasNext();) {
Part p = (Part) i.next();
QName type = ProviderUtils.getPartType(p);
String className = Utils.getJavaLocalName(getClassName(type));
String paramName = "p" + parameterCounter++;
addNewCodeLine(
pw,
className
+ " "
+ paramName
+ " = "
+ getTypeInitialiser(type)
+ ";");
String setType;
if (Character.isLowerCase(className.charAt(0))) {
setType = capitalizeFirst(className);
} else {
setType = "Object";
}
addNewCodeLine(pw, "inMsg.set");
addCode(pw, setType);
addCode(pw, "Part(\"");
addCode(pw, p.getName());
addCode(pw, "\", " + paramName + ");");
skipLines(pw, 1);
}
}
addNewCodeLine(pw, "boolean success =");
tabIn();
addNewCodeLine(
pw,
"op.executeRequestResponseOperation(inMsg, outMsg, faultMsg);");
tabOut();
skipLines(pw, 1);
addNewCodeLine(pw, "if (success) {");
tabIn();
addNewCodeLine(
pw,
"System.out.println(\"operation '"
+ op.getName()
+ "' successfull:\");");
Output out = op.getOutput();
if (out != null && out.getMessage() != null) {
List parts = out.getMessage().getOrderedParts(null);
unwrapIfWrapped(
emitter.getCurrentDefinition(),
parts,
op.getName() + "Response");
int parameterCounter = 0;
for (Iterator i = parts.iterator(); i.hasNext();) {
Part p = (Part) i.next();
QName type = ProviderUtils.getPartType(p);
String className = Utils.getJavaLocalName(getClassName(type));
String paramName = "r" + parameterCounter++;
String getType;
if (Character.isLowerCase(className.charAt(0))) {
getType = capitalizeFirst(className);
} else {
getType = "Object";
}
addNewCodeLine(
pw,
className
+ " "
+ paramName
+ " = outMsg.get"
+ getType
+ "Part(\""
+ p.getName()
+ "\");");
addNewCodeLine(
pw,
"System.out.println(\""
+ p.getName()
+ ": \" + "
+ paramName
+ ");");
}
}
skipLines(pw, 1);
addNewCodeLine(pw, "// TODO: add tests for return parts here");
skipLines(pw, 1);
tabOut();
addNewCodeLine(pw, "} else {");
tabIn();
addNewCodeLine(
pw,
"System.err.println(\"operation '"
+ op.getName()
+ "' returned a fault:\");");
addNewCodeLine(
pw,
"for (Iterator i = faultMsg.getPartNames(); i.hasNext();) {");
tabIn();
addNewCodeLine(
pw,
"System.err.println(faultMsg.getObjectPart((String) i.next()));");
tabOut();
addNewCodeLine(pw, "}");
addNewCodeLine(pw, "assertTrue(\"");
addCode(pw, opMethodName);
addCode(pw, " returned a fault!!\", false);");
tabOut();
addNewCodeLine(pw, "}");
tabOut();
addNewCodeLine(pw, "}");
skipLines(pw, 1);
}
/**
* Write the JUnit test method
*/
protected void writeTestMethod(
PrintWriter pw,
String methodName,
String portName)
throws IOException {
String testMethodname = "test" + capitalizeFirst(methodName) + portName;
addNewCodeLine(pw, "public void " + testMethodname + "() {");
tabIn();
addNewCodeLine(pw, methodName + "(\"" + portName + "\");");
tabOut();
addNewCodeLine(pw, "}");
skipLines(pw, 1);
} // writeTestMethod
/**
* Write the main method
*/
protected void writeMainMethod(PrintWriter pw) throws IOException {
addNewCodeLine(pw, "public static void main(String[] args) {");
tabIn();
addNewCodeLine(pw, "TestRunner.run(suite());");
tabOut();
addNewCodeLine(pw, "}");
skipLines(pw, 1);
} // writeMainMethod
/**
* Capatalise the first character of a String
*/
protected static String capitalizeFirst(String name) {
StringBuffer sb = new StringBuffer(name);
if (sb.length() > 0) {
sb.setCharAt(0, (char) ((sb.charAt(0) & (char) 223)));
}
return sb.toString();
}
/**
* Lowercase the first character of a String
*/
protected static String lowercaseFirst(String name) {
StringBuffer sb = new StringBuffer(name);
if (sb.length() > 0) {
sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
}
return sb.toString();
}
/**
* Gets the fully qualified Java class name from a QName
*/
protected static String getClassName(QName type) {
String className = "";
Map types = WSIFUtils.getSimpleTypesMap();
Object o = types.get(type);
if (o != null) {
className = (String) o;
} else {
className =
Utils.makePackageName(type.getNamespaceURI())
+ "."
+ Utils.xmlNameToJavaClass(type.getLocalPart());
}
return className;
}
/**
* Unwraps a WSDL message if required
*/
protected void unwrapIfWrapped(
Definition def,
List parts,
String operationName) {
if (!emitter.isNowrap()) {
Part p = ProviderUtils.getWrapperPart(parts, operationName);
if (p != null) {
List unwrappedParts;
try {
unwrappedParts = ProviderUtils.unWrapPart(p, def);
} catch (WSIFException e) {
throw new RuntimeException(
"exception unwrapping operation "
+ operationName
+ ": "
+ e.getLocalizedMessage());
}
int i = parts.indexOf(p);
parts.remove(i);
parts.addAll(i, unwrappedParts);
}
}
}
/**
* Gets the name of a WSDL operation's input message
*/
protected String getInMsgName(Operation op) {
String inMsgName = "";
Input inMsg = op.getInput();
if (inMsg != null) {
inMsgName = inMsg.getName();
}
return inMsgName;
}
/**
* Tests if the operation is overloaded in the portType
*/
protected boolean isOverloaded(PortType pt, Operation op) {
boolean overloaded = false;
String opName = op.getName();
for (Iterator i = pt.getOperations().iterator();
!overloaded && i.hasNext();
) {
Operation o2 = (Operation) i.next();
if (!op.equals(o2) && opName.equals(o2.getName())) {
overloaded = true;
}
}
return overloaded;
}
/**
* Gets the initiliser for a type
*/
protected String getTypeInitialiser(QName type) {
String s = "";
String className = Utils.getJavaLocalName(getClassName(type));
if ("int".equals(className)) {
s = "0";
} else if ("short".equals(className)) {
s = "0";
} else if ("boolean".equals(className)) {
s = "false";
} else if ("byte".equals(className)) {
s = "0";
} else if ("long".equals(className)) {
s = "0";
} else if ("double".equals(className)) {
s = "0";
} else if ("float".equals(className)) {
s = "0";
} else if ("char".equals(className)) {
s = "''";
} else {
s = "new " + className + "()";
}
return s;
}
/**
* Gets the Service Endpoint Interface name for a WSDL portType
*/
protected String getSEIName(PortType portType) {
return capitalizeFirst(
Utils.getJavaLocalName(getClassName(portType.getQName())));
}
/**
* Start a new line of code correctly indented
*/
protected void addNewCodeLine(PrintWriter pw, String line) {
pw.println();
pw.print(indent);
pw.print(line);
}
/**
* add code to an already started code line
*/
protected void addCode(PrintWriter pw, String lineFragment) {
pw.print(lineFragment);
}
/**
* Insert some blank lines into the output
*/
protected void skipLines(PrintWriter pw, int lines) {
for (int i = 0; i < lines; i++) {
pw.println();
}
}
/**
* Indent all subsequent code by one tab space
*/
protected void tabIn() {
indent += TAB;
}
/**
* Un-indent all subsequent code by one tab space
*/
protected void tabOut() {
if (indent.length() >= TAB.length()) {
indent = indent.substring(0, indent.length() - TAB.length());
}
}
} // class JavaTestCase
1.1 xml-axis-wsif/java/src/org/apache/wsif/wsdl/WSDL2Java.java
Index: WSDL2Java.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.wsif.wsdl;
import org.apache.axis.utils.CLOption;
import org.apache.axis.utils.CLOptionDescriptor;
import org.apache.axis.wsdl.gen.Parser;
import org.apache.axis.wsdl.gen.WSDL2;
import org.apache.wsif.wsdl.gen.WSIFEmitter;
/**
* WSIF WSDL2Java Utility program
*
* Generates Java source for the service endpoint interface,
* any complex types, and a WSIF testcase.
*
* @author <a href="mailto:ant.elder@uk.ibm.com">Ant Elder</a>
*/
public class WSDL2Java extends org.apache.axis.wsdl.WSDL2Java {
protected static final int TESTCASE_OPT = 't';
protected static final CLOptionDescriptor[] wsifCLOptions =
new CLOptionDescriptor[] {
new CLOptionDescriptor(
"testCase <stubs | DII | both>",
CLOptionDescriptor.ARGUMENT_OPTIONAL,
TESTCASE_OPT,
"emit a JUnit testcase class for the web service."
+ " Optionally specify if the testcase will use the"
+ " WSIF DII, stubs, or both. The default is to use stubs.")};
/**
* Constructor
*/
public WSDL2Java() {
removeOption("testCase");
removeOption("server-side");
removeOption("skeletonDeploy");
removeOption("deployScope");
addOptions(wsifCLOptions);
}
protected void parseOption(CLOption option) {
switch (option.getId()) {
case TESTCASE_OPT :
((WSIFEmitter) parser).setTestCaseWanted(true);
String arg = option.getArgument();
if ("DII".equalsIgnoreCase(arg)) {
((WSIFEmitter) parser).setTestcaseGenDII(true);
((WSIFEmitter) parser).setTestcaseGenStubs(false);
} else if ("stubs".equalsIgnoreCase(arg)) {
((WSIFEmitter) parser).setTestcaseGenStubs(true);
((WSIFEmitter) parser).setTestcaseGenDII(false);
} else if ("both".equalsIgnoreCase(arg)) {
((WSIFEmitter) parser).setTestcaseGenStubs(true);
((WSIFEmitter) parser).setTestcaseGenDII(true);
} else {
((WSIFEmitter) parser).setTestcaseGenStubs(true);
((WSIFEmitter) parser).setTestcaseGenDII(false);
}
break;
default :
super.parseOption(option);
}
}
/**
* Override createParser to use the WSIF version of Emitter.
*/
protected Parser createParser() {
return new WSIFEmitter();
}
/**
* Main
*/
public static void main(String args[]) {
WSDL2Java w2j = new WSDL2Java();
w2j.run(args);
}
}