// build the contribution to create the services and references
domainModel.getDeployedComposites().put(compositeQName, compositeModel);
domainManagementRuntime.getCompositeBuilder().build(compositeModel.getComposite());
domainModel.getDomainLevelComposite().getIncludes().add(compositeModel.getComposite());
NodeModel node = null;
// find the node for the composite to run on
if (nodeURI != null) {
// find the named node
node = domainModel.getNodes().get(nodeURI);
if (node == null){
throw new DomainException("Node " + nodeURI + " not found in domain");
}
} else {
// noddy algorithm to find a free node
// TODO - do something better
for(NodeModel tmpNode : domainModel.getNodes().values()) {
if (tmpNode.getLifecycleState() == LifecyleState.AVAILABLE){
node = tmpNode;
}
}
if (node == null){
throw new DomainException("No free node available to run composite " + compositeQName.toString());
}
}
// find all the composites that the node must know about
List<Contribution> dependentContributions = new ArrayList<Contribution>();
findDependentContributions(contributionModel.getContribution(), dependentContributions);
// assign the set of contributions to the node model
for (Contribution tmpContribution : dependentContributions){
node.getContributions().put(tmpContribution.getURI(),
domainModel.getContributions().get(tmpContribution.getURI()));
}
// assign the composite to the node model
node.getDeployedComposites().put(compositeQName, compositeModel);
node.setLifecycleState(LifecyleState.DEPLOYED);
// now pass this information over to the real node
// add contributions. Use the dependent contribution list here rather than the