Examples of invokeFunction()


Examples of javax.script.Invocable.invokeFunction()

                    invocable = (Invocable)scriptEngine;
                } catch (ClassCastException exception) {
                    throw new SerializationException(exception);
                }

                result = invocable.invokeFunction(methodName, args);
            }

            // If the function didn't return a value, return the default
            if (result == null) {
                Class<?> returnType = method.getReturnType();
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

    ScriptEngine engine = manager.getEngineByExtension("rb");
    assertNotNull("Engine should not be null",engine);
    engine.eval("def hello(s)\n   return \"Hello \" + s\nend" );
    assertTrue(engine instanceof Invocable);
    Invocable invocableScript = (Invocable) engine;
    assertEquals("Hello petra", invocableScript.invokeFunction("hello", new Object[]{"petra"}));
  }

//  public void testInvokeMethod() throws ScriptException {
//    ScriptEngineManager manager = new ScriptEngineManager();
//    ScriptEngine engine = manager.getEngineByExtension("js");
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

        }
      }
      if (scriptEngine instanceof Invocable) {
        final Invocable invocableEngine = (Invocable) scriptEngine;
        Object[] EMPTY = new Object[0];
        result = (String) invocableEngine.invokeFunction(func.getName(), EMPTY);
      }
    } catch (ScriptException e) {
      throw new OCommandScriptException("Error on execution of the script", func.getName(), e.getColumnNumber(), e);
    } catch (NoSuchMethodException e) {
      throw new OCommandScriptException("Error on execution of the script", func.getName(), 0, e);
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

 
  private void invokeFunctionOrMethod(Shell shellState, ScriptEngine engine, CommandLine cl, Object[] args) {
    try {
      Invocable inv = (Invocable) engine;
      if (cl.hasOption(function.getOpt())) {
        inv.invokeFunction(cl.getOptionValue(function.getOpt()), args);
      } else if (cl.hasOption(object.getOpt())) {
        String objectMethod = cl.getOptionValue(object.getOpt());
        String[] parts = objectMethod.split(":");
        if (!(parts.length == 2)) {
          shellState.printException(new Exception("Object and Method must be supplied"));
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByExtension("js");
    engine.eval("function hello(s) { return 'Hello ' + s; }" );
    assertTrue(engine instanceof Invocable);
    Invocable invocableScript = (Invocable) engine;
    assertEquals("Hello petra", invocableScript.invokeFunction("hello", new Object[]{"petra"}));
  }

  public void testInvokeMethod() throws ScriptException, NoSuchMethodException {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByExtension("js");
View Full Code Here

Examples of org.apache.tuscany.container.javascript.rhino.RhinoScriptInstance.invokeFunction()

    /**
     * Invokes a function on a script instance
     */
    public Object invokeTarget(final Object payload) throws InvocationTargetException {
        RhinoScriptInstance target = context.getTargetInstance();
        return target.invokeFunction(functionName, (Object[]) payload, responseClass);
    }

}
View Full Code Here

Examples of org.apache.tuscany.container.ruby.rubyscript.RubyScriptInstance.invokeFunction()

    /**
     * Invokes a function on a script instance
     */
    public Object invokeTarget(final Object payload) throws InvocationTargetException {
        RubyScriptInstance target = context.getTargetInstance();
        return target.invokeFunction(functionName,
                                     (Object[]) payload,
                                     returnType);
    }

}
View Full Code Here

Examples of org.raptorjs.rhino.JavaScriptEngine.invokeFunction()

            this.function = (NativeFunction)jsEngine.eval(
                    "(function (extensions) { return " + this.condition + ";})",
                    this.name);   
        }
       
        Boolean result =  (Boolean)jsEngine.invokeFunction(this.function, extensionCollection);
        return result.booleanValue();
    }
   
}
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor.invokeFunction()

       
        if (rightExpr instanceof Constant) {
            Constant const2 = (Constant)rightExpr;
            try {
                Object result = descriptor.invokeFunction(new Object[] { const2.getValue(), const1.getValue() } );
                combinedConst = new Constant(result, descriptor.getReturnType());
            } catch(FunctionExecutionException e) {
              throw new QueryValidatorException(e, "ERR.015.009.0003", QueryPlugin.Util.getString("ERR.015.009.0003", e.getMessage())); //$NON-NLS-1$ //$NON-NLS-2$
          }
        } else {
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor.invokeFunction()

        if(descriptor == null){
            return crit;
        }
      Object value = ((Constant)rightExpr).getValue();
      try {
        Object result = descriptor.invokeFunction(new Object[] {((Constant)rightExpr).getValue(), format});
        result = leftFunction.getFunctionDescriptor().invokeFunction(new Object[] { result, format } );
        if (((Comparable)value).compareTo(result) != 0) {
          return getSimpliedCriteria(crit, leftExpr, crit.getOperator() != CompareCriteria.EQ, true);
        }
      } catch(FunctionExecutionException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.