|
|
@ -36,7 +36,7 @@ public class CommandHandlerRegistry implements ApplicationContextAware { |
|
|
|
Class<?> targetClass = AopUtils.getTargetClass(bean); |
|
|
|
CommandMapping mapping = targetClass.getAnnotation(CommandMapping.class); |
|
|
|
if (mapping != null && bean instanceof CommandHandler) { |
|
|
|
String mappingKey = generateCommandIdentifier(mapping.moduleName(), mapping.commandName()); |
|
|
|
String mappingKey = mapping.value(); |
|
|
|
handlerMap.put(mappingKey, (CommandHandler) bean); |
|
|
|
} |
|
|
|
} |
|
|
@ -44,17 +44,15 @@ public class CommandHandlerRegistry implements ApplicationContextAware { |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过模块名称和命令名称获取命令处理器 |
|
|
|
* @param moduleName 模块名称 |
|
|
|
* @param commandName 命令名称 |
|
|
|
* @return 命令处理器 |
|
|
|
* @throws UnSupportCommandException |
|
|
|
*/ |
|
|
|
public CommandHandler getCommandHandler(@NotNull String moduleName, @NotNull String commandName) throws UnSupportCommandException { |
|
|
|
String mappingKey = generateCommandIdentifier(moduleName, commandName); |
|
|
|
if (!handlerMap.containsKey(mappingKey)) { |
|
|
|
throw new UnSupportCommandException("moduleName=" + moduleName + "commandName=" + commandName); |
|
|
|
public CommandHandler getCommandHandler(@NotNull String commandName) throws UnSupportCommandException { |
|
|
|
if (!handlerMap.containsKey(commandName)) { |
|
|
|
throw new UnSupportCommandException("commandName=" + commandName); |
|
|
|
} |
|
|
|
return handlerMap.get(mappingKey); |
|
|
|
return handlerMap.get(commandName); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|