Package org.jboss.util.stream

Examples of org.jboss.util.stream.MarshalledValueOutputStream


    * @return serialized form of the object
    */
   public static byte[] objectToByteBuffer(Object obj) throws Exception
   {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      MarshalledValueOutputStream out = new MarshalledValueOutputStream(baos);
      out.writeObject(obj);
      out.close();
      return baos.toByteArray();
   }
View Full Code Here


      loader.remove(Fqn.fromString("/"));
      int num;
      try
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
         MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
         loader.loadEntireState(os);
         num = baos.size();
      }
      catch (UnsupportedOperationException ex)
      {
         log.info("caught unsupported operation exception that's okay: ", ex);
         return;
      }

      Object txnKey = new Object();
      List<Modification> mods = createUpdates();
      loader.prepare(txnKey, mods, false);
      loader.rollback(txnKey);
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      assertEquals(num, baos.size());
   }
View Full Code Here

      loader.remove(Fqn.fromString("/"));
      int num = 0;
      try
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
         MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
         loader.loadEntireState(os);
         num = baos.size();
      }
      catch (UnsupportedOperationException ex)
      {
         System.out.println("caught unsupported operation exception that's okay: " + ex);
         return;
      }

      Object txnKey = new Object();
      List<Modification> mods = createUpdates();
      loader.prepare(txnKey, mods, false);
      loader.rollback(txnKey);
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      assertEquals(num, baos.size());
   }
View Full Code Here

      assertEquals(2, loader.get(FQN).size());

      // Save state
      byte[] state;
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      try
      {
         loader.loadEntireState(os);
      }
      catch (UnsupportedOperationException ex)
      {
         System.out.println("caught unsupported operation exception (this is expected): " + ex);
      }
      finally
      {
         cache.getMarshaller().objectToObjectStream(DefaultStateTransferManager.STREAMING_DELIMITER_NODE, os);
         os.close();
         assertTrue(baos.size() > 0);
         state = baos.toByteArray();
      }

      /* Restore state. */
 
View Full Code Here

      assertEquals(c4, loader.get(SUBTREE_FQN).get(2));
      assertEquals(2, loader.get(SUBTREE_FQN).size());

      /* Save state. */
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadState(SUBTREE_FQN, os);
      cache.getMarshaller().objectToObjectStream(DefaultStateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();
      assertTrue(baos.size() > 0);
      loader.remove(SUBTREE_FQN);

      /* Restore state. */

 
View Full Code Here

      assertEquals(c4, loader.get(SUBTREE_FQN).get(2));
      assertEquals(2, loader.get(SUBTREE_FQN).size());

      /* Save state. */
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadState(FQN, os);
      cache.getMarshaller().objectToObjectStream(DefaultStateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();
      assertTrue(baos.size() > 0);

      /* Restore state. */
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
View Full Code Here

      CacheLoader loader = loaderTL.get();

      loader.remove(Fqn.fromString("/"));

      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      os.close();
      int num = baos.size();

      Object txnKey = new Object();
      List<Modification> mods = createUpdates();
      loader.prepare(txnKey, mods, false);
      loader.rollback(txnKey);

      baos = new ByteArrayOutputStream(1024);
      os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      os.close();

      assertEquals(num, baos.size());
   }
View Full Code Here

      assertEquals(c2, loader.get(FQN).get(2));
      assertEquals(2, loader.get(FQN).size());

      /* Save state. */
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      loader.loadEntireState(os);
      cache.getMarshaller().objectToObjectStream(DefaultStateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();
      assertTrue(baos.size() > 0);

      byte[] savedState = baos.toByteArray();

      /* Restore state. */
 
View Full Code Here

               {
                  ((StateTransferStreamProvider) provider).getCurrentState(ostream);
               }
               else
               {
                  MarshalledValueOutputStream mvos = new MarshalledValueOutputStream(ostream);
                  toClose = mvos;
                  mvos.writeObject(state);
               }
            }
            catch (Exception ex)
            {
               CoreGroupCommunicationService.this.log.error("getState failed for service " + serviceName, ex);
View Full Code Here

         CoreGroupCommunicationService.this.log.debug("getState called for service " + serviceName);
        
         StateTransferProvider provider = stateProviders.get(serviceName);
         if (provider != null)
         {
            MarshalledValueOutputStream mvos = null;
            Object state = provider.getCurrentState();
            try
            {
               ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
               mvos = new MarshalledValueOutputStream(baos);
               mvos.writeObject(state);
               mvos.flush();
               mvos.close();
               return baos.toByteArray();
            }
            catch (Exception ex)
            {
               CoreGroupCommunicationService.this.log.error("getState failed for service " + serviceName, ex);
            }
            finally
            {
               if (mvos != null)
               {
                  try
                  {
                     mvos.close();
                  }
                  catch (IOException ignored)
                  {
                     log.debug("Caught exception closing stream used for marshalling state", ignored);
                  }
View Full Code Here

TOP

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

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.