正在显示
2 个修改的文件
包含
74 行增加
和
0 行删除
| 1 | +package com.crossoverjie.cim.client.service; | ||
| 2 | + | ||
| 3 | +import com.crossoverjie.cim.client.util.SpringBeanFactory; | ||
| 4 | +import com.crossoverjie.cim.common.enums.SystemCommandEnumType; | ||
| 5 | +import org.slf4j.Logger; | ||
| 6 | +import org.slf4j.LoggerFactory; | ||
| 7 | +import org.springframework.stereotype.Component; | ||
| 8 | + | ||
| 9 | +import java.util.Map; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * Function: | ||
| 13 | + * | ||
| 14 | + * @author crossoverJie | ||
| 15 | + * Date: 2019-01-27 19:39 | ||
| 16 | + * @since JDK 1.8 | ||
| 17 | + */ | ||
| 18 | +@Component | ||
| 19 | +public class InnerCommandContext { | ||
| 20 | + private final static Logger LOGGER = LoggerFactory.getLogger(InnerCommandContext.class); | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 获取执行器 | ||
| 24 | + * @param command 执行器 | ||
| 25 | + * @return | ||
| 26 | + */ | ||
| 27 | + public InnerCommand execute(String command) { | ||
| 28 | + | ||
| 29 | + Map<String, String> allClazz = SystemCommandEnumType.getAllClazz(); | ||
| 30 | + String clazz = allClazz.get(command); | ||
| 31 | + InnerCommand innerCommand = null; | ||
| 32 | + try { | ||
| 33 | + innerCommand = (InnerCommand) SpringBeanFactory.getBean(Class.forName(clazz)); | ||
| 34 | + } catch (Exception e) { | ||
| 35 | + LOGGER.error("Exception", e); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + return innerCommand; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | +} |
cim-client/src/main/java/com/crossoverjie/cim/client/service/impl/command/PrintAllCommand.java
0 → 100644
| 1 | +package com.crossoverjie.cim.client.service.impl.command; | ||
| 2 | + | ||
| 3 | +import com.crossoverjie.cim.client.service.InnerCommand; | ||
| 4 | +import com.crossoverjie.cim.common.enums.SystemCommandEnumType; | ||
| 5 | +import org.slf4j.Logger; | ||
| 6 | +import org.slf4j.LoggerFactory; | ||
| 7 | +import org.springframework.stereotype.Service; | ||
| 8 | + | ||
| 9 | +import java.util.Map; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * Function: | ||
| 13 | + * | ||
| 14 | + * @author crossoverJie | ||
| 15 | + * Date: 2019-01-27 19:37 | ||
| 16 | + * @since JDK 1.8 | ||
| 17 | + */ | ||
| 18 | +@Service | ||
| 19 | +public class PrintAllCommand implements InnerCommand { | ||
| 20 | + private final static Logger LOGGER = LoggerFactory.getLogger(PrintAllCommand.class); | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public void process(String msg) { | ||
| 24 | + Map<String, String> allStatusCode = SystemCommandEnumType.getAllStatusCode(); | ||
| 25 | + LOGGER.warn("===================================="); | ||
| 26 | + for (Map.Entry<String, String> stringStringEntry : allStatusCode.entrySet()) { | ||
| 27 | + String key = stringStringEntry.getKey(); | ||
| 28 | + String value = stringStringEntry.getValue(); | ||
| 29 | + LOGGER.warn(key + "----->" + value); | ||
| 30 | + } | ||
| 31 | + LOGGER.warn("===================================="); | ||
| 32 | + } | ||
| 33 | +} |
-
请 注册 或 登录 后发表评论