[infinispan-commits] Infinispan SVN: r478 - in trunk: core/src/main/java/org/infinispan/marshall/jboss/externalizers and 5 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Jun 17 13:20:51 EDT 2009


Author: galder.zamarreno at jboss.com
Date: 2009-06-17 13:20:50 -0400 (Wed, 17 Jun 2009)
New Revision: 478

Added:
   trunk/tree/src/main/java/org/infinispan/tree/marshall/
   trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/
   trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/FqnExternalizer.java
   trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/NodeKeyExternalizer.java
Modified:
   trunk/core/src/main/java/org/infinispan/marshall/jboss/ConstantObjectTable.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/Externalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/MarshallUtil.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ArrayListExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/BucketExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/DeltaAwareExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ExceptionResponseExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ExtendedResponseExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/GlobalTransactionExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmortalCacheEntryExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmortalCacheValueExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmutableMapExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/JGroupsAddressExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/LinkedListExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MapExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MarshalledValueExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MortalCacheEntryExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MortalCacheValueExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ReplicableCommandExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SetExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SingletonListExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SuccessfulResponseExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransactionLogExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientCacheEntryExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientCacheValueExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientMortalCacheEntryExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientMortalCacheValueExternalizer.java
   trunk/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java
   trunk/core/src/test/java/org/infinispan/marshall/jboss/JBossMarshallerTest.java
   trunk/tree/src/main/java/org/infinispan/tree/Fqn.java
   trunk/tree/src/main/java/org/infinispan/tree/NodeKey.java
Log:
[ISPN-66] (Create NodeKey and Fqn Externalizers) Created the required Externalizers. On top of that, refactored the internal Externalizer API to avoid leaking org.jboss.marshalling API to other subprojects.

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/ConstantObjectTable.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/ConstantObjectTable.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/ConstantObjectTable.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -21,8 +21,6 @@
  */
 package org.infinispan.marshall.jboss;
 
-import net.jcip.annotations.Immutable;
-
 import org.infinispan.CacheException;
 import org.infinispan.atomic.AtomicHashMap;
 import org.infinispan.commands.LockControlCommand;
@@ -87,11 +85,15 @@
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.util.FastCopyHashMap;
 import org.infinispan.util.Util;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
 import org.jboss.marshalling.Marshaller;
 import org.jboss.marshalling.ObjectTable;
 import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -113,6 +115,7 @@
  */
 @Scope(Scopes.GLOBAL)
 public class ConstantObjectTable implements ObjectTable {
+   private static final Log log = LogFactory.getLog(ConstantObjectTable.class);
    private static final int CAPACITY = 50;
    private static final Map<String, String> EXTERNALIZERS = new HashMap<String, String>(CAPACITY);
 
@@ -161,7 +164,10 @@
       EXTERNALIZERS.put(TransientCacheValue.class.getName(), TransientCacheValueExternalizer.class.getName());
       EXTERNALIZERS.put(TransientMortalCacheValue.class.getName(), TransientMortalCacheValueExternalizer.class.getName());
       
-      EXTERNALIZERS.put(Bucket.class.getName(), BucketExternalizer.class.getName());      
+      EXTERNALIZERS.put(Bucket.class.getName(), BucketExternalizer.class.getName());
+      
+      EXTERNALIZERS.put("org.infinispan.tree.NodeKey", "org.infinispan.tree.marshall.exts.NodeKeyExternalizer");
+      EXTERNALIZERS.put("org.infinispan.tree.Fqn", "org.infinispan.tree.marshall.exts.FqnExternalizer");
    }
 
    /** Contains list of singleton objects written such as constant objects, 
@@ -174,36 +180,36 @@
     * object externalizer classes to their Externalizer instances. 
     * Do not use this map for storing Externalizer implementations for user 
     * classes. For these, please use weak key based maps, i.e WeakHashMap */
