tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r1163988 - in /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core: assembly/impl/RuntimeEndpointImpl.java assembly/impl/WSDLHelper.java runtime/impl/EndpointReferenceBinderImpl.java
Date Thu, 01 Sep 2011 10:27:50 GMT
Author: slaws
Date: Thu Sep  1 10:27:50 2011
New Revision: 1163988

URL: http://svn.apache.org/viewvc?rev=1163988&view=rev
Log:
TUSCANY-3916 - Turn remote interface match back on with a couple of restrictions. Only the
top level WSDL is shared and dependent XSD is not. I've added guards for the case where parameter
types cannot be converted to WSDL. If interface information is insufficient to run the match
the interfaces are assumed to be compatible and matching is left until runtime. Having struggled
with the WSDL based approach I'm going to look at serializing the internal Tuscany model.


Modified:
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java?rev=1163988&r1=1163987&r2=1163988&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
Thu Sep  1 10:27:50 2011
@@ -1021,11 +1021,10 @@ public class RuntimeEndpointImpl extends
 
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         this.uri = in.readUTF();
-        this.xml = in.readUTF();
-/*         
+        this.xml = in.readUTF();       
         this.wsdl = in.readUTF();
         this.wsdlCallback = in.readUTF();
-*/
+
     }
 
     public void writeExternal(ObjectOutput out) throws IOException {
@@ -1039,8 +1038,7 @@ public class RuntimeEndpointImpl extends
                 throw new IllegalStateException("No serializer is configured");
             }
         }
-        
-/*        
+              
         if (wsdl == null) {
             wsdl = getWsdl();
         }
@@ -1049,8 +1047,7 @@ public class RuntimeEndpointImpl extends
         if (wsdlCallback == null) {
             wsdlCallback = getWsdlCallback();
         }
-        out.writeUTF(wsdlCallback);
-*/        
+        out.writeUTF(wsdlCallback);        
     }
     
     public String getAsXML() {
@@ -1065,7 +1062,16 @@ public class RuntimeEndpointImpl extends
         if (ic == null || ic.getInterface() == null || !ic.getInterface().isRemotable())
{
             return "";
         }
-        WSDLInterfaceContract wsdlIC = (WSDLInterfaceContract)getGeneratedWSDLContract(ic);
+        
+        WSDLInterfaceContract wsdlIC = null;
+        try {
+            wsdlIC = (WSDLInterfaceContract)getGeneratedWSDLContract(ic);
+        } catch (Exception ex){
+            // ignore WSDL generation errors as the service interface may have
+            // types that can't be converted to XML easily
+            return "";
+        }
+        
         if (wsdlIC == null) {
             return "";
         }
@@ -1091,7 +1097,16 @@ public class RuntimeEndpointImpl extends
         if (ic == null || ic.getCallbackInterface() == null || !ic.getCallbackInterface().isRemotable())
{
             return "";
         }
-        WSDLInterfaceContract wsdlIC = (WSDLInterfaceContract)getGeneratedWSDLContract(ic);
+        
+        WSDLInterfaceContract wsdlIC = null;
+        try {
+            wsdlIC = (WSDLInterfaceContract)getGeneratedWSDLContract(ic);
+        } catch (Exception ex){
+            // ignore WSDL generation errors as the service interface may have
+            // types that can't be converted to XML easily
+            return "";
+        }
+    
         if (wsdlIC == null) {
             return "";
         }
@@ -1139,13 +1154,16 @@ public class RuntimeEndpointImpl extends
             outStream.write(separator);
             writer.writeWSDL(importedWSDLDefintion.getDefinition(), outStream);
         }
