tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r643523 - in /incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl: ./ src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/ src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/
Date Tue, 01 Apr 2008 19:06:30 GMT
Author: rfeng
Date: Tue Apr  1 12:06:27 2008
New Revision: 643523

URL: http://svn.apache.org/viewvc?rev=643523&view=rev
Log:
Add more generation logic

Modified:
    incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/pom.xml
    incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
    incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
    incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/pom.xml?rev=643523&r1=643522&r2=643523&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/pom.xml Tue Apr  1 12:06:27
2008
@@ -1,21 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.    
+    * Licensed to the Apache Software Foundation (ASF) under one
+    * or more contributor license agreements.  See the NOTICE file
+    * distributed with this work for additional information
+    * regarding copyright ownership.  The ASF licenses this file
+    * to you under the Apache License, Version 2.0 (the
+    * "License"); you may not use this file except in compliance
+    * with the License.  You may obtain a copy of the License at
+    * 
+    *   http://www.apache.org/licenses/LICENSE-2.0
+    * 
+    * Unless required by applicable law or agreed to in writing,
+    * software distributed under the License is distributed on an
+    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    * KIND, either express or implied.  See the License for the
+    * specific language governing permissions and limitations
+    * under the License.    
 -->
 <project>
     <modelVersion>4.0.0</modelVersion>
@@ -46,34 +46,44 @@
             <version>2.0-incubating-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-interface-java-jaxws</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-databinding</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.axis2</groupId>
             <artifactId>axis2-java2wsdl</artifactId>
             <version>1.3</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>commons-codec</groupId>
+                    <artifactId>commons-codec</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.axis2</groupId>
             <artifactId>axis2-adb</artifactId>
             <version>1.3</version>
         </dependency>
-        
+
         <dependency>
-            <groupId>junit</groupId>                                      
+            <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>4.2</version>
             <scope>test</scope>
         </dependency>
-        
+
         <dependency>
