Examples of MarshalledValueInputStream


Examples of org.jboss.util.stream.MarshalledValueInputStream

      os.close();
      assertTrue(baos.size() > 0);

      /* Restore state. */
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
      loader.storeState(BUDDY_BASE, is);
      is.close();
      addDelay();
      assertEquals(c1, loader.get(BUDDY_PLUS_FQN).get(1));
      assertEquals(c2, loader.get(BUDDY_PLUS_FQN).get(2));
      assertEquals(2, loader.get(BUDDY_PLUS_FQN).size());
      assertEquals(c3, loader.get(BUDDY_PLUS_SUBTREE_FQN).get(1));
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

      byte[] savedState = baos.toByteArray();

      /* Restore state. */
      ByteArrayInputStream bais = new ByteArrayInputStream(savedState);
      MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
      loader.storeEntireState(is);
      is.close();

      addDelay();
      assertEquals(c1, loader.get(FQN).get(1));
      assertEquals(c2, loader.get(FQN).get(2));
      assertEquals(2, loader.get(FQN).size());
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

   public void testVersionHeaderDefaultCurrent() throws Exception
   {
      VersionAwareMarshaller marshaller = createVAMandRestartCache(Version.getVersionString(Version.getVersionShort()));

      byte[] bytes = marshaller.objectToByteBuffer("Hello");
      ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes));
      assertEquals("Version header short should be '30'", 30, in.readShort());
   }
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

   public void testVersionHeader210() throws Exception
   {
      VersionAwareMarshaller marshaller = createVAMandRestartCache("2.1.0.GA");

      byte[] bytes = marshaller.objectToByteBuffer("Hello");
      ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes));
      assertEquals("Version header short should be '21'", 21, in.readShort());
   }
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

   public void testVersionHeader200() throws Exception
   {
      VersionAwareMarshaller marshaller = createVAMandRestartCache("2.0.0.GA");

      byte[] bytes = marshaller.objectToByteBuffer("Hello");
      ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes));
      assertEquals("Version header short should be '20'", 20, in.readShort());
   }
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

      {
         ClassLoader cl = getStateTransferClassLoader();
         SwitchContext switchContext = CoreGroupCommunicationService.this.classLoaderSwitcher.getSwitchContext(cl);
         try
         {
            MarshalledValueInputStream mvis = new MarshalledValueInputStream(is);
            this.state = (Serializable) mvis.readObject();
         }
         finally
         {
            switchContext.reset();
         }
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

      // and return bytes.
      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }

   public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException, ClassNotFoundException {
      ObjectInput in = new MarshalledValueInputStream(new ByteArrayInputStream(buf, offset, length));
      return objectFromObjectStream(in);
   }
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }

   public Object objectFromByteBuffer(byte[] bytes, int offset, int len) throws IOException, ClassNotFoundException {
      int versionId;
      ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes, offset, len));
      try {
         versionId = in.readShort();
         log.trace("Read version {0}", versionId);
      }
      catch (Exception e) {
         log.error("Unable to read version id from first two bytes of stream, barfing.");
         throw new IOException("Unable to read version id from first two bytes of stream.");
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

      return defaultMarshaller.objectFromObjectStream(in);
   }

   public Object objectFromStream(InputStream is) throws IOException, ClassNotFoundException {
      short versionId;
      ObjectInputStream in = new MarshalledValueInputStream(is);
      try {
         versionId = in.readShort();
         if (trace) log.trace("Read version " + versionId);
      }
      catch (Exception e) {
         log.error("Unable to read version id from first two bytes of stream, barfing.");
         throw new IOException("Unable to read version id from first two bytes of stream.");
View Full Code Here

Examples of org.jboss.util.stream.MarshalledValueInputStream

   public synchronized void deserialize() {
      if (instance == null) {
         try {
            ByteArrayInputStream bais = new ByteArrayInputStream(raw);
            // use a MarshalledValueInputStream since it needs to be aware of any context class loaders on the current thread.
            ObjectInputStream ois = new MarshalledValueInputStream(bais);
            instance = ois.readObject();
            ois.close();
            bais.close();
         }
         catch (Exception e) {
            throw new CacheException("Unable to unmarshall value", e);
         }
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.