LOGGER.info("Installing shared resource: {}", resource);
String runtimeName = getRuntimeName(resource, true);
ResourceIdentity identity = resource.getIdentity();
String symbolicName = identity.getSymbolicName();
Version version = identity.getVersion();
File modulesDir = injectedServerEnvironment.getValue().getModulesDir();
File moduleDir = new File(modulesDir, symbolicName.replace(".", File.separator) + File.separator + version);
if (moduleDir.exists())
throw new IllegalStateException("Module dir already exists: " + moduleDir);
ResourceContent content = getFirstRelevantResourceContent(resource);
IllegalStateAssertion.assertNotNull(content, "Cannot obtain content from: " + resource);
// copy resource content
moduleDir.mkdirs();
File resFile = new File(moduleDir, runtimeName);
IOUtils.copyStream(content.getContent(), new FileOutputStream(resFile));
ModuleIdentifier modid = ModuleIdentifier.create(symbolicName, version.toString());
// generate module.xml
File xmlFile = new File(moduleDir, "module.xml");
Map<Requirement, Resource> mapping = context.getResourceMapping();
String moduleXML = generateModuleXML(resFile, resource, modid, mapping);