summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src')
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java274
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java371
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ContributionHelper.java80
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DependencyUtils.java76
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java185
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java656
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/RemoteCommand.java83
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java211
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/hotupdate/HotUpdater.java111
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/hotupdate/LastModifiedTracker.java75
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/itest/nodes/Helloworld.java29
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/ContributionClassLoaderTestCase.java49
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/ContributionUpdateTestCase.java75
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DependencyUtilsTestCase.java61
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DeployerTestCase.java51
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java123
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java315
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/UsedCompositesTestCase.java79
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/ClassLoaderReleaseTestCase.java66
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java96
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java71
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DynamicTestCase.java116
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java48
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java74
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java190
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java52
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/sample/Helloworld.java27
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/compositeImpl.composite30
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/export.jarbin0 -> 2285 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld-invalidComposite.jarbin0 -> 4868 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld2.composite29
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld2.jarbin0 -> 5620 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworldNode.xml27
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/import.jarbin0 -> 3932 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/include.composite28
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jarbin0 -> 4779 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jarbin0 -> 4586 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/nested.composite28
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jarbin0 -> 4761 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld.jarbin0 -> 4808 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld2.jarbin0 -> 4845 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sca-contribution-generated.xml23
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/domain.properties17
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.deployable.composite29
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.jarbin0 -> 4788 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.xml23
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/readme.txt8
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml27
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/readme.txt2
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/default/readme.txt4
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/default/sample-helloworld.jarbin0 -> 4808 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/export1.jarbin0 -> 2270 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/export2.jarbin0 -> 2269 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import1.dependencies19
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import1.jarbin0 -> 3969 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import2.dependencies19
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import2.jarbin0 -> 3969 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/readme.txt14
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/readme.txt4
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld.jarbin0 -> 4808 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/MANIFEST.MF14
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/maven/org.apache.tuscany.sca/sample-helloworld/pom.properties5
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/maven/org.apache.tuscany.sca/sample-helloworld/pom.xml58
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/sca-contribution.xml24
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/helloworld.composite29
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/sample/Helloworld.classbin0 -> 251 bytes
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/sample/HelloworldImpl.classbin0 -> 819 bytes
67 files changed, 4105 insertions, 0 deletions
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java
new file mode 100644
index 0000000000..b316ae7cbd
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java
@@ -0,0 +1,274 @@
+/*
+ * 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;
+
+import java.io.Reader;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.ContributionDescription;
+import org.oasisopen.sca.NoSuchServiceException;
+
+/**
+ * A Node provides APIs to configure, update, and view an SCA domain
+ */
+public interface Node {
+
+ /**
+ * Creates an installed contribution from a supplied root contribution URL.
+ * See section 10.5.1 of the Assembly Specification. This method is the same
+ * as calling installContribution(null, contributionURL, null, null)
+ *
+ * @param contributionURL the URL where the contribution is located
+ * @return the URI of the installed contribution
+ *
+ * @throws ContributionReadException
+ * @throws ValidationException
+ */
+ String installContribution(String contributionURL) throws ContributionReadException, ValidationException;
+
+ /**
+ * Creates an installed contribution from a supplied root contribution and installed at a supplied base URI.
+ * See section 10.5.1 of the Assembly Specification.
+ *
+ * @param uri the base uri of where to install the contribution. May be null in which case a URI is derived from the contribution URL
+ * @param contributionURL the URL where the contribution is located
+ * @param metaDataURL the location of an optional generated Contribution Metadata Document. See section 10.2.2
+ * of the Assembly Specification. May be null.
+ * @param dependentContributionURIs specifies the contributions that are used to resolve the dependencies of the
+ * root contribution and other dependent contributions. May be null.
+ * @return the URI of the installed contribution
+ *
+ * @throws ContributionReadException
+ * @throws ValidationException
+ */
+ String installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs) throws ContributionReadException, ValidationException;
+
+ /**
+ * Creates an installed contribution from a supplied Contribution object.
+ * See section 10.5.1 of the Assembly Specification.
+ *
+ * @param contribution the Contribution object
+ * @param dependentContributionURIs specifies the contributions that are used to resolve the dependencies of the
+ * root contribution and other dependent contributions. May be null.
+ */
+ void installContribution(Contribution contribution, List<String> dependentContributionURIs);
+
+ /**
+ * 4599 10.5.2 add Deployment Composite & update Deployment Composite
+ * 4600 Adds or updates a deployment composite using a supplied composite ("composite by value" - a data
+ * 4601 structure, not an existing resource in the Domain) to the contribution identified by a supplied contribution
+ * 4602 URI. The added or updated deployment composite is given a relative URI that matches the @name
+ * 4603 attribute of the composite, with a ".composite" suffix. Since all composites run within the context of a
+ * 4604 installed contribution (any component implementations or other definitions are resolved within that
+ * 4605 contribution), this functionality makes it possible for the deployer to create a composite with final
+ * 4606 configuration and wiring decisions and add it to an installed contribution without having to modify the
+ * 4607 contents of the root contribution.
+ * 4608 Also, in some use cases, a contribution might include only implementation code (e.g. PHP scripts). It is
+ * 4609 then possible for those to be given component names by a (possibly generated) composite that is added
+ * 4610 into the installed contribution, without having to modify the packaging. *
+ *
+ * @param contributionURI the URI of the installed contribution to add the composite to
+ * @param compositeXML the composite to add to the contribution
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ActivationException, ValidationException;
+
+ /**
+ * 4599 10.5.2 add Deployment Composite & update Deployment Composite
+ * 4600 Adds or updates a deployment composite using a supplied composite ("composite by value" - a data
+ * 4601 structure, not an existing resource in the Domain) to the contribution identified by a supplied contribution
+ * 4602 URI. The added or updated deployment composite is given a relative URI that matches the @name
+ * 4603 attribute of the composite, with a ".composite" suffix. Since all composites run within the context of a
+ * 4604 installed contribution (any component implementations or other definitions are resolved within that
+ * 4605 contribution), this functionality makes it possible for the deployer to create a composite with final
+ * 4606 configuration and wiring decisions and add it to an installed contribution without having to modify the
+ * 4607 contents of the root contribution.
+ * 4608 Also, in some use cases, a contribution might include only implementation code (e.g. PHP scripts). It is
+ * 4609 then possible for those to be given component names by a (possibly generated) composite that is added
+ * 4610 into the installed contribution, without having to modify the packaging. *
+ *
+ * @param contributionURI the URI of the installed contribution to add the composite to
+ * @param composite the Composite to add to the contribution
+ * @return
+ * @throws XMLStreamException
+ * @throws ContributionReadException
+ * @throws ActivationException
+ * @throws ValidationException
+ */
+ String addDeploymentComposite(String contributionURI, Composite composite) throws ActivationException, ValidationException;
+
+ /**
+ * 4611 11.4.310.5.3 remove Contribution
+ * 4612 Removes the deployed contribution identified by a supplied contribution URI.
+ *
+ * @param contributionURI
+ * @return List of contribution URIs (includes dependent contributions) which were removed
+ */
+ void uninstallContribution(String contributionURI);
+
+ /**
+ * 4677 10.7.1 add To Domain-Level Composite
+ * 4678 This functionality adds the composite identified by a supplied URI to the Domain Level Composite. The
+ * 4679 supplied composite URI refers to a composite within an installed contribution. The composite's installed
+ * 4680 contribution determines how the composite's artifacts are resolved (directly and indirectly). The supplied
+ * 4681 composite is added to the domain composite with semantics that correspond to the domain-level
+ * 4683 components become top-level components and the component services become externally visible
+ * 4684 services (eg. they would be present in a WSDL description of the Domain). The meaning of any promoted
+ * 4685 services and references in the supplied composite is not defined; since there is no composite scope
+ * 4686 outside the domain composite, the usual idea of promotion has no utility.
+ *
+ * @param cotributionURI
+ * @param compositeURI
+ * @throws ActivationException
+ * @throws ValidationException
+ * @throws ContributionReadException
+ */
+ void startComposite(String contributionURI, String compositeURI) throws ActivationException, ValidationException, ContributionReadException;
+ void startComposite(String contributionURI, String compositeURI, String nodeName) throws ActivationException;
+
+ void stopCompositeAndUninstallUnused(String contributionURI, String compositeURI) throws ActivationException;
+
+ /**
+ * 4687 10.7.2 remove From Domain-Level Composite
+ * 4688 Removes from the Domain Level composite the elements corresponding to the composite identified by a
+ * 4689 supplied composite URI. This means that the removal of the components, wires, services and references
+ * 4690 originally added to the domain level composite by the identified composite.
+ * @param contributionURI
+ * @param compositeURI
+ * @throws ActivationException
+ */
+ void stopComposite(String contributionURI, String compositeURI) throws ActivationException;
+
+ /**
+ * Starts all the deployable composites in a contriubution
+ * @param contributionURI
+ * @return the list of composite URIs which were started
+ * @throws ActivationException
+ * @throws ValidationException
+ * @throws ContributionReadException
+ */
+ List<String> startDeployables(String contributionURI) throws ActivationException, ValidationException, ContributionReadException;
+
+ /**
+ * 10.7.3 get Domain-Level Composite
+ * Returns a <composite> definition that has an <include> line for each composite that had been added to
+ * the domain level composite. It is important to note that, in dereferencing the included composites, any
+ * referenced artifacts are resolved in terms of that installed composite.
+ *
+ * @return
+ */
+ Composite getDomainComposite();
+
+ /**
+ * 4695 10.7.4 get QName Definition
+ * 4696 In order to make sense of the domain-level composite (as returned by get Domain-Level Composite), it
+ * 4697 needs to be possible to get the definitions for named artifacts in the included composites. This
+ * 4698 functionality takes the supplied URI of an installed contribution (which provides the context), a supplied
+ * 4699 qualified name of a definition to look up, and a supplied symbol space (as a QName, e.g.
+ * 4700 wsdl:PortTypeportType). The result is a single definition, in whatever form is appropriate for that
+ * 4701 definition type.
+ * 4702 Note that this, like all the other domain-level operations, is a conceptual operation. Its capabilities need to
+ * 4703 exist in some form, but not necessarily as a service operation with exactly this signature.
+ * @param contributionURI
+ * @param definition
+ * @param symbolSpace
+ * @return
+ */
+ Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace);
+
+// /**
+// * Probably want to be able to stop it all at once so a method called stop or shutdown or destroy
+// */
+ void stop();
+
+ /**
+ * Would also be convenient to get service proxys as from SCAClientFactory
+ */
+ <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException;
+
+ /**
+ * Get the URIs of any composites that have been started in the domain
+ * @return a map with key contributionURI and value a list of the started compositeURIs
+ */
+ Map<String, List<String>> getStartedCompositeURIs();
+
+ /**
+ * Get the URIs of all the contributions installed on this Node
+ * @return the list of installed contribution URIs
+ */
+ List<String> getInstalledContributionURIs();
+
+ /**
+ * Get an installed Contribution
+ * @param uri the URI of the contribution
+ * @return the Contribution
+ * @throws ValidationException
+ * @throws ContributionReadException
+ */
+ Contribution getContribution(String uri) throws ContributionReadException, ValidationException;
+
+ /**
+ * Gets the Domain URI used to configure this Node.
+ *
+ * @return the domain uri string
+ */
+ String getDomainURI();
+
+ /**
+ * Gets the Domain name of this Node.
+ *
+ * @return the domain name
+ */
+ String getDomainName();
+
+ List<String> getDeployableCompositeURIs(String contributionURI);
+ // TODO: should this be exposed on the interface?
+ public ContributionDescription getInstalledContribution(String contributionURI);
+
+ void validateContribution(String string) throws ContributionReadException, ValidationException;
+
+ // TODO: should these member getters be replaced with a getDomainRegistry?
+ List<String> getNodeNames();
+ String getLocalNodeName();
+ String getRunningNodeName(String contributionURI, String compositeURI);
+
+ // TODO: Add methods to get:
+ // get/display contribution content
+ // a view-only Node
+ // dirty started composites (contributions updated while composite running)
+ // adding foreign endpoints to support domain federation, eg perhaps:
+ // void addForeignEndpoint(String serviceName, Binding b);
+ // void removeForeignEndpoint(String serviceName);
+ // List<String> getForeignEndpoints();
+ // Binding getForeignEndpoint(String serviceName);
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java
new file mode 100644
index 0000000000..08c4e3604f
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/TuscanyRuntime.java
@@ -0,0 +1,371 @@
+/*
+ * 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;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.impl.NodeImpl;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.node.configuration.ContributionConfiguration;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.DomainRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * The TuscanyRuntime is the main class for using Tuscany. It can create Nodes,
+ * run composites, and provides access to various utility APIs
+ */
+public class TuscanyRuntime {
+
+ public static final String DEFAUL_DOMAIN_NAME = "default";
+ private Deployer deployer;
+ private ExtensionPointRegistry extensionPointRegistry;
+ private CompositeActivator compositeActivator;
+ private ExtensibleDomainRegistryFactory domainRegistryFactory;
+ private RuntimeAssemblyFactory assemblyFactory;
+
+ /**
+ * Creates a new TuscanyRuntime
+ * @return a TuscanyRuntime
+ */
+ public static TuscanyRuntime newInstance() {
+ return new TuscanyRuntime(null);
+ }
+
+ /**
+ * Creates a new TuscanyRuntime
+ * @param config Properties to configure the TuscanyRuntime
+ * @return a TuscanyRuntime
+ */
+ public static TuscanyRuntime newInstance(Properties config) {
+ return new TuscanyRuntime(config);
+ }
+
+ /**
+ * A helper method to run a standalone SCA composite in the default standalone SCA domain.
+ * @param compositeURI URI within the contribution of a composite to run
+ * if compositeURI is null then all deployable composites in the contribution will be run
+ * @param contributionURL URL of the contribution
+ * @param dependentContributionURLs optional URLs of dependent contributions
+ * @return a Node with installed contributions
+ */
+ public static Node runComposite(String compositeURI, String contributionURL, String... dependentContributionURLs) {
+ return runComposite(null, compositeURI, contributionURL, dependentContributionURLs);
+ }
+
+ /**
+ * A helper method to run a standalone SCA composite in a SCA domain
+ * @param domainURI the URI of the SCA domain
+ * @param compositeURI URI within the contribution of a composite to run
+ * if compositeURI is null then all deployable composites in the contribution will be run
+ * @param contributionURL URL of the contribution
+ * @param dependentContributionURLs optional URLs of dependent contributions
+ * @return a Node with installed contributions
+ */
+ public static Node runComposite(URI domainURI, String compositeURI, String contributionURL, String... dependentContributionURLs) {
+ try {
+ TuscanyRuntime runtime = newInstance();
+ String domain = domainURI == null ? DEFAUL_DOMAIN_NAME : domainURI.toString();
+ DomainRegistry domainRegistry = runtime.domainRegistryFactory.getEndpointRegistry(domain, null);
+ NodeImpl node = new NodeImpl(runtime.deployer, runtime.compositeActivator, domainRegistry, runtime.extensionPointRegistry, runtime);
+
+ if (dependentContributionURLs != null) {
+ for (int i=dependentContributionURLs.length-1; i>-1; i--) {
+ node.installContribution(null, dependentContributionURLs[i], null, null);
+ }
+ }
+
+ String curi = node.installContribution(null, contributionURL, null, null);
+ if (compositeURI != null) {
+ node.startComposite(curi, compositeURI);
+ } else {
+ for (String compURI : node.getDeployableCompositeURIs(curi)) {
+ node.startComposite(curi, compURI);
+ }
+ }
+ return node;
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected TuscanyRuntime(Properties config) {
+ init(config);
+ }
+
+ /**
+ * Creates a Node
+ * @return a Node
+ */
+ public Node createNode() {
+ return createNode((String)null);
+ }
+
+ /**
+ * Creates a Node in an SCA domain
+ * @param domainURI the URI of the SCA domain
+ * @return a Node
+ */
+ public Node createNode(String domainURI) {
+ if (domainURI == null){
+ domainURI = DEFAUL_DOMAIN_NAME;
+ }
+ DomainRegistry domainRegistry = domainRegistryFactory.getEndpointRegistry(domainURI, null);
+ return new NodeImpl(deployer, compositeActivator, domainRegistry, extensionPointRegistry, null);
+ }
+
+ /*
+ * Create a node from a file system directory.
+ * If the directory is actually a file use createNodeFromXML
+ * if the directory contains a file named node.xml then use createNodeFromXML
+ * Otherwise, the directory can contain:
+ * domain.properties
+ * contributions - jar, zip, or exploded directories
+ * sca-contribution.xml metaData files to override whats in a contribution
+ * .composite files to add to contributions as additional deployables
+ *
+ * TODO: Review if this is useful?
+ */
+ public Node createNode(File directory) throws ContributionReadException, ValidationException, ActivationException, XMLStreamException, IOException {
+
+ if (!directory.isDirectory()) {
+ return createNodeFromXML(directory.toURI().toURL().toString());
+ }
+
+ File nodeXML = new File(directory, "node.xml");
+ if (nodeXML.exists()) {
+ return createNodeFromXML(nodeXML.toURI().toURL().toString());
+ }
+
+ Properties domainProps = new Properties();
+ File propsFile = new File(directory, "domain.properties");
+ if (propsFile.exists()) {
+ domainProps.load(new FileInputStream(propsFile));
+ }
+ String domainName = domainProps.getProperty("domainName", directory.getName());
+ String domainURI = domainProps.getProperty("domainURI", domainName);
+
+ DomainRegistry domainRegistry = domainRegistryFactory.getEndpointRegistry(domainURI, domainName);
+ Node node = new NodeImpl(deployer, compositeActivator, domainRegistry, extensionPointRegistry, null);
+
+ List<String> installed = new ArrayList<String>();
+ for (File f : directory.listFiles()) {
+ if (f.getName().endsWith(".jar") || f.getName().endsWith(".zip") || (f.isDirectory() && !f.getName().startsWith("."))) {
+ String fn = f.getName().lastIndexOf('.') == -1 ? f.getName() : f.getName().substring(0, f.getName().lastIndexOf('.'));
+ // ignore the contribution if it has an associated exploded folder version
+ if (!f.isDirectory() && new File(f.getParent(), fn).isDirectory()) {
+ continue;
+ }
+ String metaData = null;
+ for (File f2 : directory.listFiles()) {
+ if (f2.getName().startsWith(fn) && f2.getName().endsWith(".xml")) {
+ metaData = f2.getPath();
+ break;
+ }
+ }
+
+ List<String> dependencyURIs = new ArrayList<String>();
+ File dependencyFile = new File(directory, fn + ".dependencies");
+ if (dependencyFile.exists()) {
+ BufferedReader br = new BufferedReader(new FileReader(dependencyFile));
+ String s;
+ while ((s = br.readLine()) != null) {
+ if (!s.startsWith("#") && s.trim().length() > 0) {
+ dependencyURIs.addAll(Arrays.asList(s.trim().split("[ ,]+")));
+ }
+ }
+ br.close();
+ }
+
+ String curi = node.installContribution(null, f.getPath(), metaData, dependencyURIs);
+ installed.add(curi);
+
+ for (File f2 : directory.listFiles()) {
+ if (f2.getName().startsWith(fn) && f2.getName().endsWith(".composite")) {
+ node.addDeploymentComposite(curi, new FileReader(f2));
+ }
+ }
+ }
+ }
+
+ for (String curi : installed) {
+ node.startDeployables(curi);
+ }
+
+ return node;
+ }
+
+ /* Node.xml hot update
+ * - domain URi changed
+ * - restart entire node
+ * - List of contributions (matched on uri)
+ * - uninstall removed
+ * - install added
+ * - for each existing
+ * - if url or metadata or duris changed - update
+ * - if startdeployables changed
+ * - if now false then stop all started
+ * - if now true then start deployables
+ *
+ *
+ *
+ */
+
+ /**
+ * Creates a Node from an XML configuration file
+ * @param configURL the URL to the XML configuration file
+ * @return Node the configured Node
+ */
+ public Node createNodeFromXML(String configURL) throws ContributionReadException, ActivationException, ValidationException {
+ NodeConfiguration configuration = loadConfiguration(configURL);
+ NodeImpl node = (NodeImpl)createNode(configuration.getDomainURI());
+ for ( ContributionConfiguration c : configuration.getContributions()) {
+ String curi = node.installContribution(c.getURI(), c.getLocation(), c.getMetaDataURL(), c.getDependentContributionURIs());
+ if (c.isStartDeployables()) {
+ for (String compURI : node.getDeployableCompositeURIs(curi)) {
+ node.startComposite(curi, compURI);
+ }
+ }
+ }
+ return node;
+ }
+
+ /**
+ * Stop the TuscanyRuntime
+ */
+ public void stop() {
+ extensionPointRegistry.stop();
+ }
+
+ protected void init(Properties config) {
+ if (config == null) {
+ config = new Properties();
+ }
+ this.extensionPointRegistry = new DefaultExtensionPointRegistry();
+ extensionPointRegistry.start();
+
+ FactoryExtensionPoint modelFactories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = new RuntimeAssemblyFactory(extensionPointRegistry);
+ modelFactories.addFactory(assemblyFactory);
+
+ UtilityExtensionPoint utilities = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.compositeActivator = utilities.getUtility(CompositeActivator.class);
+ this.deployer = utilities.getUtility(Deployer.class);
+ utilities.getUtility(RuntimeProperties.class).setProperties(config);
+ utilities.getUtility(WorkScheduler.class);
+
+ // Initialize the Tuscany module activators
+ // The module activators will be started
+ extensionPointRegistry.getExtensionPoint(ModuleActivatorExtensionPoint.class);
+
+ this.domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
+
+ }
+
+ /**
+ * Get the ExtensionPointRegistry used by this runtime
+ * @return extensionPointRegistry
+ */
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ return extensionPointRegistry;
+ }
+
+ /**
+ * Get the Deployer. The Deployer can be used to create contribution artifacts
+ * when configuring a Node programatically.
+ * @return the Deployer
+ */
+ public Deployer getDeployer() {
+ return deployer;
+ }
+
+ /**
+ * Get the AssemblyFactory. The AssemblyFactory can be used to create contribution
+ * artifact contents when configuring a Node programatically.
+ * @return the AssemblyFactory
+ */
+ public AssemblyFactory getAssemblyFactory() {
+ return assemblyFactory;
+ }
+
+ protected NodeConfiguration loadConfiguration(String configURL) {
+ InputStream xml =null;
+ try {
+ URL base = IOHelper.getLocationAsURL(configURL);
+ xml = IOHelper.openStream(base);
+ InputStreamReader reader = new InputStreamReader(xml, "UTF-8");
+ ProcessorContext context = deployer.createProcessorContext();
+ NodeConfiguration config = deployer.loadXMLDocument(reader, context.getMonitor());
+ if (base != null && config != null) {
+ // Resolve the contribution location against the node.xml
+ // TODO: absolute locations?
+ for (ContributionConfiguration c : config.getContributions()) {
+ String location = c.getLocation();
+ if (location != null) {
+ URL url = new URL(base, location);
+ url = IOHelper.normalize(url);
+ c.setLocation(url.toString());
+ }
+ }
+ }
+ return config;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ } finally {
+ try {
+ if (xml != null) xml.close();
+ } catch (IOException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ContributionHelper.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ContributionHelper.java
new file mode 100644
index 0000000000..9125fd47c8
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ContributionHelper.java
@@ -0,0 +1,80 @@
+/*
+ * 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.impl;
+
+import java.net.URLClassLoader;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.java.impl.ClassLoaderModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+import sun.misc.ClassLoaderUtil;
+
+public class ContributionHelper {
+
+ public static void close(Contribution contribution, ExtensionPointRegistry extensionPointRegistry) {
+ ClassLoader contributionClassloader = contribution.getClassLoader();
+
+ if (contributionClassloader == null && contribution.getModelResolver() instanceof ExtensibleModelResolver) {
+ ModelResolver o = ((ExtensibleModelResolver)contribution.getModelResolver()).getModelResolverInstance(ClassReference.class);
+ if (o instanceof ClassLoader) {
+ contributionClassloader = (ClassLoader)o;
+ contribution.setClassLoader(contributionClassloader);
+ }
+ }
+
+ UtilityExtensionPoint utilityExtensionPoint = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+ FactoryExtensionPoint factoryExtensionPoint = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+
+ JAXBContextHelper jaxbContextHelper = utilityExtensionPoint.getUtility(JAXBContextHelper.class);
+ jaxbContextHelper.removeJAXBContextForContribution(contributionClassloader);
+
+ JavaInterfaceFactory javaInterfaceFactory = factoryExtensionPoint.getFactory(JavaInterfaceFactory.class);
+ javaInterfaceFactory.removeInterfacesForContribution(contributionClassloader);
+
+ ProxyFactoryExtensionPoint proxyFactoryExtensionPoint = extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ ProxyFactory interfaceProxyFactory = proxyFactoryExtensionPoint.getInterfaceProxyFactory();
+ interfaceProxyFactory.removeProxiesForContribution(contributionClassloader);
+
+ DOMHelper.getInstance(extensionPointRegistry).stop();
+ java.beans.Introspector.flushCaches();
+
+ if (contributionClassloader instanceof URLClassLoader) {
+ ClassLoaderUtil.releaseLoader((URLClassLoader)contributionClassloader);
+ }
+
+ if (contributionClassloader instanceof ClassLoaderModelResolver) {
+ ClassLoaderModelResolver clmr = (ClassLoaderModelResolver) contributionClassloader;
+ clmr.clear();
+ }
+
+ contribution.setClassLoader(null);
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DependencyUtils.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DependencyUtils.java
new file mode 100644
index 0000000000..08c426da42
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DependencyUtils.java
@@ -0,0 +1,76 @@
+/*
+ * 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.impl;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+
+public class DependencyUtils {
+
+ public static List<String> getDependencies(String contributionURI, Map<String, ZipInputStream> possibles) throws ValidationException, IOException, ContributionReadException, XMLStreamException {
+ Deployer deployer = TuscanyRuntime.newInstance().getDeployer();
+
+ Map<String, ContributionMetadata> contributionMetaDatas = new HashMap<String, ContributionMetadata>();
+ for (String curi : possibles.keySet()) {
+ ZipInputStream zis = possibles.get(curi);
+ ZipEntry entry;
+ while ((entry = zis.getNextEntry()) != null) {
+ if (Contribution.SCA_CONTRIBUTION_META.equals(entry.getName())) {
+
+ byte[] buffer = new byte[2048];
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ BufferedOutputStream bos = new BufferedOutputStream(baos, buffer.length);
+
+ int size;
+ while ((size = zis.read(buffer, 0, buffer.length)) != -1) {
+ bos.write(buffer, 0, size);
+ }
+ bos.close();
+
+ contributionMetaDatas.put(curi, (ContributionMetadata)deployer.loadXMLDocument(new StringReader(baos.toString())));
+ }
+ }
+ zis.close(); // close it so no one tries to reuse the already read stream
+ }
+ Monitor monitor = deployer.createMonitor();
+ try {
+ return deployer.getDependencies(contributionMetaDatas, contributionURI, monitor);
+ } finally {
+ monitor.analyzeProblems();
+ }
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
new file mode 100644
index 0000000000..fb40980d04
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
@@ -0,0 +1,185 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.impl.CompositeImpl;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.DomainRegistry;
+
+public class DeployedComposite {
+
+ private Composite composite;
+ private Contribution contribution;
+ private List<Contribution> dependedOnContributions;
+ private Composite builtComposite;
+
+ private CompositeActivator compositeActivator;
+ private CompositeContext compositeContext;
+ private Deployer deployer;
+ private DomainRegistry domainRegistry;
+ private ExtensionPointRegistry extensionPointRegistry;
+ private List<String> usedContributionURIs;
+ private boolean endpointsIncludeDomainName;
+
+ public DeployedComposite(Composite composite,
+ Contribution contribution,
+ List<Contribution> dependedOnContributions,
+ Deployer deployer,
+ CompositeActivator compositeActivator,
+ DomainRegistry domainRegistry,
+ ExtensionPointRegistry extensionPointRegistry,
+ boolean endpointsIncludeDomainName) throws ValidationException, ActivationException {
+ this.composite = composite;
+ this.contribution = contribution;
+ this.dependedOnContributions = dependedOnContributions;
+ this.deployer = deployer;
+ this.compositeActivator = compositeActivator;
+ this.domainRegistry = domainRegistry;
+ this.extensionPointRegistry = extensionPointRegistry;
+ this.endpointsIncludeDomainName = endpointsIncludeDomainName;
+
+ try {
+ build();
+ } catch (ContributionResolveException e) {
+ throw new ActivationException(e);
+ } catch (CompositeBuilderException e) {
+ throw new ActivationException(e);
+ }
+ }
+
+ protected void build() throws ValidationException, ActivationException, ContributionResolveException, CompositeBuilderException {
+
+ List<Contribution> contributions = new ArrayList<Contribution>();
+ contributions.add(contribution);
+ contributions.get(0).getDeployables().clear();
+ contributions.get(0).getDeployables().add(composite);
+
+ contributions.addAll(dependedOnContributions);
+
+ Map<QName, List<String>> bs = new HashMap<QName, List<String>>();
+ if (endpointsIncludeDomainName) {
+ bs.put(new QName("default"), Arrays.asList(new String[]{domainRegistry.getDomainName()}));
+ }
+
+ Monitor monitor = deployer.createMonitor();
+ builtComposite = deployer.build(contributions, contributions, bs, monitor);
+ monitor.analyzeProblems();
+
+ // TODO: Ideally deployer.build would set the name and uri to what this needs
+ builtComposite.setName(composite.getName());
+ builtComposite.setURI(composite.getURI());
+ builtComposite.setContributionURI(composite.getContributionURI());
+
+ // attempt to ensure the contribution classloader is set
+ // TODO: ideally the runtime would do this itself
+ if (contribution.getClassLoader() == null && contribution.getModelResolver() instanceof ExtensibleModelResolver) {
+ ModelResolver o = ((ExtensibleModelResolver)contribution.getModelResolver()).getModelResolverInstance(ClassReference.class);
+ if (o instanceof ClassLoader) {
+ contribution.setClassLoader((ClassLoader)o);
+ }
+ }
+
+ compositeContext = new CompositeContext(extensionPointRegistry,
+ domainRegistry,
+ builtComposite,
+ null, // nothing appears to use the domain name in CompositeContext
+ null, // don't need node uri
+ deployer.getSystemDefinitions());
+ usedContributionURIs = new ArrayList<String>();
+ usedContributionURIs.add(contribution.getURI());
+ for (Contribution dc : dependedOnContributions) {
+ usedContributionURIs.add(dc.getURI());
+ }
+ }
+
+ public void start() throws ActivationException {
+ try {
+ compositeActivator.activate(compositeContext, builtComposite);
+ compositeActivator.start(compositeContext, builtComposite);
+ domainRegistry.addRunningComposite(contribution.getURI(), builtComposite);
+ } catch (ActivationException ex){
+ stop();
+ throw ex;
+ } catch (Exception ex){
+ stop();
+ throw new ActivationException(ex);
+ }
+ }
+
+ public void stop() throws ActivationException {
+ domainRegistry.removeRunningComposite(contribution.getURI(), builtComposite.getURI());
+ compositeActivator.stop(compositeContext, builtComposite);
+ compositeActivator.deactivate(builtComposite);
+ }
+
+ public String getURI() {
+ return composite.getURI();
+ }
+
+ public List<String> getContributionURIs() {
+ return usedContributionURIs;
+ }
+
+ public boolean uses(String contributionURI, String compositeURI) {
+ // TODO: builtComposite or composite?
+ return compositeUses(builtComposite, contributionURI, compositeURI);
+ }
+
+ protected boolean compositeUses(Composite c, String contributionURI, String compositeURI) {
+ if (contributionURI.equals(c.getContributionURI()) && compositeURI.equals(c.getURI())) {
+ return true;
+ }
+ for (Composite include : ((CompositeImpl)c).getFusedIncludes()) {
+ if (compositeUses(include, contributionURI, compositeURI)) {
+ return true;
+ }
+ }
+ for (Component comp : c.getComponents()) {
+ if (comp.getImplementation() instanceof Composite) {
+ if (compositeUses((Composite)comp.getImplementation(), contributionURI, compositeURI)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
new file mode 100644
index 0000000000..52a6c7ede5
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
@@ -0,0 +1,656 @@
+/*
+ * 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.impl;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.xml.Utils;
+import org.apache.tuscany.sca.common.java.io.IOHelper;
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.ActiveNodes;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.ContributionDescription;
+import org.apache.tuscany.sca.runtime.ContributionListener;
+import org.apache.tuscany.sca.runtime.DomainRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+import org.oasisopen.sca.NoSuchServiceException;
+
+import sun.misc.ClassLoaderUtil;
+
+public class NodeImpl implements Node {
+ private static final Logger logger = Logger.getLogger(NodeImpl.class.getName());
+
+ private Deployer deployer;
+ private CompositeActivator compositeActivator;
+ private DomainRegistry domainRegistry;
+ private ExtensionPointRegistry extensionPointRegistry;
+ private UtilityExtensionPoint utilityExtensionPoint;
+ private TuscanyRuntime tuscanyRuntime;
+
+ private Map<String, Contribution> loadedContributions = new ConcurrentHashMap<String, Contribution>();
+
+ private Map<String, DeployedComposite> startedComposites = new HashMap<String, DeployedComposite>();
+ private Map<String, DeployedComposite> stoppedComposites = new HashMap<String, DeployedComposite>();
+
+ private boolean endpointsIncludeDomainName;
+ private boolean quietLogging;
+
+ private boolean releaseOnUnload;
+
+ private ContributionListener contributionListener;
+
+ public NodeImpl(Deployer deployer,
+ CompositeActivator compositeActivator,
+ DomainRegistry domainRegistry,
+ ExtensionPointRegistry extensionPointRegistry,
+ TuscanyRuntime tuscanyRuntime) {
+ this.deployer = deployer;
+ this.compositeActivator = compositeActivator;
+ this.domainRegistry = domainRegistry;
+ this.extensionPointRegistry = extensionPointRegistry;
+ this.tuscanyRuntime = tuscanyRuntime;
+
+ utilityExtensionPoint = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+
+ utilityExtensionPoint.getUtility(ActiveNodes.class).getActiveNodes().add(this);
+
+ contributionListener = new ContributionListener() {
+ public void contributionInstalled(String uri) {
+ // Do nothing
+ }
+ public void contributionUpdated(String uri) {
+ unloadContribution(uri);
+ }
+ public void contributionRemoved(String uri) {
+ unloadContribution(uri);
+ }
+ private void unloadContribution(String curi) {
+ Contribution c = loadedContributions.remove(curi);
+ if (c != null) {
+ ClassLoader cl = c.getClassLoader();
+ ContributionHelper.close(c, NodeImpl.this.extensionPointRegistry);
+ if (releaseOnUnload) {
+ if (cl instanceof URLClassLoader) {
+ ClassLoaderUtil.releaseLoader((URLClassLoader)cl);
+ }
+ }
+ }
+ }
+ };
+
+ this.domainRegistry.addContributionListener(contributionListener);
+
+ endpointsIncludeDomainName = !TuscanyRuntime.DEFAUL_DOMAIN_NAME.equals(domainRegistry.getDomainName());
+
+ UtilityExtensionPoint utilities = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
+ this.releaseOnUnload = Boolean.parseBoolean(utilities.getUtility(RuntimeProperties.class).getProperties().getProperty(RuntimeProperties.RELEASE_ON_UNLOAD, "true"));
+
+ this.quietLogging = Boolean.parseBoolean(utilities.getUtility(RuntimeProperties.class).getProperties().getProperty(RuntimeProperties.QUIET_LOGGING));
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "domain: " + domainRegistry.getDomainName() + (!domainRegistry.getDomainName().equals(domainRegistry.getDomainURI()) ? "" : (" domainURI: " + domainRegistry.getDomainURI())));
+ }
+
+ // TODO: install shouldn't throw ValidationException as it shouldn't do any validation, its
+ // only here from the loadContribution in mergeContributionMetaData so change that approach
+
+ public String installContribution(String contributionURL) throws ContributionReadException, ValidationException {
+ return installContribution(null, contributionURL, null, null);
+ }
+
+ public String installContribution(String uri, String contributionURL) throws ContributionReadException, ValidationException { if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "updateUsingComposites", contributionURL);
+ return installContribution(uri, contributionURL, null, null);
+ }
+
+ public boolean updateContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs) throws ContributionReadException, ValidationException, ActivationException {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.log(Level.FINE, "updateContribution" + Arrays.asList(new Object[]{uri, contributionURL, metaDataURL, dependentContributionURIs}));
+ }
+ ContributionDescription ic = domainRegistry.getInstalledContribution(uri);
+ if (ic == null) {
+ installContribution(uri, contributionURL, metaDataURL, dependentContributionURIs);
+ return true;
+ }
+
+ // do this if only updating if the contribution has been modified:
+ // if url equal and a file and last modified not changed
+ // if metadata url equal and a file and laqst modified not changed
+ // if (dependent contributions uris not changed)
+ // return false
+
+ uninstallContribution(uri);
+
+ installContribution(uri, contributionURL, metaDataURL, dependentContributionURIs);
+
+ // merge in additional deployables
+ if (ic.getAdditionalDeployables().size() > 0) {
+ ContributionDescription newIC = getInstalledContribution(uri);
+ newIC.getAdditionalDeployables().putAll(ic.getAdditionalDeployables());
+ domainRegistry.updateInstalledContribution(newIC);
+ }
+
+ // stop/start all started composites using the contribution
+ for (DeployedComposite dc : new ArrayList<DeployedComposite>(startedComposites.values())) {
+ if (dc.getContributionURIs().contains(uri)) {
+ String dcContributionURI = dc.getContributionURIs().get(0);
+ String dcCompositeURI = dc.getURI();
+ stopComposite(dcContributionURI, dcCompositeURI);
+ String key = dcContributionURI + "/" + dcCompositeURI;
+ stoppedComposites.remove(key);
+ startComposite(dcContributionURI, dcCompositeURI);
+ }
+ }
+
+ // remove all stopped composites using the contribution
+ for (DeployedComposite dc : new ArrayList<DeployedComposite>(stoppedComposites.values())) {
+ if (dc.getContributionURIs().contains(uri)) {
+ stoppedComposites.remove(uri + "/" + dc.getURI());
+ }
+ }
+
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "updateContribution: " + uri);
+ return true;
+ }
+
+ public String installContribution(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs) throws ContributionReadException, ValidationException {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.log(Level.FINE, "installContribution" + Arrays.asList(new Object[]{uri, contributionURL, metaDataURL, dependentContributionURIs}));
+ }
+ ContributionDescription cd = new ContributionDescription(uri, IOHelper.getLocationAsURL(contributionURL).toString());
+
+ if (dependentContributionURIs != null) {
+ cd.getDependentContributionURIs().addAll(dependentContributionURIs);
+ }
+
+ if (metaDataURL != null) {
+ mergeContributionMetaData(metaDataURL, loadContribution(cd));
+ }
+
+ peekIntoContribution(cd);
+
+ domainRegistry.installContribution(cd);
+
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "installContribution: " + cd.getURI());
+ return cd.getURI();
+ }
+
+ public void installContribution(Contribution contribution, List<String> dependentContributionURIs) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.log(Level.FINE, "installContribution" + Arrays.asList(new Object[]{contribution, dependentContributionURIs}));
+ }
+ ContributionDescription cd = new ContributionDescription(contribution.getURI(), contribution.getLocation());
+ if (dependentContributionURIs != null) {
+ cd.getDependentContributionURIs().addAll(dependentContributionURIs);
+ }
+ cd.configureMetaData(contribution);
+ domainRegistry.installContribution(cd);
+ loadedContributions.put(cd.getURI(), contribution);
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "installContribution: " + cd.getURI());
+ }
+
+ public void uninstallContribution(String contributionURI) {
+
+ // note that the contribution listener that this class registers will free up the contribution's resources
+
+ domainRegistry.uninstallContribution(contributionURI);
+
+ // remove any stopped composite that used the contribution
+ Iterator<String> i = stoppedComposites.keySet().iterator();
+ while (i.hasNext()) {
+ DeployedComposite dc = stoppedComposites.get(i.next());
+ if (dc.getContributionURIs().contains(contributionURI)) {
+ i.remove();
+ }
+ }
+
+ if (loadedContributions.size() < 1) {
+ DOMHelper.getInstance(extensionPointRegistry).stop();
+ java.beans.Introspector.flushCaches();
+ }
+
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "uninstallContribution: " + contributionURI);
+ }
+
+ protected void mergeContributionMetaData(String metaDataURL, Contribution contribution) throws ValidationException {
+ ContributionMetadata metaData;
+ Monitor monitor = deployer.createMonitor();
+ try {
+ metaData = deployer.loadXMLDocument(IOHelper.getLocationAsURL(metaDataURL), monitor);
+ } catch (Exception e) {
+ throw new ValidationException(e);
+ }
+ monitor.analyzeProblems();
+ contribution.mergeMetaData(metaData);
+ }
+
+ /**
+ * Peek into the contribution to find its attributes.
+ * ASM12032 and ASM12033 say no error checking should be done during install and that should happen later, but
+ * we need to know about deployables and exports so peek into the contribution to try to get those,
+ * and just ignore any errors they might happen while doing that.
+ */
+ protected void peekIntoContribution(ContributionDescription cd) {
+ Contribution contribution = null;
+ try {
+ contribution = loadContribution(cd);
+ } catch (Exception e) {
+ // ignore it
+ }
+
+ if (contribution != null) {
+ cd.configureMetaData(contribution);
+ }
+ }
+
+ public List<String> getInstalledContributionURIs() {
+ return new ArrayList<String>(domainRegistry.getInstalledContributionURIs());
+ }
+
+ public Contribution getContribution(String contributionURI) throws ContributionReadException, ValidationException {
+ return loadContribution(getInstalledContribution(contributionURI));
+ }
+
+ public List<String> getDeployableCompositeURIs(String contributionURI) {
+ ContributionDescription cd = domainRegistry.getInstalledContribution(contributionURI);
+ List<String> deployables = new ArrayList<String>(cd.getDeployables());
+ deployables.addAll(cd.getAdditionalDeployables().keySet());
+ return deployables;
+ }
+
+ public String addDeploymentComposite(String contributionURI, Reader compositeXML) throws ContributionReadException, XMLStreamException, ValidationException {
+ ContributionDescription cd = getInstalledContribution(contributionURI);
+
+ // load it to check its valid composite XML
+ Composite composite = deployer.loadXMLDocument(compositeXML);
+
+ return addDeploymentComposite(cd, composite);
+ }
+
+ public String addDeploymentComposite(String contributionURI, Composite composite) {
+ ContributionDescription cd = getInstalledContribution(contributionURI);
+ return addDeploymentComposite(cd, composite);
+ }
+
+ protected String addDeploymentComposite(ContributionDescription cd, Composite composite) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.log(Level.FINE, "addDeploymentComposite" + Arrays.asList(new Object[]{cd, composite}));
+ }
+ if (composite.getURI() == null || composite.getURI().length() < 1) {
+ composite.setURI(composite.getName().getLocalPart() + ".composite");
+ }
+ composite.setContributionURI(cd.getURI());
+ cd.getAdditionalDeployables().put(composite.getURI(), Utils.modelToXML(composite, false, extensionPointRegistry));
+ domainRegistry.updateInstalledContribution(cd);
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "addDeploymentComposite: " + composite.getURI());
+ return composite.getURI();
+ }
+
+ public void validateContribution(String contributionURI) throws ContributionReadException, ValidationException {
+ ContributionDescription cd = getInstalledContribution(contributionURI);
+ Contribution contribution = loadContribution(cd);
+
+ Monitor monitor = deployer.createMonitor();
+ try {
+ ArrayList<Contribution> cs = new ArrayList<Contribution>();
+ cs.add(contribution);
+ cs.addAll(calculateDependentContributions(cd));
+ deployer.resolve(cs, null, monitor);
+ } catch (Exception e) {
+ loadedContributions.remove(cd.getURI());
+ throw new RuntimeException(e);
+ }
+ try {
+ monitor.analyzeProblems();
+ } catch (ValidationException e) {
+ loadedContributions.remove(cd.getURI());
+ throw e;
+ }
+ if (contribution.getClassLoader() == null && contribution.getModelResolver() instanceof ExtensibleModelResolver) {
+ ModelResolver o = ((ExtensibleModelResolver)contribution.getModelResolver()).getModelResolverInstance(ClassReference.class);
+ if (o instanceof ClassLoader) {
+ contribution.setClassLoader((ClassLoader)o);
+ }
+ }
+ }
+
+ public Map<String, List<String>> getStartedCompositeURIs() {
+ return Collections.unmodifiableMap(domainRegistry.getRunningCompositeURIs());
+ }
+
+ public void startComposite(String contributionURI, String compositeURI) throws ActivationException, ValidationException, ContributionReadException {
+ String key = contributionURI+"/"+compositeURI;
+ if (startedComposites.containsKey(key)) {
+ throw new IllegalStateException("composite already started: " + compositeURI);
+ }
+ DeployedComposite dc = stoppedComposites.remove(key);
+ try {
+ if (dc != null) {
+ dc.start();
+ startedComposites.put(key, dc);
+ } else {
+ ContributionDescription cd = getInstalledContribution(contributionURI);
+ Contribution contribution = loadContribution(cd);
+ Composite composite = contribution.getArtifactModel(compositeURI);
+ List<Contribution> dependentContributions = calculateDependentContributions(cd);
+ dc = new DeployedComposite(composite, contribution, dependentContributions, deployer, compositeActivator, domainRegistry, extensionPointRegistry, endpointsIncludeDomainName);
+ dc.start();
+ startedComposites.put(key, dc);
+ }
+ }catch(ActivationException e){
+ if(dc != null){
+ try {
+ // try to stop the composite. This should have already happened
+ // in the activator if the composite failed to start but we're
+ // being sure
+ dc.stop();
+ } catch (Exception ex) {
+ // do nothing as we are going to throw the
+ // original exception
+ }
+ stoppedComposites.put(key, dc);
+ }
+ throw e;
+ }
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "startComposite: " + key);
+ }
+
+ @Override
+ public void startComposite(String contributionURI, String compositeURI, String nodeName) throws ActivationException {
+ String response = domainRegistry.remoteCommand(nodeName, new RemoteCommand(domainRegistry.getDomainName(), "start", contributionURI, compositeURI));
+ if (!"Started.".equals(response)) {
+ throw new ActivationException(response);
+ }
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "startComposite: " + contributionURI + " " + compositeURI + " " + nodeName);
+ }
+
+ public void stopComposite(String contributionURI, String compositeURI) throws ActivationException {
+ String key = contributionURI+"/"+compositeURI;
+ DeployedComposite dc = startedComposites.remove(key);
+ if (dc != null) {
+ dc.stop();
+ stoppedComposites.put(key, dc);
+ } else {
+ String member = domainRegistry.getRunningNodeName(contributionURI, compositeURI);
+ if (member == null) {
+ throw new IllegalStateException("composite not started: " + compositeURI);
+ }
+ RemoteCommand command = new RemoteCommand(domainRegistry.getDomainName(), "stop", contributionURI, compositeURI);
+ String response = domainRegistry.remoteCommand(member, command);
+ if (!"Stopped.".equals(response)) {
+ throw new ActivationException(response);
+ }
+ }
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "stopComposite: " + key);
+ }
+
+ public void stopCompositeAndUninstallUnused(String contributionURI, String compositeURI) throws ActivationException {
+ String key = contributionURI+"/"+compositeURI;
+ DeployedComposite dc = startedComposites.remove(key);
+ if (dc != null) {
+ dc.stop();
+ } else {
+ // check in the stopped list in case it stopped on failure during start
+ dc = stoppedComposites.get(key);
+ }
+
+ if (dc != null) {
+ loop: for (String curi : dc.getContributionURIs()) {
+ for (DeployedComposite started : startedComposites.values()) {
+ if (started.getContributionURIs().contains(curi)) {
+ continue loop;
+ }
+ }
+ uninstallContribution(curi);
+ }
+ }
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "stopCompositeAndUninstallUnused: " + key);
+ }
+
+ public String getDomainURI() {
+ return domainRegistry.getDomainURI();
+ }
+
+ public String getDomainName() {
+ return domainRegistry.getDomainName();
+ }
+
+ public Composite getDomainComposite() {
+ return domainRegistry.getDomainComposite();
+ }
+
+ public <T> T getService(Class<T> interfaze, String serviceURI) throws NoSuchServiceException {
+ return ServiceHelper.getService(interfaze, serviceURI, domainRegistry, extensionPointRegistry, deployer);
+ }
+
+ public ContributionDescription getInstalledContribution(String contributionURI) {
+ ContributionDescription cd = domainRegistry.getInstalledContribution(contributionURI);
+ if (cd == null) {
+ throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ }
+ return cd;
+ }
+
+ protected Contribution loadContribution(ContributionDescription cd) throws ContributionReadException, ValidationException {
+ Contribution contribution = loadedContributions.get(cd.getURI());
+ if (contribution == null) {
+ Monitor monitor = deployer.createMonitor();
+ contribution = deployer.loadContribution(IOHelper.createURI(cd.getURI()), IOHelper.getLocationAsURL(cd.getURL()), monitor);
+
+ // TODO: should the monitor be checked? If it is then the peek in to get the metadata doesn't work if there's a problem
+ // monitor.analyzeProblems();
+ if (cd.getAdditionalDeployables().size() > 0) {
+ for (String uri : cd.getAdditionalDeployables().keySet()) {
+ String compositeXML = cd.getAdditionalDeployables().get(uri);
+ Composite composite;
+ try {
+ composite = deployer.loadXMLDocument(new StringReader(compositeXML));
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ composite.setURI(composite.getName().getLocalPart() + ".composite");
+ contribution.addComposite(composite);
+ }
+ }
+ loadedContributions.put(cd.getURI(), contribution);
+ }
+ return contribution;
+ }
+
+ protected List<Contribution> calculateDependentContributions(ContributionDescription cd) throws ContributionReadException, ValidationException {
+ Map<String, Contribution> dependentContributions = new HashMap<String, Contribution>();
+ if (cd.getDependentContributionURIs() != null && cd.getDependentContributionURIs().size() > 0) {
+ // if the install specified dependent uris use just those contributions
+ for (String uri : cd.getDependentContributionURIs()) {
+ if (!!!dependentContributions.containsKey(uri)) {
+ ContributionDescription dependee = domainRegistry.getInstalledContribution(uri);
+ if (dependee != null) {
+ dependentContributions.put(uri, loadContribution(dependee));
+ }
+ }
+ }
+ } else {
+ for (Import imprt : loadContribution(cd).getImports()) {
+ for (ContributionDescription exportingIC : findExportingContributions(imprt)) {
+ if (!!!dependentContributions.containsKey(exportingIC.getURI()) && !!!cd.getURI().equals(exportingIC.getURI())) {
+ dependentContributions.put(exportingIC.getURI(), loadContribution(exportingIC));
+ }
+ }
+ }
+ }
+ // TODO: there is also the location attribute on the import which should be taken into account
+ return new ArrayList<Contribution>(dependentContributions.values());
+ }
+
+ private List<ContributionDescription> findExportingContributions(Import imprt) {
+ List<ContributionDescription> ics = new ArrayList<ContributionDescription>();
+ // TODO: Handle Imports in a more extensible way
+ for (String curi : domainRegistry.getInstalledContributionURIs()) {
+ ContributionDescription cd = domainRegistry.getInstalledContribution(curi);
+ if (imprt instanceof JavaImport) {
+ for (String s : cd.getJavaExports()) {
+ if (s.startsWith(((JavaImport)imprt).getPackage())) {
+ ics.add(cd);
+ }
+ }
+ } else if (imprt instanceof NamespaceImport) {
+ if (cd.getNamespaceExports().contains(((NamespaceImport)imprt).getNamespace())) {
+ ics.add(cd);
+ }
+ }
+ }
+ return ics;
+ }
+
+ @Override
+ public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> startDeployables(String contributionURI) throws ActivationException, ValidationException, ContributionReadException {
+ List<String> dcURIs = getDeployableCompositeURIs(contributionURI);
+ for (String dcURI : dcURIs) {
+ startComposite(contributionURI, dcURI);
+ }
+ return dcURIs;
+ }
+
+ // TODO: these are used by the shell, should they be on the Node interface?
+ public DomainRegistry getEndpointRegistry() {
+ return domainRegistry;
+ }
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ return extensionPointRegistry;
+ }
+
+ public void stop() {
+ for (DeployedComposite dc : startedComposites.values()) {
+ try {
+ dc.stop();
+ } catch (ActivationException e) {
+ }
+ }
+ startedComposites.clear();
+ stoppedComposites.clear();
+ extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(ActiveNodes.class).getActiveNodes().remove(this);
+ domainRegistry.removeContributionListener(contributionListener);
+ if (tuscanyRuntime != null) {
+ tuscanyRuntime.stop();
+ }
+ }
+
+ @Override
+ public List<String> getNodeNames() {
+ return domainRegistry.getNodeNames();
+ }
+
+ @Override
+ public String getLocalNodeName() {
+ return domainRegistry.getLocalNodeName();
+ }
+
+ @Override
+ public String getRunningNodeName(String contributionURI, String compositeURI) {
+ return domainRegistry.getRunningNodeName(contributionURI, compositeURI);
+ }
+
+ public List<String> updateUsingComposites(String contributionURI, String compositeURI) throws ActivationException, ContributionReadException, ValidationException {
+ List<String> updated = new ArrayList<String>();
+ for (DeployedComposite dc : new ArrayList<DeployedComposite>(startedComposites.values())) {
+ if (dc.uses(contributionURI, compositeURI)) {
+ String dcContributionURI = dc.getContributionURIs().get(0);
+ String dcCompositeURI = dc.getURI();
+ stopComposite(dcContributionURI, dcCompositeURI);
+ String key = dcContributionURI + "/" + dcCompositeURI;
+ stoppedComposites.remove(key);
+ updated.add(key);
+ startComposite(dcContributionURI, dcCompositeURI);
+ }
+ }
+ if (logger.isLoggable(quietLogging? Level.FINE : Level.INFO)) logger.log(quietLogging? Level.FINE : Level.INFO, "updateUsingComposites", updated);
+ return updated;
+ }
+
+ public void uninstallContribution(String contributionURI, boolean b) throws ActivationException {
+ uninstallContribution(contributionURI);
+ if (!b) {
+ return;
+ }
+
+ // stop all started composites using the contribution
+ for (DeployedComposite dc : new ArrayList<DeployedComposite>(startedComposites.values())) {
+ if (dc.getContributionURIs().contains(contributionURI)) {
+ String dcContributionURI = dc.getContributionURIs().get(0);
+ String dcCompositeURI = dc.getURI();
+ stopComposite(dcContributionURI, dcCompositeURI);
+ String key = dcContributionURI + "/" + dcCompositeURI;
+ stoppedComposites.remove(key);
+ }
+ }
+
+ // remove all stopped composites using the contribution
+ for (DeployedComposite dc : new ArrayList<DeployedComposite>(stoppedComposites.values())) {
+ if (dc.getContributionURIs().contains(contributionURI)) {
+ stoppedComposites.remove(contributionURI + "/" + dc.getURI());
+ }
+ }
+ }
+
+ public boolean getEndpointsIncludeDomainName() {
+ return endpointsIncludeDomainName;
+ }
+
+ public void setEndpointsIncludeDomainName(boolean b) {
+ endpointsIncludeDomainName = b;
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/RemoteCommand.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/RemoteCommand.java
new file mode 100644
index 0000000000..5e150dba02
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/RemoteCommand.java
@@ -0,0 +1,83 @@
+/*
+ * 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.impl;
+
+import java.io.Serializable;
+import java.util.concurrent.Callable;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistryLocator;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.runtime.ActiveNodes;
+
+public class RemoteCommand implements Callable<String>, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ // all fields MUST be Serializable
+ private String domainName;
+ private String command;
+ private String contributionURI;
+ private String compositeURI;
+
+ public RemoteCommand(String domainName, String command, String contributionURI, String compositeURI) {
+ this.domainName = domainName;
+ this.command = command;
+ this.contributionURI = contributionURI;
+ this.compositeURI = compositeURI;
+ }
+
+ public String call() throws Exception {
+ String response;
+ try {
+ Node node = getNode();
+
+ if ("start".equals(command)) {
+ node.startComposite(contributionURI, compositeURI);
+ response = "Started.";
+ } else if ("stop".equals(command)) {
+ node.stopComposite(contributionURI, compositeURI);
+ response = "Stopped.";
+ } else {
+ response = "Unknown command: " + command;
+ }
+ } catch (Exception e) {
+ response = "REMOTE EXCEPTION: " + e.getClass() + ":" + e.getMessage();
+ }
+ return response;
+ }
+
+ private Node getNode() {
+ // TODO Several places in Tuscany need to do this type of thing, for example, processing
+ // async responses, so we need to design a "proper" way to do it
+
+ for (ExtensionPointRegistry xpr : ExtensionPointRegistryLocator.getExtensionPointRegistries()) {
+ ActiveNodes activeNodes = xpr.getExtensionPoint(UtilityExtensionPoint.class).getUtility(ActiveNodes.class);
+ for (Object o : activeNodes.getActiveNodes()) {
+ Node node = (Node)o;
+ if (node.getDomainName().equals(domainName)) {
+ return node;
+ }
+ }
+ }
+ throw new IllegalStateException("No remote Node found for domain: " + domainName);
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java
new file mode 100644
index 0000000000..3ada1bbbb1
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/ServiceHelper.java
@@ -0,0 +1,211 @@
+/*
+ * 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.impl;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.runtime.ContributionDescription;
+import org.apache.tuscany.sca.runtime.DomainRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * TODO: Merge this into sca-client RemoteServiceInvocationHandler
+ *
+ * All the code for creating a service proxy in this helper class as it feels like
+ * it doesn't all belong in the node but i can't see where to refactor it to yet.
+ * (perhaps its just the remote proxy bit that needs to go somewhere else?)
+ */
+public class ServiceHelper {
+
+ public static <T> T getService(Class<T> interfaze, String serviceURI, DomainRegistry domainRegistry, ExtensionPointRegistry extensionPointRegistry, Deployer deployer) throws NoSuchServiceException {
+
+ List<Endpoint> endpoints = domainRegistry.findEndpoint(serviceURI);
+ if (endpoints.size() < 1) {
+ throw new NoSuchServiceException(serviceURI);
+ }
+
+ String serviceName = null;
+ if (serviceURI.contains("/")) {
+ int i = serviceURI.indexOf("/");
+ if (i < serviceURI.length() - 1) {
+ serviceName = serviceURI.substring(i + 1);
+ }
+ }
+
+ Endpoint ep = endpoints.get(0);
+ if (((RuntimeComponent)ep.getComponent()).getComponentContext() != null) {
+ return ((RuntimeComponent)ep.getComponent()).getServiceReference(interfaze, serviceName).getService();
+ } else {
+ return getRemoteProxy(interfaze, ep, domainRegistry, extensionPointRegistry, deployer);
+ }
+ }
+
+ private static <T> T getRemoteProxy(Class<T> serviceInterface, Endpoint endpoint, DomainRegistry domainRegistry, ExtensionPointRegistry extensionPointRegistry, Deployer deployer) throws NoSuchServiceException {
+ FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ ProxyFactory proxyFactory =
+ new ExtensibleProxyFactory(extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
+
+ CompositeContext compositeContext =
+ new CompositeContext(extensionPointRegistry, domainRegistry, null, null, null,
+ deployer.getSystemDefinitions());
+
+ if (serviceInterface == null) {
+ try {
+ serviceInterface = (Class<T>)findInterface(endpoint, domainRegistry);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ RuntimeEndpointReference epr;
+ try {
+ epr =
+ createEndpointReference(javaInterfaceFactory,
+ compositeContext,
+ assemblyFactory,
+ endpoint,
+ serviceInterface);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ return proxyFactory.createProxy(serviceInterface, epr);
+ }
+
+ private static RuntimeEndpointReference createEndpointReference(JavaInterfaceFactory javaInterfaceFactory,
+ CompositeContext compositeContext,
+ AssemblyFactory assemblyFactory,
+ Endpoint endpoint,
+ Class<?> businessInterface)
+ throws CloneNotSupportedException, InvalidInterfaceException {
+ Component component = endpoint.getComponent();
+ ComponentService service = endpoint.getService();
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName("sca.client." + service.getName());
+
+ componentReference.setCallback(service.getCallback());
+ componentReference.getTargets().add(service);
+ componentReference.getPolicySets().addAll(service.getPolicySets());
+ componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
+ componentReference.getBindings().add(endpoint.getBinding());
+
+ InterfaceContract interfaceContract = service.getInterfaceContract();
+ Service componentTypeService = service.getService();
+ if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
+ interfaceContract = componentTypeService.getInterfaceContract();
+ }
+ interfaceContract = getInterfaceContract(javaInterfaceFactory, interfaceContract, businessInterface);
+ componentReference.setInterfaceContract(interfaceContract);
+ componentReference.setMultiplicity(Multiplicity.ONE_ONE);
+ // component.getReferences().add(componentReference);
+
+ // create endpoint reference
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setComponent(component);
+ endpointReference.setReference(componentReference);
+ endpointReference.setBinding(endpoint.getBinding());
+ endpointReference.setUnresolved(false);
+ endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
+
+ endpointReference.setTargetEndpoint(endpoint);
+
+ componentReference.getEndpointReferences().add(endpointReference);
+ ((RuntimeComponentReference)componentReference).setComponent((RuntimeComponent)component);
+ ((RuntimeEndpointReference)endpointReference).bind(compositeContext);
+
+ return (RuntimeEndpointReference)endpointReference;
+ }
+
+ private static InterfaceContract getInterfaceContract(JavaInterfaceFactory javaInterfaceFactory,
+ InterfaceContract interfaceContract,
+ Class<?> businessInterface) throws CloneNotSupportedException,
+ InvalidInterfaceException {
+ if (businessInterface == null) {
+ return interfaceContract;
+ }
+ boolean compatible = false;
+ if (interfaceContract != null && interfaceContract.getInterface() != null) {
+ Interface interfaze = interfaceContract.getInterface();
+ if (interfaze instanceof JavaInterface) {
+ Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
+ if (cls != null && businessInterface.isAssignableFrom(cls)) {
+ compatible = true;
+ }
+ }
+ }
+
+ if (!compatible) {
+ // The interface is not assignable from the interface contract
+ interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(businessInterface);
+ callInterface.setRemotable(true);
+ interfaceContract.setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(callInterface
+ .getCallbackClass()));
+ }
+ }
+
+ return interfaceContract;
+ }
+
+ private static Class<?> findInterface(Endpoint endpoint, DomainRegistry domainRegistry) throws MalformedURLException, ClassNotFoundException {
+ Interface iface = endpoint.getService().getInterfaceContract().getInterface();
+ if (iface instanceof JavaInterface) {
+ String curi = domainRegistry.getContainingCompositesContributionURI(endpoint.getComponent().getName());
+ if (curi != null) {
+ ContributionDescription ic = domainRegistry.getInstalledContribution(curi);
+ ClassLoader cl = new URLClassLoader(new URL[]{new URL(ic.getURL())}, Remotable.class.getClassLoader());
+ return cl.loadClass(((JavaInterface)iface).getName());
+ }
+ }
+ return null;
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/hotupdate/HotUpdater.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/hotupdate/HotUpdater.java
new file mode 100644
index 0000000000..7369ab385b
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/hotupdate/HotUpdater.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.impl.hotupdate;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.impl.NodeImpl;
+
+/**
+ * Code to do dynamic updates to a running Node.
+ * Very experimental presently, mainly just to see what type of things are required
+ */
+public class HotUpdater {
+
+ private final Node node;
+ private final File domainDir;
+
+ // key is contribution URI (which for exploded contributions is the directory name)
+ private final Map<String, LastModifiedTracker> contributions = new HashMap<String, LastModifiedTracker>();
+
+ private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+
+ public HotUpdater(Node node, File domainDir){
+ this.node = node;
+ this.domainDir = domainDir;
+
+ final Runnable checker = new Runnable() {
+ public void run() {
+ check();
+ }
+ };
+
+ scheduler.scheduleAtFixedRate(checker, 10, 10, TimeUnit.SECONDS);
+ }
+
+ private void check() {
+ Set<String> found = new HashSet<String>();
+ for (File f : domainDir.listFiles()) {
+ if (f.isDirectory() && !f.getName().startsWith(".")) {
+ found.add(f.getName());
+ LastModifiedTracker scanner = contributions.get(f.getName());
+ if (scanner == null) {
+ //newContribution(f);
+ contributions.put(f.getName(), new LastModifiedTracker(f));
+ } else {
+ if (scanner.checkModified()) {
+ updatedContribution(f);
+ }
+ }
+ }
+ }
+
+ HashSet<String> removed = new HashSet<String>(contributions.keySet());
+ removed.removeAll(found);
+ for (String curi : removed) {
+ removedContribution(curi);
+ }
+
+ }
+
+ private void removedContribution(String curi) {
+ try {
+ ((NodeImpl)node).uninstallContribution(curi, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ contributions.remove(curi);
+ }
+
+ private void updatedContribution(File f) {
+ try {
+ ((NodeImpl)node).updateContribution(f.getName(), f.toURI().toURL().toString(), null, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void newContribution(File f) {
+ try {
+ node.installContribution(f.getName(), f.toURI().toURL().toString(), null, null);
+ node.startDeployables(f.getName());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/hotupdate/LastModifiedTracker.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/hotupdate/LastModifiedTracker.java
new file mode 100644
index 0000000000..a129f4d0fe
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/hotupdate/LastModifiedTracker.java
@@ -0,0 +1,75 @@
+/*
+ * 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.impl.hotupdate;
+
+import java.io.File;
+
+/**
+ * Keeps track of if a file or directory has been modified since a previous check
+ */
+public class LastModifiedTracker {
+
+ private File targetFile;
+ private Long lastModified;
+
+ public LastModifiedTracker(File targetFile) {
+ this.targetFile = targetFile;
+ checkModified();
+ }
+
+ public void reset() {
+ lastModified = null;
+ }
+
+ public boolean checkModified() {
+
+ long newLastModified = getNewLastModified(targetFile);
+
+ if (lastModified == null) {
+ lastModified = newLastModified;
+ return false;
+ }
+
+ if (newLastModified > lastModified) {
+ lastModified = newLastModified;
+ return true;
+ }
+
+ return false;
+ }
+
+ protected long getNewLastModified(File f) {
+
+ if (!f.exists()) return 0;
+
+ if (f.isFile()) return f.lastModified();
+
+ long newLastModified = f.lastModified();
+
+ for (File fx : f.listFiles()) {
+ long fxLastModified = getNewLastModified(fx);
+ if (fxLastModified > newLastModified){
+ newLastModified = fxLastModified;
+ }
+ }
+
+ return newLastModified;
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/itest/nodes/Helloworld.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
new file mode 100644
index 0000000000..76f8d4400d
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
@@ -0,0 +1,29 @@
+/*
+ * 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 itest.nodes;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/ContributionClassLoaderTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/ContributionClassLoaderTestCase.java
new file mode 100644
index 0000000000..298c20b093
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/ContributionClassLoaderTestCase.java
@@ -0,0 +1,49 @@
+/*
+ * 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.impl;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.junit.Test;
+
+/**
+ * Tests that the contribution classloader is created after doing a validateContribution
+ */
+public class ContributionClassLoaderTestCase {
+
+ @Test
+ public void testInstallDeployable() throws ContributionReadException, ValidationException, ActivationException {
+ Node node = TuscanyRuntime.newInstance().createNode();
+ String curi = node.installContribution("src/test/resources/sample-helloworld.jar");
+ Contribution contribution = node.getContribution(curi);
+ Assert.assertNull(contribution.getClassLoader());
+ node.validateContribution(curi);
+ ClassLoader cl1 = contribution.getClassLoader();
+ Assert.assertNotNull(cl1);
+ node.startComposite(curi, "helloworld.composite");
+ Assert.assertEquals(cl1, node.getContribution(curi).getClassLoader());
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/ContributionUpdateTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/ContributionUpdateTestCase.java
new file mode 100644
index 0000000000..f270eb3f23
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/ContributionUpdateTestCase.java
@@ -0,0 +1,75 @@
+/*
+ * 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.impl;
+
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.Collection;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.junit.Assert;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class ContributionUpdateTestCase {
+
+ @Test
+ public void updateTest1() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, FileNotFoundException {
+ Node node = TuscanyRuntime.newInstance().createNode("updateTest1");
+ String curi = node.installContribution("src/test/resources/sample-helloworld.jar");
+ node.startDeployables(curi);
+
+ Collection<Endpoint> eps = ((NodeImpl)node).getEndpointRegistry().getEndpoints();
+ Assert.assertEquals(1, eps.size());
+ Assert.assertEquals("HelloworldComponent#service-binding(Helloworld/Helloworld)", eps.iterator().next().getURI());
+
+ ((NodeImpl)node).updateContribution(curi, "src/test/resources/sample-helloworld2.jar", null, null);
+
+ eps = ((NodeImpl)node).getEndpointRegistry().getEndpoints();
+ Assert.assertEquals(1, eps.size());
+ Assert.assertEquals("Helloworld2Component#service-binding(Helloworld/Helloworld)", eps.iterator().next().getURI());
+ }
+
+ @Test
+ public void updateWithAdditionalDeployablesTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, FileNotFoundException {
+ Node node = TuscanyRuntime.newInstance().createNode("updateWithAdditionalDeployablesTest");
+ String curi = node.installContribution("src/test/resources/sample-helloworld.jar");
+ String compURI = node.addDeploymentComposite(curi, new FileReader("src/test/resources/helloworld2.composite"));
+ node.startComposite(curi, compURI);
+
+ Collection<Endpoint> eps = ((NodeImpl)node).getEndpointRegistry().getEndpoints();
+ Assert.assertEquals(1, eps.size());
+ Assert.assertEquals("Helloworld2Component#service-binding(Helloworld/Helloworld)", eps.iterator().next().getURI());
+
+ ((NodeImpl)node).updateContribution(curi, "src/test/resources/sample-helloworld.jar", null, null);
+
+ eps = ((NodeImpl)node).getEndpointRegistry().getEndpoints();
+ Assert.assertEquals(1, eps.size());
+ Assert.assertEquals("Helloworld2Component#service-binding(Helloworld/Helloworld)", eps.iterator().next().getURI());
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DependencyUtilsTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DependencyUtilsTestCase.java
new file mode 100644
index 0000000000..a2e6abd893
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DependencyUtilsTestCase.java
@@ -0,0 +1,61 @@
+/*
+ * 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.impl;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipInputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Test;
+
+public class DependencyUtilsTestCase {
+
+ @Test
+ public void loadTest() throws ValidationException, ContributionReadException, FileNotFoundException, IOException, XMLStreamException {
+
+ List<String> importDs = DependencyUtils.getDependencies("import", initZips());
+ Assert.assertEquals(1, importDs.size());
+ Assert.assertEquals("export", importDs.get(0));
+
+ List<String> exportDs = DependencyUtils.getDependencies("export", initZips());
+ Assert.assertEquals(0, exportDs.size());
+
+ List<String> unrelatedDs = DependencyUtils.getDependencies("unrelated", initZips());
+ Assert.assertEquals(0, unrelatedDs.size());
+ }
+
+ private Map<String, ZipInputStream> initZips() throws FileNotFoundException {
+ Map<String, ZipInputStream> contributions = new HashMap<String, ZipInputStream>();
+ contributions.put("import", new ZipInputStream(new BufferedInputStream(new FileInputStream("src/test/resources/import.jar"))));
+ contributions.put("export", new ZipInputStream(new BufferedInputStream(new FileInputStream("src/test/resources/export.jar"))));
+ contributions.put("unrelated", new ZipInputStream(new BufferedInputStream(new FileInputStream("src/test/resources/sample-helloworld-nodeployable.jar"))));
+ return contributions;
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DeployerTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DeployerTestCase.java
new file mode 100644
index 0000000000..9892b0d8a7
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DeployerTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * 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.impl;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DeployerTestCase {
+
+ @Test
+ public void testArtifacts() throws ContributionReadException, ValidationException {
+
+ Node node = TuscanyRuntime.newInstance().createNode();
+ String curi = node.installContribution("src/test/resources/sample-helloworld.jar");
+ node.validateContribution(curi);
+
+ Contribution contribution = node.getContribution(curi);
+ Composite composite = contribution.getArtifactModel("helloworld.composite");
+ Component component = composite.getComponents().get(0);
+ Service service = component.getImplementation().getServices().get(0);
+
+ Assert.assertEquals("helloworld", composite.getName().getLocalPart());
+ Assert.assertEquals("HelloworldComponent", component.getName());
+ Assert.assertEquals("Helloworld", service.getName());
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java
new file mode 100644
index 0000000000..d89271f14b
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/DirectoryDomainTestCase.java
@@ -0,0 +1,123 @@
+/*
+ * 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.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.ContributionDescription;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.annotation.Remotable;
+
+public class DirectoryDomainTestCase {
+
+ @Test
+ public void testDefaultDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
+ Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/default"));
+
+ Assert.assertEquals("default", node.getDomainName());
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals("sample-helloworld", node.getInstalledContributionURIs().get(0));
+ Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+ }
+
+ @Test
+ public void testMyDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
+ Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/MyDomain"));
+
+ Assert.assertEquals("foo", node.getDomainName());
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals("helloworld-contribution", node.getInstalledContributionURIs().get(0));
+
+ // validate additional deployable composite
+ Map<String, List<String>> scs = node.getStartedCompositeURIs();
+ Assert.assertEquals(2, scs.get("helloworld-contribution").size());
+ Assert.assertTrue(scs.get("helloworld-contribution").contains("helloworld.composite"));
+ Assert.assertTrue(scs.get("helloworld-contribution").contains("helloworld2.composite"));
+
+ // validate metadata side file
+ ContributionDescription ic = node.getInstalledContribution("helloworld-contribution");
+ Assert.assertEquals(1, ic.getJavaExports().size());
+ Assert.assertEquals("sample", ic.getJavaExports().get(0));
+ }
+
+ @Test
+ public void testNodeXMLFile() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
+ Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/helloworldNode.xml"));
+ Assert.assertEquals("helloworld", node.getDomainName());
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, cs.size());
+ Assert.assertEquals("sample-helloworld", cs.get(0));
+ Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, startedComposites.size());
+ Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
+ }
+
+ @Test
+ public void testNodeXMLDomain() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
+ Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/NodeXMLDomain"));
+ Assert.assertEquals("helloworld", node.getDomainName());
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, cs.size());
+ Assert.assertEquals("sample-helloworld", cs.get(0));
+ Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, startedComposites.size());
+ Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
+ }
+
+ @Test
+ public void testExploded() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException {
+ Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/exploded"));
+ Assert.assertEquals("exploded", node.getDomainName());
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, cs.size());
+ Assert.assertEquals("sample-helloworld", cs.get(0));
+ Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, startedComposites.size());
+ Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
+ }
+
+ @Test
+ public void testDependencies() throws ContributionReadException, ActivationException, ValidationException, XMLStreamException, IOException, NoSuchServiceException {
+ Node node = TuscanyRuntime.newInstance().createNode(new File("src/test/resources/test-domains/dependencies"));
+ Assert.assertEquals("dependencies", node.getDomainName());
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(4, cs.size());
+ Assert.assertEquals("Hello 1 Petra", node.getService(TestIface.class, "Helloworld1Component").sayHello("Petra"));
+ Assert.assertEquals("Hello 2 Amelia", node.getService(TestIface.class, "Helloworld2Component").sayHello("Amelia"));
+ }
+
+ @Remotable
+ interface TestIface {
+ String sayHello(String name);
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java
new file mode 100644
index 0000000000..04dca98062
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/Node2TestCase.java
@@ -0,0 +1,315 @@
+/*
+ * 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.impl;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.ContributionDescription;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class Node2TestCase {
+
+ @Test
+ public void localInstall() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
+ node.installContribution("src/test/resources/import.jar");
+
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals("import", node.getInstalledContributionURIs().get(0));
+ Contribution c = node.getContribution("import");
+ Assert.assertNotNull(c);
+ }
+
+ @Test
+ public void remoteInstall() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
+ node.installContribution("http://repository.apache.org/content/groups/snapshots/org/apache/tuscany/sca/samples/helloworld/2.0-SNAPSHOT/helloworld-2.0-SNAPSHOT.jar");
+
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals("helloworld", node.getInstalledContributionURIs().get(0));
+ Contribution c = node.getContribution("helloworld");
+ Assert.assertNotNull(c);
+ }
+
+ @Ignore("TUSCANY-3953")
+ @Test
+ public void DistributedInstall() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
+ try {
+ Node nodeA = runtime.createNode("uri:DistributedInstall");
+ nodeA.installContribution("http://repository.apache.org/content/groups/snapshots/org/apache/tuscany/sca/samples/helloworld/2.0-SNAPSHOT/helloworld-2.0-SNAPSHOT.jar");
+ nodeA.installContribution("src/test/resources/export.jar");
+
+ Assert.assertEquals(2, nodeA.getInstalledContributionURIs().size());
+ Assert.assertTrue(nodeA.getInstalledContributionURIs().contains("export"));
+ Assert.assertTrue(nodeA.getInstalledContributionURIs().contains("helloworld"));
+ Contribution cA = nodeA.getContribution("helloworld");
+ Assert.assertNotNull(cA);
+
+ Node nodeB = runtime.createNode("uri:DistributedInstall");
+ Assert.assertEquals(2, nodeB.getInstalledContributionURIs().size());
+ Assert.assertTrue(nodeB.getInstalledContributionURIs().contains("export"));
+ Assert.assertTrue(nodeB.getInstalledContributionURIs().contains("helloworld"));
+ Contribution cB = nodeB.getContribution("helloworld");
+ Assert.assertNotNull(cB);
+
+ ContributionDescription cd = ((NodeImpl)nodeB).getInstalledContribution("export");
+ Assert.assertEquals(1, cd.getJavaExports().size());
+ Assert.assertEquals("sample", cd.getJavaExports().get(0));
+ } finally {
+ runtime.stop();
+ }
+ }
+
+ @Test
+ public void deployables() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
+ node.installContribution("src/test/resources/import.jar");
+
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals("import", node.getInstalledContributionURIs().get(0));
+ List<String> ds = node.getDeployableCompositeURIs("import");
+ Assert.assertEquals(1, ds.size());
+ Assert.assertEquals("helloworld.composite", ds.get(0));
+
+ }
+
+ @Test
+ public void exports() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
+ node.installContribution("src/test/resources/export.jar");
+
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals("export", node.getInstalledContributionURIs().get(0));
+
+ ContributionDescription cd = ((NodeImpl)node).getInstalledContribution("export");
+ Assert.assertEquals(1, cd.getJavaExports().size());
+ Assert.assertEquals("sample", cd.getJavaExports().get(0));
+ }
+
+ @Test
+ public void validValidate() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
+ node.installContribution("src/test/resources/sample-helloworld.jar");
+ node.validateContribution("sample-helloworld");
+ }
+
+ @Test
+ public void invalidValidate() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
+ node.installContribution("src/test/resources/import.jar");
+ try {
+ node.validateContribution("import");
+ } catch (ValidationException e) {
+ Assert.assertTrue(e.getMessage().endsWith("Unresolved import: Import = sample"));
+ }
+ }
+
+ @Test
+ public void importExportValidate() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
+ node.installContribution("src/test/resources/import.jar");
+ try {
+ node.validateContribution("import");
+ } catch (ValidationException e) {
+ // expected
+ }
+ node.installContribution("src/test/resources/export.jar");
+ node.validateContribution("import");
+ node.startComposite("import", "helloworld.composite");
+ Map<String, List<String>> scs = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, scs.size());
+ }
+
+ @Ignore("TUSCANY-3953")
+ @Test
+ public void importExportDistributedValidate() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
+ try {
+ Node nodeA = runtime.createNode("uri:ImportTestCase");
+ nodeA.installContribution("src/test/resources/import.jar");
+ try {
+ nodeA.validateContribution("import");
+ } catch (ValidationException e) {
+ // expected
+ }
+ Node nodeB =runtime.createNode("uri:ImportTestCase");
+ nodeB.installContribution("src/test/resources/export.jar");
+ nodeA.validateContribution("import");
+ nodeA.startComposite("import", "helloworld.composite");
+ Map<String, List<String>> scs = nodeB.getStartedCompositeURIs();
+ Assert.assertEquals(1, scs.size());
+ }finally {
+ runtime.stop();
+ }
+
+ }
+
+ @Test
+ public void startTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("ImportTestCase");
+ node.installContribution("src/test/resources/sample-helloworld.jar");
+ Assert.assertEquals(0, node.getStartedCompositeURIs().size());
+
+ node.startComposite("sample-helloworld", "helloworld.composite");
+ Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+ Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+
+ node.stopComposite("sample-helloworld", "helloworld.composite");
+// Assert.assertEquals(0, node.getStartedComposites().size());
+ node.startComposite("sample-helloworld", "helloworld.composite");
+ Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+ Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+ node.stopComposite("sample-helloworld", "helloworld.composite");
+ }
+
+ @Ignore("TUSCANY-3953")
+ @Test
+ public void startDistributedTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, InterruptedException {
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
+ try {
+ Node node = runtime.createNode("uri:ImportTestCase");
+ Node node2 = runtime.createNode("uri:ImportTestCase");
+
+ node.installContribution("src/test/resources/sample-helloworld.jar");
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals(1, node2.getInstalledContributionURIs().size());
+
+ node.startComposite("sample-helloworld", "helloworld.composite");
+ Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+ Assert.assertEquals(1, node2.getStartedCompositeURIs().size());
+
+ Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+ Assert.assertEquals("helloworld.composite", node2.getStartedCompositeURIs().get("sample-helloworld").get(0));
+
+ node.stopComposite("sample-helloworld", "helloworld.composite");
+ Assert.assertEquals(0, node.getStartedCompositeURIs().size());
+ Assert.assertEquals(0, node2.getStartedCompositeURIs().size());
+
+ node2.startComposite("sample-helloworld", "helloworld.composite");
+ Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+ Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+
+ Assert.assertEquals(1, node2.getStartedCompositeURIs().size());
+ Assert.assertEquals("helloworld.composite", node2.getStartedCompositeURIs().get("sample-helloworld").get(0));
+
+ } finally {
+ runtime.stop();
+ }
+ }
+
+ @Test
+ public void addDeploymentCompositeTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
+ Node node = TuscanyRuntime.newInstance().createNode("addDeploymentCompositeTest");
+ String curi = node.installContribution("src/test/resources/sample-helloworld.jar");
+
+ String compositeXML =
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
+ + " targetNamespace=\"http://test/composite\""
+ + " name=\"TestComposite\">"
+ + " <component name=\"TestComponent\">"
+ + " <implementation.java class=\"sample.HelloworldImpl\"/>"
+ + " </component>"
+ + "</composite>";
+ String compositeURI = node.addDeploymentComposite(curi, new StringReader(compositeXML));
+
+ node.startComposite(curi, compositeURI);
+ Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+
+ Composite dc = node.getDomainComposite();
+ Assert.assertEquals(1, dc.getIncludes().size());
+ Composite runningComposite = dc.getIncludes().get(0);
+ Assert.assertEquals("TestComposite", runningComposite.getName().getLocalPart());
+ }
+
+ @Test
+ public void invalidCompositeStartTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
+ Node node = TuscanyRuntime.newInstance().createNode("invalidCompositeStartTest");
+ String curi = node.installContribution("src/test/resources/helloworld-invalidComposite.jar");
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ Assert.assertEquals(0, node.getStartedCompositeURIs().size());
+ ContributionDescription cd = node.getInstalledContribution(curi);
+ Assert.assertEquals(1, cd.getDeployables().size());
+
+ String compositeXML =
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
+ + " targetNamespace=\"http://test/composite\""
+ + " name=\"TestComposite\">"
+ + " <component name=\"TestComponent\">"
+ + " <implementation.java class=\"sample.HelloworldImpl\"/>"
+ + " </component>"
+ + "</composite>";
+ String compositeURI = node.addDeploymentComposite(curi, new StringReader(compositeXML));
+ node.startComposite(curi, compositeURI);
+
+// node.startComposite("sample-helloworld", "helloworld.composite");
+// Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+// Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+//
+// node.stopComposite("sample-helloworld", "helloworld.composite");
+//// Assert.assertEquals(0, node.getStartedComposites().size());
+// node.startComposite("sample-helloworld", "helloworld.composite");
+// Assert.assertEquals(1, node.getStartedCompositeURIs().size());
+// Assert.assertEquals("helloworld.composite", node.getStartedCompositeURIs().get("sample-helloworld").get(0));
+// node.stopComposite("sample-helloworld", "helloworld.composite");
+ }
+
+ @Test
+ public void stopAndUnistallTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException {
+ Node node = TuscanyRuntime.newInstance().createNode("stopAndUnistallTest");
+ node.installContribution("src/test/resources/import.jar");
+ node.installContribution("src/test/resources/export.jar");
+ String compositeXML =
+ "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\""
+ + " xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\""
+ + " targetNamespace=\"http://test/composite\""
+ + " name=\"TestComposite\">"
+ + " <component name=\"TestComponent\">"
+ + " <implementation.java class=\"sample.HelloworldImpl\"/>"
+ + " </component>"
+ + "</composite>";
+ String compositeURI = node.addDeploymentComposite("export", new StringReader(compositeXML));
+ node.startComposite("import", "helloworld.composite");
+ node.startComposite("export", compositeURI);
+ Assert.assertEquals(2, node.getInstalledContributionURIs().size());
+ node.stopCompositeAndUninstallUnused("import", "helloworld.composite");
+ Assert.assertEquals(1, node.getInstalledContributionURIs().size());
+ node.stopCompositeAndUninstallUnused("export", compositeURI);
+ Assert.assertEquals(0, node.getInstalledContributionURIs().size());
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/UsedCompositesTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/UsedCompositesTestCase.java
new file mode 100644
index 0000000000..b5c24c4450
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/impl/UsedCompositesTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * 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.impl;
+
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.junit.Assert;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class UsedCompositesTestCase {
+
+ @Test
+ public void includeTest1() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, FileNotFoundException {
+ Node node = TuscanyRuntime.newInstance().createNode("localTest");
+ String curi = node.installContribution("src/test/resources/sample-helloworld.jar");
+ String compositeURI = node.addDeploymentComposite(curi, new FileReader("src/test/resources/include.composite"));
+
+ node.startComposite(curi, compositeURI);
+
+ List<String> xs = ((NodeImpl)node).updateUsingComposites(curi, "helloworld.composite");
+ Assert.assertEquals(1, xs.size());
+ Assert.assertEquals("sample-helloworld/include.composite", xs.get(0));
+ }
+ @Test
+ public void implCompositeTest() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, FileNotFoundException {
+ Node node = TuscanyRuntime.newInstance().createNode("localTest");
+ String curi = node.installContribution("src/test/resources/sample-helloworld.jar");
+ String compositeURI = node.addDeploymentComposite(curi, new FileReader("src/test/resources/compositeImpl.composite"));
+
+ node.startComposite(curi, compositeURI);
+
+ List<String> xs = ((NodeImpl)node).updateUsingComposites(curi, "helloworld.composite");
+ Assert.assertEquals(1, xs.size());
+ Assert.assertEquals("sample-helloworld/compositeImpl.composite", xs.get(0));
+ }
+
+ @Test
+ public void nestedTest1() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, XMLStreamException, FileNotFoundException {
+ Node node = TuscanyRuntime.newInstance().createNode("NestedTest");
+ String curi = node.installContribution("src/test/resources/helloworld2.jar");
+
+ node.startComposite(curi, "compositeImpl.composite");
+
+ String compositeURI = node.addDeploymentComposite(curi, new FileReader("src/test/resources/nested.composite"));
+ node.startComposite(curi, compositeURI);
+
+ List<String> xs = ((NodeImpl)node).updateUsingComposites(curi, "helloworld.composite");
+ Assert.assertEquals(2, xs.size());
+ Assert.assertTrue(xs.contains("helloworld2/compositeImpl.composite"));
+ Assert.assertTrue(xs.contains("helloworld2/nested.composite"));
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/ClassLoaderReleaseTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/ClassLoaderReleaseTestCase.java
new file mode 100644
index 0000000000..4488458f5a
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/ClassLoaderReleaseTestCase.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.runtime;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.junit.Test;
+
+public class ClassLoaderReleaseTestCase {
+
+ @Test
+ public void testInstallDeployable() throws IOException, ActivationException{
+ File f = copyFile("src/test/resources/sample-helloworld.jar");
+ Node node = TuscanyRuntime.runComposite(null, f.toURI().toURL().toString());
+ // this delete should fail on Windows as the jar is locked, but the doesn't seem to happen in 'nix
+ boolean b = f.delete();
+ if (!b) {
+ Map<String, List<String>> scuris = node.getStartedCompositeURIs();
+ node.stopCompositeAndUninstallUnused(scuris.keySet().iterator().next(), scuris.get(scuris.keySet().iterator().next()).get(0));
+ Assert.assertTrue(f.delete());
+ }
+ }
+
+ private File copyFile(String fileName) throws IOException {
+ File f = new File(fileName);
+ File newFile = File.createTempFile(getClass().getName(), ".jar");
+ InputStream in = new FileInputStream(f);
+ OutputStream out = new FileOutputStream(newFile);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ return newFile;
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java
new file mode 100644
index 0000000000..f32ff81625
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DeployerTestCase.java
@@ -0,0 +1,96 @@
+/*
+ * 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.runtime;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.deployment.Deployer;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class DeployerTestCase {
+
+ @Test
+ public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException {
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+ Node node = tuscanyRuntime.createNode("myDomain");
+
+ Deployer deployer = tuscanyRuntime.getDeployer();
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor);
+ monitor.analyzeProblems();
+
+ node.installContribution(contribution, null);
+ List<String> ics = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, ics.size());
+ Assert.assertEquals("foo", ics.get(0));
+ }
+
+ @Test
+ public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException {
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+ Node node = tuscanyRuntime.createNode("myDomain");
+
+ node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null);
+
+ Deployer deployer = tuscanyRuntime.getDeployer();
+ Monitor monitor = deployer.createMonitor();
+ Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor);
+ monitor.analyzeProblems();
+ String cmpuri = node.addDeploymentComposite("foo", composite);
+ node.startComposite("foo", cmpuri);
+ Map<String, List<String>> dcs = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld2.composite", dcs.get("foo").get(0));
+ }
+
+ @Test
+ public void testAddDeploymentCompositeXML() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException, FileNotFoundException {
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+ Node node = tuscanyRuntime.createNode("myDomain");
+
+ node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null);
+
+ String cmpuri = node.addDeploymentComposite("foo", new FileReader(new File("src/test/resources/helloworld2.composite")));
+ node.startComposite("foo", cmpuri);
+ Map<String, List<String>> dcs = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld2.composite", dcs.get("foo").get(0));
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java
new file mode 100644
index 0000000000..a4fbf5fd42
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DomainCompositeTestCase.java
@@ -0,0 +1,71 @@
+/*
+ * 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.runtime;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.xml.Utils;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.impl.NodeImpl;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class DomainCompositeTestCase {
+
+ @Test
+ public void localOnlyDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("DomainCompositeTestCase");
+ testIt(node);
+ }
+
+ @Ignore("TUSCANY-3953")
+ @Test
+ public void distributedDomain() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
+ try {
+ Node node = runtime.createNode("uri:DomainCompositeTestCase");
+ testIt(node);
+ } finally { runtime.stop(); }
+ }
+
+ private void testIt(Node node) throws ContributionReadException, ActivationException, ValidationException {
+ node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null);
+ node.startComposite("helloworld", "helloworld.composite");
+
+ Composite dc = node.getDomainComposite();
+ Assert.assertEquals("DomainCompositeTestCase", dc.getName().getLocalPart());
+ Assert.assertEquals(1, dc.getIncludes().size());
+ Composite c = dc.getIncludes().get(0);
+ Assert.assertEquals("helloworld", c.getName().getLocalPart());
+
+// String s = node.getDomainLevelCompositeAsString();
+ System.out.println(Utils.modelToXML(node.getDomainComposite(), true, ((NodeImpl)node).getExtensionPointRegistry()));
+// Assert.assertTrue(s.contains(":helloworld\""));
+
+ node.stopComposite("helloworld", "helloworld.composite");
+ Assert.assertEquals(0, node.getDomainComposite().getIncludes().size());
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DynamicTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DynamicTestCase.java
new file mode 100644
index 0000000000..f05771e129
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/DynamicTestCase.java
@@ -0,0 +1,116 @@
+/*
+ * 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.runtime;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+/**
+ * Shows how to create and run composites dynamically
+ */
+public class DynamicTestCase {
+
+ @Test
+ public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, ClassNotFoundException, IntrospectionException, IllegalArgumentException, InvocationTargetException,
+ IllegalAccessException {
+
+ // get the various factories that will be needed
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+ ExtensionPointRegistry extensionPoints = tuscanyRuntime.getExtensionPointRegistry();
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+
+ // Create a contribution
+ ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
+ Contribution contribution = contributionFactory.createContribution();
+ contribution.setURI("testContribution");
+ ModelResolverExtensionPoint modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
+ ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
+ contribution.setModelResolver(modelResolver);
+ contribution.setClassLoader(new URLClassLoader(new URL[] {new File("src/test/resources/sample-helloworld.jar").toURI().toURL()}));
+
+ // Create a composite
+ AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ Composite composite = assemblyFactory.createComposite();
+ composite.setURI("testComposite");
+ composite.setName(new QName("testComposite"));
+
+ // create a component
+ Component component = assemblyFactory.createComponent();
+ component.setName("testComponent");
+ JavaImplementationFactory javaImplementationFactory = modelFactories.getFactory(JavaImplementationFactory.class);
+ JavaImplementation javaImplementation = javaImplementationFactory.createJavaImplementation(contribution.getClassLoader().loadClass("sample.HelloworldImpl"));
+ javaImplementation.setJavaClass(contribution.getClassLoader().loadClass("sample.HelloworldImpl"));
+ component.setImplementation(javaImplementation);
+
+ // add the component to the composite
+ composite.getComponents().add(component);
+
+ // add the composite to the contribution
+ contribution.addComposite(composite);
+
+ // Now run the composite with a Tuscany Node
+ Node node = tuscanyRuntime.createNode();
+ node.installContribution(contribution, null);
+ node.startComposite(contribution.getURI(), composite.getURI());
+
+ // test that the service has started and can be invoked
+ testService(node, contribution.getClassLoader());
+
+ node.stop();
+ tuscanyRuntime.stop();
+ }
+
+ private void testService(Node node, ClassLoader classLoader) throws ClassNotFoundException, NoSuchServiceException, NoSuchDomainException, IllegalArgumentException, InvocationTargetException, IllegalAccessException {
+ Class<?> interfaze = classLoader.loadClass("sample.Helloworld");
+ Object clientProxy = node.getService(interfaze, "testComponent/Helloworld");
+ Method m = interfaze.getMethods()[0]; // the helloworld interface just has a single method "sayHello"
+ Object response = m.invoke(clientProxy, new Object[] {"Ariana"});
+ Assert.assertEquals("Hello Ariana", response);
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.java
new file mode 100644
index 0000000000..c7041fa5b4
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/NodeXMLTestCase.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.runtime;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Test;
+
+public class NodeXMLTestCase {
+
+ @Test
+ public void testHelloworldXML() throws ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNodeFromXML("src/test/resources/helloworldNode.xml");
+ Assert.assertEquals("helloworld", node.getDomainName());
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, cs.size());
+ Assert.assertEquals("sample-helloworld", cs.get(0));
+ Map<String, List<String>> startedComposites = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, startedComposites.size());
+ Assert.assertEquals("helloworld.composite", startedComposites.get("sample-helloworld").get(0));
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java
new file mode 100644
index 0000000000..97b3755f2e
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.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 org.apache.tuscany.sca.runtime;
+
+import java.util.Properties;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+import sample.Helloworld;
+
+public class PerfTest {
+
+ @Test
+ public void testStopStart() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Properties config = new Properties();
+ config.setProperty(RuntimeProperties.QUIET_LOGGING, "true");
+ Node node = TuscanyRuntime.newInstance(config).createNode();
+ node.installContribution(null, "src/test/resources/sample-helloworld.jar", null, null);
+
+ validate(node);
+
+ int count = 3000;
+ long start = System.currentTimeMillis();
+ for (int i=0; i<count; i++) {
+ node.startComposite("sample-helloworld", "helloworld.composite");
+ node.stopComposite("sample-helloworld", "helloworld.composite");
+ }
+ long total = System.currentTimeMillis() - start;
+ System.out.println(count + " = " + total + " = " + total / (double)count);
+
+ // test it still works
+ validate(node);
+ }
+
+ private void validate(Node node) throws ActivationException, ValidationException, NoSuchServiceException, ContributionReadException {
+ node.startComposite("sample-helloworld", "helloworld.composite");
+
+ Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+
+ node.stopComposite("sample-helloworld", "helloworld.composite");
+ try {
+ node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.fail();
+ } catch (NoSuchServiceException e) {
+ // expected as there is no deployables
+ }
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java
new file mode 100644
index 0000000000..27292bbc08
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TuscanyRuntimeTestCase.java
@@ -0,0 +1,190 @@
+/*
+ * 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.runtime;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+import sample.Helloworld;
+
+public class TuscanyRuntimeTestCase {
+
+ @Test
+ public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null);
+ node.startComposite("helloworld", "helloworld.composite");
+
+ Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testStopStart() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null);
+ node.startComposite("helloworld", "helloworld.composite");
+
+ Map<String, List<String>> ci = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, ci.size());
+
+ Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+
+ node.stopComposite("helloworld", "helloworld.composite");
+ try {
+ node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.fail();
+ } catch (NoSuchServiceException e) {
+ // expected as there is no deployables
+ }
+
+ node.startComposite("helloworld", "helloworld.composite");
+ helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ @Ignore("Depdends on itest/T3558 which isn't in the build?")
+ public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("store", "../../testing/itest/T3558/src/test/resources/sample-store.jar", null, null);
+ node.installContribution("store-client", "../../testing/itest/T3558/src/test/resources/sample-store-client.jar", null, null);
+ node.startComposite("store", "store.composite");
+ node.startComposite("store-client", "store-client.composite");
+
+ Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null);
+
+ try {
+ node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.fail();
+ } catch (NoSuchServiceException e) {
+ // expected as there is no deployables
+ }
+
+ node.startComposite("helloworld", "helloworld.composite");
+ Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null);
+ List<String> ics = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, ics.size());
+ Assert.assertEquals("foo", ics.get(0));
+ }
+
+ @Test
+ public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null);
+ List<String> dcs = node.startDeployables("foo");
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld.composite", dcs.get(0));
+ }
+
+ @Test
+ public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null);
+ List<String> dcs = node.startDeployables("foo");
+ Assert.assertEquals(1, dcs.size());
+ Map<String, List<String>> dcsx = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, dcsx.size());
+ node.stopComposite("foo", "helloworld.composite");
+ dcsx = node.getStartedCompositeURIs();
+ Assert.assertEquals(0, dcsx.size());
+ }
+
+ @Test
+ public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException, NoSuchServiceException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null);
+ node.startComposite("helloworld", "helloworld.composite");
+
+ Map<String, List<String>> dcs = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld.composite", dcs.get("helloworld").get(0));
+
+ Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testURI() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ Node node = TuscanyRuntime.newInstance().createNode("default");
+ String uri = node.installContribution("src/test/resources/sample-helloworld.jar");
+ Assert.assertEquals("sample-helloworld", uri);
+ }
+
+ @Test
+ public void testStaticCreate() {
+ Node node = TuscanyRuntime.runComposite("helloworld.composite", "src/test/resources/sample-helloworld.jar");
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, cs.size());
+ Map<String, List<String>> dcs = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld.composite", dcs.get("sample-helloworld").get(0));
+ }
+
+ @Test
+ public void testStaticCreateWithNullComposite() {
+ Node node = TuscanyRuntime.runComposite(null, "src/test/resources/sample-helloworld.jar");
+ List<String> cs = node.getInstalledContributionURIs();
+ Assert.assertEquals(1, cs.size());
+ Map<String, List<String>> dcs = node.getStartedCompositeURIs();
+ Assert.assertEquals(1, dcs.size());
+ Assert.assertEquals("helloworld.composite", dcs.get("sample-helloworld").get(0));
+ }
+ @Test
+ public void testRunComposite() throws NoSuchServiceException {
+ Node node = TuscanyRuntime.runComposite("helloworld.composite", "src/test/resources/sample-helloworld.jar");
+ Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+
+ @Test
+ public void testRunCompositeSharedRuntime() throws NoSuchServiceException {
+ Node node = TuscanyRuntime.runComposite(URI.create("default"), "helloworld.composite", "src/test/resources/sample-helloworld.jar");
+ Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
new file mode 100644
index 0000000000..9c5a702d78
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
@@ -0,0 +1,52 @@
+/*
+ * 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.runtime;
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.monitor.ValidationException;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+import sample.Helloworld;
+
+@Ignore("TUSCANY-3953")
+public class TwoNodesTestCase {
+
+ @Test
+ public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
+ TuscanyRuntime runtime = TuscanyRuntime.newInstance();
+ try {
+ Node node1 = runtime.createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44331");
+ node1.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null);
+ node1.startComposite("helloworld", "helloworld.composite");
+
+ Node node2 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44332&wka=127.0.0.1:44331");
+
+ Helloworld helloworldService = node2.getService(Helloworld.class, "HelloworldComponent");
+ Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+ } finally { runtime.stop(); }
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/sample/Helloworld.java b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/sample/Helloworld.java
new file mode 100644
index 0000000000..b67efbb485
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/java/sample/Helloworld.java
@@ -0,0 +1,27 @@
+/*
+ * 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 sample;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+ String sayHello(String name);
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/compositeImpl.composite b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/compositeImpl.composite
new file mode 100644
index 0000000000..735bf3bbcc
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/compositeImpl.composite
@@ -0,0 +1,30 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sample="http://sample"
+ targetNamespace="http://sample"
+ name="compositeImpl">
+
+ <component name="Helloworld2Component">
+ <implementation.composite name="sample:helloworld"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/export.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/export.jar
new file mode 100644
index 0000000000..0ca3450bed
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/export.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld-invalidComposite.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld-invalidComposite.jar
new file mode 100644
index 0000000000..fa35a21696
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld-invalidComposite.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld2.composite b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld2.composite
new file mode 100644
index 0000000000..8c7a789380
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld2.composite
@@ -0,0 +1,29 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld2">
+
+ <component name="Helloworld2Component">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld2.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld2.jar
new file mode 100644
index 0000000000..2f8e473cd0
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworld2.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworldNode.xml b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworldNode.xml
new file mode 100644
index 0000000000..ea2f577139
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/helloworldNode.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ domain="helloworld">
+
+ <contribution location="sample-helloworld.jar" startDeployables="true" />
+
+</node> \ No newline at end of file
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/import.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/import.jar
new file mode 100644
index 0000000000..4931074878
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/import.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/include.composite b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/include.composite
new file mode 100644
index 0000000000..a1d9a658be
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/include.composite
@@ -0,0 +1,28 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sample="http://sample"
+ targetNamespace="http://sample"
+ name="include">
+
+ <include name="sample:helloworld" />
+
+</composite>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar
new file mode 100644
index 0000000000..7f6073ce7f
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar
new file mode 100644
index 0000000000..2306ce4d1a
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/nested.composite b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/nested.composite
new file mode 100644
index 0000000000..1c31941a83
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/nested.composite
@@ -0,0 +1,28 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sample="http://sample"
+ targetNamespace="http://sample"
+ name="nested">
+
+ <include name="sample:compositeImpl" />
+
+</composite>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar
new file mode 100644
index 0000000000..16dde03858
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld.jar
new file mode 100644
index 0000000000..1ea85c8e63
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld2.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld2.jar
new file mode 100644
index 0000000000..80b8b2315f
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sample-helloworld2.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sca-contribution-generated.xml b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sca-contribution-generated.xml
new file mode 100644
index 0000000000..8e20561dc3
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/sca-contribution-generated.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:helloworld"/>
+</contribution>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/domain.properties b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/domain.properties
new file mode 100644
index 0000000000..d7ac22d6ad
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/domain.properties
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+domainName=foo
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.deployable.composite b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.deployable.composite
new file mode 100644
index 0000000000..8c7a789380
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.deployable.composite
@@ -0,0 +1,29 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld2">
+
+ <component name="Helloworld2Component">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.jar
new file mode 100644
index 0000000000..5198370d85
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.xml b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.xml
new file mode 100644
index 0000000000..2788e14022
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/helloworld-contribution.xml
@@ -0,0 +1,23 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <export.java package="sample" />
+</contribution>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/readme.txt b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/readme.txt
new file mode 100644
index 0000000000..10114926c4
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/MyDomain/readme.txt
@@ -0,0 +1,8 @@
+A file named domain.properties is used to override the domain name, see in the properties file for what
+other properties are supportted.
+
+Side files are used to modify the helloworld-contribution.jar installed contribution.
+- sca-contribution.xml metaData is modified by having a metaData side file named helloworld-contribution.xml
+- additional deployment composites are added with files named helloworld-contribution.<anything>.composite
+
+
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml
new file mode 100644
index 0000000000..1fe1ccff14
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/node.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ domain="helloworld">
+
+ <contribution location="../../sample-helloworld.jar" startDeployables="true" />
+
+</node> \ No newline at end of file
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/readme.txt b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/readme.txt
new file mode 100644
index 0000000000..15dac7bd0c
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/NodeXMLDomain/readme.txt
@@ -0,0 +1,2 @@
+The domain directory gets all its config from a config XML file named node.xml,
+which may refer to contributions at another location outside of the directory. \ No newline at end of file
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/default/readme.txt b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/default/readme.txt
new file mode 100644
index 0000000000..34b3e347ff
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/default/readme.txt
@@ -0,0 +1,4 @@
+The simplest domain. Just a directory of contrbutions,
+the domain is named with the directory name an the contributions
+are installed and all deployables are started.
+ \ No newline at end of file
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/default/sample-helloworld.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/default/sample-helloworld.jar
new file mode 100644
index 0000000000..1ea85c8e63
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/default/sample-helloworld.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/export1.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/export1.jar
new file mode 100644
index 0000000000..b2755b65c5
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/export1.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/export2.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/export2.jar
new file mode 100644
index 0000000000..eec5ded5ee
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/export2.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import1.dependencies b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import1.dependencies
new file mode 100644
index 0000000000..b7c54895d0
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import1.dependencies
@@ -0,0 +1,19 @@
+# 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.
+
+ export1
+
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import1.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import1.jar
new file mode 100644
index 0000000000..8402f6e3c3
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import1.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import2.dependencies b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import2.dependencies
new file mode 100644
index 0000000000..dd3052994c
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import2.dependencies
@@ -0,0 +1,19 @@
+# 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.
+
+export2
+
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import2.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import2.jar
new file mode 100644
index 0000000000..6667994eb6
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/import2.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/readme.txt b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/readme.txt
new file mode 100644
index 0000000000..fc645c0682
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/dependencies/readme.txt
@@ -0,0 +1,14 @@
+Uses the domain.properties file to show explicitly defining a contrbutions dependent contribution URIS.
+
+Contributions export1.jar and export2.jar both export the Java package "sample" and both have
+a class sample.HelloworldImpl but the classes return a sayHello string "Hello 1" in export1.jar
+and "Hello 2" in export2.jar.
+
+Contributions import1.jar and import2.jar both import the package sample and use the
+sample.HelloworldImpl class in the component implementation.
+
+The *.dependencies files explicitly set the dependency URIs used by
+Contributions import1.jar and import2.jar, without the explicit property the imports would just t
+use the first contribution found that exports the sample package.
+
+See section 10.2.1 and 10.4 in the Assembly spec.
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/readme.txt b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/readme.txt
new file mode 100644
index 0000000000..ea7af2b3f7
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/readme.txt
@@ -0,0 +1,4 @@
+A domain directory showing a contribution jar exploded into a contribution directory.
+In this case the contribution jar is ignored and the contribution directory is used.
+Thats the same approach used for things like Tomcat with exploded webapps and it
+enables more easily supporting dynamic updates to individual files in a contribution. \ No newline at end of file
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld.jar b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld.jar
new file mode 100644
index 0000000000..1ea85c8e63
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld.jar
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/MANIFEST.MF b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c5d7d06f98
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Created-By: Apache Maven
+Built-By: ant
+Build-Jdk: 1.6.0_18
+Extension-Name: sample-helloworld
+Implementation-Title: Apache Tuscany SCA Sample Helloworld
+Implementation-Vendor: The Apache Software Foundation
+Implementation-Vendor-Id: org.apache
+Implementation-Version: 2.0-SNAPSHOT
+Specification-Title: Apache Tuscany SCA Sample Helloworld
+Specification-Vendor: The Apache Software Foundation
+Specification-Version: 2.0-SNAPSHOT
+
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/maven/org.apache.tuscany.sca/sample-helloworld/pom.properties b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/maven/org.apache.tuscany.sca/sample-helloworld/pom.properties
new file mode 100644
index 0000000000..ff83691757
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/maven/org.apache.tuscany.sca/sample-helloworld/pom.properties
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Wed May 19 10:03:09 BST 2010
+version=2.0-SNAPSHOT
+groupId=org.apache.tuscany.sca
+artifactId=sample-helloworld
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/maven/org.apache.tuscany.sca/sample-helloworld/pom.xml b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/maven/org.apache.tuscany.sca/sample-helloworld/pom.xml
new file mode 100644
index 0000000000..e480d4f534
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/maven/org.apache.tuscany.sca/sample-helloworld/pom.xml
@@ -0,0 +1,58 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <packaging>jar</packaging>
+ <artifactId>sample-helloworld</artifactId>
+ <name>Apache Tuscany SCA Sample Helloworld</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/sca-contribution.xml b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e81e94d9a1
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:helloworld"/>
+ <export.java package="sample" />
+</contribution>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/helloworld.composite b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/helloworld.composite
new file mode 100644
index 0000000000..324395c246
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/helloworld.composite
@@ -0,0 +1,29 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/sample/Helloworld.class b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/sample/Helloworld.class
new file mode 100644
index 0000000000..19c82db88e
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/sample/Helloworld.class
Binary files differ
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/sample/HelloworldImpl.class b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/sample/HelloworldImpl.class
new file mode 100644
index 0000000000..575b3370c4
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/domain-node/src/test/resources/test-domains/exploded/sample-helloworld/sample/HelloworldImpl.class
Binary files differ