diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules')
2 files changed, 19 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java index 0b75ade042..9c5d19816c 100644 --- a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java +++ b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java @@ -66,12 +66,14 @@ public interface Deployer extends LifeCycleListener { * @param contribution The target contribution * @param composite The deployment composite * @param appending A flag to indicate if existing deployable composites in the contribution should be appended or replaced + * @return uri of attached composite */ - void attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending); + String attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending); /** * Configure a list of contributions to create a composite representing a view of the domain * @param contributions + * @param allContributions * @param bindingBaseURIs * @param monitor * @return 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 d8dd13f5be..ecf2adfb85 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 @@ -423,14 +423,25 @@ public class DeployerImpl implements Deployer { return contribution; } - public void attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending) { + public String attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending) { init(); + + String compositeArtifactURI = composite.getName().getLocalPart() + ".composite"; + + if (appending) { + // check its not already there + for (Artifact a : contribution.getArtifacts()) { + if (compositeArtifactURI.equals(a.getURI())) { + throw new IllegalStateException("artifact '" + compositeArtifactURI + "' already exists in contribution: " + contribution.getURI()); + } + } + } + // Create an artifact for the deployment composite Artifact artifact = contributionFactory.createArtifact(); - String uri = composite.getName().getLocalPart() + ".composite"; - artifact.setURI(uri); + artifact.setURI(compositeArtifactURI); - artifact.setLocation(uri); + artifact.setLocation(compositeArtifactURI); artifact.setModel(composite); artifact.setUnresolved(false); // Add it to the contribution @@ -442,6 +453,7 @@ public class DeployerImpl implements Deployer { contribution.getDeployables().clear(); } contribution.getDeployables().add(composite); + return compositeArtifactURI; } public Composite build(List<Contribution> contributions, List<Contribution> allContributions, Map<QName, List<String>> bindingMap, Monitor monitor) |