try {
// Initialize the runtime
initRuntime();
ConfiguredNodeImplementation configuration = null;
if (contributions == null || contributions.length == 0) {
configuration = findNodeConfiguration(compositeURI, null);
} else {
// Create a node configuration
NodeImplementationFactory nodeImplementationFactory =
modelFactories.getFactory(NodeImplementationFactory.class);
configuration = nodeImplementationFactory.createConfiguredNodeImplementation();
// Read the composite model
StAXArtifactProcessor<Composite> compositeProcessor = artifactProcessors.getProcessor(Composite.class);
// URL compositeURL = new URL(compositeURI);
logger.log(Level.INFO, "Loading composite: " + compositeURI);
CompositeDocumentProcessor compositeDocProcessor =
(CompositeDocumentProcessor)documentProcessors.getProcessor(Composite.class);
composite =
compositeDocProcessor.read(URI.create(compositeURI), new ByteArrayInputStream(compositeContent
.getBytes("UTF-8")));
analyzeProblems();
configuration.setComposite(composite);
// Create contribution models
ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
for (SCAContribution c : contributions) {
Contribution contribution = createContribution(contributionFactory, c);
configuration.getContributions().add(contribution);
}
}
// Configure the node
configureNode(configuration);