From 142168eae3c0ca47bdb22bb539b746b7b2607888 Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 26 May 2010 20:05:38 +0000 Subject: Update Deployer.attachDeploymentComposite to return the URI of the attached composite git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@948564 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/deployment/Deployer.java | 4 +++- .../tuscany/sca/deployment/impl/DeployerImpl.java | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'sca-java-2.x/trunk/modules/deployment/src') 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 contributions, List allContributions, Map> bindingMap, Monitor monitor) -- cgit v1.2.3