diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-13 14:41:29 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-13 14:41:29 +0000 |
commit | e0134ba6862381dc899d3f05d780aec9e582a162 (patch) | |
tree | b9af8e52436f75680a0a4c481245ce72af256197 /sca-java-2.x/trunk/modules/domain-node/src/main/java/org | |
parent | 40f3ad5b2d364b8594bfaac788ef184d07e92958 (diff) |
Add code for handling import/export better, imports now work when the exporting contribution is installed on a distributed remote node, woohoo.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1102763 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node/src/main/java/org')
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl2.java | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl2.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl2.java index 7bc17c959d..c1bb1c69ad 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl2.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl2.java @@ -144,9 +144,15 @@ public class NodeImpl2 { try {
deployer.resolve(contribution, dependentContributions, monitor);
} catch (Exception e) {
+ loadedContributions.remove(ic.getURI());
throw new RuntimeException(e);
}
- monitor.analyzeProblems();
+ try {
+ monitor.analyzeProblems();
+ } catch (ValidationException e) {
+ loadedContributions.remove(ic.getURI());
+ throw e;
+ }
}
public Map<String, List<QName>> getStartedComposites() {
@@ -206,7 +212,7 @@ public class NodeImpl2 { protected List<Contribution> calculateDependentContributions(InstalledContribution ic) throws ContributionReadException, ValidationException {
List<Contribution> dependentContributions = new ArrayList<Contribution>();
Contribution c = loadContribution(ic);
- if (ic.getDependentContributionURIs() != null) {
+ if (ic.getDependentContributionURIs() != null && ic.getDependentContributionURIs().size() > 0) {
// if the install specified dependent uris use just those contributions
for (String uri : ic.getDependentContributionURIs()) {
InstalledContribution dependee = endpointRegistry.getInstalledContribution(uri);
@@ -215,20 +221,36 @@ public class NodeImpl2 { }
}
} else {
- // TODO: otherwise find from the registry which contributions export the required resources
for (Import imprt : c.getImports()) {
- // TODO: Handle Imports in a more extensible way
- if (imprt instanceof JavaImport) {
-// ic.getJavaExports().add(((JavaExport)export).getPackage());
- } else if (imprt instanceof NamespaceImport) {
-// ic.getNamespaceExports().add(((NamespaceExport)export).getNamespace());
- }
-// dependentContributions.add(ics.getContribution());
+ InstalledContribution exportingIC = findExportingContribution(imprt);
+ if (exportingIC != null) {
+ dependentContributions.add(loadContribution(exportingIC));
+ }
}
}
+ // TODO: there is also the location attribute on the import which should be taken into account
return dependentContributions;
}
+ private InstalledContribution findExportingContribution(Import imprt) {
+ // TODO: Handle Imports in a more extensible way
+ for (String curi : endpointRegistry.getInstalledContributionURIs()) {
+ InstalledContribution ic = endpointRegistry.getInstalledContribution(curi);
+ if (imprt instanceof JavaImport) {
+ for (String s : ic.getJavaExports()) {
+ if (s.startsWith(((JavaImport)imprt).getPackage())) {
+ return ic;
+ }
+ }
+ } else if (imprt instanceof NamespaceImport) {
+ if (ic.getNamespaceExports().contains(((NamespaceImport)imprt).getNamespace())) {
+ return ic;
+ }
+ }
+ }
+ return null;
+ }
+
protected Composite getComposite(Contribution contribution, String compositeURI) {
for (Artifact a : contribution.getArtifacts()) {
if (a.getURI().equals(compositeURI)) {
|