private ModuleRegistry buildRegistry(String engineVersion, Module... modules) { ModuleRegistry result = new TableModuleRegistry(); result.add(buildEngineModule(engineVersion)); result.addAll(Arrays.asList(modules)); return result; } }
registry.add(module); } catch (IOException e) { logger.warn("Failed to load module.txt for classpath module {}", url);
@Override public List<Module> call() throws Exception { Map<URL, Path> filesToDownload = getDownloadUrls(moduleList); logger.info("Started downloading {} modules", filesToDownload.size()); MultiFileDownloader downloader = new MultiFileDownloader(filesToDownload, downloadProgressListener); List<Path> downloadedModulesPaths = downloader.call(); logger.info("Module download completed, loading the new modules..."); List<Module> newInstalledModules = new ArrayList<>(downloadedModulesPaths.size()); ModuleLoader loader = new ModuleLoader(moduleManager.getModuleMetadataReader()); loader.setModuleInfoPath(TerasologyConstants.MODULE_INFO_FILENAME); for (Path filePath : downloadedModulesPaths) { try { Module module = loader.load(filePath); moduleManager.getRegistry().add(module); newInstalledModules.add(module); } catch (IOException e) { logger.warn("Could not load module {}", filePath.getFileName(), e); } } logger.info("Finished loading the downloaded modules"); return newInstalledModules; }
public static ModuleManager create() throws Exception { ModuleManager moduleManager = new ModuleManagerImpl(""); try (Reader reader = new InputStreamReader(ModuleManagerFactory.class.getResourceAsStream("/module.txt"), TerasologyConstants.CHARSET)) { ModuleMetadata metadata = new ModuleMetadataReader().read(reader); moduleManager.getRegistry().add(ClasspathModule.create(metadata, ModuleManagerFactory.class)); } moduleManager.loadEnvironment(Sets.newHashSet(moduleManager.getRegistry().getLatestModuleVersion(new Name("engine"))), true); return moduleManager; } }
private void setUpMockModuleEnvironment() { ModuleManager moduleManager = mock(ModuleManager.class); ModuleRegistry moduleRegistry = new TableModuleRegistry(); Module module = mock(Module.class); when(module.isCodeModule()).thenReturn(true); when(module.getId()).thenReturn(new Name(TEST_MODULE)); when(module.getVersion()).thenReturn(new Version(0, 0, 1, true)); when(module.getMetadata()).thenReturn(new ModuleMetadata()); moduleRegistry.add(module); when(moduleManager.getRegistry()).thenReturn(moduleRegistry); ModuleEnvironment environment = mock(ModuleEnvironment.class); when(moduleManager.loadEnvironment(any(), anyBoolean())).thenReturn(environment); when(moduleManager.getEnvironment()).thenReturn(environment); registerBindButtonClasses = new ArrayList<>(); when(environment.getTypesAnnotatedWith(eq(RegisterBindButton.class))).thenReturn(registerBindButtonClasses); when(environment.getTypesAnnotatedWith(eq(RegisterBindButton.class), any())).thenReturn(registerBindButtonClasses); registerRealBindAxisClasses = new ArrayList<>(); when(environment.getTypesAnnotatedWith(eq(RegisterBindAxis.class))).thenReturn(registerRealBindAxisClasses); when(environment.getTypesAnnotatedWith(eq(RegisterBindAxis.class), any())).thenReturn(registerRealBindAxisClasses); when(environment.getModuleProviding(any())).thenReturn(new Name(TEST_MODULE)); context.put(ModuleManager.class, moduleManager); }
registry.add(engineModule);
loader.setModuleInfoPath(TerasologyConstants.MODULE_INFO_FILENAME); moduleManager.getRegistry().add(loader.load(finalPath)); receivingModule = null;