Examples of ScriptableInputStream


Examples of net.sourceforge.htmlunit.corejs.javascript.serialize.ScriptableInputStream

  public static Object deserialize( Context cx, Scriptable thisObj, Object[] args, Function funObj ) throws IOException, ClassNotFoundException {
    if ( args.length < 1 ) { throw Context.reportRuntimeError( "Expected a filename to read the serialization from" ); }
    String filename = Context.toString( args[ 0 ] );
    FileInputStream fis = new FileInputStream( filename );
    Scriptable scope = ScriptableObject.getTopLevelScope( thisObj );
    ObjectInputStream in = new ScriptableInputStream( fis, scope );
    Object deserialized = in.readObject();
    in.close();
    return Context.toObject( deserialized, scope );
  }
View Full Code Here

Examples of org.mozilla.javascript.serialize.ScriptableInputStream

     */
    public Object deserialize(InputStream in) throws IOException, ClassNotFoundException {
        core.contextFactory.enterContext();
        engines.set(this);
        try {
            ObjectInputStream sin = new ScriptableInputStream(in, core.global) {
                protected Object resolveObject(Object obj) throws IOException {
                    if (obj instanceof SerializationProxy) {
                        return ((SerializationProxy) obj).getObject(RhinoEngine.this);
                    }
                    return super.resolveObject(obj);
                }
            };
            return sin.readObject();
        } finally {
            Context.exit();
        }
    }
View Full Code Here

Examples of org.mozilla.javascript.serialize.ScriptableInputStream

          baos.close();
          byte[] serializedData = baos.toByteArray();

          // deserialize
          ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
          ScriptableInputStream sis = new ScriptableInputStream(bais, globalScope);
          globalScope = (Scriptable) sis.readObject();
          Object continuation = sis.readObject();
          sis.close();
          bais.close();

          Object result = cx.resumeContinuation(continuation, globalScope, 8);
          assertEquals(8, ((Number)result).intValue());
      } finally {
View Full Code Here

Examples of org.mozilla.javascript.serialize.ScriptableInputStream

          baos.close();
          byte[] serializedData = baos.toByteArray();

          // deserialize
          ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
          ScriptableInputStream sis = new ScriptableInputStream(bais, globalScope);
          globalScope = (Scriptable) sis.readObject();
          Object continuation = sis.readObject();
          sis.close();
          bais.close();

          Object result = cx.resumeContinuation(continuation, globalScope, 8);
          assertEquals(8, ((Number)result).intValue());
      } finally {
View Full Code Here

Examples of org.mozilla.javascript.serialize.ScriptableInputStream

          baos.close();
          byte[] serializedData = baos.toByteArray();

          // deserialize
          ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
          ScriptableInputStream sis = new ScriptableInputStream(bais, globalScope);
          globalScope = (Scriptable) sis.readObject();
          Object continuation = sis.readObject();
          sis.close();
          bais.close();

          Object result = cx.resumeContinuation(continuation, globalScope, 8);
          assertEquals(8, ((Number)result).intValue());
      } finally {
View Full Code Here

Examples of org.mozilla.javascript.serialize.ScriptableInputStream

          baos.close();
          byte[] serializedData = baos.toByteArray();

          // deserialize
          ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
          ScriptableInputStream sis = new ScriptableInputStream(bais, globalScope);
          globalScope = (Scriptable) sis.readObject();
          Object continuation = sis.readObject();
          sis.close();
          bais.close();

          Object result = cx.resumeContinuation(continuation, globalScope, "2+3");
          assertEquals(5, ((Number) result).intValue());
      } finally {
View Full Code Here

Examples of org.mozilla.javascript.serialize.ScriptableInputStream

        Scriptable globalScope = cx.initStandardObjects();
        globalScope.put("myObject", globalScope, Context.javaToJS(new MyClass(), globalScope));

        // deserialize
        ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
        ScriptableInputStream sis = new ScriptableInputStream(bais, globalScope);
        globalScope = (Scriptable) sis.readObject();
        Object continuation = sis.readObject();
        sis.close();
        bais.close();

        Object result = cx.resumeContinuation(continuation, globalScope, 8);
        assertEquals("foo", result);
      } finally {
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.