Package org.jboss.util.stream

Examples of org.jboss.util.stream.MarshalledValueInputStream


      if (bytes == null)
      {
         return null;
      }

      MarshalledValueInputStream input = new MarshalledValueInputStream(bytes);
      Object result = input.readObject();
      input.close();
      return result;
   }
View Full Code Here


               if (trace) log.trace("Integrating state for region " + fqn);
               //ClassLoader cl = (marshaller == null) ? null : marshaller.getClassLoader(fqnS);
               Fqn integrationRoot = Fqn.fromRelativeFqn(integrationBase, fqn);

               byte[] stateBuffer = entry.getValue();
               MarshalledValueInputStream in = null;
               try
               {
                  ByteArrayInputStream bais = new ByteArrayInputStream(stateBuffer);
                  in = new MarshalledValueInputStream(bais);
                  //stateMgr.setState(in, integrationRoot, cl);
                  stateTransferManager.setState(in, integrationRoot);
               }
               catch (Throwable t)
               {
                  if (t instanceof CacheException)
                  {
                     //excepected/common and can happen due to inactive regions and so on
                     log.debug(t);
                  }
                  else
                  {
                     //something has gone wrong
                     log.error("State for fqn " + fqn
                           + " could not be transferred to a buddy at "
                           + cache.getLocalAddress(), t);
                  }
               }
               finally
               {
                  if (in != null)
                  {
                     in.close();
                  }
               }
            }
            else
            {
View Full Code Here

        @Override
        protected void setStateInternal(InputStream is) throws IOException, ClassNotFoundException {
            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

        if (buffer == null) {
            return null;
        }

        ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
        MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais);
        return mvis.readObject();
    }
View Full Code Here

        }

        ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
        // read past the null/serializable byte
        bais.read();
        MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais);
        return mvis.readObject();
    }
View Full Code Here

            {
               //ClassLoader cl = (marshaller == null) ? null : marshaller.getClassLoader(fqnS);
               Fqn integrationRoot = new Fqn(integrationBase, fqn);

               byte[] stateBuffer = entry.getValue();
               MarshalledValueInputStream in = null;
               try
               {
                  ByteArrayInputStream bais = new ByteArrayInputStream(stateBuffer);
                  in = new MarshalledValueInputStream(bais);
                  //stateMgr.setState(in, integrationRoot, cl);
                  stateTransferManager.setState(in, integrationRoot);
               }
               catch (Throwable t)
               {
                  if (t instanceof CacheException)
                  {
                     //excepected/common and can happen due to inactive regions and so on
                     log.debug(t);
                  }
                  else
                  {
                     //something has gone wrong
                     log.error("State for fqn " + fqn
                           + " could not be transferred to a buddy at "
                           + cache.getLocalAddress(), t);
                  }
               }
               finally
               {
                  if (in != null)
                  {
                     in.close();
                  }
               }
            }
         }
      }
View Full Code Here

      assertNull(newImpl.get(Fqn.fromString("/a/b/d")));
      assertNull(newImpl.get(Fqn.fromString("/a/b/e")));
      assertNull(newImpl.get(Fqn.fromString("/a/f/e")));
      assertNull(newImpl.get(Fqn.ROOT));
      ByteArrayInputStream bais = new ByteArrayInputStream(newBaos.toByteArray());
      MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
      newImpl.storeEntireState(is);
      assertEquals(newImpl.get(Fqn.fromString("/a/b/c")).get("key1"), "value1");
      assertEquals(newImpl.get(Fqn.fromString("/a/b/d")).get("key2"), "value2");
      assertEquals(newImpl.get(Fqn.fromString("/a/b/e")).get("key3"), "value3");
      assertEquals(newImpl.get(Fqn.fromString("/a/f/e")).get("key4"), "value4");
View Full Code Here

      assertNull(newImpl.get(Fqn.fromString("/a/b/d")));
      assertNull(newImpl.get(Fqn.fromString("/a/b/e")));
      assertNull(newImpl.get(Fqn.fromString("/a/b")));

      ByteArrayInputStream bais = new ByteArrayInputStream(newBaos.toByteArray());
      MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
      newImpl.storeState(Fqn.fromString("/a/b"), is);

      assertEquals(newImpl.get(Fqn.fromString("/a/b/c")).get("key1"), "value1");
      assertEquals(newImpl.get(Fqn.fromString("/a/b/d")).get("key2"), "value2");
      assertEquals(newImpl.get(Fqn.fromString("/a/b/e")).get("key3"), "value3");
View Full Code Here

   @Override
   protected Object doUnmarshall(Fqn fqn, Object fromFile) throws Exception
   {
      FileInputStream fileIn = new FileInputStream((File) fromFile);
      ObjectInputStream input = new MarshalledValueInputStream(fileIn);
      Object unmarshalledObj = getMarshaller().objectFromObjectStream(input);
      input.close();
      return unmarshalledObj;
   }
View Full Code Here

   @Override
   public Object objectFromByteBuffer(byte[] buf) throws Exception
   {
      Marshaller marshaller;
      int versionId;
      ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(buf));

      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.");
View Full Code Here

TOP

Related Classes of org.jboss.util.stream.MarshalledValueInputStream

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.