-   private final Map<Class<?>, Writer> writers = new IdentityHashMap<Class<?>, Writer>(CAPACITY);
+   private final Map<Class<?>, ExternalizerAdapter> writers = new IdentityHashMap<Class<?>, ExternalizerAdapter>(CAPACITY);
 
    private byte index;
 
    public void init(RemoteCommandFactory cmdFactory, org.infinispan.marshall.Marshaller ispnMarshaller) {
       // Init singletons
       objects.add(RequestIgnoredResponse.INSTANCE);
-      writers.put(RequestIgnoredResponse.class, new InstanceWriter(index++));
+      writers.put(RequestIgnoredResponse.class, new ExternalizerAdapter(index++, new InstanceWriter()));
       objects.add(UnsuccessfulResponse.INSTANCE);
-      writers.put(UnsuccessfulResponse.class, new InstanceWriter(index++));
+      writers.put(UnsuccessfulResponse.class, new ExternalizerAdapter(index++, new InstanceWriter()));
       
       try {
          for (Map.Entry<String, String> entry : EXTERNALIZERS.entrySet()) {
-            Class typeClazz = Util.loadClass(entry.getKey());
-            Externalizer delegate = (Externalizer) Util.getInstance(entry.getValue());
-            if (delegate instanceof ReplicableCommandExternalizer) {
-               ((ReplicableCommandExternalizer) delegate).init(cmdFactory);
+            try {
+               Class typeClazz = Util.loadClass(entry.getKey());
+               Externalizer delegate = (Externalizer) Util.getInstance(entry.getValue());
+               if (delegate instanceof ReplicableCommandExternalizer) {
+                  ((ReplicableCommandExternalizer) delegate).init(cmdFactory);
+               }
+               if (delegate instanceof MarshalledValueExternalizer) {
+                  ((MarshalledValueExternalizer) delegate).init(ispnMarshaller);
+               }
+               ExternalizerAdapter rwrt = new ExternalizerAdapter(index++, delegate);
+               objects.add(rwrt);
+               writers.put(typeClazz, rwrt);               
+            } catch (ClassNotFoundException e) {
+               log.debug("Unable to load class" + e.getMessage());
             }
-            if (delegate instanceof MarshalledValueExternalizer) {
-               ((MarshalledValueExternalizer) delegate).init(ispnMarshaller);
-            }
-            Externalizer rwrt = new DelegatingReadWriter(index++, delegate);
-            objects.add(rwrt);
-            writers.put(typeClazz, rwrt);
          }
          
-      } catch (IOException e) {
-         throw new CacheException("Unable to open load magicnumbers.properties", e);
-      } catch (ClassNotFoundException e) {
-         throw new CacheException("Unable to load one of the classes defined in the magicnumbers.properties", e);
       } catch (Exception e) {
          throw new CacheException("Unable to instantiate Externalizer class", e);
       }
@@ -220,42 +226,210 @@
 
    public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
       Object o = objects.get(unmarshaller.readUnsignedByte());
-      if (o instanceof Externalizer) {
-         return ((Externalizer) o).readObject(unmarshaller);
+      if (o instanceof ExternalizerAdapter) {
+         return ((ExternalizerAdapter) o).readObject(unmarshaller);
       }
       return o;
    }
    
-   @Immutable
-   static class InstanceWriter implements Writer {
-      private final byte id;
-
-      InstanceWriter(byte objectId) {
+   static class InstanceWriter implements Externalizer {
+      public void writeObject(ObjectOutput output, Object object) throws IOException {
+         // no-op
+      }
+      
+      public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+         throw new CacheException("Read on constant instances shouldn't be called");
+      }
+   }
+   
+   class ExternalizerAdapter implements Writer {
+      final byte id;
+      final Externalizer externalizer;
+      
+      ExternalizerAdapter(byte objectId, Externalizer externalizer) {
          this.id = objectId;
+         this.externalizer = externalizer;
       }
+      
+      public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
+         return externalizer.readObject(new ObjectInputAdapter(unmarshaller));
+      }
 
       public void writeObject(Marshaller marshaller, Object object) throws IOException {
          marshaller.write(id);
+         externalizer.writeObject(new ObjectOutputAdapter(marshaller), object);
       }
-   }   
+   }
+
+   static class ObjectInputAdapter implements ObjectInput {
+      final ObjectInput input;
+      
+      ObjectInputAdapter(ObjectInput input) {
+         this.input = input;
+      }
+
+      public int available() throws IOException {
+         return input.available();
+      }
+
+      public void close() throws IOException {
+         input.close();
+      }
+
+      public int read() throws IOException {
+         return input.read();
+      }
+
+      public int read(byte[] b) throws IOException {
+         return input.read(b);
+      }
+
+      public int read(byte[] b, int off, int len) throws IOException {
+         return input.read(b, off, len);
+      }
+
+      public Object readObject() throws ClassNotFoundException, IOException {
+         return input.readObject();
+      }
+
+      public long skip(long n) throws IOException {
+         return input.skip(n);
+      }
+
+      public boolean readBoolean() throws IOException {
+         return input.readBoolean();
+      }
+
+      public byte readByte() throws IOException {
+         return input.readByte();
+      }
+
+      public char readChar() throws IOException {
+         return input.readChar();
+      }
+
+      public double readDouble() throws IOException {
+         return input.readDouble();
+      }
+
+      public float readFloat() throws IOException {
+         return input.readFloat();
+      }
+
+      public void readFully(byte[] b) throws IOException {
+         input.readFully(b);
+      }
+
+      public void readFully(byte[] b, int off, int len) throws IOException {
+         input.readFully(b, off, len);
+      }
+
+      public int readInt() throws IOException {
+         return input.readInt();
+      }
+
+      public String readLine() throws IOException {
+         return input.readLine();
+      }
+
+      public long readLong() throws IOException {
+         return input.readLong();
+      }
+
+      public short readShort() throws IOException {
+         return input.readShort();
+      }
+
+      public String readUTF() throws IOException {
+         return input.readUTF();
+      }
+
+      public int readUnsignedByte() throws IOException {
+         return input.readUnsignedByte();
+      }
+
+      public int readUnsignedShort() throws IOException {
+         return input.readUnsignedShort();
+      }
+
+      public int skipBytes(int n) throws IOException {
+         return input.skipBytes(n);
+      }
+   }
    
-   @Immutable
-   static class DelegatingReadWriter implements Externalizer {
-      private final byte id;
-      private final Externalizer delegate;
+   static class ObjectOutputAdapter implements ObjectOutput {
+      final ObjectOutput output;
+      
+      ObjectOutputAdapter(ObjectOutput output) {
+         this.output = output;
+      }
 
-      DelegatingReadWriter(byte objectId, Externalizer delegate) {
-         this.id = objectId;
-         this.delegate = delegate;
+      public void close() throws IOException {
+         output.close();
       }
 
-      public void writeObject(Marshaller marshaller, Object object) throws IOException {
-         marshaller.write(id);
-         delegate.writeObject(marshaller, object);
+      public void flush() throws IOException {
+         output.flush();
       }
 
-      public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
-         return delegate.readObject(unmarshaller);
+      public void write(int b) throws IOException {
+         output.write((int)b);
       }
-   }   
+
+      public void write(byte[] b) throws IOException {
+         output.write(b);
+      }
+
+      public void write(byte[] b, int off, int len) throws IOException {
+         output.write(b, off, len);      
+      }
+
+      public void writeObject(Object obj) throws IOException {
+         output.writeObject(obj);
+      }
+
+      public void writeBoolean(boolean v) throws IOException {
+         output.writeBoolean(v);
+      }
+
+      public void writeByte(int v) throws IOException {
+         output.writeByte(v);
+      }
+
+      public void writeBytes(String s) throws IOException {
+         output.writeBytes(s);
+      }
+
+      public void writeChar(int v) throws IOException {
+         output.writeChar(v);      
+      }
+
+      public void writeChars(String s) throws IOException {
+         output.writeChars(s);
+      }
+
+      public void writeDouble(double v) throws IOException {
+         output.writeDouble(v);
+      }
+
+      public void writeFloat(float v) throws IOException {
+         output.writeFloat(v);      
+      }
+
+      public void writeInt(int v) throws IOException {
+         output.writeInt(v);
+      }
+
+      public void writeLong(long v) throws IOException {
+         output.writeLong(v);      
+      }
+
+      public void writeShort(int v) throws IOException {
+         output.writeShort(v);
+      }
+
+      public void writeUTF(String str) throws IOException {
+         output.writeUTF(str);      
+      }
+   }
 }

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/Externalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/Externalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/Externalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,10 +22,9 @@
 package org.infinispan.marshall.jboss;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
-import org.jboss.marshalling.Unmarshaller;
-import org.jboss.marshalling.ObjectTable.Writer;
-
 /**
  * Extended interface that extends capabilities of writing predefined objects 
  * with the possibility of reading them. Any new externalizer implementations
@@ -42,16 +41,26 @@
  * @author Galder Zamarreño
  * @since 4.0
  */
-public interface Externalizer extends Writer {
+public interface Externalizer {
    
    /**
+    * Write the predefined object reference to the stream.
+    *
+    * @param output the object output to write to
+    * @param object the object reference to write
+    * @throws IOException if an I/O error occurs
+    */
+   void writeObject(ObjectOutput output, Object object) throws IOException;
+   
+   /**
     * Read an instance from the stream.  The instance will have been written by the
     * {@link #writeObject(Object)} method.
     *
-    * @param unmarshaller the unmarshaller to read from
+    * @param input the object input to read from
     * @return the object instance
     * @throws IOException if an I/O error occurs
     * @throws ClassNotFoundException if a class could not be found
     */
-   Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException;
+   Object readObject(ObjectInput input) throws IOException, ClassNotFoundException;
+
 }

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/MarshallUtil.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/MarshallUtil.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/MarshallUtil.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -30,6 +30,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.infinispan.io.UnsignedNumeric;
+
 /**
  * MarshallUtil.
  *
@@ -40,36 +42,8 @@
 @SuppressWarnings("unchecked")
 public class MarshallUtil {
 
-   /**
-    * Writes an int in a variable-length format.  Writes between one and five bytes.  Smaller values take fewer bytes.
-    * Negative numbers are not supported.
-    *
-    * @param i int to write
-    */
-   public static void writeUnsignedInt(ObjectOutput out, int i) throws IOException {
-      while ((i & ~0x7F) != 0) {
-         out.writeByte((byte) ((i & 0x7f) | 0x80));
-         i >>>= 7;
-      }
-      out.writeByte((byte) i);
-   }
-
-   /**
-    * Reads an int stored in variable-length format.  Reads between one and five bytes.  Smaller values take fewer
-    * bytes.  Negative numbers are not supported.
-    */
-   public static int readUnsignedInt(ObjectInput in) throws IOException {
-      byte b = in.readByte();
-      int i = b & 0x7F;
-      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
-         b = in.readByte();
-         i |= (b & 0x7FL) << shift;
-      }
-      return i;
-   }
-
    public static void marshallCollection(Collection c, ObjectOutput out) throws IOException {
-      writeUnsignedInt(out, c.size());
+      UnsignedNumeric.writeUnsignedInt(out, c.size());
       for (Object o : c) {
          out.writeObject(o);
       }
@@ -77,7 +51,7 @@
 
    public static void marshallMap(Map map, ObjectOutput out) throws IOException {
       int mapSize = map.size();
-      writeUnsignedInt(out, mapSize);
+      UnsignedNumeric.writeUnsignedInt(out, mapSize);
       if (mapSize == 0) return;
 
       for (Map.Entry me : (Set<Map.Entry>) map.entrySet()) {
@@ -87,35 +61,8 @@
    }
 
    public static void unmarshallMap(Map map, ObjectInput in) throws IOException, ClassNotFoundException {
-      int size = MarshallUtil.readUnsignedInt(in);
+      int size = UnsignedNumeric.readUnsignedInt(in);
       for (int i = 0; i < size; i++) map.put(in.readObject(), in.readObject());
    }
-
-   /**
-    * Writes a long in a variable-length format.  Writes between one and nine bytes.  Smaller values take fewer bytes.
-    * Negative numbers are not supported.
-    *
-    * @param i int to write
-    */
-   public static void writeUnsignedLong(ObjectOutput out, long i) throws IOException {
-      while ((i & ~0x7F) != 0) {
-         out.writeByte((byte) ((i & 0x7f) | 0x80));
-         i >>>= 7;
-      }
-      out.writeByte((byte) i);
-   }
-
-   /**
-    * Reads a long stored in variable-length format.  Reads between one and nine bytes.  Smaller values take fewer
-    * bytes.  Negative numbers are not supported.
-    */
-   public static long readUnsignedLong(ObjectInput in) throws IOException {
-      byte b = in.readByte();
-      long i = b & 0x7F;
-      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
-         b = in.readByte();
-         i |= (b & 0x7FL) << shift;
-      }
-      return i;
-   }
+   
 }

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ArrayListExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ArrayListExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ArrayListExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,12 +22,14 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import net.jcip.annotations.Immutable;
+
+import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.MarshallUtil;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.Collection;
 
@@ -39,15 +41,13 @@
  */
 @Immutable
 public class ArrayListExternalizer implements Externalizer {
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 589638638644295615L;
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       MarshallUtil.marshallCollection((Collection) subject, output);
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
-      int size = MarshallUtil.readUnsignedInt(input);
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+      int size = UnsignedNumeric.readUnsignedInt(input);
       ArrayList l = new ArrayList(size);
       for (int i = 0; i < size; i++) l.add(input.readObject());
       return l;

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/BucketExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/BucketExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/BucketExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,6 +22,8 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import net.jcip.annotations.Immutable;
 
@@ -30,8 +32,6 @@
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.loaders.bucket.Bucket;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * BucketExternalizer.
@@ -42,13 +42,13 @@
 @Immutable
 public class BucketExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       Bucket b = (Bucket) subject;
       UnsignedNumeric.writeUnsignedInt(output, b.getNumEntries());
       for (InternalCacheEntry se : b.getEntries().values()) output.writeObject(se);
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Bucket b = new Bucket();
       int numEntries = UnsignedNumeric.readUnsignedInt(input);
       for (int i = 0; i < numEntries; i++) b.addEntry((InternalCacheEntry) input.readObject());

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/DeltaAwareExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/DeltaAwareExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/DeltaAwareExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -24,10 +24,10 @@
 import net.jcip.annotations.Immutable;
 import org.infinispan.atomic.DeltaAware;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * DeltaAwareExternalizer.
@@ -38,12 +38,12 @@
 @Immutable
 public class DeltaAwareExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       DeltaAware dw = (DeltaAware) subject;
       output.writeObject(dw.delta());      
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       return input.readObject();
    }
 

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ExceptionResponseExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ExceptionResponseExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ExceptionResponseExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -4,10 +4,10 @@
 
 import org.infinispan.marshall.jboss.Externalizer;
 import org.infinispan.remoting.responses.ExceptionResponse;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * Externalizes an ExceptionResponse
@@ -18,12 +18,12 @@
 @Immutable
 public class ExceptionResponseExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       ExceptionResponse er = (ExceptionResponse) subject;
       output.writeObject(er.getException());
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       ExceptionResponse er = new ExceptionResponse();
       er.setException((Exception) input.readObject());
       return er;

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ExtendedResponseExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ExtendedResponseExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ExtendedResponseExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -26,10 +26,10 @@
 import org.infinispan.marshall.jboss.Externalizer;
 import org.infinispan.remoting.responses.ExtendedResponse;
 import org.infinispan.remoting.responses.Response;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * ExtendedResponseExternalizer.
@@ -40,13 +40,13 @@
 @Immutable
 public class ExtendedResponseExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       ExtendedResponse er = (ExtendedResponse) subject;
       output.writeBoolean(er.isReplayIgnoredRequests());
       output.writeObject(er.getResponse());
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       boolean replayIgnoredRequests = input.readBoolean();
       Response response = (Response) input.readObject();
       return new ExtendedResponse(response, replayIgnoredRequests);

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/GlobalTransactionExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/GlobalTransactionExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/GlobalTransactionExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -26,10 +26,10 @@
 import org.infinispan.marshall.jboss.Externalizer;
 import org.infinispan.remoting.transport.Address;
 import org.infinispan.transaction.xa.GlobalTransaction;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * GlobalTransactionExternalizer.
@@ -40,13 +40,13 @@
 @Immutable
 public class GlobalTransactionExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       GlobalTransaction gtx = (GlobalTransaction) subject;
       output.writeLong(gtx.getId());
       output.writeObject(gtx.getAddress());      
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       GlobalTransaction gtx = new GlobalTransaction();
       long id = input.readLong();
       Object address = input.readObject();

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmortalCacheEntryExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmortalCacheEntryExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmortalCacheEntryExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,14 +22,14 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import  java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import net.jcip.annotations.Immutable;
 
 import org.infinispan.container.entries.ImmortalCacheEntry;
 import org.infinispan.container.entries.InternalEntryFactory;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * ImmortalCacheEntryExternalizer.
@@ -40,13 +40,13 @@
 @Immutable
 public class ImmortalCacheEntryExternalizer implements Externalizer {
    
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       ImmortalCacheEntry ice = (ImmortalCacheEntry) subject;
       output.writeObject(ice.getKey());
       output.writeObject(ice.getValue());      
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Object k = input.readObject();
       Object v = input.readObject();
       return InternalEntryFactory.create(k, v);

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmortalCacheValueExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmortalCacheValueExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmortalCacheValueExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,14 +22,14 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import net.jcip.annotations.Immutable;
 
 import org.infinispan.container.entries.ImmortalCacheValue;
 import org.infinispan.container.entries.InternalEntryFactory;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * ImmortalCacheValueExternalizer.
@@ -40,12 +40,12 @@
 @Immutable
 public class ImmortalCacheValueExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       ImmortalCacheValue icv = (ImmortalCacheValue) subject;
       output.writeObject(icv.getValue());      
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Object v = input.readObject();
       return InternalEntryFactory.createValue(v);
    }

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmutableMapExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmutableMapExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ImmutableMapExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -25,10 +25,10 @@
 import org.infinispan.marshall.jboss.MarshallUtil;
 import org.infinispan.marshall.jboss.Externalizer;
 import org.infinispan.util.Immutables;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -41,11 +41,11 @@
 @Immutable
 public class ImmutableMapExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       MarshallUtil.marshallMap((Map) subject, output);      
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Map map = new HashMap();
       MarshallUtil.unmarshallMap(map, input);
       return Immutables.immutableMapWrap(map);

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/JGroupsAddressExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/JGroupsAddressExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/JGroupsAddressExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -25,10 +25,9 @@
 
 import org.infinispan.marshall.jboss.Externalizer;
 import org.infinispan.remoting.transport.jgroups.JGroupsAddress;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
-
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * JGroupsAddressExternalizer.
@@ -39,12 +38,12 @@
 @Immutable
 public class JGroupsAddressExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       JGroupsAddress address = (JGroupsAddress) subject;
       output.writeObject(address.getJGroupsAddress());
    }
 
-   public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput unmarshaller) throws IOException, ClassNotFoundException {
       JGroupsAddress address = new JGroupsAddress();
       address.setJGroupsAddress((org.jgroups.Address) unmarshaller.readObject());
       return address;

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/LinkedListExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/LinkedListExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/LinkedListExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,12 +22,14 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import net.jcip.annotations.Immutable;
+
+import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.MarshallUtil;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.Collection;
 import java.util.LinkedList;
 
@@ -40,12 +42,12 @@
 @Immutable
 public class LinkedListExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       MarshallUtil.marshallCollection((Collection) subject, output);
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
-      int size = MarshallUtil.readUnsignedInt(input);
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+      int size = UnsignedNumeric.readUnsignedInt(input);
       LinkedList l = new LinkedList();
       for (int i = 0; i < size; i++) l.add(input.readObject());
       return l;

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MapExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MapExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MapExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -24,11 +24,11 @@
 import org.infinispan.marshall.jboss.MarshallUtil;
 import org.infinispan.marshall.jboss.Externalizer;
 import org.infinispan.util.FastCopyHashMap;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 import org.jboss.marshalling.util.IdentityIntMap;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.TreeMap;
@@ -52,13 +52,13 @@
       numbers.put(FastCopyHashMap.class, FASTCOPYHASHMAP);
    }
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       int number = numbers.get(subject.getClass(), -1);
       output.writeByte(number);
       MarshallUtil.marshallMap((Map) subject, output);
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       int magicNumber = input.readUnsignedByte();
       Map subject = null;
       switch (magicNumber) {

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MarshalledValueExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MarshalledValueExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MarshalledValueExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -24,10 +24,10 @@
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.MarshalledValue;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * MarshalledValueExternalizer.
@@ -42,7 +42,7 @@
       this.ispnMarshaller = ispnMarshaller;
    }
    
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       MarshalledValue mv = ((MarshalledValue) subject);
       byte[] raw = mv.getRaw();
       UnsignedNumeric.writeUnsignedInt(output, raw.length);
