@Override public Object invokeMethod(String name, Object args) { try { return super.invokeMethod(name, args); } catch (MissingMethodException e) { return dispatch(name, unwrapArgs(args)); } }
return new ClassDispatcher(cmd, this).dispatch("", CommandClosure.unwrapArgs(args));
private CommandClosure options(Map<?, ?> options, Object[] arguments) { CommandClosure ret; if (this instanceof MethodDispatcher) { ret = new MethodDispatcher(((MethodDispatcher)this).dispatcher, ((MethodDispatcher)this).name); } else { ret = new ClassDispatcher(((ClassDispatcher)this).command, ((ClassDispatcher)this).owner); } // We merge options if (options != null && options.size() > 0) { if (this.options == null) { ret.options = new HashMap<String, Object>(); } else { ret.options = new HashMap<String, Object>(this.options); } for (Map.Entry<?, ?> arg : options.entrySet()) { ret.options.put(arg.getKey().toString(), arg.getValue()); } } // We replace arguments if (arguments != null) { ret.args = new ArrayList<Object>(Arrays.asList(arguments)); } // return ret; } }
@Override public Object call(Object[] args) { return dispatcher.dispatch(name, args); } }
if (closure instanceof MethodDispatcher) { MethodDispatcher commandClosure = (MethodDispatcher)closure; producerPipe = commandClosure.dispatcher.resolvePipe(commandClosure.name, new Object[0], true); } else if (closure instanceof ClassDispatcher) { ClassDispatcher dispatcherClosure = (ClassDispatcher)closure; producerPipe = dispatcherClosure.resolvePipe(name, new Object[0], true); } else {
@Override public final Object invokeMethod(String name, Object args) { // try { return super.invokeMethod(name, args); } catch (MissingMethodException e) { if (context instanceof InvocationContext) { InvocationContext ic = (InvocationContext)context; CRaSH crash = (CRaSH)context.getSession().get("crash"); if (crash != null) { ShellCommand cmd; try { cmd = crash.getCommand(name); } catch (NoSuchCommandException ce) { throw new InvokerInvocationException(ce); } if (cmd != null) { ClassDispatcher dispatcher = new ClassDispatcher(cmd, this); return dispatcher.dispatch("", CommandClosure.unwrapArgs(args)); } } } // throw e; } }
ShellCommand cmd = crash.getCommand(property); if (cmd != null) { return new ClassDispatcher(cmd, this);
/** * Closure invocation. * * @param arguments the closure arguments */ public Object call(Object[] arguments) { return dispatch("", arguments); }
Object dispatch(String methodName, Object[] arguments) { PipeCommandProxy pipe = resolvePipe(methodName, arguments, false); // try { pipe.fire(); return null; } catch (ScriptException e) { Throwable cause = e.getCause(); if (cause != null) { throw new InvokerInvocationException(cause); } else { throw e; } } finally { Safe.close(pipe); } }
@Override public final Object getProperty(String property) { if (context instanceof InvocationContext<?>) { CRaSH crash = (CRaSH)context.getSession().get("crash"); if (crash != null) { try { ShellCommand cmd = crash.getCommand(property); if (cmd != null) { return new ClassDispatcher(cmd, this); } } catch (NoSuchCommandException e) { throw new InvokerInvocationException(e); } } } // try { return super.getProperty(property); } catch (MissingPropertyException e) { return context.getSession().get(property); } }