incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r413106 - in /incubator/yoko/trunk/tools/src: main/java/org/apache/yoko/tools/ main/java/org/apache/yoko/tools/common/ main/java/org/apache/yoko/tools/processors/idl/ main/java/org/apache/yoko/tools/processors/wsdl/ test/resources/idl/
Date Fri, 09 Jun 2006 17:40:21 GMT
Author: bravi
Date: Fri Jun  9 10:40:20 2006
New Revision: 413106

URL: http://svn.apache.org/viewvc?rev=413106&view=rev
Log:
Updating the idltowsdl tool to add the wsdl:service when generating the wsdl. Jira: http://issues.apache.org/jira/browse/YOKO-41

Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
    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/wsdl/WSDLToCorbaBinding.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

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java?rev=413106&r1=413105&r2=413106&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java Fri Jun
 9 10:40:20 2006
@@ -88,7 +88,10 @@
         if (env.optionSet(ToolConstants.CFG_OUTPUTDIR)) {
             env.put(ToolConstants.CFG_OUTPUTDIR, doc.getParameter(ToolConstants.CFG_OUTPUTDIR));
         }
-
+        if (env.optionSet(ToolCorbaConstants.CFG_ADDRESS)) {
+            env.put(ToolCorbaConstants.CFG_ADDRESS, doc.getParameter(ToolCorbaConstants.CFG_ADDRESS));
+        }
+        
         //need to add all the other options
     }
 

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java?rev=413106&r1=413105&r2=413106&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
Fri Jun  9 10:40:20 2006
@@ -12,4 +12,5 @@
     public static final String CFG_TNS = "tns";
     public static final String CFG_SCHEMA = "schema";
     public static final String CFG_IMPORTSCHEMA = "importschema";
+    public static final String CFG_ADDRESS = "address";
 }

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=413106&r1=413105&r2=413106&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
Fri Jun  9 10:40:20 2006
@@ -6,11 +6,15 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
+import javax.wsdl.Binding;
 import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
 import javax.xml.namespace.QName;
 
 import antlr.collections.AST;
 
+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;
@@ -73,10 +77,10 @@
                 QName portType = (QName) it.next();
                 corbaBinding.addInterfaceName(portType.getLocalPart());
             }
-            corbaBinding.generateCORBABinding(def);
+            Binding[] bindings = corbaBinding.generateCORBABinding(def);
+            generateCORBAService(def, bindings);
             visitor.writeDefinition(outStream);
         } catch (Exception ex) {
-            ex.printStackTrace();
             throw new ToolException(ex.getMessage(), ex);
         }
     }
@@ -100,6 +104,30 @@
             fileName = new String(fileName.substring(0, fileName.length() - 4));
         }
         return fileName;
+    }
+
+    public void generateCORBAService(Definition def, Binding[] bindings) throws Exception
{
+        for (int i = 0; i < bindings.length; i++) {
+            String portTypeName = bindings[i].getPortType().getQName().getLocalPart();
+            QName serviceName = new QName(def.getTargetNamespace(),
+                                          portTypeName + "CORBAService");
+            Service service = def.createService();
+            service.setQName(serviceName);
+            Port port = def.createPort();
+            port.setName(portTypeName + "CORBAPort");
+            AddressType address =
+                (AddressType) def.getExtensionRegistry().createExtension(Port.class,
+                                                                         CORBAConstants.NE_CORBA_ADDRESS);
+            String addr = (String) env.get(ToolCorbaConstants.CFG_ADDRESS);
+            if (addr == null) {
+                addr = "IOR:";
+            }
+            address.setLocation(addr);
+            port.addExtensibilityElement(address);
+            service.addPort(port);
+            port.setBinding(bindings[i]);
+            def.addService(service);
+        }
     }
     
 }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java?rev=413106&r1=413105&r2=413106&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java
Fri Jun  9 10:40:20 2006
@@ -15,6 +15,7 @@
 import javax.wsdl.BindingOutput;
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
+import javax.wsdl.Port;
 import javax.wsdl.PortType;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensionRegistry;
@@ -97,7 +98,7 @@
         return def;
     }
 