@@ -50,7 +50,7 @@
       output.writeInt(mv.hashCode());      
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       int length = UnsignedNumeric.readUnsignedInt(input);
       byte[] raw = new byte[length];
       input.readFully(raw);

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MortalCacheEntryExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MortalCacheEntryExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MortalCacheEntryExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,6 +22,8 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import net.jcip.annotations.Immutable;
 
@@ -29,8 +31,6 @@
 import org.infinispan.container.entries.MortalCacheEntry;
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * MortalCacheEntryExternalizer.
@@ -41,7 +41,7 @@
 @Immutable
 public class MortalCacheEntryExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       MortalCacheEntry ice = (MortalCacheEntry) subject;
       output.writeObject(ice.getKey());
       output.writeObject(ice.getValue());
@@ -49,7 +49,7 @@
       output.writeLong(ice.getLifespan()); // could be negative so should not use unsigned longs      
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Object k = input.readObject();
       Object v = input.readObject();
       long created = UnsignedNumeric.readUnsignedLong(input);

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MortalCacheValueExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MortalCacheValueExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/MortalCacheValueExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,13 +22,13 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import org.infinispan.container.entries.InternalEntryFactory;
 import org.infinispan.container.entries.MortalCacheValue;
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * MortalCacheValueExternalizer.
@@ -38,14 +38,14 @@
  */
 public class MortalCacheValueExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       MortalCacheValue icv = (MortalCacheValue) subject;
       output.writeObject(icv.getValue());
       UnsignedNumeric.writeUnsignedLong(output, icv.getCreated());
       output.writeLong(icv.getLifespan()); // could be negative so should not use unsigned longs
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Object v = input.readObject();
       long created = UnsignedNumeric.readUnsignedLong(input);
       Long lifespan = input.readLong();

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ReplicableCommandExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ReplicableCommandExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/ReplicableCommandExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -24,10 +24,10 @@
 import org.infinispan.commands.RemoteCommandFactory;
 import org.infinispan.commands.ReplicableCommand;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * ReplicableCommandExternalizer.