-           <groupId>commons-codec</groupId>
-           <artifactId>commons-codec</artifactId>
-           <version>1.3</version>
-           <exclusions>
-               <exclusion>
-                   <groupId>commons-codec</groupId>
-                   <artifactId>commons-codec</artifactId>
-               </exclusion>
-           </exclusions>
-        </dependency>        
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.3</version>
+        </dependency>
 
     </dependencies>
 

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java?rev=643523&r1=643522&r2=643523&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
(original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
Tue Apr  1 12:06:27 2008
@@ -28,15 +28,19 @@
 import javax.wsdl.Output;
 import javax.wsdl.Part;
 import javax.wsdl.PortType;
+import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
 import javax.wsdl.factory.WSDLFactory;
 import javax.xml.namespace.QName;
 
+import org.apache.tuscany.sca.databinding.DataBinding;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
 import org.apache.tuscany.sca.interfacedef.DataType;
 import org.apache.tuscany.sca.interfacedef.Interface;
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
 import org.apache.tuscany.sca.interfacedef.util.XMLType;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
 import org.apache.ws.commons.schema.XmlSchema;
@@ -53,6 +57,7 @@
  */
 public class Interface2WSDLGenerator {
     private WSDLFactory factory;
+    private DataBindingExtensionPoint dataBindingExtensionPoint;
     private WSDLDefinitionGenerator definitionGenerator = new WSDLDefinitionGenerator();
 
     public Interface2WSDLGenerator() throws WSDLException {
@@ -60,9 +65,10 @@
         this.factory = WSDLFactory.newInstance();
     }
 
-    public Interface2WSDLGenerator(WSDLFactory factory) {
+    public Interface2WSDLGenerator(WSDLFactory factory, DataBindingExtensionPoint dataBindingExtensionPoint)
{
         super();
         this.factory = factory;
+        this.dataBindingExtensionPoint = dataBindingExtensionPoint;
     }
 
     public Definition generate(Interface interfaze) throws WSDLException {
@@ -87,31 +93,49 @@
         PortType portType = definition.createPortType();
         portType.setQName(name);
         for (Operation op : interfaze.getOperations()) {
-            javax.wsdl.Operation operation = generate(definition, op);
+            javax.wsdl.Operation operation = generateOperation(definition, op);
             portType.addOperation(operation);
         }
         portType.setUndefined(false);
         definition.addPortType(portType);
         definitionGenerator.createBinding(definition, portType);
+
+        Types types = definitionGenerator.createTypes(definition);
+
         return definition;
     }
 
     protected QName getQName(Interface i) {
         // FIXME: We need to add the name information into the Interface model 
         Class<?> javaClass = ((JavaInterface)i).getJavaClass();
-        return new QName(JavaInterfaceUtil.getNamespace(javaClass), javaClass.getSimpleName());
+        return new QName(JavaInterfaceUtil.getNamespace(javaClass), javaClass.getSimpleName(),
"tns");
     }
 
-    public javax.wsdl.Operation generate(Definition definition, Operation op) {
+    public javax.wsdl.Operation generateOperation(Definition definition, Operation op) {
         javax.wsdl.Operation operation = definition.createOperation();
         operation.setName(op.getName());
+        operation.setUndefined(false);
+
         Input input = definition.createInput();
         input.setName("input");
         Message inputMsg = definition.createMessage();
-        QName inputMsgName = new QName(definition.getQName().getNamespaceURI(), "inputMessage");
+        QName inputMsgName = new QName(definition.getQName().getNamespaceURI(), op.getName()
+ "_InputMessage");
         inputMsg.setQName(inputMsgName);
+        inputMsg.setUndefined(false);
+        definition.addMessage(inputMsg);
 
-        inputMsg.addPart(generate(definition, op.getInputType(), "parameters"));
+        // FIXME: By default, java interface is mapped to doc-lit-wrapper style WSDL
+        if (!op.isWrapperStyle()) {
+            // Generate doc-lit-wrapper style
+            inputMsg.addPart(generateWrapperPart(definition, op, true));
+        } else {
+            // Bare style
+            int i = 0;
+            for (DataType d : op.getInputType().getLogical()) {
+                inputMsg.addPart(generatePart(definition, d, "arg" + i));
+                i++;
+            }
+        }
         input.setMessage(inputMsg);
         operation.setInput(input);
 
@@ -119,10 +143,16 @@
             Output output = definition.createOutput();
             output.setName("output");
             Message outputMsg = definition.createMessage();
-            QName outputMsgName = new QName(definition.getQName().getNamespaceURI(), "outputMessage");
+            QName outputMsgName = new QName(definition.getQName().getNamespaceURI(), op.getName()
+ "_OutputMessage");
             outputMsg.setQName(outputMsgName);
+            outputMsg.setUndefined(false);
+            definition.addMessage(outputMsg);
 
-            outputMsg.addPart(generate(definition, op.getOutputType(), "return"));
+            if (!op.isWrapperStyle()) {
+                inputMsg.addPart(generateWrapperPart(definition, op, false));
+            } else {
+                inputMsg.addPart(generatePart(definition, op.getOutputType(), "return"));
+            }
             output.setMessage(outputMsg);
 
             operation.setOutput(output);
@@ -135,7 +165,7 @@
         return operation;
     }
 
-    public Part generate(Definition definition, DataType arg, String partName) {
+    public Part generatePart(Definition definition, DataType arg, String partName) {
         Part part = definition.createPart();
         part.setName(partName);
         if (arg != null && arg.getLogical() instanceof XMLType) {
@@ -148,12 +178,29 @@
         return part;
     }
 
+    public Part generateWrapperPart(Definition definition, Operation operation, boolean input)
{
+        Part part = definition.createPart();
+        String partName = input ? operation.getName() : (operation.getName() + "Response");
+        part.setName(partName);
+        if (operation.getWrapper() != null) {
+            ElementInfo elementInfo =
+                input ? operation.getWrapper().getInputWrapperElement() : operation.getWrapper()
+                    .getOutputWrapperElement();
+            part.setElementName(elementInfo.getQName());
+        }
+        return part;
+    }
+
     public XmlSchemaType getXmlSchemaType(DataType type) {
         return null;
     }
 
     // FIXME: WE need to add databinding-specific Java2XSD generation
-    public Element generateXSD() {
+    public Element generateXSD(DataType dataType) {
+        DataBinding dataBinding = dataBindingExtensionPoint.getDataBinding(dataType.getDataBinding());
+        if (dataBinding != null) {
+            // return dataBinding.generateSchema(dataType);
+        }
         return null;
     }
 

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java?rev=643523&r1=643522&r2=643523&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
(original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
Tue Apr  1 12:06:27 2008
@@ -34,6 +34,7 @@
 import javax.wsdl.Port;
 import javax.wsdl.PortType;
 import javax.wsdl.Service;
+import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap.SOAPBody;
@@ -64,6 +65,12 @@
         root = (Element)root.cloneNode(true);
         WSDLReader reader = factory.newWSDLReader();
         return reader.readWSDL(definition.getDocumentBaseURI(), root);
+    }
+    
+    public Types createTypes(Definition definition) {
+        Types types = definition.createTypes();
+        definition.setTypes(types);
+        return types;
     }
 
     public Binding createBinding(Definition definition, PortType portType) throws WSDLException
{

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java?rev=643523&r1=643522&r2=643523&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java
(original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java
Tue Apr  1 12:06:27 2008
@@ -25,6 +25,7 @@
 import javax.wsdl.xml.WSDLWriter;
 
 import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor;
 import org.junit.Test;
 
 /**
@@ -35,11 +36,12 @@
     @Test
     public void testGenerate() throws Exception {
         DefaultJavaInterfaceFactory iFactory = new DefaultJavaInterfaceFactory();
+        iFactory.addInterfaceVisitor(new JAXWSJavaInterfaceProcessor());
         org.apache.tuscany.sca.interfacedef.Interface iface = iFactory.createJavaInterface(TestJavaInterface.class);
         Interface2WSDLGenerator generator = new Interface2WSDLGenerator();
         Definition definition = generator.generate(iface);
         // System.out.println(definition);
-        
+
         WSDLWriter writer = generator.getFactory().newWSDLWriter();
         StringWriter sw = new StringWriter();
         writer.writeWSDL(definition, sw);



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message