+/* Exclude the XSD for the time being to see if we can get comparison working
+ * with the operation signatures but ignoring parameter types    
         for (XSDefinition xsdDefinition : wsdlDefinition.getXmlSchemas()){
             // we store a reference to the schema schema. We don't need to write that out.
             if (!xsdDefinition.getNamespace().equals("http://www.w3.org/2001/XMLSchema")
&&
                 xsdDefinition.getSchema() != null){
                 writeSchema(outStream, xsdDefinition.getSchema());
             }
-        }  
+        } 
+*/
     }
     
     /**

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java?rev=1163988&r1=1163987&r2=1163988&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/WSDLHelper.java
Thu Sep  1 10:27:50 2011
@@ -40,6 +40,9 @@ import javax.wsdl.Definition;
 import javax.wsdl.PortType;
 import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.xml.WSDLLocator;
 import javax.wsdl.xml.WSDLReader;
 
@@ -63,6 +66,8 @@ import org.apache.tuscany.sca.xsd.xml.XS
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.resolver.DefaultURIResolver;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.xml.sax.InputSource;
 
 public class WSDLHelper {
@@ -295,17 +300,38 @@ public class WSDLHelper {
                    
                    // extract any in-line types in the Tuscany model
                    Types types = wsdlDefinition.getDefinition().getTypes();
-                   if ( types != null){
+                   if ( types != null){                       
+/*  read XSD from WSDL rather than from registry 
                        for (int i=0; i < types.getExtensibilityElements().size(); i++){
+                       
                            String schemaName = xmlString.getBaseURI() + "#" + i++;
                            XSDInfo xsdInfo = (XSDInfo)xmlMap.get(getFilenameWithoutPath(schemaName));
                            if (xsdInfo != null){
                                wsdlDefinition.getXmlSchemas().add(xsdInfo.getXsdDefinition());
                            }
+*/ 
+                       int index = 0;
+                       for (Object ext : types.getExtensibilityElements()) {
+                           ExtensibilityElement extElement = (ExtensibilityElement)ext;
+                           Element element = null;
+                           if (extElement instanceof Schema) {
+                               element = ((Schema)extElement).getElement();
+                           }
+                           if (element != null) {
+                               XSDefinition xsDefinition = xsdFactory.createXSDefinition();
+                               xsDefinition.setUnresolved(true);
+                               xsDefinition.setNamespace(element.getAttribute("targetNamespace"));
+                               xsDefinition.setDocument(element.getOwnerDocument());
+                               XmlSchema schema = schemaCollection.read(element, null);
+                               xsDefinition.setSchema(schema);
+                               xsDefinition.setLocation(URI.create(xmlString.getBaseURI()
+ "#" + index));
+                               wsdlDefinition.getXmlSchemas().add(xsDefinition);
+                               index++;
+                           }
                        }
                    }
                 } else {
-                    // Schema should already be linked via the schema model
+                    // TODO
                 }
             }
             
@@ -484,5 +510,5 @@ public class WSDLHelper {
             return filename.substring(wsdlIndex + 1);
         }
         // What happens with generated WSDL?
-    }      
+    }  
 }

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1163988&r1=1163987&r2=1163988&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
Thu Sep  1 10:27:50 2011
@@ -969,11 +969,25 @@ public class EndpointReferenceBinderImpl
             return true;
         }     
         
+/*  For testing this code turns off remote interface matching completely   
         if (endpoint.isRemote()){
             matchAudit.append("Match because endpoint is remote");
             matchAudit.appendSeperator();
             return true;
         }
+*/       
+        
+        // If the remote interface was not retrieved successfully from the registry for whatever
reason
+        // then assume the interfaces match and leave the checking until runtime. We looking
for an interface
+        // with no operations defined to tell us this. 
+        if ((endpointContract.getInterface().getOperations().size() == 0 &&
+             endpointContract.getNormalizedWSDLContract() == null) ||
+            (endpointContract.getNormalizedWSDLContract() != null &&
+             endpointContract.getNormalizedWSDLContract().getInterface().getOperations().size()
== 0)){
+            matchAudit.append("Match because the endpoint is remote and we don't have a copy
of it's interface contract ");
+            matchAudit.appendSeperator();
+            return true;
+        }
         
         // If the contracts are not of the same type use normailized interfaces
         if (endpointReferenceContract.getClass() != endpointContract.getClass() ||



Mime
View raw message