summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/1.0-RC1b/modules/node-impl/src
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/1.0-RC1b/modules/node-impl/src')
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ComponentInfoImpl.java47
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ComponentManagerServiceImpl.java111
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ContributionManagerImpl.java332
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/DomainManagerServiceImpl.java85
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java48
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeManagerServiceImpl.java84
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCADomainServiceImpl.java158
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java551
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java456
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/AddService.java31
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/AddServiceImpl.java31
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/CalculatorService.java35
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/CalculatorServiceImpl.java74
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/DivideServiceImpl.java30
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/MultiplyServiceImpl.java30
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/SubtractService.java31
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/SubtractServiceImpl.java31
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java102
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/Calculator.composite41
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/add.wsdl88
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/multiply.wsdl81
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/subtract.wsdl87
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeB/Calculator.composite45
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeB/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeC/Calculator.composite32
-rw-r--r--tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeC/META-INF/sca-contribution.xml24
29 files changed, 2769 insertions, 0 deletions
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ComponentInfoImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ComponentInfoImpl.java
new file mode 100644
index 0000000000..5e38c6bb81
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ComponentInfoImpl.java
@@ -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.impl;
+
+import java.io.Serializable;
+
+import org.apache.tuscany.sca.node.ComponentInfo;
+
+public class ComponentInfoImpl implements ComponentInfo, Serializable {
+
+ private String name;
+ private boolean started;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isStarted() {
+ return started;
+ }
+
+ public void setStarted(boolean started) {
+ this.started = started;
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ComponentManagerServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ComponentManagerServiceImpl.java
new file mode 100644
index 0000000000..6e2c4c69cf
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ComponentManagerServiceImpl.java
@@ -0,0 +1,111 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+import org.apache.tuscany.sca.core.assembly.RuntimeComponentImpl;
+import org.apache.tuscany.sca.node.ComponentListener;
+import org.apache.tuscany.sca.node.ComponentManager;
+import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
+
+public class ComponentManagerServiceImpl implements ComponentManager {
+
+ protected List<ComponentListener> listeners = new CopyOnWriteArrayList<ComponentListener>();
+ protected String domainURI;
+ protected String nodeName;
+ protected Composite nodeComposite;
+ protected ReallySmallRuntime nodeRuntime;
+
+ public ComponentManagerServiceImpl(String domainURI, String nodeName, Composite nodeComposite, ReallySmallRuntime nodeRuntime) {
+ this.domainURI = domainURI;
+ this.nodeName = nodeName;
+ this.nodeComposite = nodeComposite;
+ this.nodeRuntime = nodeRuntime;
+ }
+
+ public void addComponentListener(ComponentListener listener) {
+ this.listeners.add(listener);
+ }
+
+ public void removeComponentListener(ComponentListener listener) {
+ this.listeners.remove(listener);
+ }
+
+ public Component getComponent(String componentName) {
+ for (Composite composite: nodeComposite.getIncludes()) {
+ for (Component component: composite.getComponents()) {
+ if (component.getName().equals(componentName)) {
+ return component;
+ }
+ }
+ }
+ return null;
+ }
+
+ public List<Component> getComponents() {
+ List<Component> components = new ArrayList<Component>();
+ for (Composite composite: nodeComposite.getIncludes()) {
+ components.addAll(composite.getComponents());
+ }
+ return components;
+ }
+
+ public void startComponent(Component component) throws ActivationException {
+ nodeRuntime.getCompositeActivator().start(component);
+ notifyComponentStarted(component);
+ }
+
+ public void stopComponent(Component component) throws ActivationException {
+ nodeRuntime.getCompositeActivator().stop(component);
+ notifyComponentStopped(component);
+ }
+
+ public void notifyComponentStarted(Component component) {
+ for (ComponentListener listener : listeners) {
+ try {
+ listener.componentStarted(component);
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO: log
+ }
+ }
+ }
+
+ public void notifyComponentStopped(Component component) {
+ for (ComponentListener listener : listeners) {
+ try {
+ listener.componentStopped(component);
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO: log
+ }
+ }
+ }
+
+ public boolean isComponentStarted(Component component) {
+ RuntimeComponentImpl runtimeComponent = (RuntimeComponentImpl)component;
+ return runtimeComponent.isStarted();
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ContributionManagerImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ContributionManagerImpl.java
new file mode 100644
index 0000000000..45d5c6f854
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/ContributionManagerImpl.java
@@ -0,0 +1,332 @@
+/*
+ * 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.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DeployedArtifact;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionException;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+import org.apache.tuscany.sca.node.CompositeManager;
+import org.apache.tuscany.sca.node.ContributionManager;
+import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
+import org.osoa.sca.ServiceRuntimeException;
+
+public class ContributionManagerImpl implements ContributionManager, CompositeManager {
+
+ protected String domainURI;
+ protected String nodeName;
+ protected Composite nodeComposite;
+ protected ReallySmallRuntime nodeRuntime;
+ private ClassLoader classLoader;
+
+ private ModelResolver modelResolver;
+
+ private Map<String, Composite> compositeArtifacts = new HashMap<String, Composite>();
+ private Map<URL, Contribution> contributions = new HashMap<URL, Contribution>();
+
+ public ContributionManagerImpl(String domainURI, String nodeName, Composite nodeComposite, ReallySmallRuntime nodeRuntime, ClassLoader classLoader, ModelResolver modelResolver) {
+ this.domainURI = domainURI;
+ this.nodeName = nodeName;
+ this.nodeComposite = nodeComposite;
+ this.nodeRuntime = nodeRuntime;
+ this.classLoader = classLoader;
+ this.modelResolver = modelResolver;
+ }
+
+ public void addContribution(URL contributionURL)
+ throws ActivationException, ContributionException, IOException, CompositeBuilderException {
+
+ if (contributionURL != null) {
+ // Get ready to add contributions to the domain
+ ContributionService contributionService = nodeRuntime.getContributionService();
+
+ // Contribute the SCA application
+ Contribution contribution = contributionService.contribute(contributionURL.toExternalForm(),
+ contributionURL,
+ modelResolver,
+ false);
+
+ contributions.put(contributionURL, contribution);
+
+ for (DeployedArtifact artifact : contribution.getArtifacts()) {
+ if (artifact.getModel() instanceof Composite) {
+ compositeArtifacts.put(artifact.getURI(), (Composite)artifact.getModel());
+ }
+ }
+
+ } else {
+ throw new ActivationException("Contribution " + contributionURL + " not found");
+ }
+ }
+
+ /**
+ * Add all composite in a contribution
+ *
+ * @param contributionURL
+ */
+ public void addAllComposites(URL contributionURL)
+ throws ActivationException, ContributionException, IOException, CompositeBuilderException {
+ Contribution contribution = contributions.get(contributionURL);
+
+ if ( contribution != null) {
+ // Add the composites to the top level domain
+ for(Composite composite: contribution.getDeployables()) {
+ nodeComposite.getIncludes().add(composite);
+ nodeRuntime.getCompositeBuilder().build(composite);
+ }
+
+ // activate all of the composites just loaded
+ for(Composite composite: contribution.getDeployables()) {
+ nodeRuntime.getCompositeActivator().activate(composite);
+ }
+ } else {
+ throw new ActivationException("Contribution " + contributionURL + " not found");
+ }
+ }
+
+ /**
+ * adds a named composite
+ *
+ * @param compositeName the name of the composite to be added
+ */
+ public void addComposite(QName compositeName){
+ //TODO
+ }
+
+ /**
+ * adds a named composite
+ *
+ * @param compositePath the path to the composite to be added
+ */
+ public void addComposite(String compositePath)
+ throws ActivationException, ContributionException, IOException, CompositeBuilderException {
+
+ Composite composite = compositeArtifacts.get(compositePath);
+
+ if (composite == null) {
+ throw new ServiceRuntimeException("Composite not found: " + compositePath);
+ }
+
+ nodeComposite.getIncludes().add(composite);
+ nodeRuntime.getCompositeBuilder().build(composite);
+ nodeRuntime.getCompositeActivator().activate(composite);
+ }
+
+ /**
+ * Starts all composites in a contribution
+ *
+ * @param contributionURL
+ */
+ public void startAllComposites(URL contributionURL)
+ throws ActivationException {
+ Contribution contribution = contributions.get(contributionURL);
+
+ if (contribution != null) {
+ for(Composite composite: contribution.getDeployables()) {
+ nodeRuntime.getCompositeActivator().start(composite);
+ }
+ } else {
+ throw new ActivationException("Contribution " + contributionURL+ " not started");
+ }
+ }
+
+ /**
+ * Starts a named composite
+ *
+ * @param compositeName the name of the composite to be started
+ */
+ public void startComposite(QName compositeName){
+
+ }
+
+ /**
+ * Starts a named composite
+ *
+ * @param compositePath the path to the composite to be started
+ */
+ public void startComposite(String compositePath)
+ throws ActivationException {
+ Composite composite = compositeArtifacts.get(compositePath);
+
+ if (composite == null) {
+ throw new ServiceRuntimeException("Composite not found: " + compositePath);
+ }
+
+ nodeRuntime.getCompositeActivator().start(composite);
+ }
+
+ /**
+ * Stops a all composites in a contribution
+ *
+ * @param compositeURL
+ */
+ public void stopAllComposites(URL contributionURL)
+ throws ActivationException {
+ Contribution contribution = contributions.get(contributionURL);
+
+ if (contribution != null) {
+ for(Composite composite: contribution.getDeployables()) {
+ nodeRuntime.getCompositeActivator().stop(composite);
+ }
+ } else {
+ throw new ActivationException("Contribution " + contributionURL+ " not stopped");
+ }
+ }
+
+ /**
+ * Stops a named composite
+ *
+ * @param compositeName the name of the composite to be stopped
+ */
+ public void stopComposite(QName compositeName){
+
+ }
+
+ /**
+ * Stops a named composite
+ *
+ * @param compositeName the name of the composite to be stopped
+ */
+ public void stopComposite(String compositePath){
+
+ }
+
+
+ public void removeContribution(URL contributionURL)
+ throws ActivationException, ContributionException {
+
+ // Remove contribution
+ nodeRuntime.getContributionService().remove(contributionURL.toExternalForm());
+ }
+
+ /**
+ * Removes all composites
+ *
+ * @param compositeName the name of the composite to be added
+ */
+ public void removeAllComposites(URL contributionURL)
+ throws ActivationException {
+ Contribution contribution = contributions.get(contributionURL);
+
+ stopAllComposites(contributionURL);
+
+ // Deactivate the composites
+ for(Composite composite: contribution.getDeployables()) {
+ nodeRuntime.getCompositeActivator().deactivate(composite);
+ }
+
+ // Remove the composites
+ for(Composite composite: contribution.getDeployables()) {
+ nodeComposite.getIncludes().remove(composite);
+ }
+
+ contributions.remove(contributionURL);
+ }
+
+ /**
+ * Removes a named composite
+ *
+ * @param compositeName the name of the composite to be added
+ */
+ public void removeComposite(QName compositeName){
+
+ }
+
+ /**
+ * Removes a named composite
+ *
+ * @param compositeName the name of the composite to be added
+ */
+ public void removeComposite(String compositePath){
+
+ }
+
+
+ /**
+ * Stop and remove everything
+ */
+ public void stop()
+ throws ActivationException, ContributionException {
+ for (URL contributionURL : contributions.keySet()){
+ stopAllComposites(contributionURL);
+ removeContribution(contributionURL);
+ }
+ }
+
+/*
+ public void addContributionJAR(URL contributionJar) throws CompositeBuilderException, ActivationException {
+
+ ContributionService contributionService = nodeRuntime.getContributionService();
+
+ Contribution contribution = contributeJAR(contributionJar, contributionService);
+
+ // Add the composites to the top level domain
+ for (Composite composite : contribution.getDeployables()) {
+ nodeComposite.getIncludes().add(composite);
+ nodeRuntime.getCompositeBuilder().build(composite);
+ }
+
+ // activate all of the composites just loaded
+ for (Composite composite : contribution.getDeployables()) {
+ nodeRuntime.getCompositeActivator().activate(composite);
+ }
+
+ // start all the composites just loaded
+ for (Composite composite : contribution.getDeployables()) {
+ nodeRuntime.getCompositeActivator().start(composite);
+ }
+ }
+
+ protected Contribution contributeJAR(URL contributionJar, ContributionService contributionService) throws ActivationException {
+ InputStream is;
+ try {
+ is = contributionJar.openStream();
+ } catch (IOException e) {
+ throw new ActivationException(e);
+ }
+ Contribution contribution;
+ try {
+ contribution = contributionService.contribute(contributionJar.toString(), contributionJar, is, modelResolver);
+ } catch (Exception e) {
+ throw new ActivationException(e);
+ }
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ throw new ActivationException(e);
+ }
+ }
+ return contribution;
+ }
+ */
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/DomainManagerServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/DomainManagerServiceImpl.java
new file mode 100644
index 0000000000..5f33ba0191
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/DomainManagerServiceImpl.java
@@ -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.impl;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.domain.DomainManagerService;
+import org.apache.tuscany.sca.domain.NodeInfo;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+
+/**
+ * Stores details of services exposed and retrieves details of remote services
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+@Scope("COMPOSITE")
+public class DomainManagerServiceImpl implements DomainManagerService{
+
+ private final static Logger logger = Logger.getLogger(DomainManagerServiceImpl.class.getName());
+
+ @Property
+ protected int retryCount = 100;
+
+ @Property
+ protected int retryInterval = 5000; //ms
+
+ @Reference
+ protected DomainManagerService domainManager;
+
+ public String registerNode(String domainUri, String nodeUri) {
+
+ String returnValue = null;
+
+ for (int i =0; i < retryCount; i++){
+ try {
+ returnValue = domainManager.registerNode(domainUri, nodeUri);
+ break;
+ } catch(UndeclaredThrowableException ex) {
+ logger.log(Level.INFO, "Trying to regsiter node " +
+ nodeUri +
+ " with domain " +
+ domainUri);
+
+ }
+
+ try {
+ Thread.sleep(retryInterval);
+ } catch(InterruptedException ex) {
+ }
+ }
+
+ return returnValue;
+ }
+
+ public String removeNode(String domainUri, String nodeUri) {
+ return domainManager.removeNode(domainUri, nodeUri);
+ }
+
+ public List<NodeInfo> getNodeInfo(){
+ return domainManager.getNodeInfo();
+ }
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
new file mode 100644
index 0000000000..14ba5fa1f9
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
@@ -0,0 +1,48 @@
+/*
+ * 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.impl;
+
+import org.apache.tuscany.sca.node.NodeFactory;
+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 class NodeFactoryImpl implements NodeFactory {
+
+ SCANode node = null;
+
+ public NodeFactoryImpl(SCANode node){
+ this.node = node;
+ }
+
+ /**
+ * Returns the domain object
+ *
+ * @return the domain
+ */
+ public SCANode getNode(){
+ return node;
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeManagerServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeManagerServiceImpl.java
new file mode 100644
index 0000000000..41de823845
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeManagerServiceImpl.java
@@ -0,0 +1,84 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+import org.apache.tuscany.sca.node.ComponentInfo;
+import org.apache.tuscany.sca.node.ComponentManagerService;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.NodeManagerInitService;
+import org.apache.tuscany.sca.node.NodeManagerService;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Stores details of services exposed and retrieves details of remote services
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-11 18:45:36 +0100 (Tue, 11 Sep 2007) $
+ */
+@Scope("COMPOSITE")
+@Service(interfaces = {NodeManagerService.class, NodeManagerInitService.class, ComponentManagerService.class})
+public class NodeManagerServiceImpl implements NodeManagerService, NodeManagerInitService, ComponentManagerService {
+
+ private SCANode node;
+
+ public String getNodeUri() {
+ return node.getNodeURI();
+ }
+
+ // NodeManagerInitService
+ public void setNode(SCANode node) {
+ this.node = node;
+ }
+
+ // ComponentManagerService
+ public List<ComponentInfo> getComponentInfos() {
+ List<ComponentInfo> componentInfos = new ArrayList<ComponentInfo>();
+ for (Component component : node.getComponentManager().getComponents()) {
+ ComponentInfo componentInfo = new ComponentInfoImpl();
+ componentInfo.setName(component.getName());
+ componentInfo.setStarted(node.getComponentManager().isComponentStarted(component));
+ componentInfos.add(componentInfo);
+ }
+ return componentInfos;
+ }
+
+ public ComponentInfo getComponentInfo(String componentName) {
+ Component component = node.getComponentManager().getComponent(componentName);
+ ComponentInfo componentInfo = new ComponentInfoImpl();
+ componentInfo.setName(component.getName());
+ componentInfo.setStarted(node.getComponentManager().isComponentStarted(component));
+ return componentInfo;
+ }
+
+ public void startComponent(String componentName) throws ActivationException {
+ node.getComponentManager().startComponent(node.getComponentManager().getComponent(componentName));
+ }
+
+ public void stopComponent(String componentName) throws ActivationException {
+ node.getComponentManager().stopComponent(node.getComponentManager().getComponent(componentName));
+ }
+
+ // TODO - ContributionManagerService
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCADomainServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCADomainServiceImpl.java
new file mode 100644
index 0000000000..328d18c5d7
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCADomainServiceImpl.java
@@ -0,0 +1,158 @@
+/*
+ * 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.impl;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.domain.SCADomainService;
+import org.apache.tuscany.sca.domain.ServiceInfo;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * Stores details of services exposed and retrieves details of remote services
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-09 23:54:46 +0100 (Sun, 09 Sep 2007) $
+ */
+public class SCADomainServiceImpl implements SCADomainService{
+
+ private final static Logger logger = Logger.getLogger(SCADomainServiceImpl.class.getName());
+
+ @Property
+ protected int retryCount = 100;
+
+ @Property
+ protected int retryInterval = 5000; //ms
+
+
+ @Reference
+ protected SCADomainService scaDomainService;
+
+ /**
+ * Accepts information about a service endpoint and holds onto it
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param nodeUri the string uri for the current node
+ * @param serviceName the name of the service that is exposed and the provided endpoint
+ * @param bindingName the remote binding that is providing the endpoint
+ * @param url the endpoint url
+ * @return dummy values just so that we don't have a void return which doesn't work
+ */
+ public String registerServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName, String URL){
+
+ String dummy = null;
+
+ for (int i =0; i < retryCount; i++){
+ try {
+ dummy = scaDomainService.registerServiceEndpoint(domainUri, nodeUri, serviceName, bindingName, URL);
+ break;
+ } catch(UndeclaredThrowableException ex) {
+ logger.log(Level.INFO, "Trying to connect to domain " +
+ domainUri +
+ " to register service " +
+ serviceName);
+
+ }
+
+ try {
+ Thread.sleep(retryInterval);
+ } catch(InterruptedException ex) {
+ }
+ }
+
+ return dummy;
+ }
+
+ /**
+ * Removes information about a service endpoint
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param nodeUri the string uri for the current node
+ * @param serviceName the name of the service that is exposed and the provided endpoint
+ * @param bindingName the remote binding that is providing the endpoint
+ * @return dummy values just so that we don't have a void return which doesn't work
+ */
+ public String removeServiceEndpoint(String domainUri, String nodeUri, String serviceName, String bindingName){
+
+ String dummy = null;
+
+ for (int i =0; i < retryCount; i++){
+ try {
+ dummy = scaDomainService.removeServiceEndpoint(domainUri, nodeUri, serviceName, bindingName);
+ break;
+ } catch(UndeclaredThrowableException ex) {
+ logger.log(Level.INFO, "Trying to connect to domain " +
+ domainUri +
+ " to remove service " +
+ serviceName);
+
+ }
+
+ try {
+ Thread.sleep(retryInterval);
+ } catch(InterruptedException ex) {
+ }
+ }
+
+ return dummy;
+ }
+
+ /**
+ * Locates information about a service endpoint
+ *
+ * @param domainUri the string uri for the distributed domain
+ * @param serviceName the name of the service that is exposed and the provided endpoint
+ * @param bindingName the remote binding that we want to find an endpoint for
+ * @return url the endpoint url
+ */
+ public String findServiceEndpoint(String domainUri, String serviceName, String bindingName){
+
+
+ String url = null;
+
+ for (int i =0; i < retryCount; i++){
+ try {
+ url = scaDomainService.findServiceEndpoint(domainUri, serviceName, bindingName);
+ break;
+ } catch(UndeclaredThrowableException ex) {
+ logger.log(Level.INFO, "Trying to connect to domain " +
+ domainUri +
+ " to find service " +
+ serviceName);
+
+ }
+
+ try {
+ Thread.sleep(retryInterval);
+ } catch(InterruptedException ex) {
+ }
+ }
+
+ return url;
+ }
+
+ public ServiceInfo getServiceInfo(){
+ return scaDomainService.getServiceInfo();
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java
new file mode 100644
index 0000000000..30ab7e3ad2
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeImpl.java
@@ -0,0 +1,551 @@
+ /*
+ * 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.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.impl.ModelResolverImpl;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+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.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;
+import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * A local representation of the sca domain running on a single node
+ *
+ * @version $Rev: 552343 $ $Date: 2007-09-09 23:54:46 +0100 (Sun, 09 Sep 2007) $
+ */
+public class SCANodeImpl extends SCADomain implements SCANode {
+
+ private final static Logger logger = Logger.getLogger(SCANodeImpl.class.getName());
+
+ public final static String LOCAL_DOMAIN_URI = "standalonedomain";
+ public final static String LOCAL_NODE_URI = "standalonenode";
+
+ private boolean isStandalone = false;
+
+ // the domain used by the node to talk to the rest of the domain
+ private EmbeddedSCADomain managementRuntime;
+
+ // 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;
+ private String nodeUri;
+ private URL nodeUrl;
+ private ReallySmallRuntime nodeRuntime;
+ private Composite nodeComposite;
+
+ // the managers used to control the domain node
+ private ComponentManagerServiceImpl componentManager;
+ private ContributionManagerImpl contributionManager;
+
+ // the proxies to the domain
+ private SCADomainService scaDomain;
+ private DomainManagerService domainManager;
+ private NodeManagerInitService nodeManagerInit;
+
+ // methods defined on the implementation only
+
+ /**
+ * Default constructor creates a standalone node with no connectivity to a wider
+ * domain and no local web page.
+ */
+ public SCANodeImpl()
+ 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();
+ }
+
+ /**
+ * Creates a node connected to a wider domain. 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
+ * @throws ActivationException
+ */
+ public SCANodeImpl(String domainUri, String nodeUri)
+ 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();
+ }
+
+ /**
+ * 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
+ * @throws ActivationException
+ */
+ public SCANodeImpl(String domainUri, String nodeUri, ClassLoader cl)
+ throws ActivationException {
+ 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);
+ }
+
+ }
+
+ /**
+ * Work out if we are representing a domain in memory or can go out to the network to
+ * get domain information. This all depends on whether there is a management
+ * composite on the classpath
+ */
+ private void init()
+ throws ActivationException {
+ try {
+
+ // create a node runtime for the domain contributions to run on
+ nodeRuntime = new ReallySmallRuntime(domainClassLoader);
+
+ // Check if node has been given a domain name to connect to
+ if (isStandalone) {
+ logger.log(Level.INFO, "Domain node will be started stand-alone as node and domain URIs are not provided");
+ managementRuntime = null;
+ scaDomain = null;
+ } else {
+ // check where domain and node uris are urls, they will be used to configure various
+ // endpoints if they are
+ URI tmpURI;
+ try {
+ tmpURI = new URI(domainUri);
+ if (tmpURI.isAbsolute()){
+ domainUrl = tmpURI.toURL();
+ }
+ } catch(Exception ex) {
+ throw new ActivationException("domain uri " +
+ domainUri +
+ "must be a valid url");
+ }
+
+ try {
+ tmpURI = new URI(nodeUri);
+ if (tmpURI.isAbsolute()){
+ nodeUrl = tmpURI.toURL();
+ }
+ } catch(Exception ex) {
+ nodeUrl = null;
+ }
+
+ createManagementNode();
+ }
+ } catch(ActivationException ex) {
+ throw ex;
+ } catch(Exception ex) {
+ throw new ActivationException(ex);
+ }
+ }
+
+ private void createManagementNode()
+ throws ActivationException {
+ try {
+ // 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.findContributionURLFromCompositeNameOrPath(domainClassLoader, null, new String[]{nodeCompositeName} );
+
+ if ( contributionURL != null ){
+ logger.log(Level.INFO, "Node management configured from " + contributionURL);
+
+ // start a local domain in order to talk to the logical domain
+ managementRuntime = new EmbeddedSCADomain(domainClassLoader, "node");
+ managementRuntime.start();
+
+ // add node composite to the management domain
+ ContributionService contributionService = managementRuntime.getContributionService();
+ Contribution contribution = null;
+
+ contribution = contributionService.contribute(nodeUri,
+ contributionURL,
+ false);
+
+ if (contribution.getDeployables().size() != 0) {
+ Composite composite = contribution.getDeployables().get(0);
+
+ managementRuntime.getDomainComposite().getIncludes().add(composite);
+ managementRuntime.getCompositeBuilder().build(composite);
+
+ // deal with the special case of registering the node manager service
+ // in service discovery. It's not on an SCA binding.
+ // TODO - really want to be able to hand out service references but they
+ // don't serialize out over web services yet.
+ SCANodeUtil.fixUpNodeServiceUrls(managementRuntime.getDomainComposite().getIncludes().get(0).getComponents(), nodeUrl);
+ SCANodeUtil.fixUpNodeReferenceUrls(managementRuntime.getDomainComposite().getIncludes().get(0).getComponents(), domainUrl);
+
+ managementRuntime.getCompositeActivator().activate(composite);
+ managementRuntime.getCompositeActivator().start(composite);
+
+ // get the management components out of the domain so that they
+ // can be configured/used.
+ scaDomain = managementRuntime.getService(SCADomainService.class, "SCADomainComponent");
+ domainManager = managementRuntime.getService(DomainManagerService.class, "DomainManagerComponent");
+ nodeManagerInit = managementRuntime.getService(NodeManagerInitService.class, "NodeManagerComponent/NodeManagerInitService");
+
+ // Now get the uri back out of the component now it has been built and started
+ // TODO - this doesn't pick up the url from external hosting environments
+ String nodeManagerUrl = SCANodeUtil.getNodeManagerServiceUrl(managementRuntime.getDomainComposite().getIncludes().get(0).getComponents());
+
+ if (nodeManagerUrl != null) {
+ if (isStandalone == false){
+ try {
+
+ scaDomain.registerServiceEndpoint(domainUri,
+ nodeUri,
+ nodeUri + "NodeManagerService",
+ "",
+ nodeManagerUrl);
+
+ } catch(Exception ex) {
+ logger.log(Level.SEVERE,
+ "Can't connect to domain manager at: " +
+ domainUrl);
+ throw new ActivationException(ex);
+ }
+ }
+ }
+
+ } else {
+ throw new ActivationException("Node management contribution " +
+ contributionURL +
+ " found but could not be loaded");
+ }
+ } else {
+ throw new ActivationException("Node management contribution " +
+ nodeCompositeName +
+ " not found on the classpath");
+ }
+ } catch(ActivationException ex) {
+ throw ex;
+ } catch(Exception ex) {
+ throw new ActivationException(ex);
+ }
+ }
+
+
+ // methods that implement interfaces
+
+ public void start() throws ActivationException {
+ // Start the runtime
+ nodeRuntime.start();
+
+ // Create an in-memory domain level composite
+ AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
+ nodeComposite = assemblyFactory.createComposite();
+ nodeComposite.setName(new QName(Constants.SCA10_NS, "domain"));
+ nodeComposite.setURI(domainUri);
+
+ // add the top level composite into the composite activator
+ nodeRuntime.getCompositeActivator().setDomainComposite(nodeComposite);
+
+ // make the domain available to the model.
+ // TODO - No sure how this should be done properly. As a nod to this though
+ // I have a domain factory which always returns the same domain
+ // object. I.e. this node
+ ModelFactoryExtensionPoint factories = nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
+ 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, applicationClassLoader, null);
+
+ if (isStandalone == false){
+ // pass this object into the node manager
+ nodeManagerInit.setNode((SCANode)this);
+
+ try {
+ // go out and add this node to the wider domain
+ domainManager.registerNode(domainUri, nodeUri);
+ } catch(Exception ex) {
+ logger.log(Level.SEVERE,
+ "Can't connect to domain manager at: " +
+ domainUrl);
+ throw new ActivationException(ex);
+ }
+ }
+ }
+
+ @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();
+
+ // Cleanup the top level composite
+ nodeComposite = null;
+
+ // remove the manager objects
+
+ // go out and remove this node from the wider domain
+ if (isStandalone == false){
+ try {
+ domainManager.removeNode(domainUri, nodeUri);
+ } catch(Exception ex) {
+ logger.log(Level.SEVERE,
+ "Can't connect to domain manager at: " +
+ domainUrl);
+ throw new ActivationException(ex);
+ }
+ }
+ }
+
+ public String getURI(){
+ return domainUri;
+ }
+
+ public String getDomainURI(){
+ return domainUri;
+ }
+
+ public String getNodeURI(){
+ return nodeUri;
+ }
+
+ public URL getDomainURL(){
+ return domainUrl;
+ }
+
+ public URL getNodeURL(){
+ return nodeUrl;
+ }
+
+ public ComponentManager getComponentManager() {
+ return componentManager;
+ }
+
+ public ContributionManager getContributionManager() {
+ return contributionManager;
+ }
+
+
+ /**
+ * Return an interface for registering local services and for
+ * finding remote services
+ *
+ * @return The service discovery interface
+ */
+ public SCADomainService getDomainService(){
+ return scaDomain;
+ }
+
+ public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
+ return (R)nodeRuntime.getProxyFactory().cast(target);
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
+ if (serviceReference == null) {
+ throw new ServiceRuntimeException("Service not found: " + serviceName);
+ }
+ return serviceReference.getService();
+ }
+
+ private <B> ServiceReference<B> createServiceReference(Class<B> businessInterface, String targetURI) {
+ try {
+ AssemblyFactory assemblyFactory = nodeRuntime.getAssemblyFactory();
+ Composite composite = assemblyFactory.createComposite();
+ composite.setName(new QName(Constants.SCA10_TUSCANY_NS, "default"));
+ RuntimeComponent component = (RuntimeComponent)assemblyFactory.createComponent();
+ component.setName("default");
+ component.setURI("default");
+ nodeRuntime.getCompositeActivator().configureComponentContext(component);
+ composite.getComponents().add(component);
+ RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
+ reference.setName("default");
+ ModelFactoryExtensionPoint factories =
+ nodeRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
+ JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
+ reference.setInterfaceContract(interfaceContract);
+ component.getReferences().add(reference);
+ reference.setComponent(component);
+ SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
+ SCABinding binding = scaBindingFactory.createSCABinding();
+ binding.setURI(targetURI);
+ reference.getBindings().add(binding);
+ return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, nodeRuntime
+ .getProxyFactory(), nodeRuntime.getCompositeActivator());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String name) {
+
+ // Extract the component name
+ String componentName;
+ String serviceName;
+ int i = name.indexOf('/');
+ if (i != -1) {
+ componentName = name.substring(0, i);
+ serviceName = name.substring(i + 1);
+
+ } else {
+ componentName = name;
+ serviceName = null;
+ }
+
+ // Lookup the component in the domain
+ Component component = componentManager.getComponent(componentName);
+ if (component == null) {
+ // The component is not local in the partition, try to create a remote service ref
+ return createServiceReference(businessInterface, name);
+ }
+ RuntimeComponentContext componentContext = null;
+
+ // If the component is a composite, then we need to find the
+ // non-composite component that provides the requested service
+ if (component.getImplementation() instanceof Composite) {
+ for (ComponentService componentService : component.getServices()) {
+ if (serviceName == null || serviceName.equals(componentService.getName())) {
+ CompositeService compositeService = (CompositeService)componentService.getService();
+ if (compositeService != null) {
+ if (serviceName != null) {
+ serviceName = "$promoted$." + serviceName;
+ }
+ componentContext =
+ ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
+ return componentContext.createSelfReference(businessInterface, compositeService
+ .getPromotedService());
+ }
+ break;
+ }
+ }
+ // No matching service is found
+ throw new ServiceRuntimeException("Composite service not found: " + name);
+ } else {
+ componentContext = ((RuntimeComponent)component).getComponentContext();
+ if (serviceName != null) {
+ return componentContext.createSelfReference(businessInterface, serviceName);
+ } else {
+ return componentContext.createSelfReference(businessInterface);
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java
new file mode 100644
index 0000000000..84bdd465c4
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/SCANodeUtil.java
@@ -0,0 +1,456 @@
+/*
+ * 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.impl;
+
+import java.io.IOException;
+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;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+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.NodeFactory;
+import org.apache.tuscany.sca.domain.SCADomain;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
+
+
+/**
+ * Some utility methods for the Node implementation
+ *
+ * @version $Rev: 556897 $ $Date: 2007-09-07 12:41:52 +0100 (Fri, 07 Sep 2007) $
+ */
+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.
+ *
+ * @param classLoader
+ * @param compositeString
+ * @return the contribution URL
+ * @throws MalformedURLException
+ */
+/*
+ public static URL findContributionFromComposite(ClassLoader classLoader, String compositeString)
+ throws MalformedURLException {
+
+ URL contributionURL = classLoader.getResource(compositeString);
+
+ if ( contributionURL != null ){
+ String contributionString = contributionURL.toExternalForm();
+ int jarPosition = contributionString.indexOf(".jar");
+
+ if (jarPosition> -1){
+ // if the node dir is in a jar just contribute the name of the jar file
+ // rather the name of the directory in the jar file.
+ // changing
+ // jar:file:/myjarfile.jar!/contributiondir
+ // to
+ // file:/myjarfile.jar
+ contributionString = contributionString.substring(0, jarPosition + 4);
+ contributionString = contributionString.substring(4);
+ contributionURL = new URL(contributionString);
+ } else {
+ // Assume the node.composite file is in a directory so find the directory name
+ // changing
+ // file:/mydir/node.composite
+ // to
+ // file:/mydir
+ int compositePosition = contributionString.indexOf(compositeString);
+ contributionString = contributionString.substring(0, compositePosition);
+ contributionURL = new URL(contributionString);
+ }
+ }
+
+ return contributionURL;
+ }
+*/
+
+ /**
+ * A rather ugly method to find and fix the url of the service, assuming that there
+ * is one.
+ *
+ * we can't get is out of a service reference
+ * the component itself doesn't know how to get it
+ * the binding can't to do it automatically as it's not the sca binding
+ *
+ * TODO - This would be better done by passing out a serializable reference to service discovery
+ * but this doesn't work yet
+ *
+ * @return node manager url
+ */
+ public static void fixUpNodeServiceUrls(List<Component> nodeComponents, URL nodeUrlString)
+ throws MalformedURLException, UnknownHostException {
+
+ for(Component component : nodeComponents){
+ for (ComponentService service : component.getServices() ){
+ for (Binding binding : service.getBindings() ) {
+ fixUpNodeServiceBindingUrl(binding, nodeUrlString);
+ }
+ }
+ }
+ }
+
+ /**
+ * Find and return the URL of the NodeManagerService
+ *
+ * @param nodeComponents
+ * @return
+ */
+ public static String getNodeManagerServiceUrl(List<Component> nodeComponents){
+ String nodeManagerUrl = null;
+
+ for(Component component : nodeComponents){
+ for (ComponentService service : component.getServices() ){
+
+ if ( service.getName().equals("NodeManagerService")) {
+ nodeManagerUrl = service.getBindings().get(0).getURI();
+ }
+ }
+ }
+
+ return nodeManagerUrl;
+ }
+
+ /**
+ * For node management services that use the http(s) protocol then use the node url as the enpoint
+ * if it has been specified otherwise find a port that isn't in use and make sure the domain name
+ * is the real domain name
+ *
+ * @param binding
+ * @param nodeURL the URL provided as the identifier of the node
+ */
+ public static void fixUpNodeServiceBindingUrl(Binding binding, URL manualUrl)
+ throws MalformedURLException, UnknownHostException{
+
+ String urlString = binding.getURI();
+
+ // only going to fiddle with bindings that use HTTP protocol
+ if( (urlString == null) ||
+ ((urlString.startsWith("http") != true ) &&
+ (urlString.startsWith("https") != true )) ||
+ (binding instanceof SCABinding)) {
+ return;
+ }
+
+ URL bindingUrl = new URL(urlString);
+ String originalHost = bindingUrl.getHost();
+ String newHost = null;
+ int originalPort = bindingUrl.getPort();
+ int newPort = 0;
+
+ if (manualUrl != null) {
+ // the required url has been specified manually
+ newHost = manualUrl.getHost();
+ newPort = manualUrl.getPort();
+
+ if ( newHost.equals("localhost")){
+ newHost = InetAddress.getLocalHost().getHostName();
+ }
+ } else {
+ // discover the host and port information
+ newHost = InetAddress.getLocalHost().getHostName();
+ newPort = findFreePort(originalPort);
+ }
+
+ // replace the old with the new
+ urlString = urlString.replace(String.valueOf(originalPort), String.valueOf(newPort));
+ urlString = urlString.replace(originalHost, newHost);
+
+ // set the address back into the NodeManager binding.
+ binding.setURI(urlString);
+ }
+
+ /**
+ * Find a port on this machine that isn't in use.
+ *
+ * @param startPort
+ * @return
+ */
+ public static int findFreePort(int startPort)
+ {
+ boolean portIsBusy = true;
+ int freePort = startPort;
+
+ do {
+ try {
+ ServerSocket socket = new ServerSocket(freePort);
+ portIsBusy = false;
+ socket.close();
+ break;
+ }
+ catch (IOException ex) {
+ // the port is busy
+ freePort = freePort + 1;
+ }
+ } while (portIsBusy || freePort > 9999);
+
+ return freePort;
+ }
+
+ /**
+ * For node services that have to talk to the domain fix up the reference URL using the
+ * provided domain url if it has been provided
+ *
+ * @param nodeComponents
+ * @param domainUrlString
+ * @throws MalformedURLException
+ * @throws UnknownHostException
+ */
+ public static void fixUpNodeReferenceUrls(List<Component> nodeComponents, URL domainUrl)
+ throws MalformedURLException, UnknownHostException, ActivationException{
+
+ for(Component component : nodeComponents){
+ for (ComponentReference reference : component.getReferences() ){
+ if ( reference.getName().equals("domainManager") ||
+ reference.getName().equals("scaDomainService")) {
+ for (Binding binding : reference.getBindings() ) {
+ fixUpNodeReferenceBindingUrl(binding, domainUrl);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * For node management references to the domain fix up the binding URLs so that they point
+ * to the endpoint described in the domainURL
+ *
+ * @param binding
+ * @param nodeURL the URL provided as the identifier of the node
+ */
+ public static void fixUpNodeReferenceBindingUrl(Binding binding, URL manualUrl)
+ throws MalformedURLException, UnknownHostException, ActivationException{
+
+ String urlString = binding.getURI();
+
+ // only going to fiddle with bindings that use HTTP protocol
+ if( (urlString == null) ||
+ ((urlString.startsWith("http") != true ) &&
+ (urlString.startsWith("https") != true )) ||
+ (binding instanceof SCABinding) ) {
+ return;
+ }
+
+ URL bindingUrl = new URL(urlString);
+ String originalHost = bindingUrl.getHost();
+ String newHost = null;
+ int originalPort = bindingUrl.getPort();
+ int newPort = 0;
+
+ if (manualUrl != null) {
+ // the required url has been specified manually
+ newHost = manualUrl.getHost();
+ newPort = manualUrl.getPort();
+ } else {
+ throw new ActivationException("domain uri can't be null");
+ }
+
+ // replace the old with the new
+ urlString = urlString.replace(String.valueOf(originalPort), String.valueOf(newPort));
+ urlString = urlString.replace(originalHost, newHost);
+
+ // set the address back into the NodeManager binding.
+ binding.setURI(urlString);
+ }
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/AddService.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/AddService.java
new file mode 100644
index 0000000000..797ebb4024
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/AddService.java
@@ -0,0 +1,31 @@
+/*
+ * 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 calculator;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * The Add service interface
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/AddServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..1a63d4ff77
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/AddServiceImpl.java
@@ -0,0 +1,31 @@
+/*
+ * 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 calculator;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ System.out.println("AddService - add " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/CalculatorService.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..ad87375529
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/CalculatorService.java
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..8ee640ed6b
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/CalculatorServiceImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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 calculator;
+
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ public double add(double n1, double n2) {
+ System.out.println("CalculatorService - add " + n1 + " and " + n2);
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ System.out.println("CalculatorService - subtract " + n1 + " and " + n2);
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ System.out.println("CalculatorService - multiply " + n1 + " and " + n2);
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ System.out.println("CalculatorService - divide " + n1 + " and " + n2);
+ return divideService.divide(n1, n2);
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/DivideService.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/DivideService.java
new file mode 100644
index 0000000000..ef6a8b375b
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/DivideService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/DivideServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..8c33862f6d
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/DivideServiceImpl.java
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/MultiplyService.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..db568cc762
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/MultiplyService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..c7fbc73c00
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/MultiplyServiceImpl.java
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/SubtractService.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..615320e670
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/SubtractService.java
@@ -0,0 +1,31 @@
+/*
+ * 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 calculator;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * The interface for the multiply service
+ */
+@Remotable
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/SubtractServiceImpl.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..abf2777c7d
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/calculator/SubtractServiceImpl.java
@@ -0,0 +1,31 @@
+/*
+ * 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 calculator;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ System.out.println("SubtractService - subtract " + n1 + " and " + n2);
+ return n1 - n2;
+ }
+
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java
new file mode 100644
index 0000000000..6af687f95d
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/InMemoryTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * 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.impl;
+
+
+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;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import calculator.CalculatorService;
+
+/**
+ * Runs a distributed domain in a single VM by using and in memory
+ * implementation of the distributed domain
+ */
+public class InMemoryTestCase {
+
+ private static String DEFAULT_DOMAIN_URI = "http://localhost:8877";
+
+ private static SCADomain registry;
+ private static SCADomain domainNodeA;
+ private static SCADomain domainNodeB;
+ private static SCADomain domainNodeC;
+ private static CalculatorService calculatorServiceA;
+ private static CalculatorService calculatorServiceB;
+
+ @BeforeClass
+ public static void init() throws Exception {
+
+ try {
+ System.out.println("Setting up domain registry");
+
+ registry = SCADomain.newInstance("domain.composite");
+
+ System.out.println("Setting up calculator ");
+
+ // Create the domain representation
+ domainNodeA = SCADomain.newInstance(DEFAULT_DOMAIN_URI, "nodeA", null, "nodeA/Calculator.composite");
+
+ // Create the domain representation
+ domainNodeB = SCADomain.newInstance(DEFAULT_DOMAIN_URI, "nodeB", null, "nodeB/Calculator.composite");
+
+ // create the node that runs the
+ // subtract component
+ 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
+ calculatorServiceA = domainNodeA.getService(CalculatorService.class, "CalculatorServiceComponent");
+ calculatorServiceB = domainNodeB.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ } catch(Exception ex){
+ System.err.println(ex.toString());
+ }
+
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ // stop the nodes and hence the domains they contain
+ domainNodeA.close();
+ domainNodeB.close();
+ domainNodeC.close();
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+
+ // Calculate
+ Assert.assertEquals(calculatorServiceA.add(3, 2), 5.0);
+ Assert.assertEquals(calculatorServiceA.subtract(3, 2), 1.0);
+ Assert.assertEquals(calculatorServiceA.multiply(3, 2), 6.0);
+ Assert.assertEquals(calculatorServiceA.divide(3, 2), 1.5);
+ Assert.assertEquals(calculatorServiceB.add(3, 2), 5.0);
+ Assert.assertEquals(calculatorServiceB.subtract(3, 2), 1.0);
+ Assert.assertEquals(calculatorServiceB.multiply(3, 2), 6.0);
+ Assert.assertEquals(calculatorServiceB.divide(3, 2), 1.5);
+
+ }
+}
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/Calculator.composite b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/Calculator.composite
new file mode 100644
index 0000000000..138a9c5652
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/Calculator.composite
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl" />
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl" />
+ </component>
+
+</composite>
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3f9ed8024b
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/add.wsdl b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/add.wsdl
new file mode 100644
index 0000000000..5dda2c214e
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/add.wsdl
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://calculator/add"
+ xmlns:tns="http://calculator/add"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="add">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://calculator/add"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="add">
+ <complexType>
+ <sequence>
+ <element name="n1" type="xsd:double"/>
+ <element name="n2" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="addResponse">
+ <complexType>
+ <sequence>
+ <element name="response" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="addRequest">
+ <wsdl:part element="tns:add" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="addResponse">
+ <wsdl:part element="tns:addResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Add">
+ <wsdl:operation name="add">
+ <wsdl:input message="tns:addRequest" name="addRequest"/>
+ <wsdl:output message="tns:addResponse" name="addResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="AddSoapBinding" type="tns:Add">
+ <wsdlsoap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="add">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="addRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="addResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="AddService">
+ <wsdl:port binding="tns:AddSoapBinding" name="AddSoapPort">
+ <!--wsdlsoap:address location="http://localhost:8085/sample-calculator-webapp-ws/services/AddService"/-->
+ <wsdlsoap:address location="http://localhost:8085/AddServiceComponent"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/multiply.wsdl b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/multiply.wsdl
new file mode 100644
index 0000000000..81033cc9ec
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/multiply.wsdl
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://calculator/multiply"
+ xmlns:tns="http://calculator/multiply"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="multiply">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://calculator/multiply"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="multiply">
+ <complexType>
+ <sequence>
+ <element name="n1" type="xsd:double"/>
+ <element name="n2" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="multiplyResponse">
+ <complexType>
+ <sequence>
+ <element name="response" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="multiplyRequest">
+ <wsdl:part element="tns:multiply" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="multiplyResponse">
+ <wsdl:part element="tns:multiplyResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Multiply">
+ <wsdl:operation name="multiply">
+ <wsdl:input message="tns:multiplyRequest" name="multiplyRequest"/>
+ <wsdl:output message="tns:multiplyResponse" name="multiplyResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="MultiplySoapBinding" type="tns:Multiply">
+ <wsdlsoap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="multiply">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="multiplyRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="multiplyResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+</wsdl:definitions>
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/subtract.wsdl b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/subtract.wsdl
new file mode 100644
index 0000000000..ed015d31c2
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeA/wsdl/subtract.wsdl
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://calculator/subtract"
+ xmlns:tns="http://calculator/subtract"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="subtract">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified"
+ targetNamespace="http://calculator/subtract"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="subtract">
+ <complexType>
+ <sequence>
+ <element name="n1" type="xsd:double"/>
+ <element name="n2" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="subtractResponse">
+ <complexType>
+ <sequence>
+ <element name="response" type="xsd:double"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="subtractRequest">
+ <wsdl:part element="tns:subtract" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="subtractResponse">
+ <wsdl:part element="tns:subtractResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Subtract">
+ <wsdl:operation name="subtract">
+ <wsdl:input message="tns:subtractRequest" name="subtractRequest"/>
+ <wsdl:output message="tns:subtractResponse" name="subtractResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="SubtractSoapBinding" type="tns:Subtract">
+ <wsdlsoap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="subtract">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="subtractRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="subtractResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="SubtractService">
+ <wsdl:port binding="tns:SubtractSoapBinding" name="SubtractSoapPort">
+ <wsdlsoap:address location="http://localhost:8088/SubtractServiceComponent"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeB/Calculator.composite b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeB/Calculator.composite
new file mode 100644
index 0000000000..08abaf40ce
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeB/Calculator.composite
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent" />
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl" />
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl" />
+ </component>
+
+</composite>
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeB/META-INF/sca-contribution.xml b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeB/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3f9ed8024b
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeB/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeC/Calculator.composite b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeC/Calculator.composite
new file mode 100644
index 0000000000..4ef4c5ddb6
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeC/Calculator.composite
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl" />
+ <service name="SubtractService">
+ <binding.sca uri="http://localhost:8086/SubtractServiceComponent"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeC/META-INF/sca-contribution.xml b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeC/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3f9ed8024b
--- /dev/null
+++ b/tags/java/sca/1.0-RC1b/modules/node-impl/src/test/resources/nodeC/META-INF/sca-contribution.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file