Package org.apache.bsf

Examples of org.apache.bsf.BSFManager.eval()


      final BSFManager interpreter = new BSFManager();
      interpreter.declareBean("chartExpression", this, getClass()); //$NON-NLS-1$
      interpreter.declareBean("chart", originalChart, JFreeChart.class); //$NON-NLS-1$
      interpreter.declareBean("runtime", runtimeWrapper, ExpressionRuntime.class); //$NON-NLS-1$
      interpreter.declareBean("dataRow", legacyDataRowWrapper, DataRow.class); //$NON-NLS-1$
      final Object o = interpreter.eval
          (postProcessingLanguage, "expression", 1, 1, postProcessingScript); //$NON-NLS-1$
      if (o instanceof JFreeChart)
      {
        return (JFreeChart) o;
      }
View Full Code Here


                    }
                }
            }

            // execute the script
            Object result = bsfManager.eval(scriptType, cacheName, 0, 0, scriptString);

            // check the result
            if (result != null && !(result instanceof String)) {
                throw new EventHandlerException("Event did not return a String result, it returned a " + result.getClass().getName());
            }
View Full Code Here

                    }
                }
            }

            // execute the script
            Object result = bsfManager.eval(scriptType, cacheName, 0, 0, scriptString);

            // check the result
            if (result != null && !(result instanceof String)) {
                throw new EventHandlerException("Event did not return a String result, it returned a " + result.getClass().getName());
            }
View Full Code Here

    @Test
    public void testLVar() throws BSFException {
        BSFManager.registerScriptingEngine("jruby",
                "org.jruby.embed.bsf.JRubyEngine", new String[]{"rb"});
        BSFManager bsf = new BSFManager();
        bsf.eval("jruby", "(java)", 1, 1, "$x='GVar'");
        bsf.eval("jruby", "(java)", 1, 1, "@gvar = \"$x = #{$x}\"");

        bsf.eval("jruby", "(java)", 1, 1, "x='LVar'");
        bsf.eval("jruby", "(java)", 1, 1, "at_exit { @result =  \"#{x} and #{$x} in an at_exit block\" }");
        Object ret = bsf.eval("jruby", "(java)", 1, 1, "@lvar = \"x = #{x}\";return @gvar, @lvar");
View Full Code Here

    public void testLVar() throws BSFException {
        BSFManager.registerScriptingEngine("jruby",
                "org.jruby.embed.bsf.JRubyEngine", new String[]{"rb"});
        BSFManager bsf = new BSFManager();
        bsf.eval("jruby", "(java)", 1, 1, "$x='GVar'");
        bsf.eval("jruby", "(java)", 1, 1, "@gvar = \"$x = #{$x}\"");

        bsf.eval("jruby", "(java)", 1, 1, "x='LVar'");
        bsf.eval("jruby", "(java)", 1, 1, "at_exit { @result =  \"#{x} and #{$x} in an at_exit block\" }");
        Object ret = bsf.eval("jruby", "(java)", 1, 1, "@lvar = \"x = #{x}\";return @gvar, @lvar");
        List<String> expResult = Arrays.asList("$x = GVar", "x = LVar");
View Full Code Here

                "org.jruby.embed.bsf.JRubyEngine", new String[]{"rb"});
        BSFManager bsf = new BSFManager();
        bsf.eval("jruby", "(java)", 1, 1, "$x='GVar'");
        bsf.eval("jruby", "(java)", 1, 1, "@gvar = \"$x = #{$x}\"");

        bsf.eval("jruby", "(java)", 1, 1, "x='LVar'");
        bsf.eval("jruby", "(java)", 1, 1, "at_exit { @result =  \"#{x} and #{$x} in an at_exit block\" }");
        Object ret = bsf.eval("jruby", "(java)", 1, 1, "@lvar = \"x = #{x}\";return @gvar, @lvar");
        List<String> expResult = Arrays.asList("$x = GVar", "x = LVar");
        assertEquals(expResult, ret);
        logger1.info(ret.toString());
View Full Code Here

        BSFManager bsf = new BSFManager();
        bsf.eval("jruby", "(java)", 1, 1, "$x='GVar'");
        bsf.eval("jruby", "(java)", 1, 1, "@gvar = \"$x = #{$x}\"");

        bsf.eval("jruby", "(java)", 1, 1, "x='LVar'");
        bsf.eval("jruby", "(java)", 1, 1, "at_exit { @result =  \"#{x} and #{$x} in an at_exit block\" }");
        Object ret = bsf.eval("jruby", "(java)", 1, 1, "@lvar = \"x = #{x}\";return @gvar, @lvar");
        List<String> expResult = Arrays.asList("$x = GVar", "x = LVar");
        assertEquals(expResult, ret);
        logger1.info(ret.toString());
        bsf.terminate();
View Full Code Here

        bsf.eval("jruby", "(java)", 1, 1, "$x='GVar'");
        bsf.eval("jruby", "(java)", 1, 1, "@gvar = \"$x = #{$x}\"");

        bsf.eval("jruby", "(java)", 1, 1, "x='LVar'");
        bsf.eval("jruby", "(java)", 1, 1, "at_exit { @result =  \"#{x} and #{$x} in an at_exit block\" }");
        Object ret = bsf.eval("jruby", "(java)", 1, 1, "@lvar = \"x = #{x}\";return @gvar, @lvar");
        List<String> expResult = Arrays.asList("$x = GVar", "x = LVar");
        assertEquals(expResult, ret);
        logger1.info(ret.toString());
        bsf.terminate();
    }
View Full Code Here

        expResult = "HELLO WORLD!";
        result = instance.eval("<script>", 0, 0, "message=\"Hello \" + \"World!\"\nmessage.upcase");
        assertEquals(expResult, result);

        manager.declareBean("greet", "Heeey", String.class);
        result = manager.eval("jruby", "<script>", 0, 0, "message=$greet + \" World!\"");
        expResult = "Heeey World!";
        assertEquals(expResult, result);
    }

    /**
 
View Full Code Here

                  "q0 * Math.exp(1.0 / $h * Math.log(1.0/2.0) * t)\n" +
                "end\n" +
                "def years_to_amount(q0, q)\n" +
                  "$h * (Math.log(q) - Math.log(q0)) / Math.log(1.0/2.0)\n" +
                "end";
        recv = manager.eval("jruby", "radioactive_decay", 0, 0, script);
        method = "amount_after_years";
        args = new Object[2];
        args[0] = 10.0; args[1] = 1000;
       
        // Radium
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.