@Override public GfshParseResult parse(String userInput) { String rawInput = convertToSimpleParserInput(userInput); // this tells the simpleParser not to interpret backslash as escaping character rawInput = rawInput.replace("\\", "\\\\"); // User SimpleParser to parse the input ParseResult result = super.parse(rawInput); if (result == null) { return null; } return new GfshParseResult(result.getMethod(), result.getInstance(), result.getArguments(), userInput); }
public Object execute(ParseResult parseResult) { Result result; Method method = parseResult.getMethod();
Method method = parseResult.getMethod();
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); } }
/** * This Code piece allows lens cli to be able to parse list arguments. It can already parse keyword args. * More details at https://github.com/spring-projects/spring-shell/issues/72 * @param parseResult * @return */ @Override public ParseResult beforeInvocation(ParseResult parseResult) { Object[] args = parseResult.getArguments(); if (args != null && Sets.newHashSet(args).size() == 1) { if (args[0] instanceof String) { String[] split = ((String) args[0]).split("\\s+"); Object[] newArgs = new String[args.length]; System.arraycopy(split, 0, newArgs, 0, split.length); parseResult = new ParseResult(parseResult.getMethod(), parseResult.getInstance(), newArgs); } } return parseResult; }
/** * This Code piece allows lens cli to be able to parse list arguments. It can already parse keyword args. * More details at https://github.com/spring-projects/spring-shell/issues/72 * @param parseResult * @return */ @Override public ParseResult beforeInvocation(ParseResult parseResult) { Object[] args = parseResult.getArguments(); if (args != null && Sets.newHashSet(args).size() == 1) { if (args[0] instanceof String) { String[] split = ((String) args[0]).split("\\s+"); Object[] newArgs = new String[args.length]; System.arraycopy(split, 0, newArgs, 0, split.length); parseResult = new ParseResult(parseResult.getMethod(), parseResult.getInstance(), newArgs); } } return parseResult; }
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 Object execute(ParseResult parseResult){ Object result = null; Method method = parseResult.getMethod(); try { Method reflectmethod = parseResult.getMethod(); MultiStepCommand cmd = reflectmethod.getAnnotation(MultiStepCommand.class); if(cmd!=null){ result = ReflectionUtils.invokeMethod(parseResult.getMethod(), parseResult.getInstance(), parseResult.getArguments());
public static Object execCLISteps(LogWrapper logWrapper, Gfsh shell, ParseResult parseResult) { CLIStep[] steps = (CLIStep[]) ReflectionUtils.invokeMethod(parseResult.getMethod(), parseResult.getInstance(), parseResult.getArguments()); if (steps != null) {
public Object execute(ParseResult parseResult){ Object result = null; Method method = parseResult.getMethod(); try { Method reflectmethod = parseResult.getMethod(); MultiStepCommand cmd = reflectmethod.getAnnotation(MultiStepCommand.class); if(cmd!=null){ result = ReflectionUtils.invokeMethod(parseResult.getMethod(), parseResult.getInstance(), parseResult.getArguments());
public static Object execCLISteps(LogWrapper logWrapper, Gfsh shell, ParseResult parseResult) { CLIStep[] steps = (CLIStep[]) ReflectionUtils.invokeMethod(parseResult.getMethod(), parseResult.getInstance(), parseResult.getArguments()); if (steps != null) {
parse = parser.parse(input); assertNotNull(parse); assertEquals("Check ParseResult method", parse.getMethod(), METHOD_command1); assertEquals("Check no. of method arguments", 5, parse.getArguments().length); parse = parser.parse(input); assertNotNull(parse); assertEquals("Check ParseResult method", parse.getMethod(), METHOD_command1); assertEquals("Check no. of method arguments", 5, parse.getArguments().length); parse = parser.parse(input); assertNotNull(parse); assertEquals("Check ParseResult method", parse.getMethod(), METHOD_command1); assertEquals("Check no. of method arguments", 5, parse.getArguments().length); ParseResult parseResult = parser.parse(command); assertNotNull(parseResult); assertEquals("Check ParseResult method", parseResult.getMethod(), METHOD_testParamConcat); assertEquals("Check no. of method arguments", 5, parseResult.getArguments().length); Object[] arguments = parseResult.getArguments(); parseResult = parser.parse(command); assertNotNull(parseResult); assertEquals("Check ParseResult method", parseResult.getMethod(), METHOD_testParamConcat); assertEquals("Check no. of method arguments", 5, parseResult.getArguments().length); arguments = parseResult.getArguments();