Package org.jboss.invocation

Examples of org.jboss.invocation.MarshalledValueOutputStream$EnableReplaceObjectAction


            if (marshal)
            {
               try
               {
                  ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
                  MarshalledValueOutputStream maos = new MarshalledValueOutputStream(baos);
                  maos.writeObject(list);
                  maos.close();
                  retval.add(baos.toByteArray());
               }
               catch (IOException e)
               {
                  throw new CacheException("Failure marshalling subtree at " + fqn, e);
View Full Code Here


      byte[] retval=null;     
     
      try {
         if(generateTransient) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
            MarshalledValueOutputStream out = new MarshalledValueOutputStream(baos);
            marshallTransientState(rootNode, out);
            out.close();
            states[0] = baos.toByteArray();
           
            if (debug) {
               log.debug("returning the in-memory state (" + states[0].length +
                         " bytes)");
            }
           
            // Return any state associated with the subtree but not stored in it
            if (cache instanceof PojoCache) {
               baos = new ByteArrayOutputStream(1024);
               out = new MarshalledValueOutputStream(baos);
               marshallAssociatedState(fqn, out);
               out.close();
               states[1] = baos.toByteArray();
              
               if (debug) {
                  log.debug("returning the associated state (" +
                            states[1].length + " bytes)");
               }
            }
         }
      }
      catch(Throwable t) {
         log.error("failed getting the in-memory (transient) state", t);
         if (!suppressErrors)
            throw t;
      }
     
      if (generatePersistent) {
         try {
            if (debug)
               log.debug("getting the persistent state");
           
            if (fqn.size() == 0)
               states[2] = cache.getCacheLoader().loadEntireState();
            else
               states[2] = ((ExtendedCacheLoader)cache.getCacheLoader()).loadState(fqn);
           
            if (debug) {
               log.debug("returning the persistent state (" +
                         states[2].length + " bytes)");
            }
         }
         catch(Throwable t) {
            log.error("failed getting the persistent state", t);
            if (!suppressErrors)
               throw t;
         }
      }
  
      // Package everything into one byte[]
      try {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
         MarshalledValueOutputStream out = new MarshalledValueOutputStream(baos);
         // Write out the version for reader can know how to integrate
         out.writeShort(STATE_TRANSFER_VERSION);
         out.writeObject(states);           
         out.close();
         retval = baos.toByteArray();
        
         log.info("returning the state for tree rooted in " + fqn.toString() +
                  "(" + retval.length + " bytes)");
        
View Full Code Here

      byte[][] states=new byte[3][]; // [transient][associated][persistent]
      states[0]=states[1]=states[2]=null;
      int[] sizes = new int[3];
      byte[] retval = null;
      int lastSize;
      MarshalledValueOutputStream out;

      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(1024);
      try {
         initializeStateTransfer(baos);
         lastSize = baos.size();
      }
      catch (Throwable t)
      {
         log.error("failed initialing state transfer byte[]", t);
         if (!suppressErrors)
            throw t;
        
         return null;
      }

      try {
        
         if(generateTransient) {
            out = new MarshalledValueOutputStream(baos);
            marshallTransientState(rootNode, out);
            out.close();
            sizes[0] = baos.size() - lastSize;
            lastSize = baos.size();
            if (debug) {
               log.debug("generated the in-memory state (" + sizes[0] +
                         " bytes)");
            }
            // Return any state associated with the subtree but not stored in it
            if (cache instanceof PojoCache) {
               out = new MarshalledValueOutputStream(baos);
               marshallAssociatedState(fqn, out);
               out.close();
               sizes[1] = baos.size() - lastSize;
               lastSize = baos.size();
               if (debug) {
                  log.debug("returning the associated state (" + sizes[1] +
                            " bytes)");
View Full Code Here

     
   }
  
   private void initializeStateTransfer(OutputStream baos) throws IOException
   {
      MarshalledValueOutputStream out = new MarshalledValueOutputStream(baos);
      out.writeShort(STATE_TRANSFER_VERSION);
      // Write a placeholder for the 3 sizes we'll merge in later
      out.writeInt(0);
      out.writeInt(0);
      out.writeInt(0);
      out.close();
   }
View Full Code Here

      byte[][] states=new byte[3][]; // [transient][associated][persistent]
      states[0]=states[1]=states[2]=null;
      int[] sizes = new int[3];
      byte[] retval = null;
      int lastSize;
      MarshalledValueOutputStream out;

      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(1024);
      try {
         initializeStateTransfer(baos);
         lastSize = baos.size();
      }
      catch (Throwable t)
      {
         log.error("failed initialing state transfer byte[]", t);
         if (!suppressErrors)
            throw t;
        
         return null;
      }

      try {
        
         if(generateTransient) {
            out = new MarshalledValueOutputStream(baos);
            marshallTransientState(rootNode, out);
            out.close();
            sizes[0] = baos.size() - lastSize;
            lastSize = baos.size();
            if (debug) {
               log.debug("generated the in-memory state (" + sizes[0] +
                         " bytes)");
            }
            // Return any state associated with the subtree but not stored in it
            if (cache instanceof PojoCache) {
               out = new MarshalledValueOutputStream(baos);
               marshallAssociatedState(fqn, out);
               out.close();
               sizes[1] = baos.size() - lastSize;
               lastSize = baos.size();
               if (debug) {
                  log.debug("returning the associated state (" + sizes[1] +
                            " bytes)");
View Full Code Here

     
   }
  
   private void initializeStateTransfer(OutputStream baos) throws IOException
   {
      MarshalledValueOutputStream out = new MarshalledValueOutputStream(baos);
      out.writeShort(STATE_TRANSFER_VERSION);
      // Write a placeholder for the 3 sizes we'll merge in later
      out.writeInt(0);
      out.writeInt(0);
      out.writeInt(0);
      out.close();
   }
View Full Code Here

     * @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

        ObjectOutputStream out;

        // based on the default marshaller, construct an object output stream based on what's compatible.
        if (defaultMarshaller instanceof LegacyTreeCacheMarshaller)
        {
            out = new MarshalledValueOutputStream(bos);
        }
        else
        {
            out = ObjectSerializationFactory.createObjectOutputStream(bos);
            out.writeShort(versionInt);
View Full Code Here

      {
         // Set the TCCL to any classloader registered for subtree
         setUnmarshallingClassLoader(subtree);
        
         ByteArrayOutputStream out_stream=new ByteArrayOutputStream(1024);
         ObjectOutputStream    out=new MarshalledValueOutputStream(out_stream);
         loadState(subtree, out);
         out.close();
         return out_stream.toByteArray();
      }
      finally
      {
         Thread.currentThread().setContextClassLoader(currentCL);
View Full Code Here

      {
         // Set the TCCL to any classloader registered for subtree
         setUnmarshallingClassLoader(subtree);

         ByteArrayOutputStream out_stream = new ByteArrayOutputStream(1024);
         ObjectOutputStream out = new MarshalledValueOutputStream(out_stream);
         loadStateFromFilessystem(subtree, out);
         out.close();

         return out_stream.toByteArray();
      }
      finally
      {
View Full Code Here

TOP

Related Classes of org.jboss.invocation.MarshalledValueOutputStream$EnableReplaceObjectAction

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.