incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r421690 - in /incubator/yoko/trunk/tools/src: main/java/org/apache/yoko/tools/processors/idl/ main/java/org/apache/yoko/tools/processors/wsdl/ test/resources/idl/
Date Thu, 13 Jul 2006 19:13:01 GMT
Author: bravi
Date: Thu Jul 13 12:13:00 2006
New Revision: 421690

URL: http://svn.apache.org/viewvc?rev=421690&view=rev
Log:
Generating the corba binding in the idltowsdl tool & removing the dependency of the wsdltocorba
tool. Related to JIRA: YOKO-88.

Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ReturnParameterVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
    incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl
    incubator/yoko/trunk/tools/src/test/resources/idl/expected_Primitives.wsdl

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
Thu Jul 13 12:13:00 2006
@@ -22,7 +22,6 @@
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.Writer;
-import java.util.Map;
 import java.util.StringTokenizer;
 
 import javax.wsdl.Binding;
@@ -36,7 +35,6 @@
 import org.apache.schemas.yoko.bindings.corba.AddressType;
 import org.apache.yoko.tools.common.CORBAConstants;
 import org.apache.yoko.tools.common.ToolCorbaConstants;
-import org.apache.yoko.tools.processors.wsdl.WSDLToCorbaBinding;
 
 import org.objectweb.celtix.tools.common.Processor;
 import org.objectweb.celtix.tools.common.ProcessorEnvironment;
@@ -88,14 +86,7 @@
                 outputWriter = fw.getWriter("", idl + ".wsdl");
             }
             Definition def = visitor.getDefinition();
-            WSDLToCorbaBinding corbaBinding = new WSDLToCorbaBinding();
-            Map portTypes = def.getPortTypes();
-            java.util.Iterator it = portTypes.keySet().iterator();
-            while (it.hasNext()) {
-                QName portType = (QName) it.next();
-                corbaBinding.addInterfaceName(portType.getLocalPart());
-            }
-            Binding[] bindings = corbaBinding.generateCORBABinding(def);
+            Binding[] bindings = visitor.getCorbaBindings();
             generateCORBAService(def, bindings);
             visitor.writeDefinition(outputWriter);
         } catch (Exception ex) {

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessagePartVisitor.java
Thu Jul 13 12:13:00 2006
@@ -28,12 +28,23 @@
 import antlr.ASTVisitor;
 import antlr.collections.AST;
 
+import org.apache.schemas.yoko.bindings.corba.ArgType;
+import org.apache.schemas.yoko.bindings.corba.ModeType;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.ParamType;
+
 public class MessagePartVisitor implements ASTVisitor {
     
+    static final String IN_PARAMETER = "inparameter";
+    static final String OUT_PARAMETER = "outparameter";
+    static final String INOUT_PARAMETER = "inoutparameter";
+
     Definition definition;
     Message inputMsg;
     Message outputMsg;
 
+    OperationType corbaOperation;
+
     TypesVisitor typesVisitor;
 
     public MessagePartVisitor(WSDLASTVisitor visitor) {
@@ -57,6 +68,10 @@
         return outputMsg;
     }
 
+    public void setCorbaOperation(OperationType op) {
+        corbaOperation = op;
+    }
+
     /**
      * Returns the name of the CORBA parameter (helper function)
      * 
@@ -81,21 +96,24 @@
         switch (node.getType()) {
         case IDLTokenTypes.LITERAL_in: {
             AST typeNode = node.getFirstChild();
-            AST partName = getPartNameNode(typeNode);
-            createInputPart(partName.toString(), typeNode);
+            String partName = getPartNameNode(typeNode).toString();
+            ArgType param = createCorbaParam(IN_PARAMETER, ModeType.IN);
+            Part input = createInputPart(partName, param, typeNode);
             break;
         }
         case IDLTokenTypes.LITERAL_inout: {
             AST typeNode = node.getFirstChild();
-            AST partName = getPartNameNode(typeNode);
-            createInputPart(partName.toString(), typeNode);
-            createOutputPart(partName.toString(), typeNode);
+            String partName = getPartNameNode(typeNode).toString();
+            ArgType param = createCorbaParam(INOUT_PARAMETER, ModeType.INOUT);
+            Part input = createInputPart(partName, param, typeNode);
+            Part output = createOutputPart(partName, param, typeNode);
             break;
         }
         case IDLTokenTypes.LITERAL_out: {
             AST typeNode = node.getFirstChild();
-            AST partName = getPartNameNode(typeNode);
-            createOutputPart(partName.toString(), typeNode);
+            String partName = getPartNameNode(typeNode).toString();
+            ArgType param = createCorbaParam(OUT_PARAMETER, ModeType.OUT);
+            Part output = createOutputPart(partName, param, typeNode);
             break;
         }
         case IDLTokenTypes.LITERAL_void: {
@@ -103,40 +121,59 @@
             break;
         }
         default: {
-            createOutputPart("return", node);
+            String partName = "return";
+            ArgType param = createCorbaReturn(partName);
+            Part part = createOutputPart(partName, param, node);
         }
         }
     }
 
-    private void createInputPart(String partName, AST typeNode) {
+    private Part createInputPart(String partName, ArgType param, AST typeNode) {
         Part part;
         QName element = inputMsg.getQName();
         if (inputMsg.getParts().size() == 0) {
             part = definition.createPart();
-            part.setName("inparameter");
+            part.setName(IN_PARAMETER);
             part.setElementName(element);
             typesVisitor.addElement(element);
             inputMsg.addPart(part);
         } else {
             part = (Part) inputMsg.getParts().get(0);
         }
-        typesVisitor.setCurrentPart(element, partName);
+        typesVisitor.setCurrentPart(element, partName, param);
         typesVisitor.visit(typeNode);
+        return part;
     }
 
-    private void createOutputPart(String partName, AST typeNode) {
+    private Part createOutputPart(String partName, ArgType param, AST typeNode) {
         Part part;
         QName element = outputMsg.getQName();
         if (outputMsg.getParts().size() == 0) {
             part = definition.createPart();
-            part.setName("outparameter");
+            part.setName(OUT_PARAMETER);
             part.setElementName(element);
             typesVisitor.addElement(element);
             outputMsg.addPart(part);
         } else {
             part = (Part) outputMsg.getParts().get(0);
         }
-        typesVisitor.setCurrentPart(element, partName);
+        typesVisitor.setCurrentPart(element, partName, param);
         typesVisitor.visit(typeNode);
+        return part;
+    }
+
+    private ArgType createCorbaParam(String partName, ModeType mode) {
+        ParamType param = new ParamType();
+        param.setName(partName);
+        param.setMode(mode);
+        corbaOperation.getParam().add(param);
+        return param;
+    }
+
+    private ArgType createCorbaReturn(String partName) {
+        ArgType param = new ArgType();
+        param.setName(partName);
+        corbaOperation.setReturn(param);
+        return param;
     }
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/MessageVisitor.java
Thu Jul 13 12:13:00 2006
@@ -19,6 +19,9 @@
 
 package org.apache.yoko.tools.processors.idl;
 
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
 import javax.wsdl.Definition;
 import javax.wsdl.Input;
 import javax.wsdl.Message;
@@ -30,11 +33,15 @@
 import antlr.ASTVisitor;
 import antlr.collections.AST;
 
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+
 public class MessageVisitor implements ASTVisitor {
     
     Definition definition;
 
     Operation operation;
+    BindingOperation bindingOperation;
+    OperationType corbaOperation;
     MessagePartVisitor partVisitor;
     ReturnParameterVisitor returnParameterVisitor;
     
@@ -48,6 +55,11 @@
         operation = op;
     }
 
+    public void setBindingOperation(BindingOperation op) {
+        bindingOperation = op;
+        corbaOperation = (OperationType) op.getExtensibilityElements().get(0);
+    }
+
     private AST getNextMessagePartNode(AST node) {
         AST currentNode = node;
         if (currentNode.getType() == IDLTokenTypes.LITERAL_unsigned) {
@@ -67,6 +79,7 @@
             case IDLTokenTypes.LITERAL_in: {
                 if (partVisitor.getInputMessage() == null) {                
                     partVisitor.setInputMessage(createInputMessage());
+                    partVisitor.setCorbaOperation(corbaOperation);
                 }
                 partVisitor.visit(node2);
                 break;
@@ -74,9 +87,11 @@
             case IDLTokenTypes.LITERAL_inout: {
                 if (partVisitor.getInputMessage() == null) {                
                     partVisitor.setInputMessage(createInputMessage());
+                    partVisitor.setCorbaOperation(corbaOperation);
                 }
                 if (partVisitor.getOutputMessage() == null) {               
                     partVisitor.setOutputMessage(createOutputMessage());
+                    partVisitor.setCorbaOperation(corbaOperation);
                 }
                 partVisitor.visit(node2);
                 break;
@@ -84,6 +99,7 @@
             case IDLTokenTypes.LITERAL_out: {
                 if (partVisitor.getOutputMessage() == null) {               
                     partVisitor.setOutputMessage(createOutputMessage());
+                    partVisitor.setCorbaOperation(corbaOperation);
                 }
                 partVisitor.visit(node2);
                 break;
@@ -95,6 +111,7 @@
             default: {
                 if (returnParameterVisitor.getOutputMessage() == null) {               
                     returnParameterVisitor.setOutputMessage(createOutputMessage());
+                    returnParameterVisitor.setCorbaOperation(corbaOperation);
                 }
                 returnParameterVisitor.visit(node2);
             }
@@ -108,10 +125,16 @@
         Message msg = definition.createMessage();
         msg.setQName(new QName(definition.getTargetNamespace(), operation.getName()));
         input.setMessage(msg);
-        input.setName(operation.getName() + "Request");
+        String msgName = operation.getName() + "Request";
+        input.setName(msgName);
         msg.setUndefined(false);
         operation.setInput(input);
         definition.addMessage(msg);
+        
+        BindingInput bindingInput = definition.createBindingInput();
+        bindingInput.setName(msgName);        
+        bindingOperation.setBindingInput(bindingInput);
+
         return msg;
     }
 
@@ -120,10 +143,16 @@
         Message msg = definition.createMessage();
         msg.setQName(new QName(definition.getTargetNamespace(), operation.getName() + "Response"));
         output.setMessage(msg);
-        output.setName(operation.getName() + "Response");
+        String msgName = operation.getName() + "Response";
+        output.setName(msgName);
         msg.setUndefined(false);
         operation.setOutput(output);
         definition.addMessage(msg);
+
+        BindingOutput bindingOutput = definition.createBindingOutput();
+        bindingOutput.setName(msgName);
+        bindingOperation.setBindingOutput(bindingOutput);
+
         return msg;
     }
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/PortTypeVisitor.java
Thu Jul 13 12:13:00 2006
@@ -19,46 +19,123 @@
 
 package org.apache.yoko.tools.processors.idl;
 
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
 import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensionRegistry;
 
 import javax.xml.namespace.QName;
 
 import antlr.ASTVisitor;
 import antlr.collections.AST;
 
+import org.apache.schemas.yoko.bindings.corba.BindingType;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+
+import org.apache.yoko.tools.common.CORBAConstants;
+
 public class PortTypeVisitor implements ASTVisitor {
     
+    static final String IDL_VERSION = ":1.0";
+    static final String REPO_STRING = "IDL:";
+
     Definition definition;
+    ExtensionRegistry extReg;
     PortType portType;
     WSDLASTVisitor wsdlASTVisitor;
 
     public PortTypeVisitor(WSDLASTVisitor visitor) {
         definition = visitor.getDefinition();
         wsdlASTVisitor = visitor;
+        extReg = definition.getExtensionRegistry();
     }
 
     public void visit(AST node) {
         portType = definition.createPortType();
         AST node2 = node.getFirstChild();
         portType.setQName(new QName(definition.getTargetNamespace(), node2.toString()));
-        node2 = node2.getNextSibling();
-        visitOperation(node2);
         portType.setUndefined(false);
         definition.addPortType(portType);
+        Binding binding = createBinding();
+        node2 = node2.getNextSibling();
+        visitOperation(binding, node2);
     }
 
-    public void visitOperation(AST node) {
+    public void visitOperation(Binding binding, AST node) {
         while (node != null) {
             MessageVisitor msgVisitor = new MessageVisitor(wsdlASTVisitor);
             Operation op = definition.createOperation();
             op.setName(node.toString());
-            msgVisitor.setOperation(op);
-            msgVisitor.visit(node);
             op.setUndefined(false);
             portType.addOperation(op);
+            BindingOperation bindingOperation = createBindingOperation(binding, op);
+            msgVisitor.setOperation(op);
+            msgVisitor.setBindingOperation(bindingOperation);
+            msgVisitor.visit(node);
             node = node.getNextSibling();
         }
+    }
+
+    public Binding createBinding() {
+        String bname = portType.getQName().getLocalPart() + "CORBABinding";
+        QName bqname = new QName(definition.getTargetNamespace(),
+                                 bname);
+        int count = 0;
+        while (queryBinding(bqname)) {
+            bname = bname + count;
+            bqname = new QName(definition.getTargetNamespace(), bname);
+        }
+        Binding binding = definition.createBinding();
+        binding.setPortType(portType);
+        binding.setQName(bqname);
+
+        try {
+            BindingType bindingType = (BindingType)
+                extReg.createExtension(Binding.class, CORBAConstants.NE_CORBA_BINDING);
+            bindingType.setRepositoryID(REPO_STRING
+                                        + portType.getQName().getLocalPart().replace('.',
'/')
+                                        + IDL_VERSION);
+            binding.addExtensibilityElement(bindingType);
+        } catch (WSDLException ex) {
+            throw new RuntimeException(ex);
+        }
+        binding.setUndefined(false);
+        definition.addBinding(binding);
+        return binding;
+    }
+
+    public BindingOperation createBindingOperation(Binding binding, Operation op) {
+        BindingOperation bindingOperation = definition.createBindingOperation();
+        OperationType operationType = null;
+        try {
+            operationType = (OperationType)extReg.createExtension(BindingOperation.class,
+                                                                  CORBAConstants.NE_CORBA_OPERATION);
+        } catch (WSDLException ex) {
+            throw new RuntimeException(ex);
+        }
+        operationType.setName(op.getName());
+        bindingOperation.addExtensibilityElement(operationType);
+        bindingOperation.setOperation(op);
+        bindingOperation.setName(op.getName());
+        binding.addBindingOperation(bindingOperation);
+        return bindingOperation;
+    }
+
+    private boolean queryBinding(QName bqname) {
+        Map bindings = definition.getBindings();
+        Iterator i = bindings.values().iterator();
+        while (i.hasNext()) {
+            Binding binding = (Binding)i.next();
+            if (binding.getQName().getLocalPart().equals(bqname.getLocalPart())) {
+                return true;
+            }
+        }
+        return false;
     }
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ReturnParameterVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ReturnParameterVisitor.java?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ReturnParameterVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ReturnParameterVisitor.java
Thu Jul 13 12:13:00 2006
@@ -28,11 +28,14 @@
 import antlr.ASTVisitor;
 import antlr.collections.AST;
 
+import org.apache.schemas.yoko.bindings.corba.ArgType;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+
 public class ReturnParameterVisitor implements ASTVisitor {
 
     Definition definition;
     Message outputMsg;
-
+    OperationType corbaOperation;
     TypesVisitor typesVisitor;
 
     public ReturnParameterVisitor(WSDLASTVisitor visitor) {
@@ -48,7 +51,11 @@
         return outputMsg;
     }
 
-    private void createOutputPart(String partName, AST typeNode) {
+    public void setCorbaOperation(OperationType op) {
+        corbaOperation = op;
+    }
+
+    private void createOutputPart(String partName) {
         Part part;
         QName element = outputMsg.getQName();
         if (outputMsg.getParts().size() == 0) {
@@ -60,11 +67,15 @@
         } else {
             part = (Part) outputMsg.getParts().get(0);
         }
-        typesVisitor.setCurrentPart(element, partName);
-        typesVisitor.visit(typeNode);
     }
     
     public void visit(AST node) {
-        createOutputPart("return", node);
+        String partName = "return";
+        createOutputPart(partName);
+        ArgType param = new ArgType();
+        param.setName(partName);
+        corbaOperation.setReturn(param);
+        typesVisitor.setCurrentPart(outputMsg.getQName(), partName, param);
+        typesVisitor.visit(node);
     }
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/TypesVisitor.java
Thu Jul 13 12:13:00 2006
@@ -32,12 +32,17 @@
 import antlr.ASTVisitor;
 import antlr.collections.AST;
 
+import org.apache.schemas.yoko.bindings.corba.ArgType;
+
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaObject;
 import org.apache.ws.commons.schema.XmlSchemaSerializer;
 
+import org.apache.yoko.tools.common.CorbaPrimitiveMap;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+
 public class TypesVisitor implements ASTVisitor {
     
     Definition definition;
@@ -46,6 +51,11 @@
     XmlSchema schema;
     XmlSchemaCollection schemas;
     XmlSchemaObject currentType;
+
+    ArgType currentParam;
+
+    CorbaPrimitiveMap corbaPrimitiveMap = new CorbaPrimitiveMap();
+
     List<String> parts = new ArrayList<String>();
 
     public TypesVisitor(WSDLASTVisitor visitor) {
@@ -75,12 +85,13 @@
         schema.getItems().add(element);
     }
 
-    public void setCurrentPart(QName el, String name) {
+    public void setCurrentPart(QName el, String name, ArgType param) {
         //get the element & check if a type has been set
         XmlSchemaElement element = (XmlSchemaElement) schema.getElements().getItem(el);
         if (element.getSchemaType() == null) {
             currentType = element;
             parts.add(name);
+            currentParam = param;
         }
     }
 
@@ -89,7 +100,9 @@
         PrimitiveTypesVisitor visitor = new PrimitiveTypesVisitor(schemas, schema);
         visitor.visit(node);
         if (currentType instanceof XmlSchemaElement) {
-            ((XmlSchemaElement) currentType).setSchemaTypeName(visitor.getSchemaType().getQName());
+            QName qname = visitor.getSchemaType().getQName();
+            ((XmlSchemaElement) currentType).setSchemaTypeName(qname);
+            currentParam.setIdltype(((CorbaTypeImpl) corbaPrimitiveMap.get(qname)).getQName());
         }
     }
 

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
Thu Jul 13 12:13:00 2006
@@ -20,17 +20,35 @@
 package org.apache.yoko.tools.processors.idl;
 
 import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
+import javax.wsdl.Port;
 import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.ExtensionRegistry;
 import javax.wsdl.factory.WSDLFactory;
 
+import javax.xml.bind.JAXBException;
+
 import antlr.ASTVisitor;
 import antlr.collections.AST;
 
+import org.apache.schemas.yoko.bindings.corba.AddressType;
+import org.apache.schemas.yoko.bindings.corba.BindingType;
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+
+import org.apache.yoko.tools.common.CORBAConstants;
 import org.apache.yoko.tools.common.WSDLUtils;
 
 import org.objectweb.celtix.tools.common.WSDLConstants;
+import org.objectweb.celtix.wsdl.JAXBExtensionHelper;
 
 public class WSDLASTVisitor implements ASTVisitor {
     
@@ -39,7 +57,8 @@
     PortTypeVisitor portTypeVisitor;
     TypesVisitor typesVisitor;
 
-    public WSDLASTVisitor(String tns) throws WSDLException {
+    public WSDLASTVisitor(String tns)
+        throws WSDLException, JAXBException {
         wsdlFactory = WSDLFactory.newInstance();
         definition = wsdlFactory.newDefinition();
         definition.setTargetNamespace(tns);
@@ -47,7 +66,9 @@
         definition.addNamespace(WSDLConstants.XSD_PREFIX, WSDLConstants.XSD_NAMESPACE);
         definition.addNamespace(WSDLConstants.SOAP_PREFIX, WSDLConstants.SOAP11_NAMESPACE);
         definition.addNamespace(WSDLConstants.TNS_PREFIX, tns);
+        definition.addNamespace(CORBAConstants.NP_WSDL_CORBA, CORBAConstants.NU_WSDL_CORBA);
         initVisitors();
+        addCorbaExtensions(definition.getExtensionRegistry());
     }
 
     public void visit(AST node) {
@@ -79,6 +100,24 @@
         return typesVisitor;
     }
 
+    public Binding[] getCorbaBindings() {
+        List<Binding> result = new ArrayList<Binding>();
+        Map bindings = definition.getBindings();
+        Iterator it = bindings.values().iterator();
+        while (it.hasNext()) {
+            Binding binding = (Binding) it.next();
+            List extElements = binding.getExtensibilityElements();
+            for (int i = 0; i < extElements.size(); i++) {
+                ExtensibilityElement el = (ExtensibilityElement) extElements.get(i);
+                if (el.getElementType().equals(CORBAConstants.NE_CORBA_BINDING)) {
+                    result.add(binding);
+                    break;
+                }
+            }
+        }
+        return (Binding[]) result.toArray(new Binding[result.size()]);
+    }
+
     private void initVisitors() {
         typesVisitor = new TypesVisitor(this);
         portTypeVisitor = new PortTypeVisitor(this);
@@ -88,5 +127,24 @@
         WSDLUtils.writeWSDL(definition, writer);
         return true;
     }
+
+    private void addCorbaExtensions(ExtensionRegistry extReg) throws JAXBException {
+        try {                      
+            JAXBExtensionHelper.addExtensions(extReg, Binding.class, BindingType.class);
+            JAXBExtensionHelper.addExtensions(extReg, BindingOperation.class, OperationType.class);
+            JAXBExtensionHelper.addExtensions(extReg, Definition.class, TypeMappingType.class);
+            JAXBExtensionHelper.addExtensions(extReg, Port.class, AddressType.class);
+
+            extReg.mapExtensionTypes(Binding.class, CORBAConstants.NE_CORBA_BINDING, BindingType.class);
+            extReg.mapExtensionTypes(BindingOperation.class, CORBAConstants.NE_CORBA_OPERATION,
+                                     org.apache.schemas.yoko.bindings.corba.OperationType.class);
+            extReg.mapExtensionTypes(Definition.class, CORBAConstants.NE_CORBA_TYPEMAPPING,
+                                     TypeMappingType.class);
+            extReg.mapExtensionTypes(Port.class, CORBAConstants.NE_CORBA_ADDRESS,
+                                     org.apache.schemas.yoko.bindings.corba.AddressType.class);
+        } catch (javax.xml.bind.JAXBException ex) {
+            throw new JAXBException(ex.getMessage());
+        }
+    }    
 
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
Thu Jul 13 12:13:00 2006
@@ -298,10 +298,12 @@
                     typeMappingType = (TypeMappingType)types.next();
                 }
             }
-            Iterator i = typeMappingType.getStructOrExceptionOrUnion().iterator();
-            while (i.hasNext()) {
-                CorbaTypeImpl corbaTypeImpl = (CorbaTypeImpl)i.next();                  
             
-                findCorbaIdlType(corbaTypeImpl);
+            if (typeMappingType != null) {
+                Iterator i = typeMappingType.getStructOrExceptionOrUnion().iterator();
+                while (i.hasNext()) {
+                    CorbaTypeImpl corbaTypeImpl = (CorbaTypeImpl)i.next();              
                 
+                    findCorbaIdlType(corbaTypeImpl);
+                }
             }
         } catch (Exception ex) {
             ex.printStackTrace();

Modified: incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld.wsdl Thu Jul 13
12:13:00 2006
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns:tns="http://schemas.apache.org/yoko/idl/HelloWorld"
xmlns:corba="http://schemas.apache.org/yoko/bindings/corba" xmlns:ns1="http://schemas.apache.org/yoko/idl/HelloWorld/corba/typemap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
-  <corba:typeMapping targetNamespace="http://schemas.apache.org/yoko/idl/HelloWorld/corba/typemap/"
/>
+<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns:tns="http://schemas.apache.org/yoko/idl/HelloWorld"
xmlns:corba="http://schemas.apache.org/yoko/bindings/corba" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
   <wsdl:types>
     <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/HelloWorld"
xmlns="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:element name="greetMeResponse" type="xs:string">
@@ -26,7 +25,7 @@
     <wsdl:operation name="greetMe">
       <corba:operation name="greetMe">
         <corba:param mode="in" name="inparameter" idltype="corba:string" />
-        <corba:return name="outparameter" idltype="corba:string" />
+        <corba:return name="return" idltype="corba:string" />
       </corba:operation>
       <wsdl:input name="greetMeRequest">
       </wsdl:input>

Modified: incubator/yoko/trunk/tools/src/test/resources/idl/expected_Primitives.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_Primitives.wsdl?rev=421690&r1=421689&r2=421690&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_Primitives.wsdl (original)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_Primitives.wsdl Thu Jul 13
12:13:00 2006
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/primitives" xmlns:tns="http://schemas.apache.org/yoko/idl/primitives"
xmlns:corba="http://schemas.apache.org/yoko/bindings/corba" xmlns:ns1="http://schemas.apache.org/yoko/idl/primitives/corba/typemap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
-  <corba:typeMapping targetNamespace="http://schemas.apache.org/yoko/idl/primitives/corba/typemap/"
/>
+<wsdl:definitions targetNamespace="http://schemas.apache.org/yoko/idl/primitives" xmlns:tns="http://schemas.apache.org/yoko/idl/primitives"
xmlns:corba="http://schemas.apache.org/yoko/bindings/corba" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
   <wsdl:types>
     <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/primitives"
xmlns="http://schemas.apache.org/yoko/idl/primitives" xmlns:xs="http://www.w3.org/2001/XMLSchema">
       <xs:element name="getShortResponse" type="xs:short">
@@ -431,7 +430,7 @@
     <corba:binding repositoryID="IDL:Primitives:1.0" />
     <wsdl:operation name="getShort">
       <corba:operation name="getShort">
-        <corba:return name="outparameter" idltype="corba:short" />
+        <corba:param mode="out" name="outparameter" idltype="corba:short" />
       </corba:operation>
       <wsdl:output name="getShortResponse">
       </wsdl:output>
@@ -445,8 +444,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetShort">
       <corba:operation name="getSetShort">
-        <corba:param mode="in" name="inparameter" idltype="corba:short" />
-        <corba:return name="outparameter" idltype="corba:short" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:short" />
       </corba:operation>
       <wsdl:input name="getSetShortRequest">
       </wsdl:input>
@@ -455,7 +453,7 @@
     </wsdl:operation>
     <wsdl:operation name="getUnsignedShort">
       <corba:operation name="getUnsignedShort">
-        <corba:return name="outparameter" idltype="corba:ushort" />
+        <corba:param mode="out" name="outparameter" idltype="corba:ushort" />
       </corba:operation>
       <wsdl:output name="getUnsignedShortResponse">
       </wsdl:output>
@@ -469,8 +467,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetUnsignedShort">
       <corba:operation name="getSetUnsignedShort">
-        <corba:param mode="in" name="inparameter" idltype="corba:ushort" />
-        <corba:return name="outparameter" idltype="corba:ushort" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:ushort" />
       </corba:operation>
       <wsdl:input name="getSetUnsignedShortRequest">
       </wsdl:input>
@@ -479,7 +476,7 @@
     </wsdl:operation>
     <wsdl:operation name="getLong">
       <corba:operation name="getLong">
-        <corba:return name="outparameter" idltype="corba:long" />
+        <corba:param mode="out" name="outparameter" idltype="corba:long" />
       </corba:operation>
       <wsdl:output name="getLongResponse">
       </wsdl:output>
@@ -493,8 +490,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetLong">
       <corba:operation name="getSetLong">
-        <corba:param mode="in" name="inparameter" idltype="corba:long" />
-        <corba:return name="outparameter" idltype="corba:long" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:long" />
       </corba:operation>
       <wsdl:input name="getSetLongRequest">
       </wsdl:input>
@@ -503,7 +499,7 @@
     </wsdl:operation>
     <wsdl:operation name="getUnsignedLong">
       <corba:operation name="getUnsignedLong">
-        <corba:return name="outparameter" idltype="corba:ulong" />
+        <corba:param mode="out" name="outparameter" idltype="corba:ulong" />
       </corba:operation>
       <wsdl:output name="getUnsignedLongResponse">
       </wsdl:output>
@@ -517,8 +513,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetUnsignedLong">
       <corba:operation name="getSetUnsignedLong">
-        <corba:param mode="in" name="inparameter" idltype="corba:ulong" />
-        <corba:return name="outparameter" idltype="corba:ulong" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:ulong" />
       </corba:operation>
       <wsdl:input name="getSetUnsignedLongRequest">
       </wsdl:input>
@@ -527,7 +522,7 @@
     </wsdl:operation>
     <wsdl:operation name="getLongLong">
       <corba:operation name="getLongLong">
-        <corba:return name="outparameter" idltype="corba:longlong" />
+        <corba:param mode="out" name="outparameter" idltype="corba:longlong" />
       </corba:operation>
       <wsdl:output name="getLongLongResponse">
       </wsdl:output>
@@ -541,8 +536,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetLongLong">
       <corba:operation name="getSetLongLong">
-        <corba:param mode="in" name="inparameter" idltype="corba:longlong" />
-        <corba:return name="outparameter" idltype="corba:longlong" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:longlong" />
       </corba:operation>
       <wsdl:input name="getSetLongLongRequest">
       </wsdl:input>
@@ -551,7 +545,7 @@
     </wsdl:operation>
     <wsdl:operation name="getUnsignedLongLong">
       <corba:operation name="getUnsignedLongLong">
-        <corba:return name="outparameter" idltype="corba:ulonglong" />
+        <corba:param mode="out" name="outparameter" idltype="corba:ulonglong" />
       </corba:operation>
       <wsdl:output name="getUnsignedLongLongResponse">
       </wsdl:output>
@@ -565,8 +559,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetUnsignedLongLong">
       <corba:operation name="getSetUnsignedLongLong">
-        <corba:param mode="in" name="inparameter" idltype="corba:ulonglong" />
-        <corba:return name="outparameter" idltype="corba:ulonglong" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:ulonglong" />
       </corba:operation>
       <wsdl:input name="getSetUnsignedLongLongRequest">
       </wsdl:input>
@@ -575,7 +568,7 @@
     </wsdl:operation>
     <wsdl:operation name="getFloat">
       <corba:operation name="getFloat">
-        <corba:return name="outparameter" idltype="corba:float" />
+        <corba:param mode="out" name="outparameter" idltype="corba:float" />
       </corba:operation>
       <wsdl:output name="getFloatResponse">
       </wsdl:output>
@@ -589,8 +582,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetFloat">
       <corba:operation name="getSetFloat">
-        <corba:param mode="in" name="inparameter" idltype="corba:float" />
-        <corba:return name="outparameter" idltype="corba:float" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:float" />
       </corba:operation>
       <wsdl:input name="getSetFloatRequest">
       </wsdl:input>
@@ -599,7 +591,7 @@
     </wsdl:operation>
     <wsdl:operation name="getDouble">
       <corba:operation name="getDouble">
-        <corba:return name="outparameter" idltype="corba:double" />
+        <corba:param mode="out" name="outparameter" idltype="corba:double" />
       </corba:operation>
       <wsdl:output name="getDoubleResponse">
       </wsdl:output>
@@ -613,8 +605,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetDouble">
       <corba:operation name="getSetDouble">
-        <corba:param mode="in" name="inparameter" idltype="corba:double" />
-        <corba:return name="outparameter" idltype="corba:double" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:double" />
       </corba:operation>
       <wsdl:input name="getSetDoubleRequest">
       </wsdl:input>
@@ -623,7 +614,7 @@
     </wsdl:operation>
     <wsdl:operation name="getChar">
       <corba:operation name="getChar">
-        <corba:return name="outparameter" idltype="corba:char" />
+        <corba:param mode="out" name="outparameter" idltype="corba:char" />
       </corba:operation>
       <wsdl:output name="getCharResponse">
       </wsdl:output>
@@ -637,8 +628,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetChar">
       <corba:operation name="getSetChar">
-        <corba:param mode="in" name="inparameter" idltype="corba:char" />
-        <corba:return name="outparameter" idltype="corba:char" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:char" />
       </corba:operation>
       <wsdl:input name="getSetCharRequest">
       </wsdl:input>
@@ -647,7 +637,7 @@
     </wsdl:operation>
     <wsdl:operation name="getWChar">
       <corba:operation name="getWChar">
-        <corba:return name="outparameter" idltype="corba:string" />
+        <corba:param mode="out" name="outparameter" idltype="corba:string" />
       </corba:operation>
       <wsdl:output name="getWCharResponse">
       </wsdl:output>
@@ -661,8 +651,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetWChar">
       <corba:operation name="getSetWChar">
-        <corba:param mode="in" name="inparameter" idltype="corba:string" />
-        <corba:return name="outparameter" idltype="corba:string" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:string" />
       </corba:operation>
       <wsdl:input name="getSetWCharRequest">
       </wsdl:input>
@@ -671,7 +660,7 @@
     </wsdl:operation>
     <wsdl:operation name="getString">
       <corba:operation name="getString">
-        <corba:return name="outparameter" idltype="corba:string" />
+        <corba:param mode="out" name="outparameter" idltype="corba:string" />
       </corba:operation>
       <wsdl:output name="getStringResponse">
       </wsdl:output>
@@ -685,8 +674,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetString">
       <corba:operation name="getSetString">
-        <corba:param mode="in" name="inparameter" idltype="corba:string" />
-        <corba:return name="outparameter" idltype="corba:string" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:string" />
       </corba:operation>
       <wsdl:input name="getSetStringRequest">
       </wsdl:input>
@@ -695,7 +683,7 @@
     </wsdl:operation>
     <wsdl:operation name="getWstring">
       <corba:operation name="getWstring">
-        <corba:return name="outparameter" idltype="corba:string" />
+        <corba:param mode="out" name="outparameter" idltype="corba:string" />
       </corba:operation>
       <wsdl:output name="getWstringResponse">
       </wsdl:output>
@@ -709,8 +697,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetWstring">
       <corba:operation name="getSetWstring">
-        <corba:param mode="in" name="inparameter" idltype="corba:string" />
-        <corba:return name="outparameter" idltype="corba:string" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:string" />
       </corba:operation>
       <wsdl:input name="getSetWstringRequest">
       </wsdl:input>
@@ -719,7 +706,7 @@
     </wsdl:operation>
     <wsdl:operation name="getBoolean">
       <corba:operation name="getBoolean">
-        <corba:return name="outparameter" idltype="corba:boolean" />
+        <corba:param mode="out" name="outparameter" idltype="corba:boolean" />
       </corba:operation>
       <wsdl:output name="getBooleanResponse">
       </wsdl:output>
@@ -733,8 +720,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetBoolean">
       <corba:operation name="getSetBoolean">
-        <corba:param mode="in" name="inparameter" idltype="corba:boolean" />
-        <corba:return name="outparameter" idltype="corba:boolean" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:boolean" />
       </corba:operation>
       <wsdl:input name="getSetBooleanRequest">
       </wsdl:input>
@@ -743,7 +729,7 @@
     </wsdl:operation>
     <wsdl:operation name="getOctet">
       <corba:operation name="getOctet">
-        <corba:return name="outparameter" idltype="corba:octet" />
+        <corba:param mode="out" name="outparameter" idltype="corba:octet" />
       </corba:operation>
       <wsdl:output name="getOctetResponse">
       </wsdl:output>
@@ -757,8 +743,7 @@
     </wsdl:operation>
     <wsdl:operation name="getSetOctet">
       <corba:operation name="getSetOctet">
-        <corba:param mode="in" name="inparameter" idltype="corba:octet" />
-        <corba:return name="outparameter" idltype="corba:octet" />
+        <corba:param mode="inout" name="inoutparameter" idltype="corba:octet" />
       </corba:operation>
       <wsdl:input name="getSetOctetRequest">
       </wsdl:input>



Mime
View raw message