[infinispan-commits] Infinispan SVN: r367 - trunk/core/src/main/java/org/infinispan/marshall/jboss.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Tue Jun 2 06:13:02 EDT 2009


Author: galder.zamarreno at jboss.com
Date: 2009-06-02 06:13:01 -0400 (Tue, 02 Jun 2009)
New Revision: 367

Removed:
   trunk/core/src/main/java/org/infinispan/marshall/jboss/ClassExternalizer.java
   trunk/core/src/main/java/org/infinispan/marshall/jboss/NumberClassExternalizer.java
Log:
[ISPN-59] Finish new JBMAR implementation removing two old deprecated classes from the 1st version.

Deleted: trunk/core/src/main/java/org/infinispan/marshall/jboss/ClassExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/ClassExternalizer.java	2009-06-01 14:17:43 UTC (rev 366)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/ClassExternalizer.java	2009-06-02 10:13:01 UTC (rev 367)
@@ -1,75 +0,0 @@
-/*
- * 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.marshall.jboss;
-
-import java.io.IOException;
-
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
-
-/**
- * JBoss Marshalling implementation is now based only on ObjectTable instances
- * and so JBMAR ClassTable is not used any longer. Instead, for those cases where
- * classes need to be written, a new ClassTable has been redefined that allows 
- * reducing the number of writes written for a Class.
- *
- * @author Galder Zamarreño
- * @since 4.0
- * @deprecated With new ObjectTable based solution where there's no need hard need to send
- * class information around and bearing in mind that instantiation based on reflection is
- * expensive, moving instantiation to the corresponding externalizer.
- */
- at Deprecated
-public interface ClassExternalizer {
-   /**
-    * Write the predefined class reference to the stream.
-    *
-    * @param output the marshaller to write to
-    * @param subjectType the class reference to write
-    * @throws IOException if an I/O error occurs
-    */
-   void writeClass(Marshaller output, Class<?> subjectType) throws IOException;
-   
-   /**
-    * Read a class from the stream, instantiate it and return it.  The class will have been written by the
-    * writeClass(Marshaller, Class) method, as defined above.
-    *
-    * @param unmarshaller the unmarshaller to read from
-    * @return an instance of the class read
-    * @throws IOException if an I/O error occurs
-    */
-   Object readClassInstance(Unmarshaller input) throws IOException;
-      
-   /**
-    * Classes that provide a shortened version of Class information should
-    * implement this interface in order to get a callback to set the ClassTable. 
-    */
-   interface ClassWritable {
-      /**
-       * Set ClassTable callback to be able to provide a write a shortened 
-       * Class version.
-       * 
-       * @param classTable
-       */
-      void setClassExternalizer(ClassExternalizer classExt);
-   }
-}

