On Sat, Jun 25, 2011 at 9:36 AM,  <antel...@apache.org> wrote:
> Author: antelder
> Date: Sat Jun 25 08:36:14 2011
> New Revision: 1139503
>
> URL: http://svn.apache.org/viewvc?rev=1139503&view=rev
> Log:
> Remove the storing of wsdl in the registry as it snot used by anythiny 
> presently now that the client has been changed to get the contribution jars 
> itself
>
> Modified:
>    
> tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java
>    
> tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java
>
> Modified: 
> tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java
> URL: 
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java?rev=1139503&r1=1139502&r2=1139503&view=diff
> ==============================================================================
> --- 
> tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java
>  (original)
> +++ 
> tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java
>  Sat Jun 25 08:36:14 2011
> @@ -22,7 +22,6 @@ package org.apache.tuscany.sca.registry.
>  import java.io.ByteArrayOutputStream;
>  import java.io.FileNotFoundException;
>  import java.io.IOException;
> -import java.io.StringReader;
>  import java.net.UnknownHostException;
>  import java.util.ArrayList;
>  import java.util.Collection;
> @@ -36,10 +35,6 @@ import java.util.concurrent.FutureTask;
>  import java.util.logging.Level;
>  import java.util.logging.Logger;
>
> -import javax.wsdl.Definition;
> -import javax.wsdl.WSDLException;
> -import javax.wsdl.xml.WSDLReader;
> -import javax.wsdl.xml.WSDLWriter;
>  import javax.xml.stream.XMLStreamException;
>  import javax.xml.stream.XMLStreamReader;
>
> @@ -56,19 +51,13 @@ import org.apache.tuscany.sca.core.Exten
>  import org.apache.tuscany.sca.core.FactoryExtensionPoint;
>  import org.apache.tuscany.sca.core.LifeCycleListener;
>  import org.apache.tuscany.sca.core.UtilityExtensionPoint;
> -import org.apache.tuscany.sca.interfacedef.InterfaceContract;
> -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.runtime.BaseDomainRegistry;
> +import org.apache.tuscany.sca.runtime.ContributionDescription;
>  import org.apache.tuscany.sca.runtime.ContributionListener;
>  import org.apache.tuscany.sca.runtime.DomainRegistry;
> -import org.apache.tuscany.sca.runtime.ContributionDescription;
>  import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
>  import org.apache.tuscany.sca.runtime.RuntimeProperties;
>  import org.oasisopen.sca.ServiceRuntimeException;
> -import org.xml.sax.InputSource;
>
>  import com.hazelcast.config.Config;
>  import com.hazelcast.config.NearCacheConfig;
> @@ -106,7 +95,6 @@ public class HazelcastDomainRegistry ext
>     // key componentName, value contributionURI
>     protected Map<String, String> runningComponentContributions;
>
> -    protected Map<Object, Object> endpointWsdls;
>     protected Map<String, Endpoint> localEndpoints = new 
> ConcurrentHashMap<String, Endpoint>();
>
>     protected Map<String, ContributionDescription> contributionDescriptions;
> @@ -147,7 +135,6 @@ public class HazelcastDomainRegistry ext
>             endpointMap = imap;
>
>             endpointOwners = hazelcastInstance.getMultiMap(domainURI + 
> "/EndpointOwners");
> -            endpointWsdls = hazelcastInstance.getMap(domainURI + 
> "/EndpointWsdls");
>
>             runningComposites = hazelcastInstance.getMap(domainURI + 
> "/RunningComposites");
>             runningCompositeOwners = hazelcastInstance.getMap(domainURI + 
> "/RunningCompositeOwners");
> @@ -182,7 +169,6 @@ public class HazelcastDomainRegistry ext
>                 hazelcastInstance = null;
>                 endpointMap = null;
>                 endpointOwners = null;
> -                endpointWsdls = null;
>                 runningComposites = null;
>                 runningCompositeOwners = null;
>             }
> @@ -290,7 +276,6 @@ public class HazelcastDomainRegistry ext
>
>         String localMemberAddr = 
> hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
>         String endpointURI = endpoint.getURI();
> -        String wsdl = getWsdl(endpoint);
>         String componentName = endpoint.getComponent().getName();
>         String curi = null;
>         if (endpoint instanceof RuntimeEndpoint) {
> @@ -304,7 +289,6 @@ public class HazelcastDomainRegistry ext
>         try {
>             localEndpoints.put(endpointURI, endpoint);
>             endpointMap.put(endpointURI, endpoint);
> -            endpointWsdls.put(endpointURI, wsdl);
>             endpointOwners.put(localMemberAddr, endpointURI);
>             if (curi != null) {
>                 runningComponentContributions.put(componentName, curi);
> @@ -317,23 +301,6 @@ public class HazelcastDomainRegistry ext
>         logger.info("Add endpoint - " + endpoint);
>     }
>
> -    private String getWsdl(Endpoint endpoint) {
> -        WSDLInterfaceContract wsdlIC = 
> (WSDLInterfaceContract)((RuntimeEndpoint)endpoint).getGeneratedWSDLContract(endpoint.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();
> -    }
> -
>     public List<Endpoint> findEndpoint(String uri) {
>         List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
>         for (Object v : endpointMap.values()) {
> @@ -353,11 +320,6 @@ public class HazelcastDomainRegistry ext
>         if (!isLocal(endpoint)) {
>             endpoint.setRemote(true);
>             ((RuntimeEndpoint)endpoint).bind(registry, this);
> -            try {
> -                setNormailizedWSDLContract(endpoint);
> -            } catch (WSDLException e) {
> -                throw new RuntimeException(e);
> -            }
>         } else {
>             // get the local version of the endpoint
>             // this local version won't have been serialized
> @@ -368,25 +330,6 @@ public class HazelcastDomainRegistry ext
>         return endpoint;
>     }
>
> -    private void setNormailizedWSDLContract(Endpoint endpoint) throws 
> WSDLException {
> -        String wsdl = endpointWsdls == null ? null : 
> (String)endpointWsdls.get(endpoint.getURI());
> -        if (wsdl == null || wsdl.length() < 1) {
> -            return;
> -        }
> -        InterfaceContract ic = 
> endpoint.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);
> -    }
> -
>     private boolean isLocal(Endpoint endpoint) {
>         return localEndpoints.containsKey(endpoint.getURI());
>     }
> @@ -416,7 +359,6 @@ public class HazelcastDomainRegistry ext
>             try {
>                 endpointOwners.remove(localMemberAddr, endpointURI);
>                 endpointMap.remove(endpointURI);
> -                endpointWsdls.remove(endpointURI);
>                 runningComponentContributions.remove(componentName);
>                 txn.commit();
>             } catch (Throwable e) {
> @@ -486,7 +428,6 @@ public class HazelcastDomainRegistry ext
>                             for (Object k : keys) {
>                                 Endpoint endpoint = 
> (Endpoint)endpointMap.remove(k);
>                                 
> runningComponentContributions.remove(endpoint.getComponent().getName());
> -                                endpointWsdls.remove(k);
>                             }
>                         }
>                         if (runningCompositeOwners.containsKey(memberAddr)) {
>
> Modified: 
> tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java
> URL: 
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java?rev=1139503&r1=1139502&r2=1139503&view=diff
> ==============================================================================
> --- 
> tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java
>  (original)
> +++ 
> tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java
>  Sat Jun 25 08:36:14 2011
> @@ -60,7 +60,6 @@ public class HazelcastClientEndpointRegi
>         initHazelcastClientInstance();
>         endpointMap = hazelcastClient.getMap(rc.getUserid() + "/Endpoints");
>         endpointOwners = hazelcastClient.getMultiMap(rc.getUserid() + 
> "/EndpointOwners");
> -        endpointWsdls = hazelcastClient.getMap(rc.getUserid() + 
> "/EndpointWsdls");
>         runningComponentContributions = hazelcastClient.getMap(rc.getUserid() 
> + "/RunningComponentContributions");
>         contributionDescriptions = hazelcastClient.getMap(rc.getUserid() + 
> "/ContributionDescriptions");
>     }
> @@ -71,7 +70,6 @@ public class HazelcastClientEndpointRegi
>             hazelcastClient.shutdown();
>             hazelcastClient = null;
>             endpointMap = null;
> -            endpointWsdls = null;
>         }
>     }
>
>
>
>

I think we need to fix the interface compatibility test that is
currently disabled in the endpoint reference binding. To do this I
think we need to re-enable this function.

Nominally the interface contract should be presented with the endpoint
when it's retrieved which is what this code is doing under the covers
in a Hazelcast specific way. We could consider extending the endpoint
serialization mechanism to take the normalized WSDL interface contract
with it. However we could also do with a more general mechanism of
getting hold of domain resources as we need to share policy as well as
interfaces. For example, we could extend the domain interface with
something like.

WSDLInterfaceContract getNormalizedEndpointInterfaceContract(Endpoint)
Policy getPolicy(QName)

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Reply via email to