@Override
public ResourceHandle installSharedResource(Resource resource, Map<Requirement, Resource> mapping) throws Exception {
LOGGER.info("Installing shared resource: {}", resource);
ResourceIdentity resid = resource.getIdentity();
ResourceContent content = resource.adapt(ResourceContent.class);
if (content == null)
throw new IllegalStateException("Cannot obtain content from: " + resource);
// copy resource content
File targetFile = new File(catalinaLib, resid.getSymbolicName() + "-" + resid.getVersion() + ".jar");
if (targetFile.exists())
throw new IllegalStateException("Module already exists: " + targetFile);
IOUtils.copyStream(content.getContent(), new FileOutputStream(targetFile));
Module module = installSharedResource(resource, targetFile);
Resource modres = module.adapt(Resource.class);
return new DefaultResourceHandle(modres, module) {