// Read the composite content after the contributions have been loaded, so that the
// policySet definitions provided by the contributions are available (TUSCANY-3569)
if (composite == null && compositeContent != null) {
logger.log(Level.INFO, "Loading composite: " + configurationName);
CompositeDocumentProcessor compositeDocProcessor =
(CompositeDocumentProcessor)documentProcessors.getProcessor(Composite.class);
composite =
compositeDocProcessor.read(URI.create(configurationName), new ByteArrayInputStream(compositeContent
.getBytes("UTF-8")));
analyzeProblems();
configuration.setComposite(composite);
}
if(composite != null && composite.isUnresolved()) {
ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
Artifact compositeFile = contributionFactory.createArtifact();
compositeFile.setUnresolved(true);
compositeFile.setURI(composite.getURI());
for (Contribution c : contributions) {
ModelResolver resolver = c.getModelResolver();
Artifact resolved = resolver.resolveModel(Artifact.class, compositeFile);
if (resolved != null && resolved.isUnresolved() == false) {
composite = (Composite) resolved.getModel();
break;
}
}
}
// FIXME: This is a hack to get a list of deployable composites. By design, the deployment composite should
// has been configured
if (composite == null) {
List<Composite> deployables = new ArrayList<Composite>();
for (Contribution c : contributions) {
deployables.addAll(c.getDeployables());
}
aggregate(deployables);
configuration.setComposite(composite);
}
Contribution contribution = null;
if (composite.getName() == null) {
// Load the specified composite
URL compositeURL;
URI uri = createURI(configuration.getComposite().getURI());
if (uri.getScheme() == null) {
// If the composite URI is a relative URI, try to resolve it within the contributions
contribution = contribution(contributions, uri.toString());
if (contribution == null) {
throw new IllegalArgumentException("Composite is not found in contributions: " + uri);
}
compositeURL = new URL(location(contribution, uri.toString()));
} else {
// If the composite URI is an absolute URI, use it as is
compositeURL = uri.toURL();
}
URLArtifactProcessor<Composite> compositeDocProcessor = documentProcessors.getProcessor(Composite.class);
// Read the composite
logger.log(Level.INFO, "Loading composite: " + compositeURL);
// InputStream is = compositeURL.openStream();
// XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
try {
composite = compositeDocProcessor.read(null, uri, compositeURL);
} catch (ContributionReadException e) {
// ignore - errors will be detected by analyzeProblems() call below
}
// reader.close();