/** * Create a ScriptableInputStream. * @param in the InputStream to read from. * @param scope the top-level scope to create the object in. */ public ScriptableInputStream(InputStream in, Scriptable scope) throws IOException { super(in); this.scope = scope; enableResolveObject(true); Context cx = Context.getCurrentContext(); if (cx != null) { this.classLoader = cx.getApplicationClassLoader(); } }
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); }
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); }
/** * Create a ScriptableInputStream. * @param in the InputStream to read from. * @param scope the top-level scope to create the object in. */ public ScriptableInputStream(InputStream in, Scriptable scope) throws IOException { super(in); this.scope = scope; enableResolveObject(true); Context cx = Context.getCurrentContext(); if (cx != null) { this.classLoader = cx.getApplicationClassLoader(); } }
/** * Create a ScriptableInputStream. * @param in the InputStream to read from. * @param scope the top-level scope to create the object in. */ public ScriptableInputStream(InputStream in, Scriptable scope) throws IOException { super(in); this.scope = scope; enableResolveObject(true); Context cx = Context.getCurrentContext(); if (cx != null) { this.classLoader = cx.getApplicationClassLoader(); } }
/** * Create a ScriptableInputStream. * @param in the InputStream to read from. * @param scope the top-level scope to create the object in. */ public ScriptableInputStream(InputStream in, Scriptable scope) throws IOException { super(in); this.scope = scope; enableResolveObject(true); Context cx = Context.getCurrentContext(); if (cx != null) { this.classLoader = cx.getApplicationClassLoader(); } }
/** * Create a ScriptableInputStream. * @param in the InputStream to read from. * @param scope the top-level scope to create the object in. */ public ScriptableInputStream(InputStream in, Scriptable scope) throws IOException { super(in); this.scope = scope; enableResolveObject(true); Context cx = Context.getCurrentContext(); if (cx != null) { this.classLoader = cx.getApplicationClassLoader(); } }
/** * Create a ScriptableInputStream. * @param in the InputStream to read from. * @param scope the top-level scope to create the object in. */ public ScriptableInputStream(InputStream in, Scriptable scope) throws IOException { super(in); this.scope = scope; enableResolveObject(true); Context cx = Context.getCurrentContext(); if (cx != null) { this.classLoader = cx.getApplicationClassLoader(); } }