summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java5
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java21
-rw-r--r--sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java17
-rw-r--r--sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java26
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java3
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java56
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java2
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java24
-rw-r--r--sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java2
9 files changed, 120 insertions, 36 deletions
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
index 4965b7c15a..0f107012c1 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
@@ -84,4 +84,9 @@ public interface EndpointRegistry {
void removeRunningComposite(QName name);
Composite getRunningComposite(QName name);
List<QName> getRunningCompositeNames();
+
+ void installContribution(String uri, String url);
+ List<String> getInstalledContributionURIs();
+ String getInstalledContributionURL(String uri);
+ void uninstallContribution(String uri);
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
index 6badcd74ef..61514df01f 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
@@ -49,6 +49,7 @@ public class EndpointRegistryImpl extends BaseEndpointRegistry implements Endpoi
private List<Endpoint> endpoints = new ArrayList<Endpoint>();
private Map<QName, Composite> runningComposites = new HashMap<QName, Composite>();
+ private Map<String, String> installedContributions = new HashMap<String, String>();
protected boolean quietLogging;
@@ -161,22 +162,18 @@ public class EndpointRegistryImpl extends BaseEndpointRegistry implements Endpoi
listeners.clear();
}
- @Override
public void addRunningComposite(Composite composite) {
runningComposites.put(composite.getName(), composite);
}
- @Override
public void removeRunningComposite(QName name) {
runningComposites.remove(name);
}
- @Override
public Composite getRunningComposite(QName name) {
return runningComposites.get(name);
}
- @Override
public List<QName> getRunningCompositeNames() {
List<QName> compositeNames = new ArrayList<QName>();
for (Composite composite : runningComposites.values()) {
@@ -185,4 +182,20 @@ public class EndpointRegistryImpl extends BaseEndpointRegistry implements Endpoi
return compositeNames;
}
+ public void installContribution(String uri, String url) {
+ installedContributions.put(uri, url);
+ }
+
+ public List<String> getInstalledContributionURIs() {
+ return new ArrayList<String>(installedContributions.keySet());
+ }
+
+ public String getInstalledContributionURL(String uri) {
+ return installedContributions.get(uri);
+ }
+
+ public void uninstallContribution(String uri) {
+ installedContributions.remove(uri);
+ }
+
}
diff --git a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
index ed903134a7..4dfda2f5b9 100644
--- a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
+++ b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
@@ -837,23 +837,32 @@ public class DeployerImpl implements Deployer {
public void stop() {
}
- @Override
public void addRunningComposite(Composite composite) {
}
- @Override
public void removeRunningComposite(QName name) {
}
- @Override
public Composite getRunningComposite(QName name) {
return null;
}
- @Override
public List<QName> getRunningCompositeNames() {
return null;
}
+ public void installContribution(String uri, String url) {
+ }
+
+ public List<String> getInstalledContributionURIs() {
+ return null;
+ }
+
+ public String getInstalledContributionURL(String uri) {
+ return null;
+ }
+
+ public void uninstallContribution(String uri) {
+ }
}
}
diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
index 8125a2c886..a0144b0a63 100644
--- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
@@ -99,7 +99,9 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
protected Map<Object, Object> endpointWsdls;
protected Map<String, Endpoint> localEndpoints = new ConcurrentHashMap<String, Endpoint>();
-
+
+ protected Map<String, String> installedContributions;
+
protected AssemblyFactory assemblyFactory;
protected Object shutdownMutex = new Object();
protected Properties properties;
@@ -141,6 +143,8 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
runningComposites = hazelcastInstance.getMap(domainURI + "/CompositeOwners");
runningCompositeOwners = hazelcastInstance.getMultiMap(domainURI + "/CompositeOwners");
+ installedContributions = hazelcastInstance.getMap(domainURI + "/InstalledContributions");
+
hazelcastInstance.getCluster().addMembershipListener(this);
// }
}
@@ -485,7 +489,6 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
return null;
}
- @Override
public void addRunningComposite(Composite composite) {
String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
String compositeXML = writeComposite(composite);
@@ -501,7 +504,6 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
}
}
- @Override
public void removeRunningComposite(QName name) {
String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
Transaction txn = hazelcastInstance.getTransaction();
@@ -516,13 +518,11 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
}
}
- @Override
public Composite getRunningComposite(QName name) {
String compositeXML = runningComposites.get(name);
return readComposite(compositeXML);
}
- @Override
public List<QName> getRunningCompositeNames() {
return new ArrayList<QName>(runningCompositeOwners.values());
}
@@ -557,4 +557,20 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
throw new RuntimeException(e);
}
}
+
+ public void installContribution(String uri, String url) {
+ installedContributions.put(uri, url);
+ }
+
+ public List<String> getInstalledContributionURIs() {
+ return new ArrayList<String>(installedContributions.keySet());
+ }
+
+ public String getInstalledContributionURL(String uri) {
+ return installedContributions.get(uri);
+ }
+
+ public void uninstallContribution(String uri) {
+ installedContributions.remove(uri);
+ }
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java
index 046ce4ac83..afdfe90c3c 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java
@@ -162,8 +162,9 @@ public interface Node {
* @param compositeURI
* @throws ActivationException
* @throws ValidationException
+ * @throws ContributionReadException
*/
- void start(String contributionURI, String compositeURI) throws ActivationException, ValidationException;
+ void start(String contributionURI, String compositeURI) throws ActivationException, ValidationException, ContributionReadException;
/**
* 4687 10.7.2 remove From Domain-Level Composite
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
index 1fc20867da..28a7952b19 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
@@ -85,7 +85,7 @@ public class NodeImpl implements Node {
private EndpointRegistry endpointRegistry;
private ExtensionPointRegistry extensionPointRegistry;
private TuscanyRuntime tuscanyRuntime;
- private Map<String, InstalledContribution> installedContributions = new HashMap<String, InstalledContribution>();
+ private Map<String, InstalledContribution> locallyInstalledContributions = new HashMap<String, InstalledContribution>();
private static Map<String, Node> allNodes = new HashMap<String, Node>();
@@ -107,6 +107,15 @@ public class NodeImpl implements Node {
if (uri == null) {
uri = getDefaultContributionURI(contributionURL);
}
+ endpointRegistry.installContribution(uri, contributionURL);
+ if (startDeployables) {
+ // TODO: sort out metadata and dependents in distributed
+ localInstall(uri, contributionURL, metaDataURL, dependentContributionURIs, startDeployables);
+ }
+ return uri;
+ }
+
+ private void localInstall(String uri, String contributionURL, String metaDataURL, List<String> dependentContributionURIs, boolean startDeployables) throws ContributionReadException, ValidationException, ActivationException {
Monitor monitor = deployer.createMonitor();
Contribution contribution = deployer.loadContribution(IOHelper.createURI(uri), IOHelper.getLocationAsURL(contributionURL), monitor);
monitor.analyzeProblems();
@@ -114,7 +123,6 @@ public class NodeImpl implements Node {
mergeContributionMetaData(metaDataURL, contribution);
}
installContribution(contribution, dependentContributionURIs, startDeployables);
- return uri;
}
private void mergeContributionMetaData(String metaDataURL, Contribution contribution) throws ValidationException {
@@ -133,7 +141,7 @@ public class NodeImpl implements Node {
public String installContribution(Contribution contribution, List<String> dependentContributionURIs, boolean startDeployables) throws ContributionReadException, ActivationException, ValidationException {
InstalledContribution ic = new InstalledContribution(contribution.getURI(), contribution.getLocation(), contribution, dependentContributionURIs);
- installedContributions.put(contribution.getURI(), ic);
+ locallyInstalledContributions.put(contribution.getURI(), ic);
if (startDeployables) {
for (Composite c : ic.getDefaultDeployables()) {
startComposite(c, ic);
@@ -159,14 +167,14 @@ public class NodeImpl implements Node {
if (ic.getDependentContributionURIs() != null) {
// if the install specified dependent uris use just those contributions
for (String uri : ic.getDependentContributionURIs()) {
- InstalledContribution dependee = installedContributions.get(uri);
+ InstalledContribution dependee = locallyInstalledContributions.get(uri);
if (dependee != null) {
dependentContributions.add(dependee.getContribution());
}
}
} else {
// otherwise use all available contributions for dependents
- for (InstalledContribution ics : installedContributions.values()) {
+ for (InstalledContribution ics : locallyInstalledContributions.values()) {
dependentContributions.add(ics.getContribution());
}
}
@@ -181,7 +189,7 @@ public class NodeImpl implements Node {
}
public String start(String contributionURI, Composite composite) throws ActivationException, ValidationException {
- InstalledContribution ic = installedContributions.get(contributionURI);
+ InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
if (ic == null) {
throw new IllegalArgumentException("contribution not installed: " + contributionURI);
}
@@ -190,10 +198,15 @@ public class NodeImpl implements Node {
return compositeArtifcatURI;
}
- public void start(String contributionURI, String compositeURI) throws ActivationException, ValidationException {
- InstalledContribution ic = installedContributions.get(contributionURI);
+ public void start(String contributionURI, String compositeURI) throws ActivationException, ValidationException, ContributionReadException {
+ InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
if (ic == null) {
- throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ String url = endpointRegistry.getInstalledContributionURL(contributionURI);
+ if (url == null) {
+ throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+ }
+ localInstall(contributionURI, url, null, null, false);
+ ic = locallyInstalledContributions.get(contributionURI);
}
if (!ic.restart(compositeURI)) {
for (Artifact a : ic.getContribution().getArtifacts()) {
@@ -208,7 +221,7 @@ public class NodeImpl implements Node {
@Override
public void stop(String contributionURI, String compositeURI) throws ActivationException {
- InstalledContribution ic = installedContributions.get(contributionURI);
+ InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
if (ic == null) {
throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
}
@@ -251,14 +264,17 @@ public class NodeImpl implements Node {
}
public List<String> removeContribution(String contributionURI) throws ActivationException {
+ endpointRegistry.uninstallContribution(contributionURI);
+
+ // TODO: should this next bit happen?
List<String> removedContributionURIs = new ArrayList<String>();
- InstalledContribution ic = installedContributions.get(contributionURI);
+ InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
if (ic != null) {
removedContributionURIs.add(ic.getURI());
for (String dependent : getDependentContributions(contributionURI)) {
removedContributionURIs.addAll(removeContribution(dependent));
}
- installedContributions.remove(contributionURI);
+ locallyInstalledContributions.remove(contributionURI);
for (String compositeURI : ic.getStartedCompositeURIs()) {
ic.stop(compositeURI);
}
@@ -285,7 +301,7 @@ public class NodeImpl implements Node {
}
public void stop() {
- ArrayList<String> ics = new ArrayList<String>(installedContributions.keySet());
+ ArrayList<String> ics = new ArrayList<String>(locallyInstalledContributions.keySet());
for (String uri : ics) {
try {
removeContribution(uri);
@@ -430,7 +446,7 @@ public class NodeImpl implements Node {
}
public List<String> getStartedCompositeURIs(String contributionURI) {
- InstalledContribution ic = installedContributions.get(contributionURI);
+ InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
if (ic == null) {
throw new IllegalArgumentException("no contribution found for: " + contributionURI);
}
@@ -438,19 +454,19 @@ public class NodeImpl implements Node {
}
public List<String> getInstalledContributionURIs() {
- return new ArrayList<String>(installedContributions.keySet());
+ return new ArrayList<String>(locallyInstalledContributions.keySet());
}
public Contribution getInstalledContribution(String uri) {
- if (installedContributions.containsKey(uri)) {
- return installedContributions.get(uri).getContribution();
+ if (locallyInstalledContributions.containsKey(uri)) {
+ return locallyInstalledContributions.get(uri).getContribution();
}
throw new IllegalArgumentException("no contribution found for: " + uri);
}
protected String getContributionUriForArtifact(String artifactURI) {
String contributionURI = null;
- for (String uri : installedContributions.keySet()) {
+ for (String uri : locallyInstalledContributions.keySet()) {
if (artifactURI.startsWith(uri)) {
contributionURI = uri;
break;
@@ -469,12 +485,12 @@ public class NodeImpl implements Node {
}
public Set<String> getDependentContributions(String contributionURI) {
- InstalledContribution ic = installedContributions.get(contributionURI);
+ InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
if (ic == null) {
throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
}
Set<String> dependentContributionURIs = new HashSet<String>();
- for (InstalledContribution icx : installedContributions.values()) {
+ for (InstalledContribution icx : locallyInstalledContributions.values()) {
if (ic != icx) {
List<Contribution> dependencies = icx.getContribution().getDependencies();
if (dependencies != null && dependencies.contains(ic.getContribution())) {
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java
index 427405f292..4b889f56bc 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java
@@ -56,7 +56,7 @@ public class PerfTest {
validate(node);
}
- private void validate(Node node) throws ActivationException, ValidationException, NoSuchServiceException {
+ private void validate(Node node) throws ActivationException, ValidationException, NoSuchServiceException, ContributionReadException {
node.start("sample-helloworld", "helloworld.composite");
Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");
diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
index d5e99132f1..f11bcc41fb 100644
--- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
@@ -444,4 +444,28 @@ public class ReplicatedEndpointRegistry extends BaseEndpointRegistry implements
return null;
}
+ @Override
+ public void installContribution(String uri, String url) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<String> getInstalledContributionURIs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getInstalledContributionURL(String uri) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void uninstallContribution(String uri) {
+ // TODO Auto-generated method stub
+
+ }
+
}
diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
index e9d8068b8a..3162833848 100644
--- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
+++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
@@ -383,7 +383,7 @@ public class Shell {
return false;
}
- boolean start(String curi, String compositeURI) throws ActivationException, ValidationException {
+ boolean start(String curi, String compositeURI) throws ActivationException, ValidationException, ContributionReadException {
Contribution c = getNode().getInstalledContribution(curi);
for (Artifact a : c.getArtifacts()) {
if (compositeURI.equals(a.getURI())) {