incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmidd...@apache.org
Subject svn commit: r514831 - /incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java
Date Mon, 05 Mar 2007 19:40:46 GMT
Author: dmiddlem
Date: Mon Mar  5 11:40:45 2007
New Revision: 514831

URL: http://svn.apache.org/viewvc?view=rev&rev=514831
Log:
Adding WSDL service generation when building the corba binding. (YOKO-298)

Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java

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?view=diff&rev=514831&r1=514830&r2=514831
==============================================================================
--- 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
Mon Mar  5 11:40:45 2007
@@ -39,6 +39,7 @@
 import javax.wsdl.Part;
 import javax.wsdl.Port;
 import javax.wsdl.PortType;
+import javax.wsdl.Service;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensionRegistry;
 import javax.xml.bind.JAXBException;
@@ -46,6 +47,7 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.wsdl.JAXBExtensionHelper;
+import org.apache.schemas.yoko.bindings.corba.AddressType;
 import org.apache.schemas.yoko.bindings.corba.ArgType;
 import org.apache.schemas.yoko.bindings.corba.BindingType;
 import org.apache.schemas.yoko.bindings.corba.MemberType;
@@ -193,6 +195,7 @@
         Binding[] bindings = new Binding[intfs.size()];
         for (int i = 0; i < intfs.size(); i++) {
             bindings[i] = generateCORBABinding(def, (PortType) intfs.get(i));
+            generateCORBAServiceForBinding(def, (PortType) intfs.get(i));
         }
         return bindings;
     }
@@ -290,6 +293,68 @@
         }
         
         return binding;
+    }
+    
+    private void generateCORBAServiceForBinding(Definition definition, PortType portType)
throws Exception {
+        QName bQName = null;
+        
+        if (extReg == null) {
+            extReg = def.getExtensionRegistry();
+            addExtensions(extReg);
+        }
+
+        String interfaceName = portType.getQName().getLocalPart();
+        String serviceName = mangleInterfaceName(interfaceName) + "CORBAService";
+        String portName = mangleInterfaceName(interfaceName) + "CORBAPort";
+
+        String bName = getMappedBindingName(interfaceName);
+        if (bName == null) {
+            bName = bindingName;
+        }
+        if (bName == null) {
+            bName = mangleInterfaceName(interfaceName) + "CORBABinding";
+        }
+
+        String prefix = definition.getPrefix(definition.getTargetNamespace());
+        if (prefix == null) {
+            prefix = "";
+        }
+
+        String corbaPrefix = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
+        if (corbaPrefix == null) {
+            corbaPrefix = new String("corba");
+            def.addNamespace(corbaPrefix, CorbaConstants.NU_WSDL_CORBA);
+        }
+        
+        // The binding should exist since it should have been created in the method before
this one
+        bQName = new QName(definition.getTargetNamespace(), bName, prefix);
+        if (!(helper.queryBinding(definition, bQName))) {
+            throw new Exception("Can not find binding for service " + serviceName);
+        }
+
+        // Build the service and port information and add it to the wsdl
+        Service service = def.createService();
+
+        Port servicePort = def.createPort();
+        servicePort.setName(portName);
+        Binding serviceBinding = def.getBinding(bQName);
+        servicePort.setBinding(serviceBinding);
+
+        try {
+            AddressType addressType = (AddressType)extReg.createExtension(Port.class, 
+                                                                          CorbaConstants.NE_CORBA_ADDRESS);
+            // TODO: Use an address from the command line or a random one if none has been
+            // specified.
+            addressType.setLocation("...");
+            servicePort.addExtensibilityElement(addressType);
+        } catch (WSDLException ex) {
+            throw new Exception("Failed to create CORBA address for service", ex);
+        }
+
+        QName serviceQName = new QName(definition.getTargetNamespace(), serviceName, prefix);
+        service.setQName(serviceQName);
+        service.addPort(servicePort);
+        definition.addService(service);
     }
 
     private void addBindingOperations(Definition definition, PortType portType, Binding binding)




Mime
View raw message