Author: rfeng
Date: Thu May 14 18:00:05 2009
New Revision: 774854

URL: http://svn.apache.org/viewvc?rev=774854&view=rev
Log:
Start to integrate the node configuration with NodeImpl

Modified:
    
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java
    
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
    
tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
    
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
    
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
    
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
    
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
    
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java

Modified: 
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java
 Thu May 14 18:00:05 2009
@@ -6,15 +6,15 @@
  * 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.    
+ * under the License.
  */
 
 package org.apache.tuscany.sca.implementation.node.launcher;
@@ -28,7 +28,7 @@
 
 /**
  * Bootstrap class for the SCA node daemon.
- *  
+ *
  * @version $Rev$ $Date$
  */
 public class NodeImplementationDaemonBootstrap {
@@ -41,12 +41,12 @@
         private ClassLoader threadContextClassLoader;
         private ClassLoader runtimeClassLoader;
         private Node daemon;
-        
+
         private NodeFacade() {
             runtimeClassLoader = 
Thread.currentThread().getContextClassLoader();
         }
-        
-        public void start() {
+
+        public Node start() {
             threadContextClassLoader = 
Thread.currentThread().getContextClassLoader();
             boolean started = false;
             try {
@@ -55,13 +55,14 @@
                 String contribution = 
ContributionLocationHelper.getContributionLocation(getClass());
                 daemon = factory.createNode("NodeDaemon.composite", new 
Contribution("node-runtime", contribution));
                 started = true;
+                return this;
             } finally {
                 if (!started) {
                     
Thread.currentThread().setContextClassLoader(threadContextClassLoader);
                 }
             }
         }
-        
+
         public void stop() {
             try {
                 
Thread.currentThread().setContextClassLoader(runtimeClassLoader);
@@ -92,14 +93,14 @@
             throw new UnsupportedOperationException();
         }
     }
-    
+
     /**
      * Constructs a new daemon bootstrap.
      */
     public NodeImplementationDaemonBootstrap() throws Exception {
         node = new NodeFacade();
     }
-    
+
     /**
      * Returns the node representing the daemon.
      * @return

Modified: 
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
 Thu May 14 18:00:05 2009
@@ -6,15 +6,15 @@
  * 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.    
+ * under the License.
  */
 
 package org.apache.tuscany.sca.implementation.node.launcher;
@@ -28,7 +28,7 @@
 
 /**
  * Bootstrap class for standalone SCA nodes.
- *  
+ *
  * @version $Rev$ $Date$
  */
 public class NodeImplementationLauncherBootstrap {
@@ -42,26 +42,27 @@
         private ClassLoader threadContextClassLoader;
         private ClassLoader runtimeClassLoader;
         private Node delegate;
-        
+
         private NodeFacade(Node delegate) {
             runtimeClassLoader = 
Thread.currentThread().getContextClassLoader();
             this.delegate = delegate;
         }
-        
-        public void start() {
+
+        public Node start() {
             threadContextClassLoader = 
Thread.currentThread().getContextClassLoader();
             boolean started = false;
             try {
                 
Thread.currentThread().setContextClassLoader(runtimeClassLoader);
                 delegate.start();
                 started = true;
+                return this;
             } finally {
                 if (!started) {
                     
Thread.currentThread().setContextClassLoader(threadContextClassLoader);
                 }
             }
         }
-        
+
         public void stop() {
             try {
                 
Thread.currentThread().setContextClassLoader(runtimeClassLoader);
@@ -92,10 +93,10 @@
             return 
(ServiceReference<B>)((Client)delegate).getServiceReference(businessInterface, 
referenceName);
         }
     }
-    
+
     /**
      * Bootstrap a new SCA node.
-     * 
+     *
      * @param configurationURI
      */
     public NodeImplementationLauncherBootstrap(String configurationURI) throws 
Exception {
@@ -105,7 +106,7 @@
 
     /**
      * Bootstrap a new SCA node.
-     * 
+     *
      * @param compositeURI
      * @param uris
      * @param locations
@@ -121,7 +122,7 @@
 
     /**
      * Bootstrap a new SCA node.
-     * 
+     *
      * @param compositeURI
      * @param uris
      * @param locations
@@ -137,7 +138,7 @@
 
     /**
      * Returns the SCA node.
-     * 
+     *
      * @return
      */
     public Node getNode() {

Modified: 
tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
 (original)
+++ 
tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
 Thu May 14 18:00:05 2009
@@ -6,15 +6,15 @@
  * 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.    
+ * under the License.
  */
 
 package org.apache.tuscany.sca.interfacedef.impl;
@@ -208,6 +208,14 @@
             }
         }
 
+        if (source.getCallbackInterface().isConversational() != 
target.getCallbackInterface().isConversational()) {
+            if (!silent) {
+                throw new IncompatibleInterfaceContractException("Interaction 
scopes do not match", source, target);
+            } else {
+                return false;
+            }
+        }
+
         for (Operation operation : 
source.getCallbackInterface().getOperations()) {
             Operation targetOperation =
                 getOperation(target.getCallbackInterface().getOperations(), 
operation.getName());

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
 Thu May 14 18:00:05 2009
@@ -6,15 +6,15 @@
  * 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.    
+ * under the License.
  */
 
 package org.apache.tuscany.sca.node;
@@ -31,14 +31,15 @@
 
     /**
      * Start the composite loaded in the node.
+     * @return Return the node itself so that we can call 
NodeFactory.newInstance().createNode(...).start()
      */
-    void start();
+    Node start();
 
     /**
      * Stop the composite loaded in the node.
      */
     void stop();
-    
+
     /**
      * Destroy the node.
      */

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
 Thu May 14 18:00:05 2009
@@ -6,21 +6,24 @@
  * 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.    
+ * under the License.
  */
 
 package org.apache.tuscany.sca.node;
 
+import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 
+import 
org.apache.tuscany.sca.node.configuration.DefaultNodeConfigurationFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
 import org.oasisopen.sca.CallableReference;
 import org.oasisopen.sca.ServiceReference;
 import org.oasisopen.sca.ServiceRuntimeException;
@@ -28,10 +31,16 @@
 /**
  * A factory for SCA processing nodes. An SCA processing node can be loaded
  * with an SCA composite and the SCA contributions required by the composite.
- * 
+ *
  * @version $Rev$ $Date$
  */
-public abstract class NodeFactory {
+public abstract class NodeFactory extends DefaultNodeConfigurationFactory {
+
+    protected static NodeFactory nodeFactory;
+
+    protected static void setNodeFactory(NodeFactory factory) {
+        nodeFactory = factory;
+    }
 
     public static class NodeProxy implements Node, Client {
         private Object node;
@@ -79,11 +88,12 @@
             }
         }
 
-        public void start() {
+        public Node start() {
             try {
-                node.getClass().getMethod("start").invoke(node);
+                return new 
NodeProxy(node.getClass().getMethod("start").invoke(node));
             } catch (Throwable e) {
                 handleException(e);
+                return null;
             }
         }
 
@@ -121,10 +131,14 @@
 
     /**
      * Returns a new SCA node factory instance.
-     *  
+     *
      * @return a new SCA node factory
      */
     public static NodeFactory newInstance() {
+        if (nodeFactory != null) {
+            return nodeFactory;
+        }
+
         NodeFactory scaNodeFactory = null;
 
         try {
@@ -133,14 +147,18 @@
             try {
                 Class<?> discoveryClass = 
Class.forName("org.apache.tuscany.sca.extensibility.ServiceDiscovery");
                 Object instance = 
discoveryClass.getMethod("getInstance").invoke(null);
-                Object factoryDeclaration = 
discoveryClass.getMethod("getFirstServiceDeclaration", 
String.class).invoke(instance, NodeFactory.class.getName());
+                Object factoryDeclaration =
+                    discoveryClass.getMethod("getFirstServiceDeclaration", 
String.class).invoke(instance,
+                                                                               
                 NodeFactory.class
+                                                                               
                     .getName());
                 if (factoryDeclaration != null) {
-                    Class<?> factoryImplClass = 
(Class<?>)factoryDeclaration.getClass().getMethod("loadClass").invoke(factoryDeclaration);
+                    Class<?> factoryImplClass =
+                        
(Class<?>)factoryDeclaration.getClass().getMethod("loadClass").invoke(factoryDeclaration);
                     scaNodeFactory = 
(NodeFactory)factoryImplClass.newInstance();
                     return scaNodeFactory;
                 }
             } catch (ClassNotFoundException e) {
-                // Ignore 
+                // Ignore
             }
 
             // Fail back to default impl
@@ -157,43 +175,63 @@
 
     /**
      * Creates a new SCA node using defaults for the contribution location and 
runnable composite
-     * 
+     *
      * @return a new SCA node.
      */
     public abstract Node createNode();
 
     /**
      * Creates a new SCA node from the configuration URL
-     * 
+     *
      * @param configurationURL the URL of the node configuration which is the 
ATOM feed
      * that contains the URI of the composite and a collection of URLs for the 
contributions
-     *  
+     *
      * @return a new SCA node.
      */
     public abstract Node createNode(String configurationURL);
 
     /**
      * Creates a new SCA node.
-     * 
-     * @param compositeURI the URI of the composite to use 
-     * @param contributions the URI of the contributions that provides the 
composites and related 
+     *
+     * @param compositeURI the URI of the composite to use
+     * @param contributions the URI of the contributions that provides the 
composites and related
      * artifacts. If the list is empty, then we will use the thread context 
classloader to discover
      * the contribution on the classpath
-     *   
+     *
      * @return a new SCA node.
      */
     public abstract Node createNode(String compositeURI, Contribution... 
contributions);
 
     /**
      * Creates a new SCA node.
-     * 
-     * @param compositeURI the URI of the composite to use 
-     * @param compositeContent the XML content of the composite to use 
-     * @param contributions the URI of the contributions that provides the 
composites and related artifacts 
+     *
+     * @param compositeURI the URI of the composite to use
+     * @param compositeContent the XML content of the composite to use
+     * @param contributions the URI of the contributions that provides the 
composites and related artifacts
      * @return a new SCA node.
      */
-    public abstract Node createNode(String compositeURI,
-                                          String compositeContent,
-                                          Contribution... contributions);
+    public abstract Node createNode(String compositeURI, String 
compositeContent, Contribution... contributions);
+
+    /**
+     * Create a new SCA node based on the configuration
+     * @param configuration
+     * @return
+     */
+    public abstract Node createNode(NodeConfiguration configuration);
 
+    /**
+     * Create the node configuration from the XML document
+     * @param configuration The input stream of the XML document
+     * @return The node configuration
+     */
+    public abstract NodeConfiguration loadConfiguration(InputStream xml);
+
+    public static void main(String args[]) {
+        NodeFactory factory = NodeFactory.newInstance();
+        NodeConfiguration nodeConfiguration =
+            
factory.createNodeConfiguration().setDomainURI("http://d1";).setURI("http://node1";)
+                .addContribution("http://c1";, "file:/a.jar");
+        Node node = factory.createNode(nodeConfiguration).start();
+
+    }
 }

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
 Thu May 14 18:00:05 2009
@@ -28,16 +28,16 @@
  */
 public interface BindingConfiguration {
     /**
-     * Get the QName of the binding
-     * @return
+     * Get the QName of the binding type
+     * @return the QName of the binding type
      */
     QName getBindingType();
 
     /**
      * Set the type of the binding
-     * @param type
+     * @param type The QName of the binding type
      */
-    void setBindingType(QName type);
+    BindingConfiguration setBindingType(QName type);
 
     /**
      * Get a list of base URIs for the binding. For each protocol supported by 
the binding,
@@ -45,4 +45,11 @@
      * @return A list of base URIs
      */
     List<String> getBaseURIs();
+
+    /**
+     * Add a base URI
+     * @param baseURI
+     * @return
+     */
+    BindingConfiguration addBaseURI(String baseURI);
 }

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
 Thu May 14 18:00:05 2009
@@ -19,6 +19,10 @@
 
 package org.apache.tuscany.sca.node.configuration;
 
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URL;
 import java.util.List;
 
 /**
@@ -35,7 +39,7 @@
      * Set the URI of the contribution
      * @param uri The URI of the contribution
      */
-    void setURI(String uri);
+    ContributionConfiguration setURI(String uri);
 
     /**
      * Get the location of the contribution
@@ -47,11 +51,52 @@
      * Set the location of the contribution
      * @param location The location of the contribution
      */
-    void setLocation(String location);
+    ContributionConfiguration setLocation(String location);
 
     /**
      * Get the list of deployment composites that are attached to the 
contribution
-     * @return
+     * @return A list of deployment composites
      */
     List<DeploymentComposite> getDeploymentComposites();
+
+    /**
+     * Add a deployment composite to this contribution
+     * @param deploymentComposite The deployment composite
+     * @return
+     */
+    ContributionConfiguration addDeploymentComposite(DeploymentComposite 
deploymentComposite);
+
+    /**
+     * Create a deployment composite and add it to the contribution 
configuration
+     * @param location The location is either relative to the contribution or
+     * @return
+     */
+    ContributionConfiguration addDeploymentComposite(URI location);
+
+    /**
+     * Attach a deployment composite to this contribution
+     * @param location
+     * @return
+     */
+    ContributionConfiguration addDeploymentComposite(URL location);
+
+    /**
+     * Attach a deployment composite to this contribution
+     * @param content The string that contains the XML description of the SCA 
composite
+     * @return
+     */
+    ContributionConfiguration addDeploymentComposite(String content);
+
+    /**
+     * Attach a deployment composite to this contribution
+     * @param content The XML description of the SCA composite from a reader
+     * @return
+     */
+    ContributionConfiguration addDeploymentComposite(Reader content);
+    /**
+     * Attach a deployment composite to this contribution
+     * @param content The XML description of the SCA composite from an input 
stream
+     * @return
+     */
+    ContributionConfiguration addDeploymentComposite(InputStream content);
 }

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
 Thu May 14 18:00:05 2009
@@ -35,7 +35,7 @@
      * Set the location of the deployment composite
      * @param location
      */
-    void setLocation(String location);
+    DeploymentComposite setLocation(String location);
 
     /**
      * Get string content of the deployment composite (XML)
@@ -47,7 +47,7 @@
      * Set the XML content for the composite
      * @param compositeXML
      */
-    void setContent(String compositeXML);
+    DeploymentComposite setContent(String compositeXML);
 
     /**
      * Get the URI of the contribution that the deployment composite is 
attached to
@@ -59,6 +59,6 @@
      * Set the URI of the contribution that the deployment composite is 
attached to
      * @param contributionURI
      */
-    void setContributionURI(String contributionURI);
+    DeploymentComposite setContributionURI(String contributionURI);
 
 }

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
 Thu May 14 18:00:05 2009
@@ -19,8 +19,14 @@
 
 package org.apache.tuscany.sca.node.configuration;
 
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URL;
 import java.util.List;
 
+import javax.xml.namespace.QName;
+
 /**
  * The configuration for a Node which represents the deployment of an SCA 
composite application
  */
@@ -35,7 +41,7 @@
      * Set the URI of the SCA domain
      * @param domainURI The URI of the SCA domain
      */
-    void setDomainURI(String domainURI);
+    NodeConfiguration setDomainURI(String domainURI);
 
     /**
      * Get the URI of the node. It uniquely identifies a node within the SCA 
domain
@@ -47,7 +53,7 @@
      * Set the URI of the node
      * @param uri The URI of the node
      */
-    void setURI(String uri);
+    NodeConfiguration setURI(String uri);
 
     /**
      * Get a list of confiurations for SCA contributions
@@ -60,4 +66,18 @@
      * @return A list of configurations for SCA bindings
      */
     List<BindingConfiguration> getBindings();
+
+    NodeConfiguration addContribution(ContributionConfiguration contribution);
+    NodeConfiguration addContribution(String contributionURI, String location);
+    NodeConfiguration addContribution(String contributionURI, URL location);
+    NodeConfiguration addContribution(URI contributionURI, URL location);
+    NodeConfiguration addContribution(URL...location);
+
+    NodeConfiguration addDeploymentComposite(String contributionURI, String 
location);
+    NodeConfiguration addDeploymentComposite(String contributionURI, Reader 
content);
+    NodeConfiguration addDeploymentComposite(String contributionURI, 
InputStream content);
+
+    NodeConfiguration addBinding(BindingConfiguration binding);
+    NodeConfiguration addBinding(QName bindingType, String...baseURIs);
+    NodeConfiguration addBinding(QName bindingType, URI...baseURIs);
 }

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
 Thu May 14 18:00:05 2009
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.node.configuration;
 
+
 /**
  * The factory to create java models related to the node configuration
  */

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
 Thu May 14 18:00:05 2009
@@ -41,8 +41,14 @@
         return type;
     }
 
-    public void setBindingType(QName type) {
+    public BindingConfiguration setBindingType(QName type) {
         this.type = type;
+        return this;
+    }
+
+    public BindingConfiguration addBaseURI(String baseURI) {
+        baseURIs.add(baseURI);
+        return this;
     }
 
 }

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
 Thu May 14 18:00:05 2009
@@ -19,6 +19,13 @@
 
 package org.apache.tuscany.sca.node.configuration.impl;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -33,6 +40,21 @@
     private String uri;
     private String location;
 
+    public ContributionConfigurationImpl() {
+        super();
+    }
+
+    public ContributionConfigurationImpl(String uri, String location) {
+        super();
+        this.uri = uri;
+        this.location = location;
+    }
+
+    public ContributionConfigurationImpl(String location) {
+        super();
+        this.uri = location;
+        this.location = location;
+    }
 
     /**
      * Get the URI of the contribution
@@ -46,8 +68,9 @@
      * Set the URI of the contribution
      * @param uri The URI of the contribution
      */
-    public void setURI(String uri) {
+    public ContributionConfiguration setURI(String uri) {
         this.uri = uri;
+        return this;
     }
 
     /**
@@ -62,8 +85,9 @@
      * Set the location of the contribution
      * @param location The location of the contribution
      */
-    public void setLocation(String location) {
+    public ContributionConfiguration setLocation(String location) {
         this.location = location;
+        return this;
     }
 
     /**
@@ -73,4 +97,59 @@
     public List<DeploymentComposite> getDeploymentComposites() {
         return deploymentComposites;
     }
+
+    public ContributionConfiguration 
addDeploymentComposite(DeploymentComposite deploymentComposite) {
+        deploymentComposites.add(deploymentComposite);
+        if (uri != null) {
+            deploymentComposite.setContributionURI(uri);
+        }
+        return this;
+    }
+
+    public ContributionConfiguration addDeploymentComposite(Reader reader) {
+        try {
+            DeploymentComposite composite = new DeploymentCompositeImpl();
+            char[] buf = new char[8192];
+            StringWriter sw = new StringWriter();
+            int size = 0;
+            while (size >= 0) {
+                size = reader.read(buf);
+                if (size > 0) {
+                    sw.write(buf, 0, size);
+                }
+            }
+            reader.close();
+            composite.setContent(sw.toString());
+            return addDeploymentComposite(composite);
+        } catch (IOException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    public ContributionConfiguration addDeploymentComposite(InputStream 
content) {
+        try {
+            InputStreamReader reader = new InputStreamReader(content, "UTF-8");
+            return addDeploymentComposite(reader);
+        } catch (IOException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    public ContributionConfiguration addDeploymentComposite(String content) {
+        DeploymentComposite composite = new DeploymentCompositeImpl();
+        composite.setContent(content);
+        return addDeploymentComposite(composite);
+    }
+
+    public ContributionConfiguration addDeploymentComposite(URI location) {
+        DeploymentComposite composite = new DeploymentCompositeImpl();
+        composite.setLocation(location.toString());
+        return addDeploymentComposite(composite);
+    }
+
+    public ContributionConfiguration addDeploymentComposite(URL location) {
+        DeploymentComposite composite = new DeploymentCompositeImpl();
+        composite.setLocation(location.toString());
+        return addDeploymentComposite(composite);
+    }
 }

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
 Thu May 14 18:00:05 2009
@@ -33,24 +33,27 @@
         return location;
     }
 
-    public void setLocation(String location) {
+    public DeploymentComposite setLocation(String location) {
         this.location = location;
+        return this;
     }
 
     public String getContent() {
         return content;
     }
 
-    public void setContent(String content) {
+    public DeploymentComposite setContent(String content) {
         this.content = content;
+        return this;
     }
 
     public String getContributionURI() {
         return contributionURI;
     }
 
-    public void setContributionURI(String contributionURI) {
+    public DeploymentComposite setContributionURI(String contributionURI) {
         this.contributionURI = contributionURI;
+        return this;
     }
 
 }

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
 Thu May 14 18:00:05 2009
@@ -22,6 +22,7 @@
 import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
 import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
 import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
 import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
 
 /**
@@ -32,7 +33,7 @@
      * Create a new instance of NodeConfiguration
      * @return
      */
-    public NodeConfigurationImpl createNodeConfiguration() {
+    public NodeConfiguration createNodeConfiguration() {
         return new NodeConfigurationImpl();
     }
 

Modified: 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
 (original)
+++ 
tuscany/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
 Thu May 14 18:00:05 2009
@@ -19,9 +19,15 @@
 
 package org.apache.tuscany.sca.node.configuration.impl;
 
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.namespace.QName;
+
 import org.apache.tuscany.sca.node.configuration.BindingConfiguration;
 import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
 import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
@@ -39,16 +45,18 @@
         return uri;
     }
 
-    public void setURI(String uri) {
+    public NodeConfiguration setURI(String uri) {
         this.uri = uri;
+        return this;
     }
 
     public String getDomainURI() {
         return domainURI;
     }
 
-    public void setDomainURI(String domainURI) {
+    public NodeConfiguration setDomainURI(String domainURI) {
         this.domainURI = domainURI;
+        return this;
     }
 
     public List<ContributionConfiguration> getContributions() {
@@ -59,5 +67,68 @@
         return bindings;
     }
 
+    public NodeConfiguration addBinding(BindingConfiguration 
bindingConfiguration) {
+        bindings.add(bindingConfiguration);
+        return this;
+    }
+
+    public NodeConfiguration addContribution(ContributionConfiguration 
contributionConfiguration) {
+        contributions.add(contributionConfiguration);
+        return this;
+    }
+
+    public NodeConfiguration addBinding(QName bindingType, String... baseURIs) 
{
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeConfiguration addBinding(QName bindingType, URI... baseURIs) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeConfiguration addContribution(String contributionURI, String 
location) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeConfiguration addContribution(String contributionURI, URL 
location) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeConfiguration addContribution(URI contributionURI, URL 
location) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeConfiguration addContribution(URL... location) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public NodeConfiguration addDeploymentComposite(String contributionURI, 
InputStream content) {
+        findContribution(contributionURI).addDeploymentComposite(content);
+        return this;
+    }
+
+    public NodeConfiguration addDeploymentComposite(String contributionURI, 
Reader content) {
+        findContribution(contributionURI).addDeploymentComposite(content);
+        return this;
+    }
+
+    public NodeConfiguration addDeploymentComposite(String contributionURI, 
String location) {
+        
findContribution(contributionURI).addDeploymentComposite(URI.create(location));
+        return this;
+    }
+
+    private ContributionConfiguration findContribution(String uri) {
+        for (ContributionConfiguration c : contributions) {
+            if (c.getURI() != null && c.getURI().equals(uri)) {
+                return c;
+            }
+        }
+        throw new IllegalArgumentException("Contribution is not found (uri=" + 
uri + ")");
+    }
 
 }

Modified: 
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
 (original)
+++ 
tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
 Thu May 14 18:00:05 2009
@@ -308,7 +308,7 @@
         for(Definitions defs: definitionsExtensionPoint.getDefinitions()) {
             DefinitionsUtil.aggregate(systemDefinitions, defs);
         }
-        
+
         DefinitionsProviderExtensionPoint definitionsProviders =
             
extensionPoints.getExtensionPoint(DefinitionsProviderExtensionPoint.class);
 
@@ -578,7 +578,7 @@
             }
         }
 
-        public void start() {
+        public Node start() {
             logger.log(Level.INFO, "Starting node: " + 
bundle.getSymbolicName());
 
             try {
@@ -590,6 +590,8 @@
                 // Start the composite
                 compositeActivator.start(composite);
 
+                return this;
+
             } catch (ActivationException e) {
                 throw new IllegalStateException(e);
             }

Modified: 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
 (original)
+++ 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
 Thu May 14 18:00:05 2009
@@ -76,6 +76,15 @@
         this.xmlOutputFactory = 
modelFactories.getFactory(XMLOutputFactory.class);
     }
 
+    public NodeConfigurationProcessor(NodeConfigurationFactory 
nodeConfigurationFactory,
+                                      XMLInputFactory xmlInputFactory,
+                                      XMLOutputFactory xmlOutputFactory) {
+        super();
+        this.nodeConfigurationFactory = nodeConfigurationFactory;
+        this.xmlInputFactory = xmlInputFactory;
+        this.xmlOutputFactory = xmlOutputFactory;
+    }
+
     public QName getArtifactType() {
         // Returns the QName of the XML element processed by this processor
         return NODE;

Modified: 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
 (original)
+++ 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
 Thu May 14 18:00:05 2009
@@ -6,37 +6,46 @@
  * 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.    
+ * under the License.
  */
 
 package org.apache.tuscany.sca.node.impl;
 
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
 import org.apache.tuscany.sca.node.Contribution;
 import org.apache.tuscany.sca.node.Node;
 import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import 
org.apache.tuscany.sca.node.configuration.xml.NodeConfigurationProcessor;
+import org.oasisopen.sca.ServiceRuntimeException;
 
 /**
  * Default implementation of an SCA node factory.
- * 
+ *
  * @version $Rev$ $Date$
  */
 public class NodeFactoryImpl extends NodeFactory {
     public NodeFactoryImpl() {
     }
-    
+
     @Override
     public Node createNode(String configurationURI) {
         return new NodeImpl(configurationURI);
     }
-    
+
     @Override
     public Node createNode(String compositeURI, Contribution... contributions) 
{
         return new NodeImpl(compositeURI, contributions);
@@ -51,4 +60,25 @@
     public Node createNode() {
         return new NodeImpl();
     }
+
+    @Override
+    public Node createNode(NodeConfiguration configuration) {
+        return null;
+    }
+
+    @Override
+    public NodeConfiguration loadConfiguration(InputStream xml) {
+        try {
+            XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+            XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+            XMLStreamReader reader = inputFactory.createXMLStreamReader(xml);
+            NodeConfigurationProcessor processor = new 
NodeConfigurationProcessor(this, inputFactory, outputFactory);
+            reader.nextTag();
+            NodeConfiguration config = processor.read(reader);
+            xml.close();
+            return config;
+        } catch (Throwable e) {
+            throw new ServiceRuntimeException(e);
+        }
+    }
 }

Modified: 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java?rev=774854&r1=774853&r2=774854&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
 (original)
+++ 
tuscany/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
 Thu May 14 18:00:05 2009
@@ -159,7 +159,7 @@
 
             Map<String, String> contributions = new HashMap<String, String>();
             contributions.put(root, root);
-            
+
             // Configure the node
             configureNode(contributions, null, null);
 
@@ -325,12 +325,12 @@
 
         DefinitionsFactory definitionsFactory = 
modelFactories.getFactory(DefinitionsFactory.class);
         systemDefinitions = definitionsFactory.createDefinitions();
-        
+
         DefinitionsExtensionPoint definitionsExtensionPoint = 
extensionPoints.getExtensionPoint(DefinitionsExtensionPoint.class);
         for(Definitions defs: definitionsExtensionPoint.getDefinitions()) {
             DefinitionsUtil.aggregate(systemDefinitions, defs);
         }
-        
+
         // Load the system definitions.xml from all of the loaded extension 
points
         DefinitionsProviderExtensionPoint definitionsProviders = 
extensionPoints.getExtensionPoint(DefinitionsProviderExtensionPoint.class);
 
@@ -370,7 +370,7 @@
     private void configureNode(Map<String, String> contributionLocations, 
String defaultCompositeURI, String defaultCompositeContent) throws Exception {
 
         List<Contribution> contributions = new ArrayList<Contribution>();
-        
+
         // Load the specified contributions
         for (String c : contributionLocations.keySet()) {
             URI contributionURI = NodeUtil.createURI(c);
@@ -415,7 +415,7 @@
         }
 
         ExtensibleModelResolver modelResolver = new 
ExtensibleModelResolver(new Contributions(contributions), modelResolvers, 
modelFactories);
-        
+
         // now resolve and add the system contribution
         contributionProcessor.resolve(systemContribution, modelResolver);
         contributions.add(systemContribution);
@@ -521,16 +521,16 @@
 
     private void buildDependencies(Contribution contribution, 
List<Contribution> contributions, Monitor monitor) {
         contribution.getDependencies().clear();
-        
+
         List<Contribution> dependencies = new ArrayList<Contribution>();
         Set<Contribution> set = new HashSet<Contribution>();
 
         dependencies.add(contribution);
         set.add(contribution);
         addContributionDependencies(contribution, contributions, dependencies, 
set, monitor);
-        
+
         Collections.reverse(dependencies);
-        
+
         contribution.getDependencies().addAll(dependencies);
     }
 
@@ -538,11 +538,11 @@
      * Analyze a contribution and add its dependencies to the given dependency 
set.
      */
     private void addContributionDependencies(Contribution contribution, 
List<Contribution> contributions, List<Contribution> dependencies, 
Set<Contribution> set, Monitor monitor) {
-        
+
         // Go through the contribution imports
         for (Import import_: contribution.getImports()) {
             boolean resolved = false;
-            
+
             // Go through all contribution candidates and their exports
             List<Export> matchingExports = new ArrayList<Export>();
             for (Contribution dependency: contributions) {
@@ -551,7 +551,7 @@
                     continue;
                 }
                 for (Export export: dependency.getExports()) {
-                    
+
                     // If an export from a contribution matches the import in 
hand
                     // add that contribution to the dependency set
                     if (import_.match(export)) {
@@ -561,20 +561,20 @@
                         if (!set.contains(dependency)) {
                             set.add(dependency);
                             dependencies.add(dependency);
-                            
-                            // Now add the dependencies of that contribution 
+
+                            // Now add the dependencies of that contribution
                             addContributionDependencies(dependency, 
contributions, dependencies, set, monitor);
                         }
                     }
                 }
             }
-            
+
             if (resolved) {
-                
+
                 // Initialize the import's model resolver with a delegating 
model
-                // resolver which will delegate to the matching exports 
+                // resolver which will delegate to the matching exports
                 import_.setModelResolver(new 
DefaultImportModelResolver(matchingExports));
-                
+
             } else {
                 // Record import resolution issue
                 if (!(import_ instanceof DefaultImport)) {
@@ -583,22 +583,22 @@
             }
         }
     }
-    
+
     /**
      * Pre-resolve phase for contributions, to set up handling of imports and 
exports prior to full resolution
      * @param contributions - the contributions to preresolve
      * @param resolver - the ModelResolver to use
      * @throws ContributionResolveException
      */
-    private void contributionsPreresolve( List<Contribution> contributions, 
ModelResolver resolver ) 
+    private void contributionsPreresolve( List<Contribution> contributions, 
ModelResolver resolver )
         throws ContributionResolveException {
-        
+
         for( Contribution contribution : contributions ) {
                 contributionProcessor.preResolve(contribution, resolver);
         } // end for
     } // end method contributionsPreresolve
 
-    public void start() {
+    public Node start() {
         logger.log(Level.INFO, "Starting node: " + configurationName);
 
         try {
@@ -608,9 +608,11 @@
 
             // Start the composite
             compositeActivator.start(composite);
-            
+
             SCAClientImpl.addDomain(getDomainName(), this);
 
+            return this;
+
         } catch (ActivationException e) {
             throw new IllegalStateException(e);
         }
@@ -635,7 +637,7 @@
         }
 
     }
-    
+
     private URI getDomainName() {
         URI domainName;
         if (configurationName != null) {
@@ -753,7 +755,7 @@
     private Composite getDefaultComposite(List<Contribution> contributions, 
String defaultCompositeURI, String content) throws Exception {
         Composite composite = assemblyFactory.createComposite();
         composite.setUnresolved(true);
-        
+
         if (content != null && content.length() > 0) {
 
             XMLStreamReader reader = inputFactory.createXMLStreamReader(new 
ByteArrayInputStream(content.getBytes("UTF-8")));
@@ -767,7 +769,7 @@
             analyzeProblems();
             useDeploymentComposite = true;
             return composite;
-            
+
         } else if (defaultCompositeURI != null && defaultCompositeURI.length() 
> 0) {
             composite.setURI(defaultCompositeURI);
             return composite;


Reply via email to