Package net.jini.io

Examples of net.jini.io.MarshalInputStream


            output.close();

            // Read transferObject from MarshalInputStream
            ByteArrayInputStream bios =
                new ByteArrayInputStream(baos.toByteArray());
            MarshalInputStream input = new FakeMarshalInputStream(
                bios,null,null);

            // Setup FakeRMIClassLoaderSpi static fields
            FakeRMIClassLoaderSpi.initLoadClass(
                new ClassNotFoundException(),
                null,
                transferObject.getName(),
                null);

            // verify result
            assertion(input.readObject() == transferObject);
        }
    }
View Full Code Here


  byte[] bytes = bout.toByteArray();

  /*
   * Read in handler (should succeed).
   */
  MarshalInputStream in =
      new MarshalInputStream(new ByteArrayInputStream(bytes),
           ClassLoader.getSystemClassLoader(),
           false, null, new HashSet());
  ActivatableInvocationHandler aihRead =
      (ActivatableInvocationHandler) in.readObject();
  System.err.println("Test 1 passed: handler read successfully");

  /*
   * Set constraints on underlying proxy to make
   * them inconsistent with handler's constraints, then
   * serialize handler.
   */
  uproxy.setConstraints(new Constraints());
  bout.reset();
  out = new MarshalOutputStream(bout, new HashSet());
  out.writeObject(aih);
  out.flush();
  bytes = bout.toByteArray();

  /*
   * Read in handler (should fail with InvalidObjectException);
   */
  try {
      in =
    new MarshalInputStream(new ByteArrayInputStream(bytes),
               ClassLoader.getSystemClassLoader(),
               false, null, new HashSet());
      aihRead = (ActivatableInvocationHandler) in.readObject();
      System.err.println("Test 2 failed: no InvalidObjectException");
      throw new RuntimeException(
    "Test 2 failed: no InvalidObjectException");
  } catch (InvalidObjectException e) {
      System.err.println(
View Full Code Here

    {
  try {
      if (System.getSecurityManager() == null) {
    System.setSecurityManager(new SecurityManager());
      }
      MarshalInputStream in =
    new MarshalInputStream(
           System.in,
           ActivationGroupInit.class.getClassLoader(),
           false, null, Collections.EMPTY_LIST);
      in.useCodebaseAnnotations();
      ActivationGroupID id  = (ActivationGroupID)in.readObject();
      ActivationGroupDesc desc = (ActivationGroupDesc)in.readObject();
      long incarnation = in.readLong();
      Class cl = RMIClassLoader.loadClass(desc.getLocation(),
            desc.getClassName());
      try {
    Method create =
        cl.getMethod("createGroup",
View Full Code Here

      s.writeObject(state);
      s.flush();
  }
 
  public void recover(InputStream in) throws Exception {
      MarshalInputStream s =
    new MarshalInputStream(in,
               ActLogHandler.class.getClassLoader(),
               false, null, Collections.EMPTY_LIST);
      s.useCodebaseAnnotations();
      state = (Activation) s.readObject();
  }
View Full Code Here

      s.writeObject(value);
      s.flush();
  }

  public void readUpdate(InputStream in) throws Exception {
      MarshalInputStream  s =
    new MarshalInputStream(in,
               ActLogHandler.class.getClassLoader(),
               false, null, Collections.EMPTY_LIST);
      s.useCodebaseAnnotations();
      applyUpdate(s.readObject());
  }
View Full Code Here

  mout.writeObject(toWrite);
  mout.flush();

  ByteArrayInputStream bin =
      new ByteArrayInputStream(bout.toByteArray());
  MarshalInputStream min =
      new MarshalInputStream(bin, defaultLoader, true, defaultLoader,
           Collections.EMPTY_LIST);
  min.useCodebaseAnnotations();

  try {
      Object read = min.readObject();
      throw new RuntimeException(
    "TEST FAILED: object read successfully");
  } catch (ClassNotFoundException e) {
      if (e.getCause() instanceof SecurityException) {
    e.printStackTrace();
View Full Code Here

      }
      streamLoader = impl.getClass().getClassLoader();
  }
 
  Collection unmodContext = Collections.unmodifiableCollection(context);
  MarshalInputStream in =
      new MarshalInputStream(request.getRequestInputStream(),
           streamLoader, integrity,
           streamLoader, unmodContext);
  in.useCodebaseAnnotations();
  return in;
    }
View Full Code Here

    MOStream out = new MOStream(bout, bcb, bcl);
    out.writeObject(verifier);
    out.close();
    if (out.replace) {
        logger.log(Level.FINER, "remarshalling verifier");
        MarshalInputStream in =
      new MarshalInputStream(
             new ByteArrayInputStream(bout.toByteArray()),
             bcl, false, null, Collections.EMPTY_SET);
        in.useCodebaseAnnotations();
        verifier = (TrustVerifier) in.readObject();
        in.close();
    }
      } catch (IOException e) {
    throw new UnmarshalException("remarshalling verifier failed",
               e);
      } catch (ClassNotFoundException e) {
View Full Code Here

        assertion(first == 0x01, "Actual first response byte: " + first);

        // read returned object
        Object returned = null;
        try {
            MarshalInputStream mis = new MarshalInputStream(
                response, null, false, null, new ArrayList());
            returned = unmarshalValue(method.getReturnType(), mis);
            assertion(mis.read() == -1);
        } catch(Throwable t) {
            assertion(false,t.toString());
        }

        // check returned object
View Full Code Here

    protected void checkUnmarshallingException(Throwable thrown,
        ByteArrayInputStream response) throws TestException
    {
        Throwable caught = null;
        try {
            MarshalInputStream marshalledResponse = new MarshalInputStream(
                response, null, false, null, new ArrayList());
            caught = (Throwable) marshalledResponse.readObject();
            assertion(marshalledResponse.read() == -1);
        } catch(Throwable t) {
            assertion(false,t.toString());
        }

        if (thrown instanceof RuntimeException) {
View Full Code Here

TOP

Related Classes of net.jini.io.MarshalInputStream

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.