String extramodules = (String) props.get(PROP_JBOSS_OSGI_SYSTEM_MODULES_EXTRA);
if (extramodules != null)
sysmodules += "," + extramodules;
// Add a dependency on the default framework modules
ModuleLoader bootLoader = Module.getBootModuleLoader();
PathFilter acceptAll = PathFilters.acceptAll();
for (String modid : sysmodules.split(",")) {
modid = modid.trim();
if (modid.length() > 0) {
ModuleIdentifier identifier = ModuleIdentifier.create(modid);
specBuilder.addDependency(DependencySpec.createModuleDependencySpec(acceptAll, acceptAll, bootLoader, identifier, false));
}
}
specBuilder.setModuleClassLoaderFactory(new BundleReferenceClassLoader.Factory(systemBundle));
try {
final ModuleSpec moduleSpec = specBuilder.create();
ModuleLoader moduleLoader = new ModuleLoader() {
@Override
protected ModuleSpec findModule(ModuleIdentifier identifier) throws ModuleLoadException {
return (moduleSpec.getModuleIdentifier().equals(identifier) ? moduleSpec : null);
}
@Override
public String toString() {
return "FrameworkModuleLoader";
}
};
return moduleLoader.loadModule(specBuilder.getIdentifier());
} catch (ModuleLoadException ex) {
throw new IllegalStateException(ex);
}
}