Package org.mozilla.javascript.serialize

Examples of org.mozilla.javascript.serialize.ScriptableOutputStream$PendingLookup


    public void serialize(Object obj, OutputStream out) throws IOException {
        core.contextFactory.enterContext();
        engines.set(this);
        try {
            // use a special ScriptableOutputStream that unwraps Wrappers
            ScriptableOutputStream sout = new ScriptableOutputStream(out, core.global) {
                protected Object replaceObject(Object obj) throws IOException {
                    if (obj instanceof HopObject)
                        return new HopObjectProxy((HopObject) obj);
                    if (obj instanceof Node)
                        return new HopObjectProxy((Node) obj);
                    if (obj instanceof GlobalObject)
                        return new GlobalProxy((GlobalObject) obj);
                    if (obj instanceof ApplicationBean)
                        return new ScriptBeanProxy("app");
                    if (obj instanceof RequestBean)
                        return new ScriptBeanProxy("req");
                    if (obj instanceof ResponseBean)
                        return new ScriptBeanProxy("res");
                    if (obj instanceof PathWrapper)
                        return new ScriptBeanProxy("path");
                    return super.replaceObject(obj);
                }
            };
            // sout.addExcludedName("Xml");
            // sout.addExcludedName("global");           

            sout.writeObject(obj);
            sout.flush();
        } finally {
            Context.exit();
        }
    }
View Full Code Here


                    }
                   
                    // bit of a hack to initialize all lazy objects that
                    // ScriptableOutputStream would initialize, so we can then
                    // safely seal it
                    new ScriptableOutputStream(new ByteArrayOutputStream(),
                            library);
                    // Finally seal the library scope
                    library.sealObject();
                }
                catch(RuntimeException e) {
View Full Code Here

          cx.callFunctionWithContinuations(f, globalScope, args);
          fail("Should throw ContinuationPending");
      } catch (ContinuationPending pending) {
          // serialize
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ScriptableOutputStream sos = new ScriptableOutputStream(baos, globalScope);
          sos.writeObject(globalScope);
          sos.writeObject(pending.getContinuation());
          sos.close();
          baos.close();
          byte[] serializedData = baos.toByteArray();

          // deserialize
          ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
View Full Code Here

          cx.callFunctionWithContinuations(f, globalScope, args);
          fail("Should throw ContinuationPending");
      } catch (ContinuationPending pending) {
          // serialize
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ScriptableOutputStream sos = new ScriptableOutputStream(baos, globalScope);
          sos.writeObject(globalScope);
          sos.writeObject(pending.getContinuation());
          sos.close();
          baos.close();
          byte[] serializedData = baos.toByteArray();

          // deserialize
          ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
View Full Code Here

          cx.callFunctionWithContinuations(f, globalScope, args);
          fail("Should throw ContinuationPending");
      } catch (ContinuationPending pending) {
          // serialize
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ScriptableOutputStream sos = new ScriptableOutputStream(baos, globalScope);
          sos.writeObject(globalScope);
          sos.writeObject(pending.getContinuation());
          sos.close();
          baos.close();
          byte[] serializedData = baos.toByteArray();

          // deserialize
          ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
View Full Code Here

          cx.callFunctionWithContinuations(f, globalScope, args);
          fail("Should throw ContinuationPending");
      } catch (ContinuationPending pending) {
          // serialize
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ScriptableOutputStream sos = new ScriptableOutputStream(baos, globalScope);
          sos.writeObject(globalScope);
          sos.writeObject(pending.getContinuation());
          sos.close();
          baos.close();
          byte[] serializedData = baos.toByteArray();

          // deserialize
          ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
View Full Code Here

        cx.callFunctionWithContinuations(f, globalScope, args);
        fail("Should throw ContinuationPending");
      } catch (ContinuationPending pending) {
        // serialize
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ScriptableOutputStream sos = new ScriptableOutputStream(baos, globalScope);
        sos.writeObject(globalScope);
        sos.writeObject(pending.getContinuation());
        sos.close();
        baos.close();
        serializedData = baos.toByteArray();
      } finally {
        Context.exit();
      }
View Full Code Here

        p.setApplicationState("foo");
       
        SerializableUtils.serialiseObject(p);

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ScriptableOutputStream out = new ScriptableOutputStream(bout, globalScope);
//        out.addExcludedName("scriptus");
        out.writeObject(globalScope);
        out.writeObject(p);
        out.close();

      }
     
//      System.out.println(ss.exec(cx, globalScope));
     
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.serialize.ScriptableOutputStream$PendingLookup

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.