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

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


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

  Modified:    src/org/jboss/cache/loader/bdbje  BdbjeCacheLoader.java
  Log:
  CacheLoader API change (remove byte based load/store)
  
  Revision  Changes    Path
  1.13      +70 -10    JBossCache/src/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BdbjeCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- BdbjeCacheLoader.java	19 Jul 2006 08:29:17 -0000	1.12
  +++ BdbjeCacheLoader.java	31 Aug 2006 14:56:47 -0000	1.13
  @@ -22,6 +22,8 @@
   import java.io.File;
   import java.io.IOException;
   import java.io.InputStreamReader;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
   import java.io.PrintStream;
   import java.io.Serializable;
   import java.util.Collections;
  @@ -47,7 +49,7 @@
    *
    * @author Mark Hayes May 16, 2004
    * @author Bela Ban
  - * @version $Id: BdbjeCacheLoader.java,v 1.12 2006/07/19 08:29:17 msurtani Exp $
  + * @version $Id: BdbjeCacheLoader.java,v 1.13 2006/08/31 14:56:47 vblagojevic Exp $
    */
   public class BdbjeCacheLoader extends AbstractCacheLoader
   {
  @@ -824,7 +826,13 @@
       * If the databases are empty a zero-lenth array is returned.
       * The export format is two consecutive DbDumps.
       */
  -   public byte[] loadEntireState()
  +   
  +   /*
  +    * kept as a reference until 
  +    * http://jira.jboss.com/jira/browse/JBCACHE-749
  +    * is fixed
  +    * 
  +    * public byte[] loadEntireState()
         throws Exception {
   
         checkOpen();
  @@ -848,7 +856,7 @@
            ps.flush();
            return baos.toByteArray();
         }
  -   }
  +   }*/
   
      /**
       * Dumps one database in ASCII format and adds a DATA=END marker line.
  @@ -864,8 +872,12 @@
       * Replace the contents of the databases with the given exported data.
       * If state is null or zero-length, the databases will be cleared.
       * The export format is two consecutive DbDumps.
  +    * 
  +    * kept as a reference until 
  +    * http://jira.jboss.com/jira/browse/JBCACHE-749
  +    * is fixed
       */
  -   public void storeEntireState(byte[] state)
  +   /*public void storeEntireState(byte[] state)
         throws Exception {
   
         checkOpen();
  @@ -880,14 +892,62 @@
            loadDatabase(catalogDbName, reader);
         }
         openDatabases();
  +   }*/
  +    
  +    /* 
  +    * http://jira.jboss.com/jira/browse/JBCACHE-749
  +    * 
  +    * 
  +    * */
  +    public void loadEntireState(ObjectOutputStream os) throws Exception
  +    {
  +       checkOpen();
  +
  +       boolean isEmpty;
  +       Cursor cursor = cacheDb.openCursor(null, null);
  +       try {
  +          isEmpty = cursor.getFirst(new DatabaseEntry(),
  +                                    new DatabaseEntry(),
  +                                    null) != OperationStatus.SUCCESS;
  +       } finally {
  +          cursor.close();
  +       }
  +       if (!isEmpty) {                         
  +          PrintStream ps = new PrintStream(os, false, "US-ASCII");
  +          dumpDatabase(cacheDbName, ps);
  +          dumpDatabase(catalogDbName, ps);
  +          ps.flush();         
  +       }       
      }
   
  -    public byte[] loadState(Fqn subtree) throws Exception
  +    public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
       {
           throw new UnsupportedOperationException("setting and loading state for specific Fqns not supported");
       }
   
  -    public void storeState(byte[] state, Fqn subtree) throws Exception
  +    /* 
  +     * http://jira.jboss.com/jira/browse/JBCACHE-749
  +     * 
  +     * 
  +     * */
  +    public void storeEntireState(ObjectInputStream is) throws Exception
  +    {
  +       checkOpen();
  +
  +       closeDatabases();
  +       env.removeDatabase(null, cacheDbName);
  +       env.removeDatabase(null, catalogDbName);
  +       if(is.available()>0)
  +       {          
  +          BufferedReader reader = new BufferedReader(new InputStreamReader(is));
  +          loadDatabase(cacheDbName, reader);
  +          loadDatabase(catalogDbName, reader);
  +       }
  +       openDatabases();
  +
  +    }
  +
  +    public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
       {
           throw new UnsupportedOperationException("setting and loading state for specific Fqns not supported");
       }
  
  
  



More information about the jboss-cvs-commits mailing list