Author: slaws
Date: Fri Nov 30 07:38:42 2007
New Revision: 599850

URL: http://svn.apache.org/viewvc?rev=599850&view=rev
Log:
Remove restriction that only deployable composites can be deployed
Remove some duplicate code from the node implementation

Modified:
    
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java
    
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeModelImpl.java
    
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionModelImpl.java
    
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java
    
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelImpl.java
    
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeModelImpl.java
    
incubator/tuscany/java/sca/modules/domain-impl/src/main/resources/webroot/index.html
    
incubator/tuscany/java/sca/modules/domain-impl/src/test/java/org/apache/tuscany/sca/domain/impl/DomainImplTestCase.java
    
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/Calculator.composite
    
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml
    
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeB/Calculator.composite
    
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/ContributionModel.java
    
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/NodeModel.java
    
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/impl/SCADomainImpl.java
 Fri Nov 30 07:38:42 2007
@@ -100,7 +100,7 @@
     protected Contribution domainManagementContribution;
     protected Composite domainManagementComposite;
     
-    // the logice for wiring up references and services at the domain level
+    // the logic for wiring up references and services at the domain level
     protected DomainWireBuilderImpl domainWireBuilder = new 
DomainWireBuilderImpl();
     
     // Used to pipe dummy node information into the domain management runtime
