diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/contribution/src/main/java')
2 files changed, 23 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java index af2dd66863..1e8c54cc9c 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java @@ -129,4 +129,6 @@ public interface Contribution extends Artifact, Extensible { * @return the model */ <T> T getArtifactModel(String uri); + + void mergeMetaData(ContributionMetadata metaData); }
\ No newline at end of file diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java index 31ddc5b793..c1b348cc8b 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java @@ -22,12 +22,14 @@ package org.apache.tuscany.sca.contribution.impl; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.ListIterator; import java.util.Set; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.ContributionMetadata; import org.apache.tuscany.sca.contribution.Export; import org.apache.tuscany.sca.contribution.Import; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; @@ -163,4 +165,23 @@ class ContributionImpl extends ExtensibleImpl implements Contribution { } throw new IllegalArgumentException("artifact not found: " + uri); } + + @Override + public void mergeMetaData(ContributionMetadata metaData) { + imports.addAll(metaData.getImports()); + exports.addAll(metaData.getExports()); + if (metaData.getDeployables().size() > 0) { + // Update the deployable Composite objects with the correct Composite object for the artifact + for (Artifact a : getArtifacts()) { + if (a.getModel() instanceof Composite) { + for (ListIterator<Composite> lit = metaData.getDeployables().listIterator(); lit.hasNext();) { + if (lit.next().getName().equals(((Composite)a.getModel()).getName())) { + lit.set((Composite)a.getModel()); + } + } + } + } + deployables.addAll(metaData.getDeployables()); + } + } } |