@@ -42,7 +42,7 @@
       this.cmdFactory = cmdFactory;
    }
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       ReplicableCommand command = (ReplicableCommand) subject;
       output.writeShort(command.getCommandId());
       Object[] args = command.getParameters();
@@ -53,7 +53,7 @@
       }
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       short methodId = input.readShort();
       byte numArgs = input.readByte();
       Object[] args = null;

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SetExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SetExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SetExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,13 +22,15 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import net.jcip.annotations.Immutable;
+
+import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.MarshallUtil;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 import org.jboss.marshalling.util.IdentityIntMap;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
@@ -51,13 +53,13 @@
       numbers.put(TreeSet.class, TREESET);
    }
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       int number = numbers.get(subject.getClass(), -1);
       output.writeByte(number);
       MarshallUtil.marshallCollection((Collection) subject, output);
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       int magicNumber = input.readUnsignedByte();
       Set subject = null;
       switch (magicNumber) {
@@ -68,7 +70,7 @@
             subject = new TreeSet();
             break;
       }
-      int size = MarshallUtil.readUnsignedInt(input);
+      int size = UnsignedNumeric.readUnsignedInt(input);
       for (int i = 0; i < size; i++) subject.add(input.readObject());
       return subject;
    }

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SingletonListExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SingletonListExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SingletonListExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -24,10 +24,10 @@
 import net.jcip.annotations.Immutable; 
 
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.Collections;
 import java.util.List;
 
