You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2005/07/29 13:26:11 UTC
svn commit: r226347 - in
/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl:
codegen/ codegen/emitter/ codegen/writer/ template/java/
Author: ajith
Date: Fri Jul 29 04:25:35 2005
New Revision: 226347
URL: http://svn.apache.org/viewcvs?rev=226347&view=rev
Log:
1. Added a new parameter for the arguments
2. Changed the skeleton generator to generate code for multiple bindings
3. Added a new template for databinding supporter to have a default databinding support
Added:
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl
Modified:
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOption.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOptionConstants.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java?rev=226347&r1=226346&r2=226347&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java Fri Jul 29 04:25:35 2005
@@ -110,6 +110,8 @@
loadLanguge(langOption.getOptionValue());
}
+ CommandLineOption dataBindingOption = (CommandLineOption) optionMap.get(
+ DATA_BINDING_TYPE_OPTION);
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOption.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOption.java?rev=226347&r1=226346&r2=226347&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOption.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOption.java Fri Jul 29 04:25:35 2005
@@ -99,6 +99,7 @@
(GENERATE_SERVICE_DESCRIPTION_OPTION).equalsIgnoreCase(
optionType) ||
(GENERATE_TEST_CASE_OPTION).equalsIgnoreCase(optionType) ||
- (STUB_LANGUAGE_OPTION).equalsIgnoreCase(optionType));
+ (STUB_LANGUAGE_OPTION).equalsIgnoreCase(optionType) ||
+ (DATA_BINDING_TYPE_OPTION).equalsIgnoreCase(optionType));
}
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOptionConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOptionConstants.java?rev=226347&r1=226346&r2=226347&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOptionConstants.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CommandLineOptionConstants.java Fri Jul 29 04:25:35 2005
@@ -32,6 +32,7 @@
public static final String PACKAGE_OPTION = "p";
public static final String STUB_LANGUAGE_OPTION = "l";
public static final String GENERATE_TEST_CASE_OPTION = "t";
+ public static final String DATA_BINDING_TYPE_OPTION = "d";
public static final String INVALID_OPTION = "INVALID_OPTION";
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java?rev=226347&r1=226346&r2=226347&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java Fri Jul 29 04:25:35 2005
@@ -34,6 +34,7 @@
public interface DataBindingTypes {
+ public static final int NONE = 0;
public static final int XML_BEANS = 1;
public static final int JAXB = 2;
@@ -86,6 +87,7 @@
public interface XSLTDatabindingSupporterTemplates {
public static final String JAVA_TEMPLATE = "/org/apache/axis2/wsdl/template/java/XMLBeansSupporterTemplate.xsl";
+ public static final String DEFAULT_TEMPLATE = "/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl";
//public static final String CSHARP_TEMPLATE = "/org/apache/axis2/wsdl/template/csharp/TestClassTemplate.xsl";
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=226347&r1=226346&r2=226347&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java Fri Jul 29 04:25:35 2005
@@ -29,6 +29,7 @@
import org.apache.wsdl.WSDLOperation;
import org.apache.wsdl.WSDLService;
import org.apache.wsdl.WSDLTypes;
+import org.apache.wsdl.WSDLBindingMessageReference;
import org.apache.wsdl.extensions.ExtensionConstants;
import org.apache.wsdl.extensions.SOAPBody;
import org.apache.wsdl.extensions.SOAPOperation;
@@ -130,35 +131,42 @@
try {
//get the binding
WSDLDescription wom = this.configuration.getWom();
- WSDLBinding axisBinding = wom.getBinding(
- AxisBindingBuilder.AXIS_BINDING_QNAME);
- WSDLService axisService = null;
- //write interfaces
- Map services = wom.getServices();
- if (!services.isEmpty()) {
- if (services.size() == 1) {
- axisService = (WSDLService) services.values().toArray()[0];
- } else {
- throw new UnsupportedOperationException(
- "Single service WSDL files only");
+ Map bindings = wom.getBindings();
+ WSDLBinding axisBinding = null;
+ WSDLService axisService = null;
+ if (bindings==null)
+ throw new CodeGenerationException("Binding needs to be present!");
+ Collection bindingCollection = bindings.values();
+ for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
+ axisBinding = (WSDLBinding)iterator.next();
+
+ //write interfaces
+ Map services = wom.getServices();
+ if (!services.isEmpty()) {
+ if (services.size() == 1) {
+ axisService = (WSDLService) services.values().toArray()[0];
+ } else {
+ throw new UnsupportedOperationException(
+ "Single service WSDL files only");
+ }
}
- }
- //
- testCompatibiltyAll(axisBinding);
- //
- writeInterface(axisBinding);
- //write interface implementations
- writeInterfaceImplementation(axisBinding, axisService);
- //write the call back handlers
- writeCallBackHandlers(axisBinding);
- //write the test classes
+ //
+ testCompatibiltyAll(axisBinding);
+ //
+ writeInterface(axisBinding);
+ //write interface implementations
+ writeInterfaceImplementation(axisBinding, axisService);
+ //write the call back handlers
+ writeCallBackHandlers(axisBinding);
+ //write the test classes
// writeTestClasses(axisBinding);
- //write the databinding supporters
- writeDatabindingSupporters(axisBinding);
- //write a dummy implementation call for the tests to run.
- //writeTestSkeletonImpl(axisBinding);
- //write a testservice.xml that will load the dummy skeleton impl for testing
- //writeTestServiceXML(axisBinding);
+ //write the databinding supporters
+ writeDatabindingSupporters(axisBinding);
+ //write a dummy implementation call for the tests to run.
+ //writeTestSkeletonImpl(axisBinding);
+ //write a testservice.xml that will load the dummy skeleton impl for testing
+ //writeTestServiceXML(axisBinding);
+ }
} catch (Exception e) {
e.printStackTrace();
throw new CodeGenerationException(e);
@@ -1004,15 +1012,18 @@
private void testCompatibilityOutput(WSDLBindingOperation binding) {
- Iterator extIterator = binding.getOutput().getExtensibilityElements()
- .iterator();
- while (extIterator.hasNext()) {
- WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
- if (element.getType().equals(ExtensionConstants.SOAP_BODY)) {
- if (WSDLConstants.WSDL_USE_ENCODED.equals(
- ((SOAPBody) element).getUse())) {
- throw new RuntimeException(
- "The use 'encoded' is not supported!");
+ WSDLBindingMessageReference output = binding.getOutput();
+ if (output!=null){
+ Iterator extIterator = output.getExtensibilityElements()
+ .iterator();
+ while (extIterator.hasNext()) {
+ WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
+ if (element.getType().equals(ExtensionConstants.SOAP_BODY)) {
+ if (WSDLConstants.WSDL_USE_ENCODED.equals(
+ ((SOAPBody) element).getUse())) {
+ throw new RuntimeException(
+ "The use 'encoded' is not supported!");
+ }
}
}
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java?rev=226347&r1=226346&r2=226347&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/DatabindingSupportClassWriter.java Fri Jul 29 04:25:35 2005
@@ -43,9 +43,9 @@
}
public void loadTemplate() {
- if (this.databindingFramework ==
- XSLTConstants.DataBindingTypes.XML_BEANS) {
- Class clazz = this.getClass();
+ Class clazz = this.getClass();
+ if ( XSLTConstants.DataBindingTypes.XML_BEANS ==
+ this.databindingFramework) {
switch (language) {
case XSLTConstants.LanguageTypes.JAVA:
this.xsltStream =
@@ -58,7 +58,10 @@
default:
throw new UnsupportedOperationException();
}
- } else {
+ } if (XSLTConstants.DataBindingTypes.NONE ==
+ this.databindingFramework) {
+ this.xsltStream = clazz.getResourceAsStream(XSLTConstants.XSLTDatabindingSupporterTemplates.DEFAULT_TEMPLATE);
+ }else{
throw new UnsupportedOperationException(
"Unsupported Data binding Framework!");
}
Added: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl?rev=226347&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl (added)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl Fri Jul 29 04:25:35 2005
@@ -0,0 +1,53 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="text"/>
+ <xsl:template match="/class">
+ package <xsl:value-of select="@package"/>;
+
+ /**
+ * Auto generated supporter class for XML beans by the Axis code generator
+ */
+
+ public class <xsl:value-of select="@name"/> {
+ <xsl:apply-templates />
+
+ public static org.apache.axis2.om.OMElement fromOM(org.apache.axis2.om.OMElement param,
+ java.lang.Class type){
+ //Just return the OMElement as it is
+ return param;
+ }
+
+ // Generates an empty object for testing
+ // Caution - need some manual editing to work properly
+ public static org.apache.axis2.om.OMElement getTestObject(java.lang.Class type){
+ try{
+ org.apache.axis2.om.OMFactory factory = org.apache.axis2.om.OMAbstractFactory.getOMFactory();
+ org.apache.axis2.om.OMNamespace emptyNamespace = factory.createOMNamespace("",null);
+ <xsl:for-each select="param">
+ <xsl:if test="@type!=''">
+ if (<xsl:value-of select="@type"/>.class.equals(type)){
+ <xsl:value-of select="@type"/> emptyObject= factory.createOMElement("test",emptyNamespace);
+ ////////////////////////////////////////////////
+ // TODO
+ // Fill in the empty object with necessaey values. Empty XMLBeans objects do not generate proper events
+ ////////////////////////////////////////////////
+ return emptyObject;
+ }
+ </xsl:if>
+ </xsl:for-each>
+ }catch(java.lang.Exception e){
+ throw new RuntimeException("Test object creation failure",e);
+ }
+ return null;
+ }
+ }
+ </xsl:template>
+
+ <xsl:template match="param">
+ <xsl:if test="@type!=''">
+ public static org.apache.axis2.om.OMElement toOM(<xsl:value-of select="@type"/> param){
+ //Just return the object as it is. it's supposed to be an OMElement
+ return param;
+ }
+ </xsl:if>
+ </xsl:template>
+ </xsl:stylesheet>
\ No newline at end of file