千家信息网

dubbo中CommandExecutor的作用是什么

发表于:2024-09-25 作者:千家信息网编辑
千家信息网最后更新 2024年09月25日,本篇内容介绍了"dubbo中CommandExecutor的作用是什么"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读
千家信息网最后更新 2024年09月25日dubbo中CommandExecutor的作用是什么

本篇内容介绍了"dubbo中CommandExecutor的作用是什么"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

本文主要研究一下dubbo的CommandExecutor

CommandExecutor

dubbo-2.7.2/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/CommandExecutor.java

public interface CommandExecutor {    /**     * Execute one command and return the execution result     *     * @param commandContext command context     * @return command execution result     * @throws NoSuchCommandException     */    String execute(CommandContext commandContext) throws NoSuchCommandException;}
  • CommandExecutor定义了execute方法,其方法传入CommandContext参数

CommandContext

dubbo-2.7.2/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/CommandContext.java

public class CommandContext {    private String commandName;    private String[] args;    private Channel remote;    private boolean isHttp;    private Object originRequest;    public CommandContext(String commandName) {        this.commandName = commandName;    }    public CommandContext(String commandName, String[] args, boolean isHttp) {        this.commandName = commandName;        this.args = args;        this.isHttp = isHttp;    }    public String getCommandName() {        return commandName;    }    public void setCommandName(String commandName) {        this.commandName = commandName;    }    public String[] getArgs() {        return args;    }    public void setArgs(String[] args) {        this.args = args;    }    public Channel getRemote() {        return remote;    }    public void setRemote(Channel remote) {        this.remote = remote;    }    public boolean isHttp() {        return isHttp;    }    public void setHttp(boolean http) {        isHttp = http;    }    public Object getOriginRequest() {        return originRequest;    }    public void setOriginRequest(Object originRequest) {        this.originRequest = originRequest;    }}
  • CommandContext定义了commandName、args、remote、isHttp、originRequest参数

DefaultCommandExecutor

dubbo-2.7.2/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/DefaultCommandExecutor.java

public class DefaultCommandExecutor implements CommandExecutor {    @Override    public String execute(CommandContext commandContext) throws NoSuchCommandException {        BaseCommand command = null;        try {            command = ExtensionLoader.getExtensionLoader(BaseCommand.class).getExtension(commandContext.getCommandName());        } catch (Throwable throwable) {                //can't find command        }        if (command == null) {            throw new NoSuchCommandException(commandContext.getCommandName());        }        return command.execute(commandContext, commandContext.getArgs());    }}
  • DefaultCommandExecutor实现了CommandExecutor接口,其execute方法会根据commandName通过ExtensionLoader来加载对应的comamnd,然后执行command的execute方法

小结

CommandExecutor定义了execute方法,其方法传入CommandContext参数;CommandContext定义了commandName、args、remote、isHttp、originRequest参数;DefaultCommandExecutor实现了CommandExecutor接口,其execute方法会根据commandName通过ExtensionLoader来加载对应的comamnd,然后执行command的execute方法

"dubbo中CommandExecutor的作用是什么"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!

方法 参数 作用 内容 接口 更多 知识 实用 学有所成 接下来 困境 实际 小结 情况 文章 案例 编带 网站 行业 过程 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 医时代互联网科技 长春网络安全技术提升十大品牌 云服务器限制delete请求 网络安全知识点归纳总结 为什么进游戏老是断开服务器 四大行软件开发哪个待遇好 怎么开服务器远程管理 在数据库建立信息表的步骤 我的世界最安全服务器的符号 软件开发实训目标 办公室网络安全措施有哪些 服务器安装2008系统鼠标不动 中心管理服务器怎么选择 互联网行业信息科技论坛网站 宝山区网络软件开发共同合作 网络安全相关文件 不用经过服务器的xss 什么是数据库加密 关于网络安全教育的材料 江苏一朵云互联网科技 app软件开发课程评语 软件开发涉及到的名词 计算机网络技术三级第二大题 多功能软件开发优势 计算机网络技术地址划分 根据网络安全法的规定什么应当 关于网络技术的书籍 数据库与银行 浙江统一软件开发设施价格优惠 数据库中的sno是什么的缩写
0