@@ -40,11 +40,11 @@
 @Immutable
 public class SingletonListExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       output.writeObject(((List) subject).get(0));
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       return Collections.singletonList(input.readObject());
    }
 

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SuccessfulResponseExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SuccessfulResponseExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/SuccessfulResponseExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -4,10 +4,10 @@
 
 import org.infinispan.marshall.jboss.Externalizer; 
 import org.infinispan.remoting.responses.SuccessfulResponse;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * Externalizes a SuccessfulResponse
@@ -18,12 +18,12 @@
 @Immutable
 public class SuccessfulResponseExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       SuccessfulResponse sr = (SuccessfulResponse) subject;
       output.writeObject(sr.getResponseValue());      
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       SuccessfulResponse sr = new SuccessfulResponse();
       sr.setResponseValue(input.readObject());
       return sr;

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransactionLogExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransactionLogExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransactionLogExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -23,14 +23,14 @@
 
 import net.jcip.annotations.Immutable; 
 import org.infinispan.commands.write.WriteCommand;
-import org.infinispan.marshall.jboss.MarshallUtil;
+import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.Externalizer;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.transaction.TransactionLog;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 /**
  * TransactionLogExternalizer.
@@ -41,18 +41,18 @@
 @Immutable
 public class TransactionLogExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       TransactionLog.LogEntry le = (TransactionLog.LogEntry) subject;
       output.writeObject(le.getTransaction());
       WriteCommand[] cmds = le.getModifications();
-      MarshallUtil.writeUnsignedInt(output, cmds.length);
+      UnsignedNumeric.writeUnsignedInt(output, cmds.length);
       for (WriteCommand c : cmds)
          output.writeObject(c);
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       GlobalTransaction gtx = (GlobalTransaction) input.readObject();
-      int numCommands = MarshallUtil.readUnsignedInt(input);
+      int numCommands = UnsignedNumeric.readUnsignedInt(input);
       WriteCommand[] cmds = new WriteCommand[numCommands];
       for (int i = 0; i < numCommands; i++) cmds[i] = (WriteCommand) input.readObject();
       return new TransactionLog.LogEntry(gtx, cmds);

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientCacheEntryExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientCacheEntryExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientCacheEntryExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,6 +22,8 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import net.jcip.annotations.Immutable;
 
@@ -29,8 +31,6 @@
 import org.infinispan.container.entries.TransientCacheEntry;
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * TransientCacheEntryExternalizer.
@@ -41,7 +41,7 @@
 @Immutable
 public class TransientCacheEntryExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       TransientCacheEntry ice = (TransientCacheEntry) subject;
       output.writeObject(ice.getKey());
       output.writeObject(ice.getValue());
@@ -49,7 +49,7 @@
       output.writeLong(ice.getMaxIdle()); // could be negative so should not use unsigned longs
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Object k = input.readObject();
       Object v = input.readObject();
       long lastUsed = UnsignedNumeric.readUnsignedLong(input);

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientCacheValueExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientCacheValueExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientCacheValueExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,6 +22,8 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import net.jcip.annotations.Immutable;
 
@@ -29,8 +31,6 @@
 import org.infinispan.container.entries.TransientCacheValue;
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * TransientCacheValueExternalizer.
@@ -41,14 +41,14 @@
 @Immutable
 public class TransientCacheValueExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       TransientCacheValue icv = (TransientCacheValue) subject;
       output.writeObject(icv.getValue());
       UnsignedNumeric.writeUnsignedLong(output, icv.getLastUsed());
       output.writeLong(icv.getMaxIdle()); // could be negative so should not use unsigned longs
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Object v = input.readObject();
       long lastUsed = UnsignedNumeric.readUnsignedLong(input);
       Long maxIdle = input.readLong();

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientMortalCacheEntryExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientMortalCacheEntryExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientMortalCacheEntryExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,6 +22,8 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import net.jcip.annotations.Immutable;
 
@@ -29,8 +31,6 @@
 import org.infinispan.container.entries.TransientMortalCacheEntry;
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * TransientMortalCacheEntryExternalizer.
@@ -41,7 +41,7 @@
 @Immutable
 public class TransientMortalCacheEntryExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       TransientMortalCacheEntry ice = (TransientMortalCacheEntry) subject;
       output.writeObject(ice.getKey());
       output.writeObject(ice.getValue());
@@ -51,7 +51,7 @@
       output.writeLong(ice.getMaxIdle()); // could be negative so should not use unsigned longs
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Object k = input.readObject();
       Object v = input.readObject();
       long created = UnsignedNumeric.readUnsignedLong(input);

Modified: trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientMortalCacheValueExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientMortalCacheValueExternalizer.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/externalizers/TransientMortalCacheValueExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -22,6 +22,8 @@
 package org.infinispan.marshall.jboss.externalizers;
 
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import net.jcip.annotations.Immutable;
 
@@ -29,8 +31,6 @@
 import org.infinispan.container.entries.TransientMortalCacheValue;
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.jboss.Externalizer;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
 
 /**
  * TransientMortalCacheValueExternalizer.
@@ -41,7 +41,7 @@
 @Immutable
 public class TransientMortalCacheValueExternalizer implements Externalizer {
 
-   public void writeObject(Marshaller output, Object subject) throws IOException {
+   public void writeObject(ObjectOutput output, Object subject) throws IOException {
       TransientMortalCacheValue icv = (TransientMortalCacheValue) subject;
       output.writeObject(icv.getValue());
       UnsignedNumeric.writeUnsignedLong(output, icv.getCreated());
@@ -50,7 +50,7 @@
       output.writeLong(icv.getMaxIdle()); // could be negative so should not use unsigned longs
    }
 
-   public Object readObject(Unmarshaller input) throws IOException, ClassNotFoundException {
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
       Object v = input.readObject();
       long created = UnsignedNumeric.readUnsignedLong(input);
       Long lifespan = input.readLong();

Modified: trunk/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/test/java/org/infinispan/marshall/MarshalledValueTest.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -19,6 +19,8 @@
 import org.infinispan.test.MultipleCacheManagersTest;
 import org.infinispan.test.TestingUtil;
 import org.infinispan.util.ObjectDuplicator;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -428,6 +430,7 @@
       int i;
       boolean b;
       static int serializationCount, deserializationCount;
+      final Log log = LogFactory.getLog(Pojo.class);
 
       public boolean equals(Object o) {
          if (this == o) return true;
@@ -452,6 +455,7 @@
          out.writeInt(i);
          out.writeBoolean(b);
          serializationCount++;
+         log.trace("serializationCount=" + serializationCount);
       }
 
       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

Modified: trunk/core/src/test/java/org/infinispan/marshall/jboss/JBossMarshallerTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/marshall/jboss/JBossMarshallerTest.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/core/src/test/java/org/infinispan/marshall/jboss/JBossMarshallerTest.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -46,12 +46,9 @@
 import org.infinispan.container.entries.TransientCacheValue;
 import org.infinispan.container.entries.TransientMortalCacheEntry;
 import org.infinispan.container.entries.TransientMortalCacheValue;
-import org.infinispan.io.ExposedByteArrayOutputStream;
 import org.infinispan.loaders.bucket.Bucket;
 import org.infinispan.marshall.MarshalledValue;
-import org.infinispan.marshall.MarshalledValueTest;
 import org.infinispan.marshall.VersionAwareMarshaller;
-import org.infinispan.marshall.MarshalledValueTest.Pojo;
 import org.infinispan.remoting.responses.ExceptionResponse;
 import org.infinispan.remoting.responses.ExtendedResponse;
 import org.infinispan.remoting.responses.RequestIgnoredResponse;
@@ -70,7 +67,8 @@
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
-import java.io.ByteArrayInputStream;
+import java.io.Externalizable;
+import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.*;
@@ -167,12 +165,12 @@
    }
    
    public void testMarshalledValueGetMarshalling() throws Exception {
-      MarshalledValueTest.Pojo ext = new MarshalledValueTest.Pojo();
+      Pojo ext = new Pojo();
       MarshalledValue mv = new MarshalledValue(ext, true, marshaller);
       byte[] bytes = marshaller.objectToByteBuffer(mv);
       MarshalledValue rmv = (MarshalledValue) marshaller.objectFromByteBuffer(bytes);
       assert rmv.equals(mv) : "Writen[" + mv + "] and read[" + rmv + "] objects should be the same";
-      assert rmv.get() instanceof Pojo;
+      assert rmv.get() instanceof Pojo;         
    }
 
    public void testSingletonListMarshalling() throws Exception {
@@ -350,4 +348,40 @@
       assert readObj.equals(writeObj) : "Writen[" + writeObj + "] and read[" + readObj + "] objects should be the same";
    }
 
+   static class Pojo implements Externalizable {
+      int i;
+      boolean b;
+      static int serializationCount, deserializationCount;
+
+      public boolean equals(Object o) {
+         if (this == o) return true;
+         if (o == null || getClass() != o.getClass()) return false;
+
+         Pojo pojo = (Pojo) o;
+
+         if (b != pojo.b) return false;
+         if (i != pojo.i) return false;
+
+         return true;
+      }
+
+      public int hashCode() {
+         int result;
+         result = i;
+         result = 31 * result + (b ? 1 : 0);
+         return result;
+      }
+
+      public void writeExternal(ObjectOutput out) throws IOException {
+         out.writeInt(i);
+         out.writeBoolean(b);
+         serializationCount++;
+      }
+
+      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+         i = in.readInt();
+         b = in.readBoolean();
+         deserializationCount++;
+      }
+   }
 }

Modified: trunk/tree/src/main/java/org/infinispan/tree/Fqn.java
===================================================================
--- trunk/tree/src/main/java/org/infinispan/tree/Fqn.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/tree/src/main/java/org/infinispan/tree/Fqn.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -25,11 +25,6 @@
 import net.jcip.annotations.Immutable;
 import org.infinispan.util.Immutables;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -80,7 +75,7 @@
  * @since 4.0
  */
 @Immutable
