Search in sources :

Example 1 with ModuleInf

use of com.shulie.instrument.simulator.module.mgr.model.ModuleInf in project LinkAgent by shulieTech.

the class ModuleManagementModule method detail.

@Command(value = "detail", description = "模块详情")
public CommandResponse detail(final Map<String, String> param) throws ModuleException {
    final String moduleId = param.get("moduleId");
    try {
        if (StringUtils.isBlank(moduleId)) {
            // 如果参数不对,则认为找不到对应的仿真器模块,返回400
            return CommandResponse.failure("moduleId parameter was required.");
        }
        if (StringUtils.isNotBlank(moduleId)) {
            for (final ModuleSpec moduleSpec : moduleManager.listModuleSpecs()) {
                if (!StringUtils.equals(moduleSpec.getModuleId(), moduleId)) {
                    continue;
                }
                ModuleInf moduleInf = new ModuleInf();
                moduleInf.setModuleId(moduleSpec.getModuleId());
                moduleInf.setSystemModule(moduleSpec.isSystemModule());
                moduleInf.setExportClasses(moduleSpec.getExportClasses());
                moduleInf.setExportExactlyPackages(moduleSpec.getExportExactlyPackages());
                moduleInf.setExportExactlyResources(moduleSpec.getExportExactlyResources());
                moduleInf.setExportPackages(moduleSpec.getExportPackages());
                moduleInf.setExportPrefixPackages(moduleSpec.getExportPrefixPackages());
                moduleInf.setExportPrefixResources(moduleSpec.getExportPrefixResources());
                moduleInf.setExportResources(moduleSpec.getExportResources());
                moduleInf.setExportSuffixPackages(moduleSpec.getExportSuffixPackages());
                moduleInf.setExportSuffixResources(moduleSpec.getExportSuffixResources());
                moduleInf.setAuthor(moduleSpec.getAuthor());
                moduleInf.setVersion(moduleSpec.getVersion());
                moduleInf.setPriority(moduleSpec.getPriority());
                moduleInf.setSupportedModes(moduleSpec.getSupportedModes());
                moduleInf.setActiveOnLoad(moduleSpec.isActiveOnLoad());
                return CommandResponse.success(moduleId);
            }
        }
        return CommandResponse.failure("moduleId arguments is required.");
    } catch (Throwable e) {
        logger.error("SIMULATOR: module management detail err. moduleId:{}", moduleId, e);
        return CommandResponse.failure(e);
    }
}
Also used : ModuleInf(com.shulie.instrument.simulator.module.mgr.model.ModuleInf) Command(com.shulie.instrument.simulator.api.annotation.Command)

Example 2 with ModuleInf

use of com.shulie.instrument.simulator.module.mgr.model.ModuleInf in project LinkAgent by shulieTech.

the class ModuleManagementModule method list.

@Command(value = "list", description = "模块列表")
public CommandResponse list() throws IOException {
    try {
        List<ModuleInf> moduleInfoList = new ArrayList<ModuleInf>();
        for (final ModuleSpec moduleSpec : moduleManager.listModuleSpecs()) {
            ModuleInf moduleInf = new ModuleInf();
            moduleInf.setModuleId(moduleSpec.getModuleId());
            moduleInf.setSystemModule(moduleSpec.isSystemModule());
            moduleInf.setPath(moduleSpec.getFile() != null ? moduleSpec.getFile().getCanonicalPath() : null);
            moduleInf.setSwitchControl(moduleSpec.getDependencies());
            moduleInf.setExportClasses(moduleSpec.getExportClasses());
            moduleInf.setExportExactlyPackages(moduleSpec.getExportExactlyPackages());
            moduleInf.setExportExactlyResources(moduleSpec.getExportExactlyResources());
            moduleInf.setExportPackages(moduleSpec.getExportPackages());
            moduleInf.setExportPrefixPackages(moduleSpec.getExportPrefixPackages());
            moduleInf.setExportPrefixResources(moduleSpec.getExportPrefixResources());
            moduleInf.setExportResources(moduleSpec.getExportResources());
            moduleInf.setExportSuffixPackages(moduleSpec.getExportSuffixPackages());
            moduleInf.setExportSuffixResources(moduleSpec.getExportSuffixResources());
            moduleInf.setAuthor(moduleSpec.getAuthor());
            moduleInf.setVersion(moduleSpec.getVersion());
            moduleInf.setPriority(moduleSpec.getPriority());
            moduleInf.setSupportedModes(moduleSpec.getSupportedModes());
            moduleInf.setActiveOnLoad(moduleSpec.isActiveOnLoad());
            moduleInf.setDescription(moduleSpec.getDescription());
            moduleInfoList.add(moduleInf);
        }
        return CommandResponse.success(moduleInfoList);
    } catch (Throwable e) {
        logger.error("SIMULATOR: module management list module err.", e);
        return CommandResponse.failure(e);
    }
}
Also used : ArrayList(java.util.ArrayList) ModuleInf(com.shulie.instrument.simulator.module.mgr.model.ModuleInf) Command(com.shulie.instrument.simulator.api.annotation.Command)

Aggregations

Command (com.shulie.instrument.simulator.api.annotation.Command)2 ModuleInf (com.shulie.instrument.simulator.module.mgr.model.ModuleInf)2 ArrayList (java.util.ArrayList)1