[jboss-cvs] JBossCache/src/org/jboss/cache/loader/jdbm ...

Vladmir Blagojevic vladimir.blagojevic at jboss.com
Thu Aug 31 10:56:46 EDT 2006


  User: vblagojevic
  Date: 06/08/31 10:56:46

  Modified:    src/org/jboss/cache/loader/jdbm  JdbmCacheLoader.java
  Log:
  CacheLoader API change (remove byte based load/store)
  
  Revision  Changes    Path
  1.11      +105 -8    JBossCache/src/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JdbmCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- JdbmCacheLoader.java	19 Jul 2006 08:29:18 -0000	1.10
  +++ JdbmCacheLoader.java	31 Aug 2006 14:56:46 -0000	1.11
  @@ -54,7 +54,7 @@
    * plans to fix this.
    *
    * @author Elias Ross
  - * @version $Id: JdbmCacheLoader.java,v 1.10 2006/07/19 08:29:18 msurtani Exp $
  + * @version $Id: JdbmCacheLoader.java,v 1.11 2006/08/31 14:56:46 vblagojevic Exp $
    */
   public class JdbmCacheLoader extends AbstractCacheLoader
   {
  @@ -550,17 +550,21 @@
         transactions.remove(tx);
      }
   
  -   public byte[] loadEntireState()
  +   /*public byte[] loadEntireState()
         throws Exception
      {
         return loadState(Fqn.ROOT);
  -   }
  +   }*/
   
      /**
       * Export the contents of the databases as a byte array.
       * If the databases are empty a zero-lenth array is returned.
  +    * 
  +    * kept as a reference until 
  +    * http://jira.jboss.com/jira/browse/JBCACHE-748
  +    * is fixed
       */
  -   public byte[] loadState(Fqn subtree)
  +   /*public byte[] loadState(Fqn subtree)
         throws Exception
      {
         ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
  @@ -591,23 +595,27 @@
         {
            Thread.currentThread().setContextClassLoader(currentCL);
         }
  -   }
  +   }*/
   
      /**
       * Replace the contents of the databases with the given exported data.
       * If state is null or zero-length, the databases will be cleared.
       */
  -   public void storeEntireState(byte[] state)
  +   /*public void storeEntireState(byte[] state)
         throws Exception
      {
         storeState(state, Fqn.ROOT);
  -   }
  +   }*/
   
      /**
       * Replace the contents of the databases with the given exported data.
       * If state is null or zero-length, the databases will be cleared.
  +    * 
  +    *  kept as a reference until 
  +    * http://jira.jboss.com/jira/browse/JBCACHE-748
  +    * is fixed
       */
  -   public void storeState(byte[] state, Fqn subtree) throws Exception 
  +   /*public void storeState(byte[] state, Fqn subtree) throws Exception 
      {
         ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
         try
  @@ -642,6 +650,95 @@
         {
            Thread.currentThread().setContextClassLoader(currentCL);
         }
  +   }*/
  +   
  +   /*
  +    *TODO http://jira.jboss.com/jira/browse/JBCACHE-748
  +    * 
  +    */
  +   public void loadEntireState(ObjectOutputStream os) throws Exception
  +   {
  +      loadState(Fqn.ROOT,os);
  +   }
  +   /*
  +    *TODO http://jira.jboss.com/jira/browse/JBCACHE-748
  +    * 
  +    */
  +   public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
  +   {
  +      ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
  +
  +      try
  +      {
  +         // Set the TCCL to any classloader registered for subtree
  +         setUnmarshallingClassLoader(subtree);        
  +
  +         synchronized (tree)
  +         {
  +            TupleBrowser browser = tree.browse(subtree);
  +            Tuple t = new Tuple();
  +            while (browser.getNext(t))
  +            {
  +               Fqn fqn = (Fqn) t.getKey();
  +               if (!fqn.isChildOrEquals(subtree))
  +                  break;
  +               os.writeObject(fqn);
  +               os.writeObject(t.getValue());
  +            }
  +         }
  +         os.flush();         
  +      }
  +      finally
  +      {
  +         Thread.currentThread().setContextClassLoader(currentCL);
  +      }
  +   }
  +   /*
  +    *TODO http://jira.jboss.com/jira/browse/JBCACHE-748
  +    * 
  +    */
  +   public void storeEntireState(ObjectInputStream is) throws Exception
  +   {
  +      storeState(Fqn.ROOT,is);      
  +   }
  +   
  +   /*
  +    *TODO http://jira.jboss.com/jira/browse/JBCACHE-748
  +    * 
  +    */
  +   public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
  +   {
  +      ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
  +      try
  +      {
  +         // Set the TCCL to any classloader registered for subtree
  +         setUnmarshallingClassLoader(subtree);                 
  +         
  +         erase0(subtree);
  +         
  +         boolean moveToBuddy = 
  +            subtree.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN) && subtree.size() > 1;
  +   
  +         // store new state
  +         Fqn storeFqn;
  +         while (is.available() > 0) {
  +            Fqn fqn = (Fqn)is.readObject();
  +   
  +            if (moveToBuddy)
  +               storeFqn = BuddyManager.getBackupFqn(subtree, fqn);
  +            else
  +               storeFqn = fqn;
  +            
  +            Object value = is.readObject();
  +            tree.insert(storeFqn, value, true);
  +         } 
  +         commit();
  +      }
  +      finally
  +      {
  +         Thread.currentThread().setContextClassLoader(currentCL);
  +      }
  +      
      }
   
      /**
  
  
  



More information about the jboss-cvs-commits mailing list