use of com.shulie.instrument.simulator.module.model.info.CommandInfo in project LinkAgent by shulieTech.
the class InfoModule method modules.
@Command(value = "commands", description = "查看所有的命令")
public CommandResponse modules() {
try {
List<CommandInfo> commands = new ArrayList<CommandInfo>();
for (ExtensionModule module : moduleManager.list()) {
Class<?> classOfModule = module.getClass();
// 判断模块是否实现了@Information标记
if (!classOfModule.isAnnotationPresent(ModuleInfo.class)) {
continue;
}
final ModuleInfo info = classOfModule.getAnnotation(ModuleInfo.class);
if (info == null) {
continue;
}
for (final Method method : getMethodsListWithAnnotation(module.getClass(), Command.class)) {
final Command commandAnnotation = method.getAnnotation(Command.class);
if (null == commandAnnotation) {
continue;
}
CommandInfo commandInfo = new CommandInfo();
commandInfo.setModuleId(info.id());
commandInfo.setCommand(commandAnnotation.value());
commandInfo.setCommandDescription(commandAnnotation.description());
commands.add(commandInfo);
}
}
return CommandResponse.success(commands);
} catch (Throwable e) {
LOGGER.error("SIMULATOR: execute command info/commands error.", e);
return CommandResponse.failure(e);
}
}
Aggregations