代码拉取完成,页面将自动刷新
同步操作将从 杭州开云集致科技有限公司/hasor 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
提供一个 Telnet 环境支持,给予没有界面类的应用一个可以通过命令行进行交互的工具。
实现一个控制台命令。
public class HelloWordExecutor implements TelExecutor {
/** 命令的帮助信息,在 help <command> 时候输出这个信息 */
public String helpInfo() {
return "hello help.";
}
/** 执行命令体 */
public String doCommand(TelCommand telCommand) throws Throwable {
return "you say ->" + telCommand.getCommandName();
}
}
利用 telnet 命令来交互
public static void main(String[] args) {
AppContext appContext = Hasor.create().build((TelModule) apiBinder -> {
TelnetBuilder telnetBuild = apiBinder.asTelnet("127.0.0.1", 2180);
telnetBuild.addExecutor("hello").to(HelloWordExecutor.class);
}
appContext.joinSignal();
}
输入 telnet 127.0.0.1 2180
之后
>telnet 127.0.0.1 2180
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
--------------------------------------------
Welcome to tConsole!
login : Tue Jan 07 14:26:29 CST 2020 now. form /127.0.0.1:60023
workAt : /127.0.0.1:2180
Tips: You can enter a 'help' or 'help -a' for more information.
use the 'exit' or 'quit' out of the console.
--------------------------------------------
tConsole>
充当命令工具包,建议利用 Spring Boot 的 fat jar 打包能力整合使用。
public static void main(String[] args) {
AppContext appContext = Hasor.create().build((TelModule) apiBinder -> {
HostBuilder hostBuild = apiBinder.asHostWithSTDO().preCommand(args);
hostBuild.addExecutor("hello").to(HelloWordExecutor.class);
}
}
输入 java xxx.jar hello
执行 hello 命令。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。