tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1132533 - in /tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl: DeployedComposite.java NodeImpl.java ServiceHelper.java
Date Mon, 06 Jun 2011 06:34:15 GMT
Author: antelder
Date: Mon Jun  6 06:34:15 2011
New Revision: 1132533

URL: http://svn.apache.org/viewvc?rev=1132533&view=rev
Log:
Fix NPE when stopping a remote composite

Modified:
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java?rev=1132533&r1=1132532&r2=1132533&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
Mon Jun  6 06:34:15 2011
@@ -86,6 +86,7 @@ public class DeployedComposite {
         // TODO: Ideally deployer.build would set the name and uri to what this needs
         builtComposite.setName(composite.getName());
         builtComposite.setURI(composite.getURI());
+        builtComposite.setContributionURI(composite.getContributionURI());
         monitor.analyzeProblems();
 
         compositeContext = new CompositeContext(extensionPointRegistry, 

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java?rev=1132533&r1=1132532&r2=1132533&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
Mon Jun  6 06:34:15 2011
@@ -261,7 +261,10 @@ public class NodeImpl implements Node {
     public void stopComposite(String contributionURI, String compositeURI) throws ActivationException
{
         String key = contributionURI+"/"+compositeURI;
         DeployedComposite dc = startedComposites.remove(key);
-        if (dc == null) {
+        if (dc != null) {
+            dc.stop();
+            stoppedComposites.put(key, dc);
+        } else {
             String member = domainRegistry.getRunningMember(contributionURI, compositeURI);
             if (member == null) {
                 throw new IllegalStateException("composite not started: " + compositeURI);
@@ -272,8 +275,6 @@ public class NodeImpl implements Node {
                 throw new ActivationException(response);
             }
         }
-        dc.stop();
-        stoppedComposites.put(key, dc);
     }
 
     public String getDomainName() {

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java?rev=1132533&r1=1132532&r2=1132533&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java
Mon Jun  6 06:34:15 2011
@@ -19,8 +19,13 @@
 
 package org.apache.tuscany.sca.impl;
 
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.List;
 
+import javax.xml.bind.JAXBElement;
+
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Component;
 import org.apache.tuscany.sca.assembly.ComponentReference;
@@ -42,6 +47,7 @@ import org.apache.tuscany.sca.interfaced
 import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
 import org.apache.tuscany.sca.runtime.DomainRegistry;
+import org.apache.tuscany.sca.runtime.ContributionDescription;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
@@ -89,6 +95,14 @@ public class ServiceHelper {
             new CompositeContext(extensionPointRegistry, domainRegistry, null, null, null,
                                  deployer.getSystemDefinitions());
 
+        if (serviceInterface == null) {
+            try {
+                serviceInterface = (Class<T>)findInterface(endpoint, domainRegistry);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+
         RuntimeEndpointReference epr;
         try {
             epr =
@@ -170,6 +184,8 @@ public class ServiceHelper {
             // The interface is not assignable from the interface contract
             interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
             JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(businessInterface);
+            callInterface.setRemotable(true);
+            callInterface.resetDataBinding(JAXBElement.class.getName());
             interfaceContract.setInterface(callInterface);
             if (callInterface.getCallbackClass() != null) {
                 interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(callInterface
@@ -179,4 +195,17 @@ public class ServiceHelper {
 
         return interfaceContract;
     }
+
+    private static Class<?> findInterface(Endpoint endpoint, DomainRegistry domainRegistry)
throws MalformedURLException, ClassNotFoundException {
+        Interface iface = endpoint.getService().getInterfaceContract().getInterface();
+        if (iface instanceof JavaInterface) {
+            String curi = domainRegistry.getContainingCompositesContributionURI(endpoint.getComponent().getName());
+            if (curi != null) {
+                ContributionDescription ic = domainRegistry.getInstalledContribution(curi);
+                ClassLoader cl = new URLClassLoader(new URL[]{new URL(ic.getURL())});
+                return cl.loadClass(((JavaInterface)iface).getName());
+            }
+        }
+        return null;
+    }
 }



Mime
View raw message