Package org.mozilla.javascript

Examples of org.mozilla.javascript.ScriptableObject$Slot


  public boolean shouldExecute( final Map currentInputs, final Log logger ) throws Exception {
    boolean shouldExecute = true;
    Context cx = ContextFactory.getGlobal().enterContext();
    try {
      ScriptableObject scriptable = new RhinoScriptable();
      // initialize the standard javascript objects
      Scriptable scope = cx.initStandardObjects( scriptable );
      ScriptableObject.defineClass( scope, JavaScriptResultSet.class );
      Object inputValue;
      IActionParameter inputParameter;
View Full Code Here


        script = buffer.toString();
        if ( ComponentBase.debug ) {
          debug( "script=" + script ); //$NON-NLS-1$
        }
        try {
          ScriptableObject scriptable = new RhinoScriptable();
          // initialize the standard javascript objects
          Scriptable scope = cx.initStandardObjects( scriptable );

          Object resultObject = executeScript( scriptable, scope, script, cx );
          if ( oldStyleOutputs ) {
View Full Code Here

  private static Function compile(String function) {
    final ContextFactory contextFactory = ContextFactory.getGlobal();
    final Context context = contextFactory.enterContext();
    context.setOptimizationLevel(9);

    final ScriptableObject scope = context.initStandardObjects();

    final org.mozilla.javascript.Function fn = context.compileFunction(scope, function, "fn", 1, null);
    Context.exit();

View Full Code Here

    private ModelAndView handleRequestInContext(
            final HttpServletRequest request,
            final HttpServletResponse response,
            final NativeContinuation continuation, final Context cx) throws Exception
    {
        final ScriptableObject scope;
        if(continuation == null)
        {
            scope = scriptStorage.createNewTopLevelScope(cx);
        }
        else
View Full Code Here

        }
    }
   
    ScriptableObject createNewTopLevelScope(Context cx)
    {
        ScriptableObject scope = (ScriptableObject)cx.newObject(library);
        scope.setPrototype(library);
        scope.setParentScope(null);
        return scope;
    }
View Full Code Here

    final ContextFactory factory = new ContextFactory();
    final Context cx = factory.enterContext();

    try {
          final ScriptableObject topScope = cx.initStandardObjects();
          final Foo foo = new Foo();

          // define custom setter method
          final Method setMyPropMethod = Foo.class.getMethod("setMyProp", Foo2.class);
          foo.defineProperty("myProp", null, null, setMyPropMethod, ScriptableObject.EMPTY);

          topScope.put("foo", topScope, foo);

          ScriptableObject.defineClass(topScope, Foo2.class);

          cx.evaluateString(topScope, scriptCode, "myScript", 1, null);
    }
View Full Code Here

    final ContextAction action = new ContextAction()
    {
      public Object run(final Context _cx)
      {
        final ScriptableObject scope = _cx.initStandardObjects();
        final Object result = _cx.evaluateString(scope, script, "test script", 0, null);
        assertEquals("b1,b2,a0,a1,,a3", Context.toString(result));
        return null;
      }
    };
View Full Code Here

   
    final ContextAction action = new ContextAction()
    {
      public Object run(final Context _cx)
      {
        final ScriptableObject scope = _cx.initStandardObjects();
        final Object result = _cx.evaluateString(scope, script, "test script", 0, null);
        return null;
      }
    };
View Full Code Here

    final ContextAction action = new ContextAction()
    {
      public Object run(final Context _cx)
      {
        final ScriptableObject scope = _cx.initStandardObjects();
        final Object result = _cx.evaluateString(scope, script, "test script", 0, null);
        assertEquals("object", ScriptRuntime.typeof(result));
        assertEquals("1", Context.toString(result));
        return null;
      }
View Full Code Here

        reference.put("b", Boolean.TRUE);
        reference.put("c", new HashMap());
        reference.put(new Integer(1), new Integer(42));
        // get a js object as map
        Context context = Context.enter();
        ScriptableObject scope = context.initStandardObjects();
        map = (Map<Object, Object>) context.evaluateString(scope,
                "({ a: 'a', b: true, c: new java.util.HashMap(), 1: 42});",
                "testsrc", 1, null);
        Context.exit();
    }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ScriptableObject$Slot

Copyright © 2018 www.massapicom. 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.