package org.box.metadata.shell.web;
import java.io.PrintStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.collections.buffer.BoundedFifoBuffer;
import org.box.metadata.cli.MetaCli;
import org.box.metadata.cli.MetaCommandLineParser.ParserType;
import org.box.metadata.cli.exception.ParseException;
import org.box.metadata.shell.AbstractShell;
import org.box.metadata.shell.WebShellDefaultConfiguration;
import org.box.metadata.shell.console.ConsoleDefaultConfiguration;
import org.box.metadata.shell.web.server.NativeServer;
import org.box.metadata.shell.web.server.ShellOutStream;
import org.eclipse.jetty.server.Server;
public class WebShell extends AbstractShell {
private static final Logger LOG = Logger.getLogger(WebShell.class.getName());
public static final String SERVLET_CONTEXT_SHELL_ATTRIBUTE = "shell";
private final BoundedFifoBuffer inBuffer = new BoundedFifoBuffer(100);
private volatile boolean consoleBusy = true;
private volatile String currentInput;
private volatile String currentSession;
private ShellOutStream outStream;
public WebShell(Class<?> cfgClass) {
super(cfgClass, ConsoleDefaultConfiguration.class, WebShellDefaultConfiguration.class);
}
public WebShell(ParserType parserType, Class<?> cfgClass) {
super(parserType, cfgClass, ConsoleDefaultConfiguration.class, WebShellDefaultConfiguration.class);
}
/*
* (non-Javadoc)
* @see org.box.metadata.shell.Shell#displayMessage(java.lang.String)
*/
@Override
public void displayMessage(String msg) {
System.out.println(msg);
}
/*
* (non-Javadoc)
* @see org.box.metadata.shell.AbstractShell#run(java.lang.String[])
*/
@Override
public void run(String[] args) {
WebShellDefaultConfiguration cfg = new WebShellDefaultConfiguration();
try {
cfg = MetaCli.parse(args, WebShellDefaultConfiguration.class);
} catch (ParseException e) {
if (LOG.isLoggable(Level.WARNING))
LOG.warning("Unable to create custom configuration: " + e.getMessage());
}
outStream = new ShellOutStream(this, cfg.getBufferSize());
addListener(outStream);
Server server = new NativeServer(cfg, this);
try {
server.start();
} catch (Exception e) {
throw new RuntimeException("Unable to start Native Server: ", e);
}
PrintStream origOut = System.out;
System.setOut(outStream.getPrintStream());
super.run(new String[0]);
System.setOut(origOut);
try {
server.stop();
} catch (Exception e) {
throw new RuntimeException("Unable to stop Jetty Server: ", e);
}
}
public ShellOutStream getOutStream() {
return outStream;
}
/*
* (non-Javadoc)
* @see org.box.metadata.shell.AbstractShell#getUserInput()
*/
@Override
protected String getUserInput() {
while (inBuffer.isEmpty()) {
synchronized (this) {
try {
consoleBusy = false;
currentInput = null;
currentSession = null;
wait();
} catch (InterruptedException e) {
System.err.println("Warning: " + e);
}
}
}
consoleBusy = true;
synchronized (inBuffer) {
String[] remove = (String[]) inBuffer.remove();
currentInput = remove[0];
currentSession = remove[1];
return currentInput;
}
}
public boolean isConsoleBusy() {
return consoleBusy;
}
public void submitInput(String input, String sessionId) {
synchronized (inBuffer) {
if (!inBuffer.isFull()) {
inBuffer.add(new String[]{input, sessionId});
}
}
synchronized (this) {
notify();
}
}
public String getCurrentInput() {
return currentInput;
}
public String getCurrentSession() {
return currentSession;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
web-cli-shell.zip_The Web_cli
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共11个文件
java:8个
classpath:1个
xml:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 156 浏览量
2022-09-23
00:15:00
上传
评论
收藏 10KB ZIP 举报
温馨提示
Web implementation of the CLI
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 11 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/823be93c18be4b9fa55c75bb75c369e0_weixin_42659791.jpg!1)
Kinonoyomeo
- 粉丝: 77
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 10Eclipse项目源码.jpg
- 大屏可视化数据课程项目
- Maven 快速入门指南:安装和配置方法详解
- STM32物信息通过MQTT协议上传云平台
- STM32物信息通过MQTT协议上传云平台
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6260.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6259.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6258.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6257.0)
- Screenshot_2024_0614_022736.png
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)