-    public void generateCORBABinding(Definition definition) throws Exception {    
+    public Binding[] generateCORBABinding(Definition definition) throws Exception {    
         def = definition;
         if (extReg == null) {
             extReg = def.getExtensionRegistry();
@@ -154,18 +155,7 @@
             } else {
                 PortType portType = null;
                 if (portTypes.size() > 1) {
-                    StringBuffer sb = new StringBuffer();
-                    org.objectweb.celtix.common.i18n.Message msgDef = 
-                        new org.objectweb.celtix.common.i18n.Message(
-                            "Multiple PortTypes defined in wsdl", LOG);
-                    sb.append(msgDef.toString());
-                    Iterator it2 = portTypes.keySet().iterator();
-                    int cnt = 0;
-                    while (it2.hasNext()) {
-                        cnt++;
-                        sb.append("  " + cnt + " --> " + ((QName) it2.next()).getLocalPart());
-                    }
-                    throw new Exception(sb.toString());
+                    throwMultiplePortTypeException(portTypes);
                 } else {
                     portType = (PortType) portTypes.keySet().iterator().next();
                     interfaceNames.add(portType.getQName().getLocalPart());
@@ -175,12 +165,28 @@
             }
         }
 
+        Binding[] bindings = new Binding[intfs.size()];
         for (int i = 0; i < intfs.size(); i++) {
-            generateCORBABinding(def, (PortType) intfs.get(i));
+            bindings[i] = generateCORBABinding(def, (PortType) intfs.get(i));
+        }
+        return bindings;
+    }
+
+    private void throwMultiplePortTypeException(Map portTypes) throws Exception {
+        StringBuffer sb = new StringBuffer();
+        org.objectweb.celtix.common.i18n.Message msgDef = 
+            new org.objectweb.celtix.common.i18n.Message("Multiple PortTypes defined in wsdl",
LOG);
+        sb.append(msgDef.toString());
+        Iterator it2 = portTypes.keySet().iterator();
+        int cnt = 0;
+        while (it2.hasNext()) {
+            cnt++;
+            sb.append("  " + cnt + " --> " + ((QName) it2.next()).getLocalPart());
         }
+        throw new Exception(sb.toString());
     }
 
-    private void generateCORBABinding(Definition definition, PortType portType) throws Exception
{
+    private Binding generateCORBABinding(Definition definition, PortType portType) throws
Exception {
         QName bqname = null;
 
         if (extReg == null) {
@@ -257,6 +263,7 @@
         } catch (Exception ex) {
             ex.printStackTrace();
         }
+        return binding;
     }
 
     private void addBindingOperations(Definition definition, PortType portType, Binding binding)

@@ -294,19 +301,21 @@
     }
 
     public void addExtensions(ExtensionRegistry extRegistry) throws JAXBException {
-        try {
-                      
+        try {                      
             JAXBExtensionHelper.addExtensions(extReg, Binding.class, BindingType.class);
             JAXBExtensionHelper.addExtensions(extReg, BindingOperation.class,
                                               org.apache.schemas.yoko.bindings.corba.OperationType.class);
             JAXBExtensionHelper.addExtensions(extReg, Definition.class, TypeMappingType.class);
+            JAXBExtensionHelper.addExtensions(extReg, Port.class,
+                                              org.apache.schemas.yoko.bindings.corba.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) {
             LOG.log(Level.SEVERE, "Failing to serialize/deserialize extensions", 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=413106&r1=413105&r2=413106&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
Fri Jun  9 10:40:20 2006
@@ -13,6 +13,7 @@
 import javax.wsdl.Binding;
 import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
+import javax.wsdl.Port;
 import javax.wsdl.extensions.ExtensionRegistry;
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
@@ -96,12 +97,16 @@
             JAXBExtensionHelper.addExtensions(extReg, BindingOperation.class,
                                               org.apache.schemas.yoko.bindings.corba.OperationType.class);
             JAXBExtensionHelper.addExtensions(extReg, Definition.class, TypeMappingType.class);
+            JAXBExtensionHelper.addExtensions(extReg, Port.class,
+                                              org.apache.schemas.yoko.bindings.corba.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) {
             LOG.log(Level.SEVERE, "Failing to serialize/deserialize extensions", ex);

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=413106&r1=413105&r2=413106&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 Fri Jun  9
10:40:20 2006
@@ -23,5 +23,8 @@
       </wsdl:output>
     </wsdl:operation>
   </wsdl:binding>
+  <wsdl:service name="HelloWorldCORBAService">
+    <wsdl:port name="HelloWorldCORBAPort" binding="tns:HelloWorldCORBABinding">
+<corba:address location="IOR:" />    </wsdl:port>
+  </wsdl:service>
 <corba:typeMapping targetNamespace="http://schemas.apache.org/yoko/idl/HelloWorld/corba/typemap/"
/></wsdl:definitions>
-



Mime
View raw message