Package net.jini.io

Examples of net.jini.io.MarshalInputStream


      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

          boolean integrity,
          Collection context)
          throws IOException
      {
          ClassLoader loader = getClassLoader();
          return new MarshalInputStream(
        request.getRequestInputStream(),
        loader, integrity, loader,
        Collections.unmodifiableCollection(context));
          // useStreamCodebases() not invoked
      }
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

  if (Proxy.getInvocationHandler(proxy) != this) {
      throw new IllegalArgumentException("not proxy for this");
  }
  ClassLoader proxyLoader = getProxyLoader(proxy.getClass());
  Collection unmodContext = Collections.unmodifiableCollection(context);
  MarshalInputStream in =
      new MarshalInputStream(request.getResponseInputStream(),
           proxyLoader, integrity, proxyLoader,
           unmodContext);
  in.useCodebaseAnnotations();
  return in;
    }
View Full Code Here

                        boolean integrity,
                        Collection context)
                        throws IOException
                    {
                        ClassLoader loader = getClassLoader();
                        return new MarshalInputStream(
                            request.getRequestInputStream(),
                            loader, integrity, loader,
                            Collections.unmodifiableCollection(context));
                        // useStreamCodebases() not invoked
                    }
View Full Code Here

    /**
     * This method performs all actions mentioned in class description.
     */
    public void run() throws Exception {
        MarshalInputStream stream;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.flush();
        ByteArrayInputStream bais =
            new ByteArrayInputStream(baos.toByteArray());
        ArrayList al = new ArrayList();
        PipedInputStream pis = new PipedInputStream();

        logger.log(Level.FINE,"=================================");
        logger.log(Level.FINE,"test case 1: "
            + "MarshalInputStream(null,*,*,*,null)");
        logger.log(Level.FINE,"");

        try {
            stream = new MarshalInputStream(null,null,false,null,null);
            assertion(false);
        } catch (NullPointerException ignore) {
        }

        logger.log(Level.FINE,"=================================");
        logger.log(Level.FINE,"test case 2: "
            + "MarshalInputStream(InputStream,*,*,*,null)");
        logger.log(Level.FINE,"");

        try {
            stream = new MarshalInputStream(bais,null,false,null,null);
            assertion(false);
        } catch (NullPointerException ignore) {
        }

        logger.log(Level.FINE,"=================================");
        logger.log(Level.FINE,"test case 3: "
            + "MarshalInputStream(null,*,*,*,Collection)");
        logger.log(Level.FINE,"");

        try {
            stream = new MarshalInputStream(null,null,false,null,al);
            assertion(false);
        } catch (NullPointerException ignore) {
        }

        logger.log(Level.FINE,"=================================");
        logger.log(Level.FINE,"test case 4: "
            + "getObjectStreamContext method returns constructor arg");
        logger.log(Level.FINE,"");

        bais.reset();
        stream = new MarshalInputStream(bais,null,false,null,al);
        assertion(stream.getObjectStreamContext() == al);

        logger.log(Level.FINE,"=================================");
        logger.log(Level.FINE,"test case 5: "
            + "constructor throws IOException");
        logger.log(Level.FINE,"");

        try {
            stream = new MarshalInputStream(pis,null,false,null,al);
            assertion(false);
        } catch (IOException ignore) {
        }

        logger.log(Level.FINE,"=================================");
View Full Code Here

            // Attempt to read from MarshalInputStream

            ByteArrayInputStream bios = new ByteArrayInputStream(
                baos.toByteArray());
            MarshalInputStream input = new FakeMarshalInputStream(
                bios,readAnnotationException,null);

            // verify result

            try {
                System.out.println("readObject: " + input.readObject());
                throw new AssertionError("readObject() call should fail");
            } catch (Throwable caught) {
                assertion(readAnnotationException.equals(caught),
                    caught.toString());
            }
View Full Code Here

                "com.sun.jini.test.spec.io.util.FakeIntegrityVerifier."
                + "providesIntegrity","" + providesIntegrity);

            ByteArrayInputStream bios =
                new ByteArrayInputStream(baos.toByteArray());
            MarshalInputStream input = new MarshalInputStream(
                bios,null,true,new FakeClassLoader(),context);
            input.useCodebaseAnnotations();

            // verify result

            if (shouldThrowException) {
                try {
                    input.readObject();
                    assertion(false);
                } catch (ClassNotFoundException ignore) { }
            } else {
                if (transferObject instanceof Proxy) {
                    // can't .equals written and read Proxy classes
                    // since they are defined in different class loaders
                    Object received = input.readObject();
                    assertion(received instanceof Proxy);
                    Class[] rClasses =
                        received.getClass().getInterfaces();
                    Class[] tClasses =
                        transferObject.getClass().getInterfaces();
                    assertion(rClasses.length == tClasses.length);
                    for (int j = 0; j < rClasses.length; j++) {
                        assertion(rClasses[j].getName().equals(
                            tClasses[j].getName()));
                    }
                } else {
                    assertion(transferObject.equals(input.readObject()));
                }
            }
        }
    }
View Full Code Here

            output.close();

            // Read transferObject from MarshalInputStream
            ByteArrayInputStream bios =
                new ByteArrayInputStream(baos.toByteArray());
            MarshalInputStream input = new FakeMarshalInputStream(
                bios,null,readAnnotationReturnVal,false);
            if (callUseCodebaseAnnotations) {
                input.useCodebaseAnnotations();
            }

            // Setup FakeRMIClassLoaderSpi static fields
            if (transferObject instanceof Proxy) {
                FakeRMIClassLoaderSpi.initLoadProxyClass(
                    loadClassException,
                    (callUseCodebaseAnnotations ?
                        readAnnotationReturnVal : null),
                    new String[] {interfaceName},
                    null);
            } else {
                FakeRMIClassLoaderSpi.initLoadClass(
                    loadClassException,
                    (callUseCodebaseAnnotations ?
                        readAnnotationReturnVal : null),
                    transferObject.getClass().getName(),
                    null);
            }

            // verify result
            try {
                input.readObject();
                throw new TestException("should have never reached here");
            } catch (Throwable caught) {
                if (loadClassException instanceof
                    ClassNotFoundException)
                {
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.