tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1148316 - in /tuscany/sca-java-2.x/trunk/modules/core: META-INF/MANIFEST.MF src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
Date Tue, 19 Jul 2011 13:41:07 GMT
Author: antelder
Date: Tue Jul 19 13:41:06 2011
New Revision: 1148316

URL: http://svn.apache.org/viewvc?rev=1148316&view=rev
Log:
Update the Runtime Endpoint to include its normalized wsdl in its serialization

Modified:
    tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF?rev=1148316&r1=1148315&r2=1148316&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/META-INF/MANIFEST.MF Tue Jul 19 13:41:06 2011
@@ -35,6 +35,9 @@ Import-Package: javax.security.auth,
  javax.xml.namespace,
  javax.xml.stream,
  javax.xml.transform,
+ javax.wsdl,
+ javax.wsdl.xml,
+ org.xml.sax,
  net.sf.cglib.proxy;resolution:=optional,
  org.apache.tuscany.sca.assembly;version="2.0.0",
  org.apache.tuscany.sca.assembly.builder;version="2.0.0",

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=1148316&r1=1148315&r2=1148316&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
Tue Jul 19 13:41:06 2011
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.core.assembly.impl;
 
+import java.io.ByteArrayOutputStream;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -30,6 +31,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.xml.WSDLWriter;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
@@ -76,6 +81,10 @@ import org.apache.tuscany.sca.interfaced
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
 import org.apache.tuscany.sca.invocation.Interceptor;
 import org.apache.tuscany.sca.invocation.InterceptorAsync;
 import org.apache.tuscany.sca.invocation.InvocationChain;
@@ -94,8 +103,8 @@ import org.apache.tuscany.sca.provider.P
 import org.apache.tuscany.sca.provider.PolicyProviderFactory;
 import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
 import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
 import org.apache.tuscany.sca.runtime.DomainRegistry;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
 import org.apache.tuscany.sca.runtime.EndpointSerializer;
 import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -106,6 +115,7 @@ import org.apache.tuscany.sca.runtime.Ru
 import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
 import org.apache.tuscany.sca.work.WorkScheduler;
 import org.oasisopen.sca.ServiceRuntimeException;
+import org.xml.sax.InputSource;
 
 /**
  * Runtime model for Endpoint that supports java serialization
@@ -130,6 +140,7 @@ public class RuntimeEndpointImpl extends
     private transient ServiceBindingProvider bindingProvider;
     private transient List<PolicyProvider> policyProviders;
     private String xml;
+    private String wsdl;
 
     protected InterfaceContract bindingInterfaceContract;
     protected InterfaceContract serviceInterfaceContract;
@@ -928,6 +939,7 @@ public class RuntimeEndpointImpl extends
                     } // end if
                 } // end if
             } // end if
+            setNormailizedWSDLContract();
         } // end if
         super.resolve();
     } // end method resolve
@@ -1002,6 +1014,7 @@ public class RuntimeEndpointImpl extends
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         this.uri = in.readUTF();
         this.xml = in.readUTF();
+        this.wsdl = in.readUTF();
     }
 
     public void writeExternal(ObjectOutput out) throws IOException {
@@ -1015,7 +1028,63 @@ public class RuntimeEndpointImpl extends
                 throw new IllegalStateException("No serializer is configured");
             }
         }
+        
+        if (wsdl == null) {
+            wsdl = getWsdl();
+        }
+        out.writeUTF(wsdl);
+    }
+    
+    public String getAsXML() {
+        if (xml == null) {
+            this.xml = serializer.write(this);
+        }
+        return xml;
+    }
+    
+    private String getWsdl() {
+        InterfaceContract ic = getComponentServiceInterfaceContract();
+        if (ic == null || ic.getInterface() == null || !!!ic.getInterface().isRemotable())
{
+            return "";
+        }
+        WSDLInterfaceContract wsdlIC = (WSDLInterfaceContract)getGeneratedWSDLContract(getComponentServiceInterfaceContract());
+        if (wsdlIC == null) {
+            return "";
+        }
+        WSDLInterface wsdl = (WSDLInterface)wsdlIC.getInterface();
+        WSDLDefinition d = wsdl.getWsdlDefinition();
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        try {
+            WSDLWriter writer = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
+            writer.writeWSDL(d.getDefinition(), outStream);
+        } catch (Exception e){
+            throw new RuntimeException(e);
+        }
+        return outStream.toString();
     }
+
+    private void setNormailizedWSDLContract() {
+        if (wsdl == null || wsdl.length() < 1) {
+            return;
+        }
+        try {
+            InterfaceContract ic = getComponentServiceInterfaceContract();
+            WSDLFactory wsdlFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(WSDLFactory.class);
+            WSDLInterfaceContract wsdlIC = wsdlFactory.createWSDLInterfaceContract();
+            WSDLInterface wsdlIface = wsdlFactory.createWSDLInterface();
+            WSDLDefinition wsdlDef = wsdlFactory.createWSDLDefinition();
+            WSDLReader reader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
+            InputSource inputSource = new InputSource(new StringReader(wsdl));
+            Definition def = reader.readWSDL("", inputSource);
+            wsdlDef.setDefinition(def);
+            wsdlIface.setWsdlDefinition(wsdlDef);
+            wsdlIC.setInterface(wsdlIface);
+            ic.setNormailizedWSDLContract(wsdlIC);
+        } catch (WSDLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
     public InterfaceContract getGeneratedWSDLContract(InterfaceContract interfaceContract)
{
 
         if ( interfaceContract.getNormalizedWSDLContract() == null){



Mime
View raw message