当前位置: 首页>>代码示例>>Java>>正文


Java JLineShell类代码示例

本文整理汇总了Java中org.springframework.shell.core.JLineShell的典型用法代码示例。如果您正苦于以下问题:Java JLineShell类的具体用法?Java JLineShell怎么用?Java JLineShell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JLineShell类属于org.springframework.shell.core包,在下文中一共展示了JLineShell类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: HandleHelp

import org.springframework.shell.core.JLineShell; //导入依赖的package包/类
private InterpreterResult HandleHelp(JLineShell shell, String st) {
  java.util.logging.StreamHandler sh = null;
  java.util.logging.Logger springLogger = null;
  java.util.logging.Formatter formatter = new java.util.logging.Formatter() {
    public String format(java.util.logging.LogRecord record) {
      return record.getMessage();
    }
  };
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  try {
    sh = new java.util.logging.StreamHandler(baos, formatter);
    springLogger = HandlerUtils.getLogger(org.springframework.shell.core.SimpleParser.class);
    springLogger.addHandler(sh);
    shell.executeCommand(st);
  } catch (Exception e) {
    s_logger.error(e.getMessage(), e);
    return new InterpreterResult(Code.ERROR, e.getMessage());
  }
  finally {
    sh.flush();
    springLogger.removeHandler(sh);
    sh.close();
  }
  return new InterpreterResult(Code.SUCCESS, baos.toString());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:26,代码来源:LensInterpreter.java

示例2: getJLineShell

import org.springframework.shell.core.JLineShell; //导入依赖的package包/类
private JLineShell getJLineShell(Bootstrap bs) {
  if (bs instanceof LensBootstrap) {
    return ((LensBootstrap) bs).getLensJLineShellComponent();
  } else {
    return bs.getJLineShellComponent();
  }
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:8,代码来源:LensInterpreter.java

示例3: closeShell

import org.springframework.shell.core.JLineShell; //导入依赖的package包/类
private void closeShell(JLineShell shell) {
  if (shell instanceof LensJLineShellComponent) {
    ((LensJLineShellComponent) shell).stop();
  } else {
    ((JLineShellComponent) shell).stop();
  }
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:8,代码来源:LensInterpreter.java

示例4: shell

import org.springframework.shell.core.JLineShell; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(JLineShell.class)
public JLineShellComponent shell() {
	return new JLineShellComponent();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:6,代码来源:BaseShellAutoConfiguration.java

示例5: interpret

import org.springframework.shell.core.JLineShell; //导入依赖的package包/类
@Override
public InterpreterResult interpret(String input, InterpreterContext context) {
  if (input == null || input.length() == 0) {
    return new InterpreterResult(Code.ERROR, "no command submitted");
  }
  String st = input.replaceAll("\\n", " ");
  s_logger.info("LensInterpreter command: " + st);
  
  Bootstrap bs = createBootstrap();
  JLineShell  shell = getJLineShell(bs);
  CommandResult res = null;
  LensClient lensClient = null;
  String qh = null;
  
  if (st.trim().startsWith("help")) {
    return HandleHelp(shell, st);
  }
  
  try {
    lensClient = createAndSetLensClient(bs);
    s_clientMap.put(lensClient, true);
    
    String lensCommand = modifyQueryStatement(st);
    
    s_logger.info("executing command : " + lensCommand);
    res = shell.executeCommand(lensCommand);
    
    if (!lensCommand.equals(st) && res != null 
        && res.getResult() != null 
        && res.getResult().toString().trim().matches("[a-z0-9-]+")) {
      // setup query progress tracking
      qh = res.getResult().toString();
      s_paraToQH.put(context.getParagraphId(), 
        new ExecutionDetail(qh, lensClient, shell));
      String getResultsCmd = "query results --async false " + qh;
      s_logger.info("executing query results command : " + context.getParagraphId() 
        + " : " + getResultsCmd);
      res = shell.executeCommand(getResultsCmd); 
      s_paraToQH.remove(context.getParagraphId());
    }
  } catch (Exception ex) {
    s_logger.error("error in interpret", ex);
    return new InterpreterResult(Code.ERROR, ex.getMessage());
  } 
  finally {
    if (shell != null) {
      closeShell(shell);
    }
    if (lensClient != null) {
      closeLensClient(lensClient);
      s_clientMap.remove(lensClient);
    }
    if (qh != null) {
      s_paraToQH.remove(context.getParagraphId());
    }
  }
  return new InterpreterResult(Code.SUCCESS, formatResult(st, res));
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:59,代码来源:LensInterpreter.java

示例6: getProgress

import org.springframework.shell.core.JLineShell; //导入依赖的package包/类
@Override
public int getProgress(InterpreterContext context) {
  if (s_paraToQH.containsKey(context.getParagraphId())) {
    s_logger.info("number of items for which progress can be reported :" + s_paraToQH.size());
    s_logger.info("number of open lensclient :" + s_clientMap.size());
    Bootstrap bs = createBootstrap();
    JLineShell shell = getJLineShell(bs);
    LensClient lensClient = null;
    String qh = s_paraToQH.get(context.getParagraphId()).getQueryHandle();
    try {
      s_logger.info("fetch query status for : (" + context.getParagraphId() + ") :" + qh);
      lensClient = createAndSetLensClient(bs);
      s_clientMap.put(lensClient, true);
      CommandResult res = shell.executeCommand("query status " + qh);
      s_logger.info(context.getParagraphId() + " --> " + res.getResult().toString());
      //change to debug
      Pattern pattern = Pattern.compile(".*(Progress : (\\d\\.\\d)).*");
      Matcher matcher = pattern.matcher(res.getResult().toString().replaceAll("\\n", " "));
      if (matcher.find(2)) {
        Double d = Double.parseDouble(matcher.group(2)) * 100;
        if (d.intValue() == 100) {
          s_paraToQH.remove(context.getParagraphId());
        }
        return d.intValue();
      } else {
        return 1;
      }
    }
    catch (Exception e) {
      s_logger.error("unable to get progress for (" + context.getParagraphId() + ") :" + qh, e);
      s_paraToQH.remove(context.getParagraphId());
      return 0;
    } finally {
      if (lensClient != null) {
        closeLensClient(lensClient);
        s_clientMap.remove(lensClient);
      }
      if (shell != null) {
        closeShell(shell);
      }
    }
  }
  return 0;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:45,代码来源:LensInterpreter.java

示例7: ExecutionDetail

import org.springframework.shell.core.JLineShell; //导入依赖的package包/类
ExecutionDetail(String qh, LensClient lensClient, JLineShell shell) {
  this.queryHandle = qh;
  this.lensClient = lensClient;
  this.shell = shell;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:6,代码来源:ExecutionDetail.java

示例8: getShell

import org.springframework.shell.core.JLineShell; //导入依赖的package包/类
public JLineShell getShell() {
  return shell;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:4,代码来源:ExecutionDetail.java


注:本文中的org.springframework.shell.core.JLineShell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。