summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-14 18:00:05 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-05-14 18:00:05 +0000
commit6f5177c379df8f30e1002065881845abf39b8931 (patch)
tree37ecd3bc1e5fefc7e55844adb5144ccf7b46256e
parentae60ec5e5c598de4d05cb1a44a38df2c9622d146 (diff)
Start to integrate the node configuration with NodeImpl
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@774854 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java21
-rw-r--r--java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java27
-rw-r--r--java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java14
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java11
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java88
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java15
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java51
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java6
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java24
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java1
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java8
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java83
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java9
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java3
-rw-r--r--java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java75
-rw-r--r--java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java6
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java9
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java42
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java52
19 files changed, 435 insertions, 110 deletions
diff --git a/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java b/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java
index 202514d89e..e4e88003c7 100644
--- a/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java
+++ b/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationDaemonBootstrap.java
@@ -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 @@ import org.oasisopen.sca.ServiceReference;
/**
* Bootstrap class for the SCA node daemon.
- *
+ *
* @version $Rev$ $Date$
*/
public class NodeImplementationDaemonBootstrap {
@@ -41,12 +41,12 @@ public class NodeImplementationDaemonBootstrap {
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 @@ public class NodeImplementationDaemonBootstrap {
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 @@ public class NodeImplementationDaemonBootstrap {
throw new UnsupportedOperationException();
}
}
-
+
/**
* Constructs a new daemon bootstrap.
*/
public NodeImplementationDaemonBootstrap() throws Exception {
node = new NodeFacade();
}
-
+
/**
* Returns the node representing the daemon.
* @return
diff --git a/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java b/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
index 2daab36796..a26f63f9d0 100644
--- a/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
+++ b/java/sca/modules/implementation-node-runtime/src/main/java/org/apache/tuscany/sca/implementation/node/launcher/NodeImplementationLauncherBootstrap.java
@@ -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 @@ import org.oasisopen.sca.ServiceReference;
/**
* Bootstrap class for standalone SCA nodes.
- *
+ *
* @version $Rev$ $Date$
*/
public class NodeImplementationLauncherBootstrap {
@@ -42,26 +42,27 @@ public class NodeImplementationLauncherBootstrap {
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 @@ public class NodeImplementationLauncherBootstrap {
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 @@ public class NodeImplementationLauncherBootstrap {
/**
* Bootstrap a new SCA node.
- *
+ *
* @param compositeURI
* @param uris
* @param locations
@@ -121,7 +122,7 @@ public class NodeImplementationLauncherBootstrap {
/**
* Bootstrap a new SCA node.
- *
+ *
* @param compositeURI
* @param uris
* @param locations
@@ -137,7 +138,7 @@ public class NodeImplementationLauncherBootstrap {
/**
* Returns the SCA node.
- *
+ *
* @return
*/
public Node getNode() {
diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
index 9e7d6882f7..f13da1d6a1 100644
--- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
+++ b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
@@ -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 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
}
}
+ 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());
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
index 3f4998bcc9..d14c1a65ad 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
@@ -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 @@ public interface Node extends Client {
/**
* 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.
*/
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
index 426c32bd49..0c1e9bb642 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
@@ -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 @@ import org.oasisopen.sca.ServiceRuntimeException;
/**
* 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 abstract class NodeFactory {
}
}
- 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 @@ public abstract class NodeFactory {
/**
* 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 @@ public abstract class NodeFactory {
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 @@ public abstract class NodeFactory {
/**
* 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();
+
+ }
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
index 489a3fd2e3..f3be7c5c35 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
@@ -28,16 +28,16 @@ import javax.xml.namespace.QName;
*/
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 @@ public interface BindingConfiguration {
* @return A list of base URIs
*/
List<String> getBaseURIs();
+
+ /**
+ * Add a base URI
+ * @param baseURI
+ * @return
+ */
+ BindingConfiguration addBaseURI(String baseURI);
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
index 0de5e0b473..3e9946fe80 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
@@ -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 @@ public interface ContributionConfiguration {
* 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 @@ public interface ContributionConfiguration {
* 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);
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
index c322d7ed15..65337abdfb 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
@@ -35,7 +35,7 @@ public interface DeploymentComposite {
* 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 @@ public interface DeploymentComposite {
* 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 @@ public interface DeploymentComposite {
* Set the URI of the contribution that the deployment composite is attached to
* @param contributionURI
*/
- void setContributionURI(String contributionURI);
+ DeploymentComposite setContributionURI(String contributionURI);
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
index f1eeb868ff..4054ffc250 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
@@ -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 @@ public interface NodeConfiguration {
* 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 @@ public interface NodeConfiguration {
* 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 @@ public interface NodeConfiguration {
* @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);
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
index ca1afee923..f03a895114 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.node.configuration;
+
/**
* The factory to create java models related to the node configuration
*/
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
index eb5ac2915b..dd38f97161 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java
@@ -41,8 +41,14 @@ class BindingConfigurationImpl implements BindingConfiguration {
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;
}
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
index d34fac866c..b863ede5f6 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java
@@ -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 @@ class ContributionConfigurationImpl implements ContributionConfiguration {
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 @@ class ContributionConfigurationImpl implements ContributionConfiguration {
* 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 @@ class ContributionConfigurationImpl implements ContributionConfiguration {
* 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 @@ class ContributionConfigurationImpl implements ContributionConfiguration {
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);
+ }
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
index fabba4551e..4edcf75bba 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java
@@ -33,24 +33,27 @@ class DeploymentCompositeImpl implements DeploymentComposite {
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;
}
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
index 96ca3e6199..fe5e9012cf 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.node.configuration.impl;
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 @@ public abstract class NodeConfigurationFactoryImpl implements NodeConfigurationF
* Create a new instance of NodeConfiguration
* @return
*/
- public NodeConfigurationImpl createNodeConfiguration() {
+ public NodeConfiguration createNodeConfiguration() {
return new NodeConfigurationImpl();
}
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
index 4f13959ced..162918f98d 100644
--- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
+++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
@@ -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 @@ class NodeConfigurationImpl implements NodeConfiguration {
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 @@ class NodeConfigurationImpl implements NodeConfiguration {
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 + ")");
+ }
}
diff --git a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
index 1ce13f0aaa..aada9e7843 100644
--- a/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
+++ b/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeFactoryImpl.java
@@ -308,7 +308,7 @@ public class NodeFactoryImpl {
for(Definitions defs: definitionsExtensionPoint.getDefinitions()) {
DefinitionsUtil.aggregate(systemDefinitions, defs);
}
-
+
DefinitionsProviderExtensionPoint definitionsProviders =
extensionPoints.getExtensionPoint(DefinitionsProviderExtensionPoint.class);
@@ -578,7 +578,7 @@ public class NodeFactoryImpl {
}
}
- public void start() {
+ public Node start() {
logger.log(Level.INFO, "Starting node: " + bundle.getSymbolicName());
try {
@@ -590,6 +590,8 @@ public class NodeFactoryImpl {
// Start the composite
compositeActivator.start(composite);
+ return this;
+
} catch (ActivationException e) {
throw new IllegalStateException(e);
}
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
index 5d5a9bfa66..889ea6f118 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
@@ -76,6 +76,15 @@ public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implem
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;
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
index 5ee68899a9..292839fe3a 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
@@ -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 class NodeFactoryImpl extends NodeFactory {
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);
+ }
+ }
}
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index ed0a509684..22fd8bce84 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -159,7 +159,7 @@ public class NodeImpl implements Node, Client, SCAClient {
Map<String, String> contributions = new HashMap<String, String>();
contributions.put(root, root);
-
+
// Configure the node
configureNode(contributions, null, null);
@@ -325,12 +325,12 @@ public class NodeImpl implements Node, Client, SCAClient {
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 @@ public class NodeImpl implements Node, Client, SCAClient {
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 @@ public class NodeImpl implements Node, Client, SCAClient {
}
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 @@ public class NodeImpl implements Node, Client, SCAClient {
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 @@ public class NodeImpl implements Node, Client, SCAClient {
* 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 @@ public class NodeImpl implements Node, Client, SCAClient {
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 @@ public class NodeImpl implements Node, Client, SCAClient {
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 @@ public class NodeImpl implements Node, Client, SCAClient {
}
}
}
-
+
/**
* 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 @@ public class NodeImpl implements Node, Client, SCAClient {
// Start the composite
compositeActivator.start(composite);
-
+
SCAClientImpl.addDomain(getDomainName(), this);
+ return this;
+
} catch (ActivationException e) {
throw new IllegalStateException(e);
}
@@ -635,7 +637,7 @@ public class NodeImpl implements Node, Client, SCAClient {
}
}
-
+
private URI getDomainName() {
URI domainName;
if (configurationName != null) {
@@ -753,7 +755,7 @@ public class NodeImpl implements Node, Client, SCAClient {
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 @@ public class NodeImpl implements Node, Client, SCAClient {
analyzeProblems();
useDeploymentComposite = true;
return composite;
-
+
} else if (defaultCompositeURI != null && defaultCompositeURI.length() > 0) {
composite.setURI(defaultCompositeURI);
return composite;