Deleted: trunk/core/src/main/java/org/infinispan/marshall/jboss/NumberClassExternalizer.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/jboss/NumberClassExternalizer.java	2009-06-01 14:17:43 UTC (rev 366)
+++ trunk/core/src/main/java/org/infinispan/marshall/jboss/NumberClassExternalizer.java	2009-06-02 10:13:01 UTC (rev 367)
@@ -1,151 +0,0 @@
-/*
- * 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.marshall.jboss;
-
-import net.jcip.annotations.Immutable;
-import org.infinispan.CacheException;
-import org.infinispan.commands.LockControlCommand;
-import org.infinispan.commands.read.GetKeyValueCommand;
-import org.infinispan.commands.remote.ClusteredGetCommand;
-import org.infinispan.commands.remote.MultipleRpcCommand;
-import org.infinispan.commands.remote.SingleRpcCommand;
-import org.infinispan.commands.tx.CommitCommand;
-import org.infinispan.commands.tx.PrepareCommand;
-import org.infinispan.commands.tx.RollbackCommand;
-import org.infinispan.commands.write.ClearCommand;
-import org.infinispan.commands.write.InvalidateCommand;
-import org.infinispan.commands.write.InvalidateL1Command;
-import org.infinispan.commands.write.PutKeyValueCommand;
-import org.infinispan.commands.write.PutMapCommand;
-import org.infinispan.commands.write.RemoveCommand;
-import org.infinispan.commands.write.ReplaceCommand;
-import org.infinispan.util.FastCopyHashMap;
-import org.infinispan.util.Util;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
-import org.jboss.marshalling.util.IdentityIntMap;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-/**
- * MagicNumberClassTable.
- *
- * @author Galder Zamarreño
- * @since 4.0
- * @deprecated With new ObjectTable based solution where there's no need hard need to send
- * class information around and bearing in mind that instantiation based on reflection is
- * expensive, moving simple map/set collection handling to the each externalizer.
- */
- at Immutable
- at Deprecated
-public class NumberClassExternalizer implements ClassExternalizer {
-   private static final List<String> MAGIC_NUMBERS = new ArrayList<String>();
-   private static final int HASHMAP = 0;
-   private static final int TREEMAP = 1;
-   private static final int FASTCOPYHASHMAP = 2;
-   private static final int HASHSET = 3;
-   private static final int TREESET = 4;
-
-   static {
-      MAGIC_NUMBERS.add(HASHMAP, HashMap.class.getName());
-      MAGIC_NUMBERS.add(TREEMAP, TreeMap.class.getName());
-      MAGIC_NUMBERS.add(FASTCOPYHASHMAP, FastCopyHashMap.class.getName());
-      
-      MAGIC_NUMBERS.add(HASHSET, HashSet.class.getName());
-      MAGIC_NUMBERS.add(TREESET, TreeSet.class.getName());
-      
-//      MAGIC_NUMBERS.add(ClusteredGetCommand.class.getName());
-//      MAGIC_NUMBERS.add(MultipleRpcCommand.class.getName());
-//      MAGIC_NUMBERS.add(SingleRpcCommand.class.getName());
-//      MAGIC_NUMBERS.add(GetKeyValueCommand.class.getName());
-//      MAGIC_NUMBERS.add(PutKeyValueCommand.class.getName());
-//      MAGIC_NUMBERS.add(RemoveCommand.class.getName());
-//      MAGIC_NUMBERS.add(InvalidateCommand.class.getName());
-//      MAGIC_NUMBERS.add(ReplaceCommand.class.getName());
-//      MAGIC_NUMBERS.add(ClearCommand.class.getName());
-//      MAGIC_NUMBERS.add(PutMapCommand.class.getName());
-//      MAGIC_NUMBERS.add(PrepareCommand.class.getName());
-//      MAGIC_NUMBERS.add(CommitCommand.class.getName());
-//      MAGIC_NUMBERS.add(RollbackCommand.class.getName());
-//      MAGIC_NUMBERS.add(InvalidateL1Command.class.getName());
-//      MAGIC_NUMBERS.add(LockControlCommand.class.getName());
-   }
-   
-   /** Class to int mapping providing magic number to be written. Do not use 
-    * this map for storing user classes. For these, please use weak key based 
-    * maps, i.e WeakHashMap */
-   private final IdentityIntMap<Class<?>> numbers = new IdentityIntMap<Class<?>>();
-   /** Contains list of class objects written. When writing, index of each 
-    * class object object, or magic number, is written, and when reading, index 
-    * is used to find the instance in this list.*/
-   private final List<Class<?>> classes = new ArrayList<Class<?>>();
-   private byte index;
-
-   public NumberClassExternalizer() {
-      try {
-         for (String entry : MAGIC_NUMBERS) {
-            Class clazz = Util.loadClass(entry);
-            numbers.put(clazz, index++);
-            classes.add(clazz);
-         }
-      } 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);
-      }
-   }
-
-   public void stop() {
-      classes.clear();
-      numbers.clear();
-   }
-
-   public void writeClass(Marshaller marshaller, Class<?> clazz) throws IOException {
-      int number = numbers.get(clazz, -1);
-      marshaller.writeByte(number);
-   }
-
-   public Object readClassInstance(Unmarshaller unmarshaller) throws IOException {
-      int magicNumber = unmarshaller.readUnsignedByte();
-      switch (magicNumber) {
-         case HASHMAP:
-            return new HashMap();
-         case TREEMAP:
-            return new TreeMap();
-         case FASTCOPYHASHMAP:
-            return new FastCopyHashMap();
-         case HASHSET:
-            return new HashSet();
-         case TREESET:
-            return new TreeSet();
-         default:
-            return null;
-      }
-   }
-   
-}




More information about the infinispan-commits mailing list