• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ParseResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testGfshExecutionStartegyExecute

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
/**
 * tests execute method by executing dummy method command1
 */
@Test
public void testGfshExecutionStartegyExecute() throws Exception {
  CommandManager commandManager = CommandManager.getInstance();
  assertNotNull("CommandManager should not be null.", commandManager);
  commandManager.add(Commands.class.newInstance());
  GfshParser parser = new GfshParser(commandManager);
  String[] command1Names =
      ((CliCommand) Commands.class.getMethod(COMMAND1_NAME).getAnnotation(CliCommand.class))
          .value();
  String input = command1Names[0];
  ParseResult parseResult = null;
  parseResult = parser.parse(input);
  String[] args = new String[] {command1Names[0]};
  Gfsh gfsh = Gfsh.getInstance(false, args, new GfshConfig());
  GfshExecutionStrategy gfshExecutionStrategy = new GfshExecutionStrategy(gfsh);
  Result resultObject = (Result) gfshExecutionStrategy.execute(parseResult);
  String str = resultObject.nextLine();
  assertTrue(str.trim().equals(COMMAND1_SUCESS));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:23,代码来源:GfshExecutionStrategyJUnitTest.java


示例2: testGfshExecutionStartegyExecute

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
public void testGfshExecutionStartegyExecute() throws Exception {

    CommandManager commandManager = null;
    try {
      commandManager = CommandManager.getInstance();
      assertNotNull("CommandManager should not be null.", commandManager);      
      commandManager.add(Commands.class.newInstance());
      GfshParser parser = new GfshParser(commandManager);
      String[] command1Names = ((CliCommand) Commands.class.getMethod(
          COMMAND1_NAME).getAnnotation(CliCommand.class)).value();
      String input =command1Names[0];
      ParseResult parseResult = null;   
      parseResult = parser.parse(input);  
      String[] args = new String[] {command1Names[0]  };
      Gfsh gfsh = Gfsh.getInstance(false, args, new GfshConfig());      
      GfshExecutionStrategy gfshExecutionStrategy = new GfshExecutionStrategy(gfsh);
      Result resultObject = (Result)gfshExecutionStrategy.execute(parseResult);     
      String str  = resultObject.nextLine();      
      assertTrue(str.trim().equals(COMMAND1_SUCESS));      
    } catch (Exception e) {   
      throw e;
    }
  }
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:GfshExecutionStrategyJUnitTest.java


示例3: execute

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
public Object execute(ParseResult parseResult) throws RuntimeException {
  Assert.notNull(parseResult, "Parse result required");
  logger.info("LensSimpleExecutionStrategy execute method invoked");
  synchronized (this) {
    Assert.isTrue(isReadyForCommands(), "SimpleExecutionStrategy not yet ready for commands");
    Object target = parseResult.getInstance();
    if (target instanceof ExecutionProcessor) {
      ExecutionProcessor processor = ((ExecutionProcessor) target);
      parseResult = processor.beforeInvocation(parseResult);
      try {
        Object result = invoke(parseResult);
        processor.afterReturningInvocation(parseResult, result);
        return result;
      } catch (Throwable th) {
        processor.afterThrowingInvocation(parseResult, th);
        return handleThrowable(th);
      }
    }
    else {
      return invoke(parseResult);
    }
  }
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:24,代码来源:LensSimpleExecutionStrategy.java


示例4: execute

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
public Object execute(ParseResult parseResult) throws RuntimeException {
	Assert.notNull(parseResult, "Parse result required");
	synchronized (mutex) {
		Assert.isTrue(isReadyForCommands(), "SimpleExecutionStrategy not yet ready for commands");
		Object target = parseResult.getInstance();
		if (target instanceof ExecutionProcessor) {
			ExecutionProcessor processor = ((ExecutionProcessor) target);
			parseResult = processor.beforeInvocation(parseResult);
			try {
				Object result = invoke(parseResult);
				processor.afterReturningInvocation(parseResult, result);
				return result;
			} catch (Throwable th) {
				processor.afterThrowingInvocation(parseResult, th);
				return handleThrowable(th);
			}
		} else {
			return invoke(parseResult);
		}
	}
}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:22,代码来源:CustomShellComponent.java


示例5: parseCommand

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
public ParseResult parseCommand(String commentLessLine)
    throws CommandProcessingException, IllegalStateException {
  if (commentLessLine != null) {
    return getParser().parse(commentLessLine);
  }
  throw new IllegalStateException("Command String should not be null.");
}
 
开发者ID:ampool,项目名称:monarch,代码行数:8,代码来源:CommandProcessor.java


示例6: invoke

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
private Object invoke(ParseResult parseResult) {
  try {
    return ReflectionUtils.invokeMethod(parseResult.getMethod(),
      parseResult.getInstance(), parseResult.getArguments());
  } catch (Throwable th) {
    logger.severe("Command failed " + th);
    return handleThrowable(th);
  }
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:10,代码来源:LensSimpleExecutionStrategy.java


示例7: beforeInvocation

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
@Override
public ParseResult beforeInvocation(ParseResult invocationContext) {

	watch = new StopWatch();
	watch.start();

	return invocationContext;
}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:9,代码来源:TimedCommand.java


示例8: invoke

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
private Object invoke(ParseResult parseResult) {
	try {
		Method method = parseResult.getMethod();
		ReflectionUtils.makeAccessible(method);
		return ReflectionUtils.invokeMethod(method, parseResult.getInstance(), parseResult.getArguments());
	} catch (Throwable th) {
		logger.severe("Command failed " + th);
		return handleThrowable(th);
	}
}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:11,代码来源:CustomShellComponent.java


示例9: execCLISteps

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
public static Object execCLISteps(LogWrapper logWrapper, Gfsh shell, ParseResult parseResult) {
  CLIStep[] steps = (CLIStep[]) ReflectionUtils.invokeMethod(parseResult.getMethod(),
      parseResult.getInstance(), parseResult.getArguments());
  if (steps != null) {
    boolean endStepReached = false;
    int stepNumber = 0;
    CLIStep nextStep = steps[stepNumber];
    Result lastResult = null;
    SectionResultData nextStepArgs = null;
    while (!endStepReached) {
      try {
        Result result = executeStep(logWrapper, shell, nextStep, parseResult, nextStepArgs);
        String nextStepString = null;
        nextStepString = getNextStep(result);
        nextStepArgs = extractArgumentsForNextStep(result);
        if (!"END".equals(nextStepString)) {
          String step = nextStepString;
          boolean stepFound = false;
          for (CLIStep s : steps)
            if (step.equals(s.getName())) {
              nextStep = s;
              stepFound = true;
            }
          if (!stepFound) {
            return ResultBuilder.buildResult(ResultBuilder.createErrorResultData()
                .addLine("Wrong step name returned by previous step : " + step));
          }
        } else {
          lastResult = result;
          endStepReached = true;
        }

      } catch (CLIStepExecption e) {
        endStepReached = true;
        lastResult = e.getResult();
      }
    }
    return lastResult;
  } else {
    Gfsh.println("Command returned null steps");
    return ResultBuilder.buildResult(ResultBuilder.createErrorResultData()
        .addLine("Multi-step command Return NULL STEP Array"));
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:45,代码来源:CLIMultiStepHelper.java


示例10: getParseResult

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
/**
 * @return the parseResult
 */
ParseResult getParseResult() {
  return parseResult;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:7,代码来源:CommandStatementImpl.java


示例11: setParseResult

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
/**
 * @param parseResult the parseResult to set
 */
void setParseResult(ParseResult parseResult) {
  this.parseResult = parseResult;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:7,代码来源:CommandStatementImpl.java


示例12: execCLISteps

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
public static Object execCLISteps(LogWrapper logWrapper, Gfsh shell, ParseResult parseResult) {
  CLIStep[] steps = (CLIStep[]) ReflectionUtils.invokeMethod(parseResult.getMethod(), parseResult.getInstance(),
      parseResult.getArguments());
  if (steps != null) {
    boolean endStepReached = false;
    int stepNumber = 0;
    CLIStep nextStep = steps[stepNumber];
    Result lastResult = null;
    SectionResultData nextStepArgs = null;
    while (!endStepReached) {
      try {
        Result result = executeStep(logWrapper, shell, nextStep, parseResult, nextStepArgs);
        String nextStepString = null;
        nextStepString = getNextStep(result);
        nextStepArgs = extractArgumentsForNextStep(result);          
        if (!"END".equals(nextStepString)) {
          String step = nextStepString;
          boolean stepFound = false;
          for (CLIStep s : steps)
            if (step.equals(s.getName())) {
              nextStep = s;
              stepFound = true;
            }
          if (!stepFound) {
            return ResultBuilder.buildResult(ResultBuilder.createErrorResultData().addLine(
                "Wrong step name returned by previous step : " + step));
          }
        } else {
          lastResult = result;
          endStepReached = true;
        }

      } catch (CLIStepExecption e) {
        endStepReached = true;
        lastResult = e.getResult();
      }
    }
    return lastResult;
  } else {
    Gfsh.println("Command returned null steps");
    return ResultBuilder.buildResult(ResultBuilder.createErrorResultData().addLine(
        "Multi-step command Return NULL STEP Array"));
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:45,代码来源:CLIMultiStepHelper.java


示例13: executeStep

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
private static Result executeStep(LogWrapper logWrapper,
                                  Gfsh shell,
                                  CLIStep nextStep,
                                  ParseResult parseResult,
                                  SectionResultData nextStepArgs)
{
  try {
    if (nextStep instanceof CLIRemoteStep) {        
      if (shell.isConnectedAndReady()) {
        if (GfshParseResult.class.isInstance(parseResult)) {
          GfshParseResult gfshParseResult = (GfshParseResult) parseResult;

          CommandRequest commandRequest = new CommandRequest(gfshParseResult, prepareJSONArgs(shell.getEnv(), nextStepArgs));
          commandRequest.setCustomInput(changeStepName(gfshParseResult.getUserInput(), nextStep.getName()));

          return ResultBuilder.fromJson((String) shell.getOperationInvoker().processCommand(commandRequest));
        } else {
          throw new IllegalArgumentException("Command Configuration/Definition error.");
        }
      } else {
        try{throw new Exception();} catch (Exception ex) {ex.printStackTrace();}
        throw new IllegalStateException(
            "Can't execute a remote command without connection. Use 'connect' first to connect.");
      }
    } else {
      Map<String, String> args = CommandExecutionContext.getShellEnv();
      if (args == null) {
        args = new HashMap<String, String>();
        CommandExecutionContext.setShellEnv(args);
      }
      if (nextStepArgs != null) {
        GfJsonObject argsJSon = nextStepArgs.getSectionGfJsonObject();
        Gfsh.getCurrentInstance().setEnvProperty(CLIMultiStepHelper.STEP_ARGS, argsJSon.toString());
      }
      return nextStep.exec();
    }
  } catch (CLIStepExecption e) {
    logWrapper.severe("CLIStep " + nextStep.getName() + " failed aborting command");
    throw e;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:42,代码来源:CLIMultiStepHelper.java


示例14: parseCommand

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
public ParseResult parseCommand(String commentLessLine) throws CommandProcessingException, IllegalStateException {
  if (commentLessLine != null) {
    return getParser().parse(commentLessLine);
  }
  throw new IllegalStateException("Command String should not be null.");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:7,代码来源:CommandProcessor.java


示例15: TestableGfsh

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
public TestableGfsh(String name, boolean launchShell, String[] args) throws ClassNotFoundException, IOException {
    super(launchShell, args, new TestableGfshConfig(name));
    oldParser = super.getParser();
    resultLatch = new CountDownLatch(1);
    parserHook = new Parser() {

      @Override
      public ParseResult parse(String buffer) {
        Util.debug("In parsing hook .... with input buffer <" + buffer + ">");
        ParseResult result = null;
        try{
          result = oldParser.parse(buffer);
        }catch(Exception e){
          String reason = e.getMessage() != null ? " Reason: "+e.getMessage() + " Exception: " + String.valueOf(e) : " Exception: " + String.valueOf(e);
          addError("Parsing failed...."  + reason + " buffer returned by EIS " + eis.getBufferFormdAfterReading(),e);
          return null;
        }
        if(result==null){
        	addError("Parsing failed....",null);
        }else{
          Util.log("Parse Result is " + result);
        }
        return result;
      }

//      @Override
      public int completeAdvanced(String buffer, int cursor, List<Completion> candidates) {
        return oldParser.completeAdvanced(buffer, cursor, candidates);
      }

      @Override
      public int complete(String buffer, int cursor, List<String> candidates) {
        return oldParser.complete(buffer, cursor, candidates);
      }
    };

    this.name = name;
    Util.debug("Using CommandManager configured with commands "+ this.getCommandNames(""));
    eis = new EventedInputStream();
    output = new ByteArrayOutputStream(1024 * 10);
    PrintStream sysout = new PrintStream(output, true);
    TestableGfsh.setGfshOutErr(sysout);

//    Writer out = new BufferedWriter(new OutputStreamWriter(sysout));  // saj
    wrappedOut = new BufferedWriter(new OutputStreamWriter(sysout));

    try {
      ConsoleReaderWrapper wrapper = new ConsoleReaderWrapper(eis, wrappedOut);
      Util.debug("Reader created is " + wrapper);
      newConsoleReader = wrapper;
      reader = newConsoleReader;
      completorAdaptor = new JLineCompletorAdapterWrapper(getParser(), this);
    } catch (IOException e) {
      e.printStackTrace();
      throw e;
    }
  }
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:58,代码来源:TestableGfsh.java


示例16: getExecutionStrategy

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
@Override
protected ExecutionStrategy getExecutionStrategy() {

  final ExecutionStrategy oldStrategy = super.getExecutionStrategy();
  return new ExecutionStrategy() {
    public Object execute(ParseResult parseResult) throws RuntimeException {
      Object obj = null;
      String command = null;
      try {
        String method = parseResult.getMethod().getName();
        String className = parseResult.getInstance().getClass().getCanonicalName();
        command = className + "." + method;
        Util.log("Executing command " + command + " with Gfsh instance " + gfshThreadLocal.get());
        long l1 = System.currentTimeMillis();
        obj = oldStrategy.execute(parseResult);
        long l2 = System.currentTimeMillis();
        Util.log("Completed execution of command " + command + " in " + (l2-l1) + " ms.");
        if(obj!=null){
          Util.log("Command output class is " + obj.getClass());
        }else{
          obj =  "VOID";
        }
      } catch (Exception e) {
        addError("Error running command " , e);
        throw new RuntimeException(e);
      }
      Util.debug("Adding outuut and notifying threads ..");
      addOutput(command, obj);
      if(command.equals(EXIT_SHELL_COMMAND))
        resultLatch.countDown();
      return obj;
    }

    public boolean isReadyForCommands() {
      return oldStrategy.isReadyForCommands();
    }

    public void terminate() {
      oldStrategy.terminate();
      Util.log("GFSH is exiting now, thankyou for using");
    }
  };
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:44,代码来源:TestableGfsh.java


示例17: afterReturningInvocation

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
@Override
public void afterReturningInvocation(ParseResult invocationContext, Object result) {
	stopAndLog();
}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:5,代码来源:TimedCommand.java


示例18: afterThrowingInvocation

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
@Override
public void afterThrowingInvocation(ParseResult invocationContext, Throwable thrown) {
	stopAndLog();
}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:5,代码来源:TimedCommand.java


示例19: beforeInvocation

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
@Override
public ParseResult beforeInvocation(ParseResult invocationContext)
{
  return invocationContext;
}
 
开发者ID:iisi-nj,项目名称:GemFireLite,代码行数:6,代码来源:AbstractCommand.java


示例20: afterReturningInvocation

import org.springframework.shell.event.ParseResult; //导入依赖的package包/类
@Override
public void afterReturningInvocation(ParseResult invocationContext, Object result)
{
  invocationContext.toString();
}
 
开发者ID:iisi-nj,项目名称:GemFireLite,代码行数:6,代码来源:AbstractCommand.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PreemptionContract类代码示例发布时间:2022-05-22
下一篇:
Java SteeringAcceleration类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap