*/
private ConfiguredNodeImplementation findNodeConfiguration(final String compositeURI, ClassLoader classLoader)
throws Exception {
NodeImplementationFactory nodeImplementationFactory =
modelFactories.getFactory(NodeImplementationFactory.class);
ConfiguredNodeImplementation config = nodeImplementationFactory.createConfiguredNodeImplementation();
// Default to thread context classloader
if (classLoader == null) {
classLoader = Thread.currentThread().getContextClassLoader();
}
String contributionArtifactPath = compositeURI;
URL contributionArtifactURL = null;
if (compositeURI != null) {
contributionArtifactURL = getResource(classLoader, compositeURI);
if (contributionArtifactURL == null) {
throw new IllegalArgumentException("Composite not found: " + contributionArtifactPath);
}
// Set to relative URI to avoid duplicate loading
Composite composite = createComposite(compositeURI);
config.setComposite(composite);
} else {
// No composite is specified, tring to search the SCA metadata files
contributionArtifactPath = Contribution.SCA_CONTRIBUTION_META;
contributionArtifactURL = getResource(classLoader, Contribution.SCA_CONTRIBUTION_META);
if (contributionArtifactURL == null) {
contributionArtifactPath = Contribution.SCA_CONTRIBUTION_GENERATED_META;
contributionArtifactURL = getResource(classLoader, Contribution.SCA_CONTRIBUTION_GENERATED_META);
}
if (contributionArtifactURL == null) {
contributionArtifactPath = Contribution.SCA_CONTRIBUTION_DEPLOYABLES;
contributionArtifactURL = getResource(classLoader, Contribution.SCA_CONTRIBUTION_DEPLOYABLES);
}
// No contribution can be discovered
if (contributionArtifactURL == null) {
throw new IllegalArgumentException("No default contribution can be discovered on the classpath");
}
// No composite will be created, all deployable composites will be used later
}
Contribution c = getContribution(contributionArtifactURL, contributionArtifactPath);
config.getContributions().add(c);
return config;
}