Package org.jboss.invocation

Examples of org.jboss.invocation.MarshalledValueInputStream


{

   public ObjectInputStream createObjectInputStream(byte[] bytes) throws IOException
   {
      ByteArrayInputStream in = new ByteArrayInputStream(bytes);
      return new MarshalledValueInputStream(in);
   }
View Full Code Here


        {
            return null;
        }

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

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

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

        marshaller = getMarshaller(versionId);

        if (marshaller instanceof LegacyTreeCacheMarshaller)
        {
            // create a more 'compatible' ObjectInputStream.
            in = new MarshalledValueInputStream(new ByteArrayInputStream(buf));
        }

        try
        {
            return marshaller.objectFromStream(in);
        }
        catch (Exception e)
        {
            if (marshaller instanceof LegacyTreeCacheMarshaller)
            {
                // the default marshaller IS the legacy marshaller!!
                throw e;
            }
            else
            {
                // retry with legacy marshaller - this is probably because the version id was incorrectly read.
                if (log.isInfoEnabled())
                {
                    log.info("Caught exception unmarshalling stream with specific versioned marshaller " + marshaller.getClass() + ".  Attempting to try again with legacy marshaller " + LegacyTreeCacheMarshaller.class);
                }
                // create a more 'compatible' ObjectInputStream.
                try
                {
                   in = new MarshalledValueInputStream(new ByteArrayInputStream(buf));
                   return getMarshaller(VERSION_LEGACY).objectFromStream(in);
                }
                catch (Exception e1)
                {
                   log.debug("Retry with legacy marshaller failed as well; throwing original exception", e1);
View Full Code Here

      {
         // Set the TCCL to any classloader registered for subtree
         setUnmarshallingClassLoader(subtree);
        
         ByteArrayInputStream in_stream=new ByteArrayInputStream(state);
         MarshalledValueInputStream in=new MarshalledValueInputStream(in_stream);
         NodeData nd;
  
         // remove entire existing state
         this.remove(subtree);
        
         boolean moveToBuddy =
            subtree.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN) && subtree.size() > 1;
  
         // store new state
         Fqn fqn = null;
         while(in.available() > 0)
         {
            nd=(NodeData)in.readObject();
           
            if (moveToBuddy)
               fqn = BuddyManager.getBackupFqn(subtree, nd.fqn);
            else
               fqn = nd.fqn;
View Full Code Here

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

         ByteArrayInputStream in_stream = new ByteArrayInputStream(state);
         MarshalledValueInputStream in = new MarshalledValueInputStream(in_stream);
         NodeData nd;

         // remove entire existing state
         this.remove(subtree);

         boolean moveToBuddy =
                 subtree.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN) && subtree.size() > 1;

         // store new state
         Fqn fqn;
         while (in_stream.available() > 0)
         {
            nd = (NodeData) in.readObject();

            if (moveToBuddy)
               fqn = BuddyManager.getBackupFqn(subtree, nd.fqn);
            else
               fqn = nd.fqn;
View Full Code Here

      // this node exists so we should never return a null after this... at worst case, an empty HashMap.
      File child = new File(f, DATA);
      if (!child.exists()) return new HashMap(0); // no node attribs exist hence the empty HashMap.
      //if(!child.exists()) return null;
      FileInputStream in = new FileInputStream(child);
      MarshalledValueInputStream input = new MarshalledValueInputStream(in);
      Map m = (Map) input.readObject();
      in.close();
      return m;
   }
View Full Code Here

    * @param state
    * @throws Exception
    */
   public void storeEntireState(byte[] state) throws Exception {
      ByteArrayInputStream in_stream=new ByteArrayInputStream(state);
      MarshalledValueInputStream in=new MarshalledValueInputStream(in_stream);
      NodeData nd;

      // remove entire existing state
      this.remove(Fqn.fromString("/"));

      // store new state
      try {
         while(true) {
            nd=(NodeData) in.readObject();
            if(nd.attrs != null)
               this.put(nd.fqn, nd.attrs, true); // creates a node with 0 or more attributes
            else
               this.put(nd.fqn, null)// creates a node with null attributes
         }
View Full Code Here

      if (log_.isTraceEnabled()) {
         log_.trace("recv");
         log_.trace(getColumnDump(bytes));
      }
      ByteArrayInputStream is = new ByteArrayInputStream(bytes);
      ObjectInputStream ois = new MarshalledValueInputStream(is);

      // Read the fqn first
      String fqn = ois.readUTF();
      ClassLoader oldTcl = null;;
      Region region = null;
      if(fqn != null && !fqn.equals("NULL"))
      {
         // obtain a region from RegionManager, if not, will use default.
         region = getRegion(fqn);

         if(region != null)
         {
            // If the region has been marked inactive, we still have
            // to return a MethodCall or RpcDispatcher will log an Error.
            // So, return a call to the TreeCache "_notifyCallOnInactive" method
            if (region.getStatus() == Region.STATUS_INACTIVE)
            {
                if (log_.isTraceEnabled())
                {
                    log_.trace("objectFromByteBuffer(): fqn: " + fqn + " is in the inactive default region");
                }

               return MethodCallFactory.create(MethodDeclarations.notifyCallOnInactiveMethod,
                                     new Object[] { fqn} );
            }

            // If the region has an associated CL, read the value using it
            ClassLoader cl = region.getClassLoader();
            if (cl != null)
            {
               oldTcl = Thread.currentThread().getContextClassLoader();
               Thread.currentThread().setContextClassLoader(cl);

                if (log_.isTraceEnabled())
                {
                    log_.trace("objectFromByteBuffer(): fqn: " + fqn + " Will use customed class loader " + cl);
                }
            }
         }
         else if (defaultInactive_)
         {
            // No region but default inactive means region is inactive

             if (log_.isTraceEnabled())
             {
                 log_.trace("objectFromByteBuffer(): fqn: " + fqn + " is in an inactive region");
             }

            return MethodCallFactory.create(MethodDeclarations.notifyCallOnInactiveMethod,
                  new Object[] { fqn} );
         }
      }

      // Read the MethodCall object using specified class loader
      Object obj = null;
      try
      {
         obj = ois.readObject();
      } finally
      {
          if (oldTcl != null)
          {
              Thread.currentThread().setContextClassLoader(oldTcl);
View Full Code Here

      ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
      try
      {
         // Use an ObjectInputStream that instantiates objects
         // using the Thread Context ClassLoader (TCL)
         ObjectInputStream oos = new MarshalledValueInputStream(bais);
         return oos.readObject();
      }
      catch (Exception e)
      {
         log.error("Cannot deserialize", e);
         return null;
View Full Code Here

TOP

Related Classes of org.jboss.invocation.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.