You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2007/09/17 09:31:43 UTC
svn commit: r576287 [2/2] - in /incubator/tuscany/branches/sca-java-1.0:
distribution/webapp/src/main/java/org/apache/tuscany/sca/webapp/
itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/
modules/ modules/binding-sca-axis...
Modified: incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java Mon Sep 17 00:31:38 2007
@@ -49,9 +49,9 @@
import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
import org.apache.tuscany.sca.node.ComponentManager;
import org.apache.tuscany.sca.node.ContributionManager;
-import org.apache.tuscany.sca.node.SCADomain;
import org.apache.tuscany.sca.node.SCANode;
import org.apache.tuscany.sca.node.NodeManagerInitService;
+import org.apache.tuscany.sca.domain.SCADomain;
import org.apache.tuscany.sca.domain.DomainManagerService;
import org.apache.tuscany.sca.domain.SCADomainService;
import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
@@ -70,7 +70,7 @@
*
* @version $Rev: 552343 $ $Date: 2007-09-09 23:54:46 +0100 (Sun, 09 Sep 2007) $
*/
-public class SCANodeImpl implements SCADomain, SCANode {
+public class SCANodeImpl extends SCADomain implements SCANode {
private final static Logger logger = Logger.getLogger(SCANodeImpl.class.getName());
@@ -85,6 +85,9 @@
// class loader used to get the runtime going
private ClassLoader domainClassLoader;
+ // class loader used to get application resources
+ private ClassLoader applicationClassLoader;
+
// representation of the private state of the node that the domain is running on
private String domainUri;
private URL domainUrl;
@@ -95,7 +98,6 @@
// the managers used to control the domain node
private ComponentManagerServiceImpl componentManager;
- // private CompositeManagerImpl compositeManager;
private ContributionManagerImpl contributionManager;
// the proxies to the domain
@@ -113,6 +115,8 @@
throws ActivationException {
this.domainUri = LOCAL_DOMAIN_URI ;
this.nodeUri = LOCAL_NODE_URI;
+ this.domainClassLoader = SCANodeImpl.class.getClassLoader();
+ this.applicationClassLoader = Thread.currentThread().getContextClassLoader();
this.isStandalone = true;
init();
}
@@ -129,6 +133,8 @@
throws ActivationException {
this.domainUri = domainUri;
this.nodeUri = nodeUri;
+ this.domainClassLoader = SCANodeImpl.class.getClassLoader();
+ this.applicationClassLoader = Thread.currentThread().getContextClassLoader();
this.isStandalone = LOCAL_DOMAIN_URI.equals(domainUri);
init();
}
@@ -139,7 +145,7 @@
*
* @param domainUri - identifies what host and port the domain service is running on, e.g. http://localhost:8081
* @param nodeUri - if this is a url it is assumed that this will be used as root url for management components, e.g. http://localhost:8082
- * @param classpath the classpath to use for loading system resources for the node
+ * @param cl - the ClassLoader to use for loading system resources for the node
* @throws ActivationException
*/
public SCANodeImpl(String domainUri, String nodeUri, ClassLoader cl)
@@ -147,8 +153,50 @@
this.domainUri = domainUri;
this.nodeUri = nodeUri;
this.domainClassLoader = cl;
+ this.applicationClassLoader = Thread.currentThread().getContextClassLoader();
+ this.isStandalone = LOCAL_DOMAIN_URI.equals(domainUri);
+ init();
+ }
+
+ /**
+ * Creates a node connected to a wider domain and allows a classpath to be specified.
+ * To find its place in the domain node and domain identifiers must be provided.
+ *
+ * @param domainUri - identifies what host and port the domain service is running on, e.g. http://localhost:8081
+ * @param nodeUri - if this is a url it is assumed that this will be used as root url for management components, e.g. http://localhost:8082
+ * @param cl - the ClassLoader to use for loading system resources for the node
+ * @param applicationCl - the ClassLoader to use for loading application resources for the node
+ * @throws ActivationException
+ */
+ public SCANodeImpl(String domainUri, String nodeUri, ClassLoader cl, ClassLoader applicationCl, String contributionPath, String[] composites)
+ throws ActivationException {
+ this.domainUri = domainUri;
+ this.nodeUri = nodeUri;
+ this.domainClassLoader = cl;
+ this.applicationClassLoader = applicationCl;
this.isStandalone = LOCAL_DOMAIN_URI.equals(domainUri);
init();
+ start();
+
+ try {
+ URL contributionURL = SCANodeUtil.findContributionURLFromCompositeNameOrPath(applicationClassLoader, contributionPath, composites);
+
+ contributionManager.addContribution(contributionURL);
+
+ if (composites.length > 0 ){
+ for(int i = 0; i < composites.length; i++) {
+ contributionManager.addComposite(composites[i]);
+ contributionManager.startComposite(composites[i]);
+ }
+ } else {
+ contributionManager.addAllComposites(contributionURL);
+ contributionManager.startAllComposites(contributionURL);
+ }
+
+ } catch(Exception ex) {
+ throw new ActivationException(ex);
+ }
+
}
/**
@@ -159,9 +207,6 @@
private void init()
throws ActivationException {
try {
- if (domainClassLoader == null) {
- domainClassLoader = SCANodeImpl.class.getClassLoader();
- }
// create a node runtime for the domain contributions to run on
nodeRuntime = new ReallySmallRuntime(domainClassLoader);
@@ -210,7 +255,7 @@
// create a runtime for components to run on that will be used for talking to the
// rest of the domain. The components are defined in the node.composite file
String nodeCompositeName = "node.composite";
- URL contributionURL = SCANodeUtil.findContributionFromComposite(domainClassLoader, nodeCompositeName );
+ URL contributionURL = SCANodeUtil.findContributionURLFromCompositeNameOrPath(domainClassLoader, null, new String[]{nodeCompositeName} );
if ( contributionURL != null ){
logger.log(Level.INFO, "Node management configured from " + contributionURL);
@@ -310,12 +355,12 @@
// I have a domain factory which always returns the same domain
// object. I.e. this node
ModelFactoryExtensionPoint factories = nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
- DomainFactoryImpl domainFactory = new DomainFactoryImpl(this);
+ NodeFactoryImpl domainFactory = new NodeFactoryImpl(this);
factories.addFactory(domainFactory);
// create the domain node managers
componentManager = new ComponentManagerServiceImpl(domainUri, nodeUri, nodeComposite, nodeRuntime);
- contributionManager = new ContributionManagerImpl(domainUri, nodeUri, nodeComposite, nodeRuntime, domainClassLoader, null);
+ contributionManager = new ContributionManagerImpl(domainUri, nodeUri, nodeComposite, nodeRuntime, applicationClassLoader, null);
if (isStandalone == false){
// pass this object into the node manager
@@ -332,8 +377,21 @@
}
}
}
+
+ @Override
+ public void close() {
+ try {
+ stop();
+ } catch (Exception ex) {
+ throw new ServiceRuntimeException(ex);
+ }
+ }
public void stop() throws ActivationException {
+ // stop the components
+
+ // remove contributions
+
// Stop the node
nodeRuntime.stop();
@@ -355,6 +413,10 @@
}
}
+ public String getURI(){
+ return domainUri;
+ }
+
public String getDomainURI(){
return domainUri;
}
@@ -374,22 +436,11 @@
public ComponentManager getComponentManager() {
return componentManager;
}
-
-/*
- public CompositeManager getCompositeManager() {
- return compositeManager;
- }
-*/
public ContributionManager getContributionManager() {
return contributionManager;
}
-
- public ContributionManager getContributionManager(ClassLoader classLoader) {
-
- return new ContributionManagerImpl(domainUri, nodeUri, nodeComposite, nodeRuntime, classLoader, new ModelResolverImpl(classLoader));
- }
-
+
/**
* Return an interface for registering local services and for
Modified: incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java Mon Sep 17 00:31:38 2007
@@ -23,6 +23,7 @@
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.ServerSocket;
+import java.net.URI;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.List;
@@ -34,10 +35,12 @@
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.util.FileHelper;
import org.apache.tuscany.sca.core.assembly.ActivationException;
import org.apache.tuscany.sca.domain.SCADomainService;
-import org.apache.tuscany.sca.node.SCADomainFactory;
-import org.apache.tuscany.sca.node.SCADomain;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.domain.SCADomain;
import org.osoa.sca.CallableReference;
import org.osoa.sca.ServiceReference;
@@ -50,6 +53,174 @@
public class SCANodeUtil {
private final static Logger logger = Logger.getLogger(SCANodeUtil.class.getName());
+ /**
+ * Given a contribution path an array of composite names or neither this method finds
+ * a suitable contribution to load
+ *
+ * @param classLoader
+ * @param compositePath
+ * @param composites
+ * @return the contribution URL
+ * @throws MalformedURLException
+ */
+/* original version
+ public static URL findContributionURLFromCompositeNameOrPath(ClassLoader classLoader, String contributionPath, String[] composites)
+ throws MalformedURLException {
+ if (contributionPath != null && contributionPath.length() > 0) {
+ //encode spaces as they would cause URISyntaxException
+ contributionPath = contributionPath.replace(" ", "%20");
+ URI contributionURI = URI.create(contributionPath);
+ if (contributionURI.isAbsolute() || composites.length == 0) {
+ return new URL(contributionPath);
+ }
+ }
+
+ String contributionArtifactPath = null;
+ URL contributionArtifactURL = null;
+ if (composites != null && composites.length > 0 && composites[0].length() > 0) {
+
+ // Here the SCADomain was started with a reference to a composite file
+ contributionArtifactPath = composites[0];
+ contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
+ if (contributionArtifactURL == null) {
+ throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath);
+ }
+ } else {
+
+ // Here the SCANode was started without any reference to a composite file
+ // We are going to look for an sca-contribution.xml or sca-contribution-generated.xml
+
+ // Look for META-INF/sca-contribution.xml
+ contributionArtifactPath = Contribution.SCA_CONTRIBUTION_META;
+ contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
+
+ // Look for META-INF/sca-contribution-generated.xml
+ if (contributionArtifactURL == null) {
+ contributionArtifactPath = Contribution.SCA_CONTRIBUTION_GENERATED_META;
+ contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
+ }
+
+ // Look for META-INF/sca-deployables directory
+ if (contributionArtifactURL == null) {
+ contributionArtifactPath = Contribution.SCA_CONTRIBUTION_DEPLOYABLES;
+ contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
+ }
+ }
+
+ if (contributionArtifactURL == null) {
+ throw new IllegalArgumentException("Can't determine contribution deployables. Either specify a composite file, or use an sca-contribution.xml file to specify the deployables.");
+ }
+
+ URL contributionURL = null;
+ // "jar:file://....../something.jar!/a/b/c/app.composite"
+ try {
+ String url = contributionArtifactURL.toExternalForm();
+ String protocol = contributionArtifactURL.getProtocol();
+ if ("file".equals(protocol)) {
+ // directory contribution
+ if (url.endsWith(contributionArtifactPath)) {
+ String location = url.substring(0, url.lastIndexOf(contributionArtifactPath));
+ // workaround from evil url/uri form maven
+ contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+
+ } else if ("jar".equals(protocol)) {
+ // jar contribution
+ String location = url.substring(4, url.lastIndexOf("!/"));
+ // workaround for evil url/uri from maven
+ contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+ } catch (MalformedURLException mfe) {
+ throw new IllegalArgumentException(mfe);
+ }
+
+ return contributionURL;
+ }
+ */
+ public static URL findContributionURLFromCompositeNameOrPath(ClassLoader classLoader, String contributionPath, String[] composites)
+ throws MalformedURLException {
+
+ String contributionArtifactPath = null;
+ URL contributionArtifactURL = null;
+
+
+ if (contributionPath != null && contributionPath.length() > 0) {
+
+ //encode spaces as they would cause URISyntaxException
+ contributionPath = contributionPath.replace(" ", "%20");
+ URI contributionURI = URI.create(contributionPath);
+ if (contributionURI.isAbsolute() || composites.length == 0) {
+ return new URL(contributionPath);
+ } else {
+ // contributionArtifactURL = classLoader.getResource(contributionPath);
+ // if (contributionArtifactURL == null) {
+ // throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath);
+ // }
+ }
+ }
+
+ if ( contributionArtifactURL == null){
+ if (composites != null && composites.length > 0 && composites[0].length() > 0) {
+
+ // Here the SCADomain was started with a reference to a composite file
+ contributionArtifactPath = composites[0];
+ contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
+ if (contributionArtifactURL == null) {
+ throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath);
+ }
+ } else {
+
+ // Here the SCANode was started without any reference to a composite file
+ // We are going to look for an sca-contribution.xml or sca-contribution-generated.xml
+
+ // Look for META-INF/sca-contribution.xml
+ contributionArtifactPath = Contribution.SCA_CONTRIBUTION_META;
+ contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
+
+ // Look for META-INF/sca-contribution-generated.xml
+ if (contributionArtifactURL == null) {
+ contributionArtifactPath = Contribution.SCA_CONTRIBUTION_GENERATED_META;
+ contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
+ }
+
+ // Look for META-INF/sca-deployables directory
+ if (contributionArtifactURL == null) {
+ contributionArtifactPath = Contribution.SCA_CONTRIBUTION_DEPLOYABLES;
+ contributionArtifactURL = classLoader.getResource(contributionArtifactPath);
+ }
+ }
+ }
+
+ if (contributionArtifactURL == null) {
+ throw new IllegalArgumentException("Can't determine contribution deployables. Either specify a composite file, or use an sca-contribution.xml file to specify the deployables.");
+ }
+
+ URL contributionURL = null;
+ // "jar:file://....../something.jar!/a/b/c/app.composite"
+ try {
+ String url = contributionArtifactURL.toExternalForm();
+ String protocol = contributionArtifactURL.getProtocol();
+ if ("file".equals(protocol)) {
+ // directory contribution
+ if (url.endsWith(contributionArtifactPath)) {
+ String location = url.substring(0, url.lastIndexOf(contributionArtifactPath));
+ // workaround from evil url/uri form maven
+ contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+
+ } else if ("jar".equals(protocol)) {
+ // jar contribution
+ String location = url.substring(4, url.lastIndexOf("!/"));
+ // workaround for evil url/uri from maven
+ contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+ } catch (MalformedURLException mfe) {
+ throw new IllegalArgumentException(mfe);
+ }
+
+ return contributionURL;
+ }
+
/**
* Given the name of a composite this method finds the contribution that it belongs to
* this could be either a local directory of a jar file.
@@ -59,6 +230,7 @@
* @return the contribution URL
* @throws MalformedURLException
*/
+/*
public static URL findContributionFromComposite(ClassLoader classLoader, String compositeString)
throws MalformedURLException {
@@ -92,7 +264,7 @@
return contributionURL;
}
-
+*/
/**
* A rather ugly method to find and fix the url of the service, assuming that there
@@ -109,7 +281,6 @@
*/
public static void fixUpNodeServiceUrls(List<Component> nodeComponents, URL nodeUrlString)
throws MalformedURLException, UnknownHostException {
- String nodeManagerUrl = null;
for(Component component : nodeComponents){
for (ComponentService service : component.getServices() ){
@@ -228,7 +399,6 @@
*/
public static void fixUpNodeReferenceUrls(List<Component> nodeComponents, URL domainUrl)
throws MalformedURLException, UnknownHostException, ActivationException{
- String nodeManagerUrl = null;
for(Component component : nodeComponents){
for (ComponentReference reference : component.getReferences() ){
Modified: incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java Mon Sep 17 00:31:38 2007
@@ -22,6 +22,7 @@
import junit.framework.Assert;
+import org.apache.tuscany.sca.domain.SCADomain;
import org.apache.tuscany.sca.node.impl.SCANodeImpl;
import org.apache.tuscany.sca.node.impl.SCANodeUtil;
import org.junit.AfterClass;
@@ -36,12 +37,12 @@
*/
public class InMemoryTestCase {
- private static String DEFULT_DOMAIN_URI = "http://localhost:8877";
+ private static String DEFAULT_DOMAIN_URI = "http://localhost:8877";
- private static SCANodeImpl registry;
- private static SCANodeImpl domainNodeA;
- private static SCANodeImpl domainNodeB;
- private static SCANodeImpl domainNodeC;
+ private static SCADomain registry;
+ private static SCADomain domainNodeA;
+ private static SCADomain domainNodeB;
+ private static SCADomain domainNodeC;
private static CalculatorService calculatorServiceA;
private static CalculatorService calculatorServiceB;
@@ -51,27 +52,19 @@
try {
System.out.println("Setting up domain registry");
- registry = new SCANodeImpl();
- registry.start();
- registry.getContributionManager().startContribution(SCANodeUtil.findContributionFromComposite(InMemoryTestCase.class.getClassLoader(), "domain.composite"));
+ registry = SCADomain.newInstance("domain.composite");
System.out.println("Setting up calculator ");
// Create the domain representation
- domainNodeA = new SCANodeImpl(DEFULT_DOMAIN_URI, "nodeA");
- domainNodeA.start();
- domainNodeA.getContributionManager().startContribution(InMemoryTestCase.class.getClassLoader().getResource("nodeA/"));
+ domainNodeA = SCADomain.newInstance(DEFAULT_DOMAIN_URI, "nodeA", null, "nodeA/Calculator.composite");
// Create the domain representation
- domainNodeB = new SCANodeImpl(DEFULT_DOMAIN_URI, "nodeB");
- domainNodeB.start();
- domainNodeB.getContributionManager().startContribution(InMemoryTestCase.class.getClassLoader().getResource("nodeB/"));
-
+ domainNodeB = SCADomain.newInstance(DEFAULT_DOMAIN_URI, "nodeB", null, "nodeB/Calculator.composite");
+
// create the node that runs the
// subtract component
- domainNodeC = new SCANodeImpl(DEFULT_DOMAIN_URI, "http://localhost:8088");
- domainNodeC.start();
- domainNodeC.getContributionManager().startContribution(InMemoryTestCase.class.getClassLoader().getResource("nodeC/"));
+ domainNodeC = SCADomain.newInstance(DEFAULT_DOMAIN_URI, "nodeC", null, "nodeC/Calculator.composite");
// get a reference to the calculator service from domainA
// which will be running this component
@@ -87,9 +80,9 @@
@AfterClass
public static void destroy() throws Exception {
// stop the nodes and hence the domains they contain
- domainNodeA.stop();
- domainNodeB.stop();
- domainNodeC.stop();
+ domainNodeA.close();
+ domainNodeB.close();
+ domainNodeC.close();
}
@Test
Modified: incubator/tuscany/branches/sca-java-1.0/modules/node/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/pom.xml?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/pom.xml Mon Sep 17 00:31:38 2007
@@ -53,11 +53,17 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-core</artifactId>
<version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-node-api</artifactId>
+ <artifactId>tuscany-domain-api</artifactId>
<version>1.0-incubating-SNAPSHOT</version>
</dependency>
Added: incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentInfo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentInfo.java?rev=576287&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentInfo.java (added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentInfo.java Mon Sep 17 00:31:38 2007
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+/**
+ * A collection of information about a component
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public interface ComponentInfo {
+
+ /**
+ * Get the component name
+ *
+ * @return component name
+ */
+ public String getName();
+
+ /**
+ * Set the component name
+ *
+ * @param name component name
+ */
+ public void setName(String name);
+
+ /**
+ * Set to true if the component has been started
+ *
+ * @return true if the component is started
+ */
+ public boolean isStarted();
+
+ /**
+ * Set the started status of the component
+ *
+ * @param started
+ */
+ public void setStarted(boolean started);
+
+}
Added: incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentListener.java?rev=576287&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentListener.java (added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentListener.java Mon Sep 17 00:31:38 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+import java.util.EventListener;
+
+import org.apache.tuscany.sca.assembly.Component;
+
+/**
+ * A listener interface for changes in component state
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public interface ComponentListener extends EventListener {
+
+ /**
+ * Component has been started
+ *
+ * @param component
+ */
+ void componentStarted(Component component);
+
+ /**
+ * Compoent has been stopped
+ *
+ * @param component
+ */
+ void componentStopped(Component component);
+
+}
Added: incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManager.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManager.java?rev=576287&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManager.java (added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManager.java Mon Sep 17 00:31:38 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+
+/**
+ * A set of operations for managing the components in a node
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public interface ComponentManager {
+
+ /**
+ * Get a list of component objects
+ *
+ * @return list of components
+ */
+ List<Component> getComponents();
+
+ /**
+ * Get a component object by name
+ *
+ * @param componentName
+ * @return component
+ */
+ Component getComponent(String componentName);
+
+ /**
+ * Returns true if the named component is started
+ * @param component
+ * @return true if component is started
+ */
+ boolean isComponentStarted(Component component);
+
+ /**
+ * Start a component. Makes it ready to receive messages
+ *
+ * @param component
+ * @throws ActivationException
+ */
+ void startComponent(Component component) throws ActivationException;
+
+ /**
+ * Stop component.
+ * @param component
+ * @throws ActivationException
+ */
+ void stopComponent(Component component) throws ActivationException;
+
+ /**
+ * Add a listener that will be called back when the component state changes
+ *
+ * @param listener
+ */
+ void addComponentListener(ComponentListener listener);
+
+ /**
+ * Remove a component listener
+ *
+ * @param listener
+ */
+ void removeComponentListener(ComponentListener listener);
+
+}
Added: incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManagerService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManagerService.java?rev=576287&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManagerService.java (added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ComponentManagerService.java Mon Sep 17 00:31:38 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * A service interface for managing the components in a node
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+@Remotable
+public interface ComponentManagerService {
+
+ /**
+ * Get a list of component info. On for each component in the node
+ *
+ * @return
+ */
+ List<ComponentInfo> getComponentInfos();
+
+ /**
+ * The info for a named component
+ *
+ * @param componentName
+ * @return
+ */
+ ComponentInfo getComponentInfo(String componentName);
+
+ /**
+ * Start a component, making it ready to receive messages
+ *
+ * @param componentName
+ * @throws ActivationException
+ */
+ void startComponent(String componentName) throws ActivationException;
+
+ /**
+ * Stop a component
+ *
+ * @param componentName
+ * @throws ActivationException
+ */
+ void stopComponent(String componentName) throws ActivationException;
+
+}
Added: incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/CompositeManager.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/CompositeManager.java?rev=576287&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/CompositeManager.java (added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/CompositeManager.java Mon Sep 17 00:31:38 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.contribution.service.ContributionException;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+
+
+/**
+ * A management interface for composites in the distributed domain
+ *
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public interface CompositeManager {
+
+ /**
+ * Add all composite in a contribution
+ *
+ * @param contributionURL
+ */
+ public abstract void addAllComposites(URL contributionURL)
+ throws ActivationException, ContributionException, IOException, CompositeBuilderException;
+
+ /**
+ * adds a named composite
+ *
+ * @param compositeName the name of the composite to be added
+ */
+ public abstract void addComposite(QName compositeName);
+
+ /**
+ * Removes a named composite
+ *
+ * @param compositeName the name of the composite to be added
+ */
+ public abstract void removeComposite(QName compositeName);
+
+ /**
+ * Starts all composites in a contribution
+ *
+ * @param contributionURL
+ */
+ public abstract void startAllComposites(URL contributionURL)
+ throws ActivationException;
+
+ /**
+ * Starts a named composite
+ *
+ * @param compositeName the name of the composite to be started
+ */
+ public abstract void startComposite(QName compositeName);
+
+ /**
+ * Stops a named composite
+ *
+ * @param compositeName the name of the composite to be stopped
+ */
+ public abstract void stopComposite(QName compositeName);
+
+
+}
Added: incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ContributionManager.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ContributionManager.java?rev=576287&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ContributionManager.java (added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/ContributionManager.java Mon Sep 17 00:31:38 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.contribution.service.ContributionException;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+
+
+/**
+ * A management interface for contributions in the distributed domain
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-09 23:54:46 +0100 (Sun, 09 Sep 2007) $
+ */
+public interface ContributionManager {
+
+ /**
+ * Accepts a new contribution and passes it onto the domain implementation
+ *
+ * @param contributionLocation the URL location of the contribution
+ * @throws ActivationException
+ */
+ public void addContribution(URL contrubutionLocation)
+ throws ActivationException, ContributionException, IOException, CompositeBuilderException;
+
+ /**
+ * Removes the specified contribution from the domain
+ *
+ * @param contributionname
+ * throws ActivationException
+ */
+ public void removeContribution(URL contributionName)
+ throws ActivationException, ContributionException;
+
+}
Added: incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java?rev=576287&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java (added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java Mon Sep 17 00:31:38 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+import org.apache.tuscany.sca.node.SCANode;
+
+/**
+ * A factory that always returns the same domain object
+ *
+ * @version $Rev: 556897 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public interface NodeFactory {
+
+ /**
+ * Returns the domain object
+ *
+ * @return the domain
+ */
+ public SCANode getNode();
+
+}
Added: incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/SCANode.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/SCANode.java?rev=576287&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/SCANode.java (added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/node/src/main/java/org/apache/tuscany/sca/node/SCANode.java Mon Sep 17 00:31:38 2007
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.node;
+
+import java.net.URL;
+
+import org.apache.tuscany.sca.domain.SCADomainService;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
+
+
+/**
+ * An SCA Node. Where a domain runs components
+ *
+ * @version $Rev: 556897 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+public interface SCANode {
+
+ /**
+ * Returns the name of the distributed domain that this node
+ * is part of.
+ *
+ * @return the domain URI
+ */
+ public String getDomainURI();
+
+ /**
+ * Returns the name of the name of this node
+ *
+ * @return the node name
+ */
+ public String getNodeURI();
+
+
+ /**
+ * Returns the URL of the distributed domain that this node
+ * is part of.
+ *
+ * @return the domain URL
+ */
+ public URL getDomainURL();
+
+ /**
+ * Returns the URL of the name of this node
+ *
+ * @return the node name
+ */
+ public URL getNodeURL();
+
+ /**
+ * Return an interface for registering and looking up remote services
+ *
+ * @return The service discovery interface
+ */
+ public SCADomainService getDomainService();
+
+ /**
+ * Return the nodes component manager
+ *
+ * @return component manager
+ */
+ public ComponentManager getComponentManager();
+
+ /**
+ * Return the nodes contribution manager
+ *
+ * @return contribution manager
+ */
+ public ContributionManager getContributionManager();
+
+ /**
+ * Cast a type-safe reference to a CallableReference. Converts a type-safe
+ * reference to an equivalent CallableReference; if the target refers to a
+ * service then a ServiceReference will be returned, if the target refers to
+ * a callback then a CallableReference will be returned.
+ *
+ * @param target a reference proxy provided by the SCA runtime
+ * @param <B> the Java type of the business interface for the reference
+ * @param <R> the type of reference to be returned
+ * @return a CallableReference equivalent for the proxy
+ * @throws IllegalArgumentException if the supplied instance is not a
+ * reference supplied by the SCA runtime
+ */
+ public abstract <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException;
+
+ /**
+ * Returns a proxy for a service provided by a component in the SCA domain.
+ *
+ * @param businessInterface the interface that will be used to invoke the
+ * service
+ * @param serviceName the name of the service
+ * @param <B> the Java type of the business interface for the service
+ * @return an object that implements the business interface
+ */
+ public abstract <B> B getService(Class<B> businessInterface, String serviceName);
+
+ /**
+ * Returns a ServiceReference for a service provided by a component in the
+ * SCA domain.
+ *
+ * @param businessInterface the interface that will be used to invoke the
+ * service
+ * @param serviceName the name of the service
+ * @param <B> the Java type of the business interface for the service
+ * @return a ServiceReference for the designated service
+ */
+ public abstract <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName);
+
+}
Modified: incubator/tuscany/branches/sca-java-1.0/modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/pom.xml?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/pom.xml Mon Sep 17 00:31:38 2007
@@ -78,6 +78,7 @@
<module>discovery-jms</module>
-->
<module>domain</module>
+ <module>domain-api</module>
<module>domain-impl</module>
<module>extension-helper</module>
<module>host-embedded</module>
@@ -116,7 +117,6 @@
<module>maven-java2wsdl</module>
<module>maven-wsdl2java</module>
<module>node</module>
- <module>node-api</module>
<module>node-impl</module>
<module>policy</module>
<module>policy-xml</module>
Modified: incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/build.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/build.xml?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/build.xml (original)
+++ incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/build.xml Mon Sep 17 00:31:38 2007
@@ -129,7 +129,7 @@
<pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-interface\1.0-incubating-SNAPSHOT\tuscany-interface-1.0-incubating-SNAPSHOT.jar"/>
<pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-policy-xml\1.0-incubating-SNAPSHOT\tuscany-policy-xml-1.0-incubating-SNAPSHOT.jar"/>
<pathelement location="${m2.repo}\commons-logging\commons-logging\1.1\commons-logging-1.1.jar"/>
- <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-node-api\1.0-incubating-SNAPSHOT\tuscany-node-api-1.0-incubating-SNAPSHOT.jar"/>
+ <pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-domain-api\1.0-incubating-SNAPSHOT\tuscany-domain-api-1.0-incubating-SNAPSHOT.jar"/>
<pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-extension-helper\1.0-incubating-SNAPSHOT\tuscany-extension-helper-1.0-incubating-SNAPSHOT.jar"/>
<pathelement location="${m2.repo}\org\apache\geronimo\specs\geronimo-activation_1.1_spec\1.0-M1\geronimo-activation_1.1_spec-1.0-M1.jar"/>
<pathelement location="${m2.repo}\org\apache\tuscany\sca\tuscany-binding-jsonrpc\1.0-incubating-SNAPSHOT\tuscany-binding-jsonrpc-1.0-incubating-SNAPSHOT.jar"/>
Modified: incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/main/java/node/CalculatorNode.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/main/java/node/CalculatorNode.java?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/main/java/node/CalculatorNode.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/main/java/node/CalculatorNode.java Mon Sep 17 00:31:38 2007
@@ -21,6 +21,7 @@
import java.io.IOException;
+import org.apache.tuscany.sca.domain.SCADomain;
import org.apache.tuscany.sca.node.impl.SCANodeImpl;
import calculator.CalculatorService;
@@ -47,23 +48,14 @@
String domainName = args[0];
String nodeName = args[1];
- // Create the distributed domain representation. We use the network implementation
- // here so that the node contacts a registry running somewhere out on the
- // network.
- SCANodeImpl node = new SCANodeImpl(domainName, nodeName);
- node.start();
-
- // the application components are added. The null here just gets the node
- // implementation to read a directory from the classpath with the node name
- // TODO - should be done as a management action.
- node.getContributionManager().startContribution(CalculatorNode.class.getClassLoader().getResource(nodeName + "/"));
+ SCADomain domainNode = SCADomain.newInstance(domainName, nodeName, null, nodeName + "/");
// nodeA is the head node and runs some tests while all other nodes
// simply listen for incoming messages
if ( nodeName.equals("nodeA") ) {
// do some application stuff
CalculatorService calculatorService =
- node.getService(CalculatorService.class, "CalculatorServiceComponent");
+ domainNode.getService(CalculatorService.class, "CalculatorServiceComponent");
// Calculate
System.out.println("3 + 2=" + calculatorService.add(3, 2));
@@ -92,7 +84,7 @@
}
// stop the node and all the domains in it
- node.stop();
+ domainNode.close();
} catch(Exception ex) {
System.err.println("Exception in node - " + ex.getMessage());
Modified: incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/main/java/node/DomainNode.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/main/java/node/DomainNode.java?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/main/java/node/DomainNode.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/main/java/node/DomainNode.java Mon Sep 17 00:31:38 2007
@@ -18,6 +18,7 @@
*/
package node;
+import org.apache.tuscany.sca.domain.SCADomain;
import org.apache.tuscany.sca.node.impl.SCANodeImpl;
import org.apache.tuscany.sca.node.impl.SCANodeUtil;
@@ -32,15 +33,12 @@
public static void main(String[] args) {
try {
- SCANodeImpl domain;
- domain = new SCANodeImpl();
- domain.start();
- domain.getContributionManager().startContribution(SCANodeUtil.findContributionFromComposite(DomainNode.class.getClassLoader(), "domain.composite"));
+ SCADomain domainNode = SCADomain.newInstance("domain.composite");
System.out.println("Domain node started (press enter to shutdown)");
System.in.read();
- domain.stop();
+ domainNode.close();
} catch (Exception e) {
e.printStackTrace();
}
Modified: incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java?rev=576287&r1=576286&r2=576287&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-1.0/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java Mon Sep 17 00:31:38 2007
@@ -21,6 +21,7 @@
import junit.framework.Assert;
+import org.apache.tuscany.sca.domain.SCADomain;
import org.apache.tuscany.sca.node.impl.SCANodeImpl;
import org.apache.tuscany.sca.node.impl.SCANodeUtil;
import org.junit.AfterClass;
@@ -37,10 +38,10 @@
private static String DEFAULT_DOMAIN_URL = "http://localhost:8877";
- private static SCANodeImpl domain;
- private static SCANodeImpl domainNodeA;
- private static SCANodeImpl domainNodeB;
- private static SCANodeImpl domainNodeC;
+ private static SCADomain domain;
+ private static SCADomain domainNodeA;
+ private static SCADomain domainNodeB;
+ private static SCADomain domainNodeC;
private static CalculatorService calculatorServiceA;
@@ -49,29 +50,20 @@
try {
System.out.println("Setting up domain registry");
-
- domain = new SCANodeImpl();
- domain.start();
- domain.getContributionManager().startContribution(SCANodeUtil.findContributionFromComposite(DomainInMemoryTestCase.class.getClassLoader(), "domain.composite"));
+ domain = SCADomain.newInstance("domain.composite");
System.out.println("Setting up distributed nodes");
// Create the domain representation
- domainNodeA = new SCANodeImpl(DEFAULT_DOMAIN_URL, "nodeA");
- domainNodeA.start();
- domainNodeA.getContributionManager().startContribution(DomainInMemoryTestCase.class.getClassLoader().getResource("nodeA/"));
+ domainNodeA = SCADomain.newInstance(DEFAULT_DOMAIN_URL, "nodeA", null, "nodeA/Calculator.composite");
// Create the domain representation
- domainNodeB = new SCANodeImpl(DEFAULT_DOMAIN_URL, "nodeB");
- domainNodeB.start();
- domainNodeB.getContributionManager().startContribution(DomainInMemoryTestCase.class.getClassLoader().getResource("nodeB/"));
+ domainNodeB = SCADomain.newInstance(DEFAULT_DOMAIN_URL, "nodeB", null, "nodeB/Calculator.composite");
// create the node that runs the
// subtract component
- domainNodeC = new SCANodeImpl(DEFAULT_DOMAIN_URL, "nodeC");
- domainNodeC.start();
- domainNodeC.getContributionManager().startContribution(DomainInMemoryTestCase.class.getClassLoader().getResource("nodeC/"));
-
+ domainNodeC = SCADomain.newInstance(DEFAULT_DOMAIN_URL, "nodeC", null, "nodeC/Calculator.composite");
+
// get a reference to the calculator service from domainA
// which will be running this component
calculatorServiceA = domainNodeA.getService(CalculatorService.class, "CalculatorServiceComponent");
@@ -83,10 +75,10 @@
@AfterClass
public static void destroy() throws Exception {
// stop the domain and hence the nodes it contains
- domainNodeA.stop();
- domainNodeB.stop();
- domainNodeC.stop();
- domain.stop();
+ domainNodeA.close();
+ domainNodeB.close();
+ domainNodeC.close();
+ domain.close();
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org