-public class Fqn implements Comparable<Fqn>, Externalizable {
+public class Fqn implements Comparable<Fqn> {
    /**
     * Separator between FQN elements.
     */
@@ -237,23 +232,6 @@
    }
 
    /**
-    * Retrieves an Fqn read from an object input stream, typically written to using {@link
-    * #writeExternal(java.io.ObjectOutput)}.
-    *
-    * @param in input stream
-    * @return an Fqn
-    * @throws IOException            in the event of a problem reading the stream
-    * @throws ClassNotFoundException in the event of classes that comprise the element list of this Fqn not being found
-    * @since 4.0
-    */
-   public static Fqn fromExternalStream(ObjectInput in) throws IOException, ClassNotFoundException {
-      Fqn f = new Fqn();
-      f.readExternal(in);
-      return f;
-   }
-
-
-   /**
     * Obtains an ancestor of the current Fqn.  Literally performs <code>elements.subList(0, generation)</code> such that
     * if <code> generation == Fqn.size() </code> then the return value is the Fqn itself (current generation), and if
     * <code> generation == Fqn.size() - 1 </code> then the return value is the same as <code> Fqn.getParent() </code>
@@ -353,20 +331,6 @@
       return stringRepresentation;
    }
 
-   public void writeExternal(ObjectOutput out) throws IOException {
-      out.writeShort(size);
-      for (Object element : elements) {
-         out.writeObject(element);
-      }
-   }
-
-   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-      size = in.readShort();
-      this.elements = new ArrayList(size);
-      for (int i = 0; i < size; i++) elements.add(in.readObject());
-   }
-
-
    /**
     * Returns true if this Fqn is child of parentFqn. Example usage:
     * <pre>

Modified: trunk/tree/src/main/java/org/infinispan/tree/NodeKey.java
===================================================================
--- trunk/tree/src/main/java/org/infinispan/tree/NodeKey.java	2009-06-17 16:31:30 UTC (rev 477)
+++ trunk/tree/src/main/java/org/infinispan/tree/NodeKey.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -25,17 +25,15 @@
 
 import org.infinispan.util.Util;
 
-import java.io.Serializable;
-
 /**
  * A class that represents the key to a node
  *
  * @author Manik Surtani
  * @since 4.0
  */
-public class NodeKey implements Serializable {
-   Fqn fqn;
-   Type contents;
+public class NodeKey {
+   final Fqn fqn;
+   final Type contents;
 
    public static enum Type {
       DATA, STRUCTURE
@@ -45,7 +43,15 @@
       this.contents = contents;
       this.fqn = fqn;
    }
+   
+   public Fqn getFqn() {
+      return fqn;
+   }
 
+   public Type getContents() {
+      return contents;
+   }
+
    public boolean equals(Object o) {
       if (this == o) return true;
       if (o == null || getClass() != o.getClass()) return false;

Added: trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/FqnExternalizer.java
===================================================================
--- trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/FqnExternalizer.java	                        (rev 0)
+++ trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/FqnExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.tree.marshall.exts;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.infinispan.marshall.jboss.Externalizer;
+import org.infinispan.tree.Fqn;
+
+/**
+ * FqnExternalizer.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class FqnExternalizer implements Externalizer {
+
+   public void writeObject(ObjectOutput output, Object object) throws IOException {
+      Fqn fqn = (Fqn) object;
+      output.writeShort(fqn.size());
+      for (Object element : fqn.peekElements()) output.writeObject(element);
+   }
+
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+      short size = input.readShort();
+      List elements = new ArrayList(size);
+      for (int i = 0; i < size; i++) elements.add(input.readObject());
+      return Fqn.fromList(elements);
+   }
+
+}

Added: trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/NodeKeyExternalizer.java
===================================================================
--- trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/NodeKeyExternalizer.java	                        (rev 0)
+++ trunk/tree/src/main/java/org/infinispan/tree/marshall/exts/NodeKeyExternalizer.java	2009-06-17 17:20:50 UTC (rev 478)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.tree.marshall.exts;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import static org.infinispan.tree.NodeKey.Type.*;
+
+import org.infinispan.marshall.jboss.Externalizer;
+import org.infinispan.tree.Fqn;
+import org.infinispan.tree.NodeKey;
+
+/**
+ * NodeKeyExternalizer.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class NodeKeyExternalizer implements Externalizer {
+   private static final byte DATA_BYTE = 1;
+   private static final byte STRUCTURE_BYTE = 2;
+
+   public void writeObject(ObjectOutput output, Object object) throws IOException {
+      NodeKey key = (NodeKey) object;
+      output.writeObject(key.getFqn());
+      byte type = 0;
+      switch (key.getContents()) {
+         case DATA:
+            type = DATA_BYTE;
+            break;
+         case STRUCTURE:
+            type = STRUCTURE_BYTE;
+            break;
+      }
+      output.write(type);
+   }
+   
+   public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+      Fqn fqn = (Fqn) input.readObject();
+      int typeb = input.readUnsignedByte();
+      NodeKey.Type type = null; 
+      switch (typeb) {
+         case DATA_BYTE:
+            type = DATA;
+            break;
+         case STRUCTURE_BYTE:
+            type = STRUCTURE;
+            break;
+      }
+      return new NodeKey(fqn, type);
+   }
+
+}




More information about the infinispan-commits mailing list