* @throws ContributionException
*/
private Contribution readContributionMetadata(URL sourceURL) throws ContributionException {
Contribution contributionMetadata = contributionFactory.createContribution();
ContributionMetadataDocumentProcessor metadataDocumentProcessor =
new ContributionMetadataDocumentProcessor(modelFactories, staxProcessor, monitor);
final URL[] urls = {sourceURL};
// Allow access to create classloader. Requires RuntimePermission in security policy.
URLClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() {
public URLClassLoader run() {
return new URLClassLoader(urls, null);
}
});
for (String path: new String[]{
Contribution.SCA_CONTRIBUTION_GENERATED_META,
Contribution.SCA_CONTRIBUTION_META}) {
URL url = cl.getResource(path);
if (url != null) {
ContributionMetadata contribution = metadataDocumentProcessor.read(sourceURL, URI.create(path), url);
contributionMetadata.getImports().addAll(contribution.getImports());
contributionMetadata.getExports().addAll(contribution.getExports());
contributionMetadata.getDeployables().addAll(contribution.getDeployables());
}
}