/** Invoke the declared method with the specified arguments and interpreter reference. This is the simplest form of invoke() for BshMethod intended to be used in reflective style access to bsh scripts. */ public Object invoke( Object[] argValues, BshEvaluatingVisitor visitor ) throws EvalError { return invoke( argValues, visitor, null, false ); }
/** Invoke the declared method with the specified arguments and interpreter reference. This is the simplest form of invoke() for BshMethod intended to be used in reflective style access to bsh scripts. */ public Object invoke( Object[] argValues, Interpreter interpreter ) throws EvalError { return invoke( argValues, interpreter, null, null, false ); }
public Object invoke(Object obj, Object... args) throws Exception { return _method.invoke(args != null ? args : new Object[0], _ip); }
/** Invoke the bsh method with the specified args, interpreter ref, and callstack. callerInfo is the node representing the method invocation It is used primarily for debugging in order to provide access to the text of the construct that invoked the method through the namespace. @param callerInfo is the BeanShell AST node representing the method invocation. It is used to print the line number and text of errors in EvalError exceptions. If the node is null here error messages may not be able to point to the precise location and text of the error. @param callstack is the callstack. If callstack is null a new one will be created with the declaring namespace of the method on top of the stack (i.e. it will look for purposes of the method invocation like the method call occurred in the declaring (enclosing) namespace in which the method is defined). */ public Object invoke( Object[] argValues, Interpreter interpreter, CallStack callstack, SimpleNode callerInfo ) throws EvalError { return invoke( argValues, interpreter, callstack, callerInfo, false ); }
/** Invoke the bsh method with the specified args, interpreter ref, and callstack. callerInfo is the node representing the method invocation It is used primarily for debugging in order to provide access to the text of the construct that invoked the method through the namespace. @param callerInfo is the BeanShell AST node representing the method invocation. It is used to print the line number and text of errors in EvalError exceptions. If the node is null here error messages may not be able to point to the precise location and text of the error. @param visitor is the callstack. If callstack is null a new one will be created with the declaring namespace of the method on top of the stack (i.e. it will look for purposes of the method invocation like the method call occurred in the declaring (enclosing) namespace in which the method is defined). */ public Object invoke( Object[] argValues, BshEvaluatingVisitor visitor, SimpleNode callerInfo ) throws EvalError { return invoke( argValues, visitor, callerInfo, false ); }
constructor.invoke(args, instanceThis.declaringInterpreter);
/** Get a property from a scripted object or Primitive.VOID if no such * property exists. * @param propName the prop name * @param interp the interp * @return the property value * @throws UtilEvalError the util eval error */ Object getPropertyValue(final String propName, final Interpreter interp) throws UtilEvalError { String accessorName = Reflect.accessorName(Reflect.GET_PREFIX, propName); final Class<?>[] classArray = Reflect.ZERO_TYPES; BshMethod m = this.getMethod(accessorName, classArray); try { if (m != null) return m.invoke((Object[]) null, interp); accessorName = Reflect.accessorName(Reflect.IS_PREFIX, propName); m = this.getMethod(accessorName, classArray); if (m != null && m.getReturnType() == Boolean.TYPE) return m.invoke((Object[]) null, interp); return Primitive.VOID; } catch (final EvalError ee) { throw new UtilEvalError("'This' property accessor threw exception: " + ee.getMessage(), ee); } }
public Object invoke(final Map<String, ?> context) throws EvalError { final NameSpace nameSpace = new NameSpace(_interpreter.getClassManager(), "BeanshellExecutable"); nameSpace.setParent(_interpreter.getNameSpace()); final BshMethod method = new BshMethod(_method.getName(), _method.getReturnType(), _method.getParameterNames(), _method.getParameterTypes(), _method.methodBody, nameSpace, _method.getModifiers()); for (final Map.Entry<String, ?> entry : context.entrySet()) { try { nameSpace.setVariable(entry.getKey(), entry.getValue(), false); } catch (final UtilEvalError e) { throw new EvalError("cannot set variable '" + entry.getKey() + '\'', null, null, e); } } final Object result = method.invoke(new Object[0], new BshEvaluatingVisitor(null, _interpreter)); if (result instanceof Primitive) { if (( (Primitive) result).getType() == Void.TYPE) { return null; } return ( (Primitive) result).getValue(); } return result; }
public Object invoke(final Map<String, ?> context) throws EvalError { final NameSpace nameSpace = new NameSpace("BeanshellExecutable", _interpreter.getClassManager()); nameSpace.setParent(_interpreter.getNameSpace()); final BshMethod method = new BshMethod(_method.getName(), _method.getReturnType(), _method.getParameterNames(), _method.getParameterTypes(), _method.getParameterModifiers(), _method.methodBody, nameSpace, _method.getModifiers()); for (final Map.Entry<String, ?> entry : context.entrySet()) { try { final Object value = entry.getValue(); nameSpace.setVariable(entry.getKey(), value != null ? value : Primitive.NULL, false); } catch (final UtilEvalError e) { throw new EvalError("cannot set variable '" + entry.getKey() + '\'', null, null, e); } } final Object result = method.invoke(Reflect.ZERO_ARGS, _interpreter); if ( Types.getType(result) == Void.TYPE ) return null; return Primitive.unwrap(result); }
/** This is the invocation handler for the dynamic proxy. <p> Notes: Inner class for the invocation handler seems to shield this unavailable interface from JDK1.2 VM... I don't understand this. JThis works just fine even if those classes aren't there (doesn't it?) This class shouldn't be loaded if an XThis isn't instantiated in NameSpace.java, should it? */ class Handler implements InvocationHandler, java.io.Serializable { public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { try { return invokeImpl( proxy, method, args ); } catch ( TargetError te ) { // Unwrap target exception. If the interface declares that // it throws the ex it will be delivered. If not it will be // wrapped in an UndeclaredThrowable // This isn't simple because unwrapping this loses all context info. // So rewrap is better than unwrap. - fschmidt Throwable t = te.getTarget(); Class<? extends Throwable> c = t.getClass(); String msg = t.getMessage(); try {
&& namespace.isChildOf(meth.declaringNameSpace); return meth.invoke( args, interpreter, callstack, callerInfo, overrideChild ); return invokeMethod.invoke( new Object [] { commandName, args }, interpreter, callstack, callerInfo ); return ((BshMethod)commandObject).invoke( args, interpreter, callstack, callerInfo );
constructor.invoke(args, new BshEvaluatingVisitor(callstack, interpreter), null/*callerInfo*/, false/*overrideNameSpace*/);
BshMethod m = thisNamespace.getMethod(methodName, Types.getTypes(args), true); if ( null != m ) return m.invoke(args, interpreter, callstack, callerInfo);