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

Galder Zamarreno galder.zamarreno at jboss.com
Wed Mar 7 18:32:06 EST 2007


  User: gzamarreno
  Date: 07/03/07 18:32:06

  Modified:    src/org/jboss/cache/loader    JDBCCacheLoader.java
                        AdjListJDBCCacheLoader.java FileCacheLoader.java
  Log:
  [JBCACHE-964] Work committed:
  - Transforming Cache Loaders implemented and unit tests provided
  - migration folder structure. See JIRA.
  - build.xml modified to compile, jar, create manifest for migration jar
  and also added examples and migration jar to distros.
  - example created and tested; it includes readme.txt with details of the
  example and how to run it.
  Still TODO:
  - Unit tests for transforming cache loaders need to run from build.xml
  - Documentation for transforming cache loaders in users guide, what are
  they, when to use them,...etc.
  - Fix JBCACHE-877 that occurrs when unzipping JBossCache-core-2.0.0.BETA2.zip 
  and running the examples. Workaround is to bring trove.jar into its lib.
  - Get examples/cacheloader-migration/build.sh working
  - Move JDBCCacheLoaderOld to the migration side. It's not that straightforward due to classes in
  /src having dependencies on it. Needs further study.
  
  Revision  Changes    Path
  1.35      +2 -1      JBossCache/src/org/jboss/cache/loader/JDBCCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JDBCCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/JDBCCacheLoader.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -b -r1.34 -r1.35
  --- JDBCCacheLoader.java	5 Mar 2007 21:59:25 -0000	1.34
  +++ JDBCCacheLoader.java	7 Mar 2007 23:32:05 -0000	1.35
  @@ -30,6 +30,7 @@
    * be different for proprietary systems.
    * 
    * @author Mircea.Markus at iquestint.com
  + * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
    * @version 1.0
    */
   public class JDBCCacheLoader extends AdjListJDBCCacheLoader
  @@ -150,7 +151,7 @@
               ObjectInputStream ois;
               try
               {
  -                Object marshalledNode = getMarshaller().objectFromStream(is);
  +                Object marshalledNode = unmarshall(is);
                   result = (Map<Object, Object>) marshalledNode;
               }
               catch (Exception e)
  
  
  
  1.2       +12 -1     JBossCache/src/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AdjListJDBCCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/AdjListJDBCCacheLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- AdjListJDBCCacheLoader.java	5 Mar 2007 21:10:43 -0000	1.1
  +++ AdjListJDBCCacheLoader.java	7 Mar 2007 23:32:06 -0000	1.2
  @@ -23,6 +23,7 @@
    * case of Modified Preorder Model. Even more there is no costly update indexes operation.
    *
    * @author Mircea.Markus at iquestint.com
  + * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
    * @version 1.0
    */
   public abstract class AdjListJDBCCacheLoader extends AbstractCacheLoader
  @@ -346,7 +347,7 @@
                           //                 Object marshalledNode = ois.readObject();
   
                           // deserialize result
  -                        Object marshalledNode = getMarshaller().objectFromStream(is);
  +                        Object marshalledNode = unmarshall(is);
                           oldNode = (Map) marshalledNode;
                       }
                       catch (Exception e)
  @@ -648,6 +649,16 @@
           }
       }
   
  +    protected Object unmarshall(InputStream from) throws Exception
  +    {
  +       return getMarshaller().objectFromStream(from);
  +    }
  +
  +    protected Object marshall(Object obj) throws Exception
  +    {
  +       return getMarshaller().objectToByteBuffer(obj);
  +    }
  +
       private static String toUpperCase(String s)
       {
           return s.toUpperCase(Locale.ENGLISH);
  
  
  
  1.30      +20 -9     JBossCache/src/org/jboss/cache/loader/FileCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FileCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/FileCacheLoader.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -b -r1.29 -r1.30
  --- FileCacheLoader.java	30 Jan 2007 19:22:07 -0000	1.29
  +++ FileCacheLoader.java	7 Mar 2007 23:32:06 -0000	1.30
  @@ -28,7 +28,7 @@
    *
    * @author Bela Ban
    * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  - * @version $Id: FileCacheLoader.java,v 1.29 2007/01/30 19:22:07 gzamarreno Exp $
  + * @version $Id: FileCacheLoader.java,v 1.30 2007/03/07 23:32:06 gzamarreno Exp $
    */
   public class FileCacheLoader extends AbstractCacheLoader
   {
  @@ -361,10 +361,7 @@
         if (!child.exists()) return new HashMap(0); // no node attribs exist hence the empty HashMap.
         //if(!child.exists()) return null;
   
  -      FileInputStream fileIn = new FileInputStream(child);
  -      ObjectInputStream input = ObjectSerializationFactory.createObjectInputStream(fileIn);
  -      Map m = (Map) getMarshaller().objectFromObjectStream(input);
  -      fileIn.close();
  +      Map m = (Map)unmarshall(child);
         return m;
      }
   
  @@ -388,10 +385,7 @@
            }
         }
   
  -      FileOutputStream fileOut = new FileOutputStream(child);
  -      ObjectOutputStream output = ObjectSerializationFactory.createObjectOutputStream(fileOut);
  -      getMarshaller().objectToObjectStream(attrs, output);
  -      fileOut.close();
  +      marshall(attrs, child);
      }
   
      protected boolean isCharacterPortableLocation(String fileAbsolutePath)
  @@ -436,4 +430,21 @@
   
         return true;
      }
  +
  +   protected Object unmarshall(File from) throws Exception
  +   {
  +      FileInputStream fileIn = new FileInputStream(from);
  +      ObjectInputStream input = ObjectSerializationFactory.createObjectInputStream(fileIn);
  +      Object unmarshalledObj = getMarshaller().objectFromObjectStream(input);
  +      fileIn.close();
  +      return unmarshalledObj;
  +   }
  +
  +   protected void marshall(Object obj, File to) throws Exception
  +   {
  +      FileOutputStream fileOut = new FileOutputStream(to);
  +      ObjectOutputStream output = ObjectSerializationFactory.createObjectOutputStream(fileOut);
  +      getMarshaller().objectToObjectStream(obj, output);
  +      fileOut.close();
  +   }
   }
  
  
  



More information about the jboss-cvs-commits mailing list