Author: antelder
Date: Tue Jun 14 08:57:19 2011
New Revision: 1135417

URL: http://svn.apache.org/viewvc?rev=1135417&view=rev
Log:
Update to support using a node.xml config file in the domain directory

Added:
    
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/
    
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml
Modified:
    
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java
    
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java

Modified: 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java?rev=1135417&r1=1135416&r2=1135417&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java
 Tue Jun 14 08:57:19 2011
@@ -163,7 +163,9 @@ public class TuscanyRuntime {
     
     /*
      * Create a node from a file system directory. 
-     * The directory can contain:
+     * If the directory is actually a file use createNodeFromXML
+     * if the directory contains a file named node.xml then use 
createNodeFromXML
+     * Otherwise, the directory can contain:
      *  domain.properties 
      *  contributions - jar, zip, or exploded directories
      *  sca-contribution.xml metaData files to override whats in a contribution
@@ -173,6 +175,15 @@ public class TuscanyRuntime {
      */
     public Node createNode(File directory) throws ContributionReadException, 
ValidationException, ActivationException, XMLStreamException, IOException {
         
+        if (!directory.isDirectory()) {
+            return createNodeFromXML(directory.toURI().toURL().toString());
+        }
+        
+        File nodeXML = new File(directory, "node.xml");
+        if (nodeXML.exists()) {
+            return createNodeFromXML(nodeXML.toURI().toURL().toString());
+        }
+        
         Properties domainProps = new Properties();
         File propsFile = new File(directory, "domain.properties");
         if (propsFile.exists()) {

Modified: 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java?rev=1135417&r1=1135416&r2=1135417&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java
 Tue Jun 14 08:57:19 2011
@@ -69,4 +69,27 @@ public class DirectoryDomainTestCase {
         Assert.assertEquals("sample", ic.getJavaExports().get(0));
     }
 
+    @Test
+    public void testNodeXMLFile() throws ContributionReadException, 
ActivationException, ValidationException, XMLStreamException, IOException {
+        Node node = TuscanyRuntime.newInstance().createNode(new 
File("src/test/resources/helloworldNode.xml"));
+        Assert.assertEquals("helloworld", node.getDomainName());
+        List<String> cs = node.getInstalledContributionURIs();
+        Assert.assertEquals(1, cs.size());
+        Assert.assertEquals("sample-helloworld", cs.get(0));
+        Map<String, List<String>> startedComposites = 
node.getStartedCompositeURIs();
+        Assert.assertEquals(1, startedComposites.size());
+        Assert.assertEquals("helloworld.composite", 
startedComposites.get("sample-helloworld").get(0));
+    }
+
+    @Test
+    public void testNodeXMLDomain() throws ContributionReadException, 
ActivationException, ValidationException, XMLStreamException, IOException {
+        Node node = TuscanyRuntime.newInstance().createNode(new 
File("src/test/resources/test-domains/NodeXMLDomain"));
+        Assert.assertEquals("helloworld", node.getDomainName());
+        List<String> cs = node.getInstalledContributionURIs();
+        Assert.assertEquals(1, cs.size());
+        Assert.assertEquals("sample-helloworld", cs.get(0));
+        Map<String, List<String>> startedComposites = 
node.getStartedCompositeURIs();
+        Assert.assertEquals(1, startedComposites.size());
+        Assert.assertEquals("helloworld.composite", 
startedComposites.get("sample-helloworld").get(0));
+    }
 }

Added: 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml?rev=1135417&view=auto
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml
 (added)
+++ 
tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml
 Tue Jun 14 08:57:19 2011
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * Licensed to the Apache Software Foundation (ASF) under one
+    * or more contributor license agreements.  See the NOTICE file
+    * distributed with this work for additional information
+    * regarding copyright ownership.  The ASF licenses this file
+    * to you under the Apache License, Version 2.0 (the
+    * "License"); you may not use this file except in compliance
+    * with the License.  You may obtain a copy of the License at
+    *
+    *   http://www.apache.org/licenses/LICENSE-2.0
+    *
+    * Unless required by applicable law or agreed to in writing,
+    * software distributed under the License is distributed on an
+    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    * KIND, either express or implied.  See the License for the
+    * specific language governing permissions and limitations
+    * under the License.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912";
+    xmlns="http://tuscany.apache.org/xmlns/sca/1.1";
+    xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1";
+    domain="helloworld">
+
+    <contribution location="../../sample-helloworld.jar" 
startDeployables="true" />
+
+</node>
\ No newline at end of file


Reply via email to