@@ -279,9 +279,6 @@
             if ( domainModel.getContributions().containsKey(contributionURI) 
== false ){
                 contributionModel = parseContribution(contributionURI, 
contributionURL);
 
-                // add contribution to the domain
-                domainModel.getContributions().put(contributionURI, 
contributionModel);
-
                 // assign the contribution to the referenced node
                 NodeModel node = domainModel.getNodes().get(nodeURI);
                 
@@ -305,7 +302,7 @@
                 ContributionModel contributionModel = 
domainModel.getContributions().get(contributionURI);
                 
                 // remove deployed composites
-                for (QName compositeQName : 
contributionModel.getDeployableComposites().keySet()){
+                for (QName compositeQName : 
contributionModel.getDeployedComposites().keySet()){
                     domainModel.getDeployedComposites().remove(compositeQName);
                 }
                     
@@ -313,10 +310,15 @@
                 domainModel.getContributions().remove(contributionURI);
 
                 // remove the contribution from the referenced node
-                NodeModel node = domainModel.getNodes().get(nodeURI);
+                NodeModel nodeModel = domainModel.getNodes().get(nodeURI);
                 
-                if ((node != null)) {
-                    node.getContributions().remove(contributionURI);
+                if ((nodeModel != null)) {
+                    nodeModel.getContributions().remove(contributionURI);
+                    
+                    // remove deployed composites
+                    for (QName compositeQName : 
contributionModel.getDeployedComposites().keySet()){
+                        
nodeModel.getDeployedComposites().remove(compositeQName);
+                    }
                 } 
             }            
  
@@ -329,21 +331,24 @@
     
     public void registerDomainLevelComposite(String nodeURI, String 
compositeQNameString) throws DomainException{
         try {
-            // get the composite from the node
-            NodeModel node = domainModel.getNodes().get(nodeURI);
-            
             QName compositeQName = QName.valueOf(compositeQNameString);
             
-            if (node != null) {
-                for (ContributionModel contributionModel : 
node.getContributions().values()){
-                    CompositeModel compositeModel = 
contributionModel.getComposites().get(compositeQName);
-                    
-                    if (compositeModel != null){
-                        node.getDeployedComposites().put(compositeQName, 
compositeModel);
-                        
domainModel.getDeployedComposites().put(compositeQName, compositeModel);
+            if 
(!domainModel.getDeployedComposites().containsKey(compositeQName)){
+                // get the composite from the node
+                NodeModel node = domainModel.getNodes().get(nodeURI);
+                
+                if (node != null) {
+                    for (ContributionModel contributionModel : 
node.getContributions().values()){
+                        CompositeModel compositeModel = 
contributionModel.getComposites().get(compositeQName);
+                        
+                        if (compositeModel != null){
+                            
contributionModel.getDeployedComposites().put(compositeQName, compositeModel);
+                            node.getDeployedComposites().put(compositeQName, 
compositeModel);
+                            
domainModel.getDeployedComposites().put(compositeQName, compositeModel);
+                        }
                     }
-                }
-            }             
+                }   
+            }
         } catch (Exception ex) {
             logger.log(Level.SEVERE, "Exception when registering domain level 
composite " + 
                                      nodeURI +  " " +
@@ -401,7 +406,6 @@
         logger.log(Level.FINE, "Removed service: " +  serviceName );   
         
         notifyServiceChange(serviceName);
-        
     }
     
     private void notifyServiceChange(String serviceName) {
@@ -515,8 +519,7 @@
     
     public void destroy() throws DomainException {
         try {
-            // Stop and destroy all nodes
-            // this should unregister all nodes
+            // Stop and destroy all nodes. This should unregister all nodes
             
             //Get all nodes out of the domain. Destroying them will cause them 
to 
             //call back to the domain to unregister so we need to avoid 
concurrent updates
@@ -557,7 +560,7 @@
             factories.removeFactory(nodeFactory); 
             nodeFactory.setNode(null);
             
-            // Stop the node
+            // Stop the SCA runtime that the domain is using
             domainManagementRuntime.stop();
                         
         } catch(ActivationException ex) {
@@ -603,11 +606,18 @@
             //        are working quite right
             addContribution(contributionURI, contributionURL);
             
-            // automatically add the domain level composites back into the 
domain
-            // from the updated composite
-            ContributionModel contributionModel = 
domainModel.getContributions().get(contributionURI);
-            for (CompositeModel compositeModel : 
contributionModel.getDeployableComposites().values()){
-                addToDomainLevelComposite(compositeModel.getCompositeQName());
+            // add the deployed composites back into the domain if they still 
exist
+            // if they don't then the user will have to add and start any new 
composites manually
+            for (QName compositeQName : deployedCompositeNames) {
+                // make sure the composite still exists
+                CompositeModel compositeModel = findComposite(compositeQName);
+           
+                if (compositeModel != null){
+                    
addToDomainLevelComposite(compositeModel.getCompositeQName());
+                } else {
+                    // the composite has been removed from the contribution 
+                    // by the update
+                }
             }
             
             // automatically start all the composites
@@ -623,7 +633,7 @@
             // get the contribution model
             ContributionModel contributionModel = 
domainModel.getContributions().get(contributionURI);
             
-            // remove deployed composites
+            // remove potentially deployed composites
             for (QName compositeQName : 
contributionModel.getDeployableComposites().keySet()){
                 domainModel.getDeployedComposites().remove(compositeQName);
             }
@@ -654,6 +664,7 @@
                         }
                         
                         node.getContributions().clear();
+                        node.getDeployedComposites().clear();
                     } catch (Exception ex) {
                         // TODO - collate errors and report
                         ex.printStackTrace();
@@ -675,19 +686,22 @@
         // find this composite and add the composite as a deployed composite
         
         for (ContributionModel contribution : 
domainModel.getContributions().values()){
-            CompositeModel composite = 
contribution.getDeployableComposites().get(compositeName);
+            CompositeModel composite = 
contribution.getComposites().get(compositeName);
             if (composite != null) {
                 domainModel.getDeployedComposites().put(compositeName, 
composite);
             }
         }
     }
       
-    public void removeFromDomainLevelComposite(QName compositeName) throws 
DomainException {
+    public void removeFromDomainLevelComposite(QName compositeQName) throws 
DomainException {
 
-        domainModel.getDeployedComposites().remove(compositeName);
+        domainModel.getDeployedComposites().remove(compositeQName);
+        
+        ContributionModel contributionModel = 
findContributionFromComposite(compositeQName);
+        contributionModel.getDeployedComposites().remove(compositeQName);
         
         for(NodeModel node : domainModel.getNodes().values()) {
-            if ( node.getDeployedComposites().containsValue(compositeName)){
+            if ( node.getDeployedComposites().containsValue(compositeQName)){
                 try {
                     if (node.getIsRunning()) {
                         
((NodeModelImpl)node).getSCANodeManagerService().stop();
@@ -695,7 +709,7 @@
                     }
                     // TODO - how to remove it from the node???
                     
-                    node.getDeployedComposites().remove(compositeName);
+                    node.getDeployedComposites().remove(compositeQName);
                 } catch (Exception ex) {
                     // TODO - collate errors and report
                     ex.printStackTrace();
@@ -750,27 +764,21 @@
         return artifactString;
     }
       
-    public void startComposite(QName compositeName) throws DomainException {
+    public void startComposite(QName compositeQName) throws DomainException {
         
         // find the composite object from the list of deployed composites
-        CompositeModel compositeModel = 
domainModel.getDeployedComposites().get(compositeName);
+        CompositeModel compositeModel = 
domainModel.getDeployedComposites().get(compositeQName);
         
         if (compositeModel == null){
-            throw new DomainException("Can't start composite " + 
compositeName.toString() +
+            throw new DomainException("Can't start composite " + 
compositeQName.toString() +
                                       " as it hasn't been added to the domain 
level composite");
         }
         
-        ContributionModel contributionModel = null;
-        
         // find the contribution that has this composite
-        for (ContributionModel tmpContributionModel : 
domainModel.getContributions().values()){
-            if 
(tmpContributionModel.getDeployableComposites().containsKey(compositeName)){
-                contributionModel = tmpContributionModel;
-            }
-        }
+        ContributionModel contributionModel = 
findContributionFromComposite(compositeQName);
         
         if (contributionModel == null){
-            throw new DomainException("Can't find contribution for composite " 
+ compositeName.toString());
+            throw new DomainException("Can't find contribution for composite " 
+ compositeQName.toString());
         }
          
         List<Contribution> dependentContributions = new 
ArrayList<Contribution>();
@@ -788,13 +796,13 @@
                                                 
domainModel.getContributions().get(tmpContribution.getURI()));
                 }
                 
-                node.getDeployedComposites().put(compositeName, 
compositeModel);
+                node.getDeployedComposites().put(compositeQName, 
compositeModel);
                 break;
             }
         }      
         
         if (node == null){
-            throw new DomainException("No free node available to run composite 
"  + compositeName.toString());
+            throw new DomainException("No free node available to run composite 
"  + compositeQName.toString());
         }        
         
         try {
@@ -808,15 +816,12 @@
             }
     
             // deploy composite
-            
((NodeModelImpl)node).getSCANodeManagerService().addToDomainLevelComposite(compositeName.toString());
+            
((NodeModelImpl)node).getSCANodeManagerService().addToDomainLevelComposite(compositeQName.toString());
             
             // start node
             ((NodeModelImpl)node).getSCANodeManagerService().start();
             node.setIsRunning(true);
-            
-            // TODO
-            // somewhere we need to add the deployed composites into the node 
model 
-            
+                        
         } catch (Exception ex) {
             throw new DomainException(ex);
         }
@@ -847,6 +852,32 @@
         }     
     }
     
+    private ContributionModel findContributionFromComposite(QName 
compositeQName){
+        ContributionModel returnContributionModel = null;
+        
+        for(ContributionModel contributionModel : 
domainModel.getContributions().values()){            
+            if (contributionModel.getComposites().containsKey(compositeQName)){
+                returnContributionModel = contributionModel;
+            }
+        }
+        
+        return returnContributionModel;
+    }
+    
+    private CompositeModel findComposite(QName compositeQName){
+        CompositeModel returnCompositeModel = null;
+        
+        for(ContributionModel contributionModel : 
domainModel.getContributions().values()){
+            returnCompositeModel = 
contributionModel.getComposites().get(compositeQName);
+            
+            if (returnCompositeModel != null){
+                break;
+            }
+        }
+        
+        return returnCompositeModel;
+    }
+    
     // Recursively look for contributions that contain included artifacts. 
Deepest dependencies
     // appear first in the list
     // This function should be moved to the contribution package.
@@ -900,12 +931,21 @@
             // add the deployable composite info to the domain model 
             for (Composite composite : contribution.getDeployables()) {
                 CompositeModel compositeModel = 
contributionModel.getComposites().get(composite.getName());
-                
contributionModel.getDeployableComposites().put(compositeModel.getCompositeQName(),
 compositeModel);
+                
+                if (compositeModel != null){
+                    
contributionModel.getDeployableComposites().put(compositeModel.getCompositeQName(),
 compositeModel);
+                } else {
+                    throw new DomainException("Deployable composite name " + 
+                                              composite.getName() + 
+                                              " doesn't match a composite in 
the contribution " +
+                                              contributionURI );
+                }
                 
                 // build the contribution to create the services and references
                 domainManagementRuntime.getCompositeBuilder().build(composite);
             }
-            
+        } catch(DomainException ex) {   
+            throw ex;
         } catch(Exception ex) {
             throw new DomainException(ex);
         } 

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeModelImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeModelImpl.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeModelImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/CompositeModelImpl.java
 Fri Nov 30 07:38:42 2007
@@ -27,7 +27,7 @@
 
 
 /**
- * A composite. 
+ * A wrapper for the assembly model composite 
  * 
  * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) 
$
  */

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionModelImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionModelImpl.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionModelImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/ContributionModelImpl.java
 Fri Nov 30 07:38:42 2007
@@ -30,7 +30,7 @@
 import org.apache.tuscany.sca.domain.model.ContributionModel;
 
 /**
- * A contribution.
+ * A wrapper for the contribution 
  * 
  * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) 
$
  */
@@ -41,6 +41,7 @@
     private String contributionURL;
     private Map<QName, CompositeModel> composites = new HashMap<QName, 
CompositeModel>();   
     private Map<QName, CompositeModel> deployableComposites = new 
HashMap<QName, CompositeModel>();
+    private Map<QName, CompositeModel> deployedComposites = new HashMap<QName, 
CompositeModel>();
     
     /**
      * Retrieve the contribution object
@@ -102,5 +103,9 @@
     
     public Map<QName, CompositeModel> getDeployableComposites(){
         return deployableComposites;
-    }    
+    }
+    
+    public Map<QName, CompositeModel> getDeployedComposites(){
+        return deployedComposites;
+    }
 }

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelFactoryImpl.java
 Fri Nov 30 07:38:42 2007
@@ -27,7 +27,7 @@
 import org.apache.tuscany.sca.domain.model.ServiceModel;
 
 /**
- * A node. Runs SCA composites
+ * The factory used to create model elements
  * 
  * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) 
$
  */

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelImpl.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/DomainModelImpl.java
 Fri Nov 30 07:38:42 2007
@@ -31,7 +31,8 @@
 
 
 /**
- * A domain. Manages nodes
+ * A model of the domain and the artifacts that it managers. Acts as a holder 
for the 
+ * various other tuscany models involved
  * 
  * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) 
$
  */

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeModelImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeModelImpl.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeModelImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/main/java/org/apache/tuscany/sca/domain/model/impl/NodeModelImpl.java
 Fri Nov 30 07:38:42 2007
@@ -40,12 +40,13 @@
  */
 public class NodeModelImpl implements NodeModel {
     
+    private LifecyleState state = LifecyleState.AVAILABLE;
     private String nodeURI;
     private String nodeURL;
     private boolean isRunning = false;
     private Externalizable nodeManagerReference;
     private Map<String, ContributionModel> contributions = new HashMap<String, 
ContributionModel>();
-    private Map<QName, CompositeModel> composites = new HashMap<QName, 
CompositeModel>();
+    private Map<QName, CompositeModel> deployedComposites = new HashMap<QName, 
CompositeModel>();
     private Map<String, ServiceModel> services = new HashMap<String, 
ServiceModel>();
     
     /**
@@ -134,7 +135,7 @@
     }
     
     public Map<QName, CompositeModel> getDeployedComposites(){
-        return composites;
+        return deployedComposites;
     }
     
     public Map<String, ServiceModel> getServices(){

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/main/resources/webroot/index.html
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/main/resources/webroot/index.html?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/main/resources/webroot/index.html
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/main/resources/webroot/index.html
 Fri Nov 30 07:38:42 2007
@@ -24,7 +24,7 @@
        
     <script language="JavaScript">
     
-       domainManager = new 
JSONRpcClient("../DomainManagerComponent/DomainManagementService").Service;
+       domainManager = new 
JSONRpcClient("../SCADomainManagerComponent/SCADomainManagerService").Service;
        var domainInfo;
 
        function getDomainInfo() {
@@ -39,8 +39,8 @@
           
           text = text + "<H2>Nodes</H2>";
           
-          for (var i in domainInfo.nodes.list){
-              var nodeURI = domainInfo.nodes.list[i];
+          for (var i in domainInfo.nodes){
+              var nodeURI = domainInfo.nodes[i];
              
               text = text + "<table>";
               text = text + "<TR CLASS='source_1' >";           
@@ -55,8 +55,8 @@
           
          text = text + "<H2>Domain Contributions</H2>";
             
-         for (var i in domainInfo.contributions.list){
-              var contributionURI = domainInfo.contributions.list[i];
+         for (var i in domainInfo.contributions){
+              var contributionURI = domainInfo.contributions[i];
               text = text + "<table>";
               text = text + "<TR CLASS='source_1' >";
               text = text + "  <TD>";
@@ -68,8 +68,8 @@
 
          text = text + "<H2>Deployable Composites</H2>";
  
-         for (var i in domainInfo.deployedComposites.list){
-              var compositeQName = domainInfo.deployedComposites.list[i];
+         for (var i in domainInfo.deployedComposites){
+              var compositeQName = domainInfo.deployedComposites[i];
               text = text + "<table>";
               text = text + "<TR CLASS='source_1' >";
               text = text + "  <TD>";
@@ -92,8 +92,8 @@
           var text = "";
           
           
-          for (var i in nodeInfo.contributions.list){
-              var contributionURI = nodeInfo.contributions.list[i];
+          for (var i in nodeInfo.contributions){
+              var contributionURI = nodeInfo.contributions[i];
               
               text = text + "<TR CLASS='source_2' >";
               text = text + "  <TD/>";

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/test/java/org/apache/tuscany/sca/domain/impl/DomainImplTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/test/java/org/apache/tuscany/sca/domain/impl/DomainImplTestCase.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/test/java/org/apache/tuscany/sca/domain/impl/DomainImplTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/test/java/org/apache/tuscany/sca/domain/impl/DomainImplTestCase.java
 Fri Nov 30 07:38:42 2007
@@ -21,6 +21,8 @@
 import java.io.Externalizable;
 import java.net.URL;
 
+import javax.xml.namespace.QName;
+
 import org.apache.tuscany.sca.domain.SCADomain;
 import org.apache.tuscany.sca.domain.SCADomainEventService;
 import org.apache.tuscany.sca.domain.SCADomainFactory;
@@ -44,7 +46,7 @@
 public class DomainImplTestCase {
 
     private static SCADomain domain;
-    private static SCADomainEventService domainSPI;
+    private static SCADomainEventService domainEventService;
     private static ClassLoader cl;
 
     @BeforeClass
@@ -54,7 +56,7 @@
             cl = DomainImplTestCase.class.getClassLoader();
             SCADomainFactory domainFactory = SCADomainFactory.newInstance();
             domain = domainFactory.createSCADomain("http://localhost:9999";); 
-            domainSPI = (SCADomainEventService)domain;
+            domainEventService = (SCADomainEventService)domain;
 
         } catch (Exception e) {
             e.printStackTrace();
@@ -71,12 +73,12 @@
     }  
     
     @Test
-    public void testAddNode() throws Exception { 
+    public void testRegisterNodes() throws Exception { 
         CallableReference<SCANodeManagerService> node1Ref = new 
TestCallableReferenceImpl<SCANodeManagerService>();
-        domainSPI.registerNode("http://localhost:8100/mynode1";, 
"http://localhost:9999";, (Externalizable)node1Ref);
+        domainEventService.registerNode("http://localhost:8100/mynode1";, 
"http://localhost:9999";, (Externalizable)node1Ref);
         
         CallableReference<SCANodeManagerService> node2Ref = new 
TestCallableReferenceImpl<SCANodeManagerService>();
-        domainSPI.registerNode("http://localhost:8200/mynode2";, 
"http://localhost:9999";, (Externalizable)node2Ref);
+        domainEventService.registerNode("http://localhost:8200/mynode2";, 
"http://localhost:9999";, (Externalizable)node2Ref);
     }
     
     @Test
@@ -87,7 +89,18 @@
     @Test
     public void testAddContributionWithoutMetaData() throws Exception {    
         domain.addContribution("contributionNodeB", cl.getResource("nodeB/"));
-    }    
+    }  
+    
+    @Test
+    public void testAddToDomainLevelComposite() throws Exception {    
+        domain.addToDomainLevelComposite(new QName("http://sample";, 
"CalculatorA"));
+    } 
+    
+    @Test
+    public void testStartComposite() throws Exception {   
+        domain.startComposite(new QName("http://sample";, "CalculatorA"));
+    }
+    
     
     @Test
     public void testRemoveContributions() throws Exception { 
@@ -96,9 +109,9 @@
     }   
     
     @Test
-    public void testRemoveNodes() throws Exception { 
-        domainSPI.unregisterNode("http://localhost:8100/mynode1";);
-        domainSPI.unregisterNode("http://localhost:8200/mynode2";);
+    public void testUnregisterNodes() throws Exception { 
+        domainEventService.unregisterNode("http://localhost:8100/mynode1";);
+        domainEventService.unregisterNode("http://localhost:8200/mynode2";);
     }     
     
     //@Test

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/Calculator.composite
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/Calculator.composite?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/Calculator.composite
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/Calculator.composite
 Fri Nov 30 07:38:42 2007
@@ -20,7 +20,7 @@
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
            targetNamespace="http://sample";
            xmlns:sample="http://sample";
-           name="Calculator">
+           name="CalculatorA">
 
     <component name="CalculatorServiceComponentA">
                <implementation.java class="calculator.CalculatorServiceImpl"/>

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml
 Fri Nov 30 07:38:42 2007
@@ -20,5 +20,5 @@
 <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0";
              targetNamespace="http://sample";
               xmlns:sample="http://sample";>
-   <deployable composite="sample:Calculator"/>
+   <deployable composite="sample:CalculatorA"/>
 </contribution>

Modified: 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeB/Calculator.composite
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeB/Calculator.composite?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeB/Calculator.composite
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain-impl/src/test/resources/nodeB/Calculator.composite
 Fri Nov 30 07:38:42 2007
@@ -20,7 +20,7 @@
 <composite xmlns="http://www.osoa.org/xmlns/sca/1.0";
            targetNamespace="http://sample";
            xmlns:sample="http://sample";
-           name="Calculator">
+           name="CalculatorB">
 
     <component name="AddServiceComponentB">
         <implementation.java class="calculator.AddServiceImpl" />

Modified: 
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/ContributionModel.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/ContributionModel.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/ContributionModel.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/ContributionModel.java
 Fri Nov 30 07:38:42 2007
@@ -75,5 +75,6 @@
     public void setContributionURL(String contributionURL);
     
     public Map<QName, CompositeModel> getComposites();       
-    public Map<QName, CompositeModel> getDeployableComposites();   
+    public Map<QName, CompositeModel> getDeployableComposites(); 
+    public Map<QName, CompositeModel> getDeployedComposites(); 
 }

Modified: 
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/NodeModel.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/NodeModel.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/NodeModel.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/domain/src/main/java/org/apache/tuscany/sca/domain/model/NodeModel.java
 Fri Nov 30 07:38:42 2007
@@ -33,6 +33,7 @@
  * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) 
$
  */
 public interface NodeModel {
+    public enum LifecyleState {AVAILABLE, DEPLOYED, RUNNING, UNAVAILABLE }; 
     
     /**
      * Retrieve the node uri

Modified: 
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java?rev=599850&r1=599849&r2=599850&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java
 Fri Nov 30 07:38:42 2007
@@ -75,8 +75,9 @@
     // identity and endpoints for the node and the domain it belongs to
     private String nodeURI;
     private URL nodeURL;
+    private String logicalNodeURI;
     private String domainURI; 
-    private String nodeGroupURI;
+
 
     // The tuscany runtime that does the hard work
     private ReallySmallRuntime nodeRuntime;
@@ -113,10 +114,10 @@
      * group of nodes. For example, in load balancing scenarios this will be 
the loaded balancer itself 
      * @throws ActivationException
      */
-    public SCANodeImpl(String nodeURI, String domainURI, String nodeGroupURI) 
throws NodeException {
+    public SCANodeImpl(String physicalNodeURI, String domainURI, String 
logicalNodeURI) throws NodeException {
         this.domainURI = domainURI;
-        this.nodeURI = nodeURI;
-        this.nodeGroupURI = nodeGroupURI;
+        this.nodeURI = physicalNodeURI;
+        this.logicalNodeURI = logicalNodeURI;
         this.nodeClassLoader = Thread.currentThread().getContextClassLoader(); 
       
         init();
     }    
@@ -132,10 +133,10 @@
      * @param cl - the ClassLoader to use for loading system resources for the 
node
      * @throws ActivationException
      */
-    public SCANodeImpl(String nodeURI, String domainURI, String nodeGroupURI, 
ClassLoader cl) throws NodeException {
+    public SCANodeImpl(String physicalNodeURI, String domainURI, String 
logicalNodeURI, ClassLoader cl) throws NodeException {
         this.domainURI = domainURI;
         this.nodeURI = nodeURI;
-        this.nodeGroupURI = nodeGroupURI;
+        this.logicalNodeURI = logicalNodeURI;
         this.nodeClassLoader = cl;
         init();
     }    
@@ -450,40 +451,40 @@
         return deployable;
     }
     
-    public void addToDomainLevelComposite(QName compositeName) throws 
NodeException {
+    public void addToDomainLevelComposite(QName compositeQName) throws 
NodeException {
         
         if (nodeStarted){
-            throw new NodeException("Can't add composite " + 
compositeName.toString() + " when the node is running. Call stop() on the node 
first");
+            throw new NodeException("Can't add composite " + 
compositeQName.toString() + " when the node is running. Call stop() on the node 
first");
         }
        
         // if no composite name is specified add all deployable composites
         // to the domain
-        if (compositeName == null){
-            for (Contribution contribution : contributions.values()){
-                for (Composite composite : contribution.getDeployables()) {
-                    if (!nodeComposite.getIncludes().contains(composite)) {
-                        nodeComposite.getIncludes().add(composite);
-                        
-                        try {
-                            // register the composite with the domain
-                            
((SCADomainProxyImpl)scaDomain).registerDomainLevelComposite(nodeURI, 
composite.getName().toString());                  
-                        
-                        } catch (Exception ex) {
-                            throw new NodeException(ex);
-                        }                        
-                    }
-                } 
-            }
+        if (compositeQName == null){
+            for (Composite composite : composites.values()) {
+                if (!nodeComposite.getIncludes().contains(composite)) {
+                    nodeComposite.getIncludes().add(composite);
+                    
+                    try {
+                        // register the composite with the domain
+                        
((SCADomainProxyImpl)scaDomain).registerDomainLevelComposite(nodeURI, 
composite.getName().toString());                  
+                    
+                    } catch (Exception ex) {
+                        throw new NodeException(ex);
+                    }                        
+                }
+            } 
         } else {          
-            Composite composite = composites.get(compositeName);
+            Composite composite = composites.get(compositeQName);
             
             if (composite == null) {
-                throw new NodeException("Composite " + 
compositeName.toString() + " not found" );
+                throw new NodeException("Composite " + 
compositeQName.toString() + " not found" );
             }
             
+            /* being marked as deployable is only an indicator and shouldn;t 
be enforced             
             if ( !isDeployable(composite)){
-                throw new NodeException("Composite " + 
compositeName.toString() + " is not deployable");
+                throw new NodeException("Composite " + 
compositeQName.toString() + " is not deployable");
             }
+            */
             
             // if the named composite is not already in the list then deploy it
             if (!nodeComposite.getIncludes().contains(composite)) {
@@ -498,15 +499,9 @@
                 }                 
             }
         }  
-        
-        
     }
     
     public void addToDomainLevelComposite(String compositePath) throws 
NodeException {
-        
-        if (nodeStarted){
-            throw new NodeException("Can't add composite " + compositePath + " 
when the node is running. Call stop() on the node first");
-        }
        
         if (compositePath == null){
             throw new NodeException("Composite path cannot be null");
@@ -514,26 +509,7 @@
                  
         Composite composite = compositeFiles.get(compositePath);
         
-        if (composite == null) {
-            throw new NodeException("Composite file " + compositePath + " not 
found");
-        }     
-      
-        if ( !isDeployable(composite)){
-            throw new NodeException("Composite " + compositePath + " is not 
deployable");
-        }            
-        
-        // if the named composite is not already in the list then deploy it
-        if (!nodeComposite.getIncludes().contains(composite)) {
-            nodeComposite.getIncludes().add(composite);
-            
-            try {
-                // register the composite with the domain
-                
((SCADomainProxyImpl)scaDomain).registerDomainLevelComposite(nodeURI, 
composite.getName().toString());                  
-            
-            } catch (Exception ex) {
-                throw new NodeException(ex);
-            }             
-        }
+        addToDomainLevelComposite(composite.getName());
     }
 
     /**
@@ -545,7 +521,7 @@
      * without URIs 
      */    
     private void configureDefaultPort() {
-        Composite composite = 
composites.get(nodeComposite.getIncludes().get(0));
+        Composite composite = nodeComposite.getIncludes().get(1);
         if (composite == null) {
             return;
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to