[infinispan-commits] Infinispan SVN: r2030 - in branches/4.1.x: cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje and 52 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Tue Jul 13 04:52:42 EDT 2010


Author: manik.surtani at jboss.com
Date: 2010-07-13 04:52:33 -0400 (Tue, 13 Jul 2010)
New Revision: 2030

Added:
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/AbstractStreamingMarshaller.java
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/Marshaller.java
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/StreamingMarshaller.java
Removed:
   branches/4.1.x/cachestore/remote/src/main/java/org/infinispan/loaders/remote/InternalCacheEntryMarshaller.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/HotRodMarshaller.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/SerializationMarshaller.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/VHelper.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/InputStreamAdapter.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/OutputStreamAdapter.java
   branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/VHelperTest.java
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/AbstractMarshaller.java
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/Marshaller.java
Modified:
   branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/BdbjeCacheStore.java
   branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/BdbjeResourceFactory.java
   branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/InternalCacheEntryBinding.java
   branches/4.1.x/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreIntegrationVamTest.java
   branches/4.1.x/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreTest.java
   branches/4.1.x/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java
   branches/4.1.x/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationVamTest.java
   branches/4.1.x/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java
   branches/4.1.x/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreTest.java
   branches/4.1.x/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreVamTest.java
   branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/DataManipulationHelper.java
   branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/JdbcUtil.java
   branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStore.java
   branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ConnectionFactory.java
   branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/SimpleConnectionFactory.java
   branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStore.java
   branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStore.java
   branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java
   branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreVamTest.java
   branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java
   branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest.java
   branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest2.java
   branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
   branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest.java
   branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest2.java
   branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmCacheStore.java
   branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmCacheStoreConfig.java
   branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmSerializer.java
   branches/4.1.x/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreVamTest.java
   branches/4.1.x/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStore.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/RemoteCacheImpl.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/consistenthash/ConsistentHashFactory.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientDecoder.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientEncoder.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransport.java
   branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java
   branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/HotRodIntegrationTest.java
   branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/retry/DistributionRetryTest.java
   branches/4.1.x/core/src/main/java/org/infinispan/CacheDelegate.java
   branches/4.1.x/core/src/main/java/org/infinispan/affinity/KeyGenerator.java
   branches/4.1.x/core/src/main/java/org/infinispan/config/GlobalConfiguration.java
   branches/4.1.x/core/src/main/java/org/infinispan/distribution/ConsistentHashHelper.java
   branches/4.1.x/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java
   branches/4.1.x/core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java
   branches/4.1.x/core/src/main/java/org/infinispan/factories/EmptyConstructorNamedCacheFactory.java
   branches/4.1.x/core/src/main/java/org/infinispan/factories/InterceptorChainFactory.java
   branches/4.1.x/core/src/main/java/org/infinispan/factories/MarshallerFactory.java
   branches/4.1.x/core/src/main/java/org/infinispan/factories/TransactionManagerFactory.java
   branches/4.1.x/core/src/main/java/org/infinispan/factories/TransportFactory.java
   branches/4.1.x/core/src/main/java/org/infinispan/interceptors/MarshalledValueInterceptor.java
   branches/4.1.x/core/src/main/java/org/infinispan/jmx/AbstractJmxRegistration.java
   branches/4.1.x/core/src/main/java/org/infinispan/jmx/ResourceDMBean.java
   branches/4.1.x/core/src/main/java/org/infinispan/lifecycle/ModuleLifecycle.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/AbstractCacheLoader.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/AbstractCacheStore.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheLoader.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheLoaderManagerImpl.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheStore.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/LockSupportCacheStore.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/cluster/ClusterCacheLoader.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/AbstractDelegatingStore.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/AsyncStore.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/ChainingCacheStore.java
   branches/4.1.x/core/src/main/java/org/infinispan/loaders/file/FileCacheStore.java
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/MarshalledValue.java
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/VersionAwareMarshaller.java
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/jboss/ConstantObjectTable.java
   branches/4.1.x/core/src/main/java/org/infinispan/marshall/jboss/JBossMarshaller.java
   branches/4.1.x/core/src/main/java/org/infinispan/remoting/InboundInvocationHandlerImpl.java
   branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/Transport.java
   branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java
   branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/jgroups/MarshallerAdapter.java
   branches/4.1.x/core/src/main/java/org/infinispan/statetransfer/StateTransferManagerImpl.java
   branches/4.1.x/core/src/main/java/org/infinispan/transaction/TransactionLog.java
   branches/4.1.x/core/src/main/java/org/infinispan/transaction/lookup/GenericTransactionManagerLookup.java
   branches/4.1.x/core/src/main/java/org/infinispan/transaction/lookup/JBossStandaloneJTAManagerLookup.java
   branches/4.1.x/core/src/main/java/org/infinispan/util/ClassFinder.java
   branches/4.1.x/core/src/main/java/org/infinispan/util/ModuleProperties.java
   branches/4.1.x/core/src/main/java/org/infinispan/util/Util.java
   branches/4.1.x/core/src/main/java/org/infinispan/util/logging/LogFactory.java
   branches/4.1.x/core/src/test/java/org/infinispan/eviction/MarshalledValuesEvictionTest.java
   branches/4.1.x/core/src/test/java/org/infinispan/eviction/MarshalledValuesManualEvictionTest.java
   branches/4.1.x/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java
   branches/4.1.x/core/src/test/java/org/infinispan/loaders/dummy/DummyInMemoryCacheStore.java
   branches/4.1.x/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreTest.java
   branches/4.1.x/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreVamTest.java
   branches/4.1.x/core/src/test/java/org/infinispan/marshall/TestObjectStreamMarshaller.java
   branches/4.1.x/core/src/test/java/org/infinispan/marshall/jboss/JBossMarshallerTest.java
   branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
   branches/4.1.x/jopr-plugin/src/main/java/org/infinispan/jopr/ConnectionHelper.java
Log:
1. Make Util.getInstance() NOT throw an exception except ConfigurationException, and provide alternative, Strict methods
2. Update usages of this method accordingly.
3. Marshaller, AbstractMarshaller and StreamMarshaller refactoring
4. Removed VHelper and SerializationMarshaller from hotrod-client
5. Removed InputStreamAdapter and OutputStreamAdapter from hotrod-client
6. Removed InternalCacheEntryMarshaller from remotecachestore

Modified: branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/BdbjeCacheStore.java
===================================================================
--- branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/BdbjeCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/BdbjeCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -21,7 +21,7 @@
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheLoaderMetadata;
 import org.infinispan.loaders.modifications.Modification;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.util.ReflectionUtil;
 import org.infinispan.util.logging.Log;
@@ -90,12 +90,12 @@
     * @see BdbjeCacheStoreConfig
     */
    @Override
-   public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       BdbjeCacheStoreConfig cfg = (BdbjeCacheStoreConfig) config;
       init(cfg, new BdbjeResourceFactory(cfg), cache, m);
    }
 
-   void init(BdbjeCacheStoreConfig cfg, BdbjeResourceFactory factory, Cache cache, Marshaller m) throws CacheLoaderException {
+   void init(BdbjeCacheStoreConfig cfg, BdbjeResourceFactory factory, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       if (trace) log.trace("initializing BdbjeCacheStore");
       printLicense();
       super.init(cfg, cache, m);

Modified: branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/BdbjeResourceFactory.java
===================================================================
--- branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/BdbjeResourceFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/BdbjeResourceFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -10,8 +10,7 @@
 import com.sleepycat.util.ExceptionUnwrapper;
 import org.infinispan.CacheException;
 import org.infinispan.container.entries.InternalCacheEntry;
-import org.infinispan.loaders.CacheLoaderException;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -94,7 +93,7 @@
      * @throws com.sleepycat.je.DatabaseException
      *          if the StoredMap cannot be opened.
      */
-    public StoredMap<Object, InternalCacheEntry> createStoredMapViewOfDatabase(Database database, StoredClassCatalog classCatalog, Marshaller m) throws DatabaseException {
+    public StoredMap<Object, InternalCacheEntry> createStoredMapViewOfDatabase(Database database, StoredClassCatalog classCatalog, StreamingMarshaller m) throws DatabaseException {
         EntryBinding<Object> storedEntryKeyBinding =
                 new SerialBinding<Object>(classCatalog, Object.class);
         EntryBinding<InternalCacheEntry> storedEntryValueBinding = new InternalCacheEntryBinding(m);
@@ -116,7 +115,7 @@
      * @throws com.sleepycat.je.DatabaseException
      *          if the StoredMap cannot be opened.
      */
-    public StoredSortedMap<Long, Object> createStoredSortedMapForKeyExpiry(Database database, StoredClassCatalog classCatalog, Marshaller marshaller) throws DatabaseException {
+    public StoredSortedMap<Long, Object> createStoredSortedMapForKeyExpiry(Database database, StoredClassCatalog classCatalog, StreamingMarshaller marshaller) throws DatabaseException {
         EntryBinding<Long> expiryKeyBinding =
                 new SerialBinding<Long>(classCatalog, Long.class);
         EntryBinding<Object> expiryValueBinding =

Modified: branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/InternalCacheEntryBinding.java
===================================================================
--- branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/InternalCacheEntryBinding.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/bdbje/src/main/java/org/infinispan/loaders/bdbje/InternalCacheEntryBinding.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -4,14 +4,14 @@
 import com.sleepycat.je.DatabaseEntry;
 import com.sleepycat.util.RuntimeExceptionWrapper;
 import org.infinispan.container.entries.InternalCacheEntry;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 
 import java.io.IOException;
 
 class InternalCacheEntryBinding implements EntryBinding<InternalCacheEntry> {
-   Marshaller m;
+   StreamingMarshaller m;
 
-   InternalCacheEntryBinding(Marshaller m) {
+   InternalCacheEntryBinding(StreamingMarshaller m) {
       this.m = m;
    }
 

Modified: branches/4.1.x/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreIntegrationVamTest.java
===================================================================
--- branches/4.1.x/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreIntegrationVamTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreIntegrationVamTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.bdbje;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "unit", enabled = true, testName = "loaders.bdbje.BdbjeCacheStoreIntegrationVamTest")
 public class BdbjeCacheStoreIntegrationVamTest extends BdbjeCacheStoreIntegrationTest {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreTest.java
===================================================================
--- branches/4.1.x/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -16,7 +16,7 @@
 import org.infinispan.container.entries.InternalEntryFactory;
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.modifications.Store;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.TestObjectStreamMarshaller;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.transaction.xa.GlobalTransactionFactory;
@@ -88,12 +88,12 @@
       }
 
       @Override
-      public StoredMap createStoredMapViewOfDatabase(Database database, StoredClassCatalog classCatalog, Marshaller m) throws DatabaseException {
+      public StoredMap createStoredMapViewOfDatabase(Database database, StoredClassCatalog classCatalog, StreamingMarshaller m) throws DatabaseException {
          return cacheMap;
       }
 
       @Override
-      public StoredSortedMap<Long, Object> createStoredSortedMapForKeyExpiry(Database database, StoredClassCatalog classCatalog, Marshaller marshaller) throws DatabaseException {
+      public StoredSortedMap<Long, Object> createStoredSortedMapForKeyExpiry(Database database, StoredClassCatalog classCatalog, StreamingMarshaller marshaller) throws DatabaseException {
          return expiryMap;
       }
 

Modified: branches/4.1.x/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java
===================================================================
--- branches/4.1.x/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -8,15 +8,13 @@
 import org.infinispan.loaders.BaseCacheStoreTest;
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheStore;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.test.TestingUtil;
 import org.jclouds.blobstore.BlobStore;
-import org.jclouds.blobstore.BlobStoreContext;
 import org.jclouds.blobstore.domain.Blob;
 import org.jclouds.blobstore.domain.PageSet;
 import org.jclouds.blobstore.domain.StorageMetadata;
 import org.jclouds.blobstore.options.ListContainerOptions;
-import org.jgroups.protocols.TUNNEL;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.BeforeTest;
@@ -33,7 +31,6 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
-import java.util.concurrent.TimeUnit;
 
 import static org.testng.Assert.assertEquals;
 
@@ -146,7 +143,7 @@
       cs.store(InternalEntryFactory.create("k2", "v2", -1, -1));
       cs.store(InternalEntryFactory.create("k3", "v3", -1, -1));
 
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       ObjectOutput oo = marshaller.startObjectOutput(out, false);
       try {
@@ -220,7 +217,7 @@
       cs.store(InternalEntryFactory.create("k2", "v2", -1, -1));
       cs.store(InternalEntryFactory.create("k3", "v3", -1, -1));
 
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       byte[] dummyStartBytes = {1, 2, 3, 4, 5, 6, 7, 8};
       byte[] dummyEndBytes = {8, 7, 6, 5, 4, 3, 2, 1};

Modified: branches/4.1.x/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationVamTest.java
===================================================================
--- branches/4.1.x/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationVamTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/cloud/src/integrationtest/java/org/infinispan/loaders/cloud/CloudCacheStoreIntegrationVamTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.cloud;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "unit", sequential = true, testName = "loaders.cloud.CloudCacheStoreIntegrationVamTest")
 public class CloudCacheStoreIntegrationVamTest extends CloudCacheStoreIntegrationTest {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java
===================================================================
--- branches/4.1.x/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -15,7 +15,7 @@
 import org.infinispan.loaders.bucket.Bucket;
 import org.infinispan.loaders.bucket.BucketBasedCacheStore;
 import org.infinispan.loaders.modifications.Modification;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 import org.jboss.util.stream.Streams;
@@ -98,13 +98,13 @@
    }
 
    @Override
-   public void init(CacheLoaderConfig cfg, Cache<?, ?> cache, Marshaller m)
+   public void init(CacheLoaderConfig cfg, Cache<?, ?> cache, StreamingMarshaller m)
          throws CacheLoaderException {
       this.cfg = (CloudCacheStoreConfig) cfg;
       init(cfg, cache, m, null, null, null, true);
    }
 
-   public void init(CacheLoaderConfig cfg, Cache<?, ?> cache, Marshaller m, BlobStoreContext ctx,
+   public void init(CacheLoaderConfig cfg, Cache<?, ?> cache, StreamingMarshaller m, BlobStoreContext ctx,
                     BlobStore blobStore, AsyncBlobStore asyncBlobStore, boolean constructInternalBlobstores)
          throws CacheLoaderException {
       super.init(cfg, cache, m);

Modified: branches/4.1.x/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreTest.java
===================================================================
--- branches/4.1.x/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -8,10 +8,7 @@
 import org.infinispan.loaders.BaseCacheStoreTest;
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheStore;
-import org.infinispan.marshall.Marshaller;
-import org.jclouds.blobstore.BlobStoreContext;
-import org.jclouds.blobstore.BlobStoreContextBuilder;
-import org.jclouds.blobstore.TransientBlobStoreContextBuilder;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -99,7 +96,7 @@
       cs.store(InternalEntryFactory.create("k2", "v2", -1, -1));
       cs.store(InternalEntryFactory.create("k3", "v3", -1, -1));
 
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       ObjectOutput oo = marshaller.startObjectOutput(out, false);
       try {
@@ -169,7 +166,7 @@
       cs.store(InternalEntryFactory.create("k2", "v2", -1, -1));
       cs.store(InternalEntryFactory.create("k3", "v3", -1, -1));
 
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       byte[] dummyStartBytes = {1, 2, 3, 4, 5, 6, 7, 8};
       byte[] dummyEndBytes = {8, 7, 6, 5, 4, 3, 2, 1};

Modified: branches/4.1.x/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreVamTest.java
===================================================================
--- branches/4.1.x/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreVamTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/cloud/src/test/java/org/infinispan/loaders/cloud/CloudCacheStoreVamTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.cloud;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "unit", testName = "loaders.cloud.CloudCacheStoreVamTest")
 public class CloudCacheStoreVamTest extends CloudCacheStoreTest {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/DataManipulationHelper.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/DataManipulationHelper.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/DataManipulationHelper.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -24,7 +24,7 @@
 import org.infinispan.container.entries.InternalCacheEntry;
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -51,10 +51,10 @@
 
    private ConnectionFactory connectionFactory;
    private TableManipulation tableManipulation;
-   protected Marshaller marshaller;
+   protected StreamingMarshaller marshaller;
 
 
-   public DataManipulationHelper(ConnectionFactory connectionFactory, TableManipulation tableManipulation, Marshaller marshaller) {
+   public DataManipulationHelper(ConnectionFactory connectionFactory, TableManipulation tableManipulation, StreamingMarshaller marshaller) {
       this.connectionFactory = connectionFactory;
       this.tableManipulation = tableManipulation;
       this.marshaller = marshaller;

Modified: branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/JdbcUtil.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/JdbcUtil.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/JdbcUtil.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -23,7 +23,7 @@
 
 import org.infinispan.io.ByteBuffer;
 import org.infinispan.loaders.CacheLoaderException;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -73,7 +73,7 @@
       }
    }
 
-   public static ByteBuffer marshall(Marshaller marshaller, Object bucket) throws CacheLoaderException {
+   public static ByteBuffer marshall(StreamingMarshaller marshaller, Object bucket) throws CacheLoaderException {
       try {
          return marshaller.objectToBuffer(bucket);
       } catch (IOException e) {
@@ -83,7 +83,7 @@
       }
    }
 
-   public static Object unmarshall(Marshaller marshaller, InputStream inputStream) throws CacheLoaderException {
+   public static Object unmarshall(StreamingMarshaller marshaller, InputStream inputStream) throws CacheLoaderException {
       try {
          return marshaller.objectFromInputStream(inputStream);
       } catch (IOException e) {

Modified: branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStore.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -33,7 +33,7 @@
 import org.infinispan.loaders.jdbc.JdbcUtil;
 import org.infinispan.loaders.jdbc.TableManipulation;
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -83,7 +83,7 @@
    private DataManipulationHelper dmHelper;
    private String cacheName;
 
-   public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       if (log.isTraceEnabled())
          log.trace("Initializing JdbcBinaryCacheStore " + config);
       super.init(config, cache, m);

Modified: branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ConnectionFactory.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ConnectionFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ConnectionFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -38,11 +38,7 @@
     * name.
     */
    public static ConnectionFactory getConnectionFactory(String connectionFactoryClass) throws CacheLoaderException {
-      try {
-         return (ConnectionFactory) Util.getInstance(connectionFactoryClass);
-      } catch (Exception e) {
-         throw new CacheLoaderException(e);
-      }
+      return (ConnectionFactory) Util.getInstance(connectionFactoryClass);
    }
 
    /**

Modified: branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/SimpleConnectionFactory.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/SimpleConnectionFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/SimpleConnectionFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -78,17 +78,8 @@
    }
 
    private void loadDriver(String driverClass) throws CacheLoaderException {
-      try {
-         if (log.isTraceEnabled()) {
-            log.trace("Attempting to load driver " + driverClass);
-         }
-         Util.getInstance(driverClass);
-      }
-      catch (Throwable th) {
-         String message = "Failed loading driver with class: '" + driverClass + "'";
-         log.error(message, th);
-         throw new CacheLoaderException(message, th);
-      }
+      if (log.isTraceEnabled()) log.trace("Attempting to load driver " + driverClass);
+      Util.getInstance(driverClass);
    }
 
    public String getConnectionUrl() {
@@ -106,8 +97,8 @@
    @Override
    public String toString() {
       return "SimpleConnectionFactory{" +
-            "connectionUrl='" + connectionUrl + '\'' +
-            ", userName='" + userName + '\'' +
-            "} " + super.toString();
+              "connectionUrl='" + connectionUrl + '\'' +
+              ", userName='" + userName + '\'' +
+              "} " + super.toString();
    }
 }

Modified: branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStore.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -32,7 +32,7 @@
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory;
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
 import org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -72,7 +72,7 @@
    private ConnectionFactory sharedConnectionFactory;
 
    @Override
-   public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       super.init(config, cache, m);
       this.config = (JdbcMixedCacheStoreConfig) config;
       binaryCacheStore.init(this.config.getBinaryCacheStoreConfig(), cache, m);

Modified: branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStore.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -33,7 +33,7 @@
 import org.infinispan.loaders.jdbc.JdbcUtil;
 import org.infinispan.loaders.jdbc.TableManipulation;
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -84,7 +84,7 @@
    private DataManipulationHelper dmHelper;
    private String cacheName;
 
-   public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       super.init(config, cache, m);
       this.config = (JdbcStringBasedCacheStoreConfig) config;
       this.cacheName = cache.getName();

Modified: branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -34,7 +34,9 @@
  */
 public class JdbcStringBasedCacheStoreConfig extends AbstractNonDelegatingJdbcCacheStoreConfig {
 
-   /** The serialVersionUID */
+   /**
+    * The serialVersionUID
+    */
    private static final long serialVersionUID = 8835350707132331983L;
 
    private Key2StringMapper key2StringMapper;
@@ -72,11 +74,7 @@
     */
    public void setKey2StringMapperClass(String className) {
       testImmutability("key2StringMapper");
-      try {
-         key2StringMapper = (Key2StringMapper) Util.getInstance(className);
-      } catch (Exception e) {
-         throw new IllegalArgumentException("Could not load Key2StringMapper :'" + className + "'", e);
-      }
+      key2StringMapper = (Key2StringMapper) Util.getInstance(className);
    }
 
    /**
@@ -94,5 +92,5 @@
       JdbcStringBasedCacheStoreConfig result = (JdbcStringBasedCacheStoreConfig) super.clone();
       result.key2StringMapper = key2StringMapper;
       return result;
-   }   
+   }
 }

Modified: branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreVamTest.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreVamTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreVamTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.jdbc.binary;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "functional", testName = "loaders.jdbc.binary.JdbcBinaryCacheStoreVamTest")
 public class JdbcBinaryCacheStoreVamTest extends JdbcBinaryCacheStoreTest {   
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -33,7 +33,7 @@
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
 import org.infinispan.loaders.jdbc.stringbased.DefaultKey2StringMapper;
 import org.infinispan.loaders.jdbc.stringbased.Person;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.TestObjectStreamMarshaller;
 import org.infinispan.test.fwk.UnitTestDatabaseManager;
 import org.testng.annotations.AfterMethod;
@@ -133,7 +133,7 @@
       cacheStore.store(InternalEntryFactory.create(MIRCEA, "value1"));
       cacheStore.store(InternalEntryFactory.create(MANIK, "value2"));
       assertRowCounts(2, 2);
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       ObjectOutput oo = marshaller.startObjectOutput(out, false);
       try {
@@ -225,7 +225,7 @@
       assert value == rowCount : "Expected " + rowCount + " rows, actual value is " + value;
    }
 
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       return new TestObjectStreamMarshaller(false);
    }
 }

Modified: branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.jdbc.mixed;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "functional", testName = "loaders.jdbc.mixed.JdbcMixedCacheStoreVamTest")
 public class JdbcMixedCacheStoreVamTest extends JdbcMixedCacheStoreTest {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest2.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest2.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest2.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.jdbc.mixed;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "functional", testName = "loaders.jdbc.mixed.JdbcMixedCacheStoreVamTest2")
 public class JdbcMixedCacheStoreVamTest2 extends JdbcMixedCacheStoreTest2 {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -30,7 +30,7 @@
 import org.infinispan.loaders.jdbc.TableManipulation;
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory;
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.TestObjectStreamMarshaller;
 import org.infinispan.test.fwk.UnitTestDatabaseManager;
 import org.testng.annotations.AfterMethod;
@@ -163,7 +163,7 @@
       return store.getConnectionFactory();
    }
    
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       return new TestObjectStreamMarshaller(false);
    }
 }

Modified: branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.jdbc.stringbased;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "functional", testName = "loaders.jdbc.stringbased.JdbcStringBasedCacheStoreVamTest")
 public class JdbcStringBasedCacheStoreVamTest extends JdbcStringBasedCacheStoreTest {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest2.java
===================================================================
--- branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest2.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest2.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.jdbc.stringbased;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "functional", testName = "loaders.jdbc.stringbased.JdbcStringBasedCacheStoreVamTest2")
 public class JdbcStringBasedCacheStoreVamTest2 extends JdbcStringBasedCacheStoreTest2 {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmCacheStore.java
===================================================================
--- branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -20,7 +20,7 @@
 import org.infinispan.loaders.modifications.Modification;
 import org.infinispan.loaders.modifications.Remove;
 import org.infinispan.loaders.modifications.Store;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -76,7 +76,7 @@
    }
 
    @Override
-   public void init(CacheLoaderConfig clc, Cache cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig clc, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       super.init(clc, cache, m);
       this.config = (JdbmCacheStoreConfig) clc;
    }

Modified: branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmCacheStoreConfig.java
===================================================================
--- branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmCacheStoreConfig.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmCacheStoreConfig.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -9,27 +9,29 @@
 
 /**
  * Configures {@link JdbmCacheStore}.
- * 
+ *
  * @author Elias Ross
  * @author Galder Zamarreño
  * @since 4.0
  */
 public class JdbmCacheStoreConfig extends LockSupportCacheStoreConfig {
 
-   /** The serialVersionUID */
+   /**
+    * The serialVersionUID
+    */
    private static final long serialVersionUID = -3686035269816837880L;
-   /** 
+   /**
     * @configRef desc="A location on disk where the store can write internal files"
     */
    String location = "jdbm";
-   /** 
-    * @configRef desc="Comparator class used to sort the keys by the cache loader. 
+   /**
+    * @configRef desc="Comparator class used to sort the keys by the cache loader.
     * This should only need to be set when using keys that do not have a natural ordering."
     */
    String comparatorClassName = NaturalComparator.class.getName();
-   
-   /** 
-    * @configRef desc="Whenever a new entry is stored, an expiry entry is created and added 
+
+   /**
+    * @configRef desc="Whenever a new entry is stored, an expiry entry is created and added
     * to the a queue that is later consumed by the eviction thread. This parameter sets the size
     * of this queue."
     */
@@ -71,11 +73,7 @@
     * Returns a new comparator instance based on {@link #setComparatorClassName(String)}.
     */
    public Comparator createComparator() {
-      try {
-         return (Comparator) Util.getInstance(comparatorClassName);
-      } catch (Exception e) {
-         throw new CacheException(e);
-      }
+      return (Comparator) Util.getInstance(comparatorClassName);
    }
 
 }

Modified: branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmSerializer.java
===================================================================
--- branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmSerializer.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbm/src/main/java/org/infinispan/loaders/jdbm/JdbmSerializer.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -2,12 +2,12 @@
 
 import java.io.IOException;
 
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 
 import jdbm.helper.Serializer;
 
 /**
- * Uses the configured (runtime) {@link Marshaller} of the cache.
+ * Uses the configured (runtime) {@link org.infinispan.marshall.StreamingMarshaller} of the cache.
  * This Serializer is thus not really serializiable.
  * 
  * @author Elias Ross
@@ -15,12 +15,12 @@
 @SuppressWarnings("serial")
 public class JdbmSerializer implements Serializer {
     
-    private transient Marshaller marshaller;
+    private transient StreamingMarshaller marshaller;
 
     /**
      * Constructs a new JdbmSerializer.
      */
-    public JdbmSerializer(Marshaller marshaller) {
+    public JdbmSerializer(StreamingMarshaller marshaller) {
         if (marshaller == null)
             throw new NullPointerException("marshaller");
         this.marshaller = marshaller;

Modified: branches/4.1.x/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreVamTest.java
===================================================================
--- branches/4.1.x/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreVamTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreVamTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.jdbm;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "unit", testName = "loaders.jdbm.JdbmCacheStoreVamTest")
 public class JdbmCacheStoreVamTest extends JdbmCacheStoreTest {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Deleted: branches/4.1.x/cachestore/remote/src/main/java/org/infinispan/loaders/remote/InternalCacheEntryMarshaller.java
===================================================================
--- branches/4.1.x/cachestore/remote/src/main/java/org/infinispan/loaders/remote/InternalCacheEntryMarshaller.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/remote/src/main/java/org/infinispan/loaders/remote/InternalCacheEntryMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,40 +0,0 @@
-package org.infinispan.loaders.remote;
-
-import org.infinispan.client.hotrod.HotRodMarshaller;
-import org.infinispan.client.hotrod.exceptions.HotRodClientException;
-import org.infinispan.marshall.Marshaller;
-
-import java.io.IOException;
-
-/**
- * Marshaller used internally by the remote cache store.
- *
- * @author Mircea.Markus at jboss.com
- * @since 4.1
- */
-public class InternalCacheEntryMarshaller implements HotRodMarshaller {
-
-   public final Marshaller marshaller;
-
-   public InternalCacheEntryMarshaller(Marshaller marshaller) {
-      this.marshaller = marshaller;
-   }
-
-   @Override
-   public byte[] marshallObject(Object toMarshall) {
-      try {
-         return marshaller.objectToByteBuffer(toMarshall);
-      } catch (IOException e) {
-         throw new HotRodClientException(e);
-      }
-   }
-
-   @Override
-   public Object readObject(byte[] bytes) {
-      try {
-         return marshaller.objectFromByteBuffer(bytes);
-      } catch (Exception e) {
-         throw new HotRodClientException(e);
-      }
-   }
-}

Modified: branches/4.1.x/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStore.java
===================================================================
--- branches/4.1.x/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/cachestore/remote/src/main/java/org/infinispan/loaders/remote/RemoteCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -9,7 +9,7 @@
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheLoaderMetadata;
 import org.infinispan.manager.CacheContainer;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -124,7 +124,7 @@
    }
 
    @Override
-   public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache<?, ?> cache, StreamingMarshaller m) throws CacheLoaderException {
       super.init(config, cache, m);
       this.config = (RemoteCacheStoreConfig) config;
    }
@@ -132,10 +132,10 @@
    @Override
    public void start() throws CacheLoaderException {
       super.start();
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
 
       if (marshaller == null) {throw new IllegalStateException("Null marshaller not allowed!");}
-      remoteCacheManager = new RemoteCacheManager(new InternalCacheEntryMarshaller(marshaller), config.getHotRodClientProperties());
+      remoteCacheManager = new RemoteCacheManager(marshaller, config.getHotRodClientProperties());
       if (config.getRemoteCacheName().equals(CacheContainer.DEFAULT_CACHE_NAME))
          remoteCache = remoteCacheManager.getCache();
       else

Deleted: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/HotRodMarshaller.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/HotRodMarshaller.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/HotRodMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,26 +0,0 @@
-package org.infinispan.client.hotrod;
-
-import net.jcip.annotations.ThreadSafe;
-
-import java.util.Properties;
-
-/**
- * Used for un/marshalling objects sent between hotrod client and server (hotrod is a binary protocol).
- * A single instance of this class is shared by all threads, so this class needs to be thread safe.
- *
- * @author Mircea.Markus at jboss.com
- * @since 4.1
- */
- at ThreadSafe 
-public interface HotRodMarshaller {
-
-   void init(Properties config);
-
-   /**
-    * @param isKeyHint if true the object passed to the marshaller is a key. This info can be used to optimize the
-    * size of the allocated byte[].
-    */
-   byte[] marshallObject(Object toMarshall, boolean isKeyHint);
-
-   Object readObject(byte[] bytes);
-}

Modified: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -5,12 +5,16 @@
 import org.infinispan.client.hotrod.impl.protocol.HotRodOperations;
 import org.infinispan.client.hotrod.impl.protocol.HotRodOperationsImpl;
 import org.infinispan.client.hotrod.impl.RemoteCacheImpl;
-import org.infinispan.client.hotrod.impl.SerializationMarshaller;
 import org.infinispan.client.hotrod.impl.transport.TransportFactory;
-import org.infinispan.client.hotrod.impl.transport.VHelper;
+
 import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory;
+import org.infinispan.config.ConfigurationException;
 import org.infinispan.executors.ExecutorFactory;
 import org.infinispan.manager.CacheContainer;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.jboss.JBossMarshaller;
+import org.infinispan.util.TypedProperties;
+import org.infinispan.util.Util;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -27,6 +31,8 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import static org.infinispan.util.Util.getInstance;
+
 /**
  * Factory for {@link org.infinispan.client.hotrod.RemoteCache}s. <p/> <p> <b>Lifecycle:</b> </p> In order to be able to
  * use an {@link org.infinispan.client.hotrod.RemoteCache}, the {@link org.infinispan.client.hotrod.RemoteCacheManager}
@@ -43,32 +49,32 @@
  * <p/>
  * <p/>
  * <b>Configuration:</b>
- * <p>
- *  The cache manager is configured through a {@link java.util.Properties} object passed to the C-tor (there are also
- *  "simplified" C-tors that rely on default values). Bellow is the list of supported configuration elements:
+ * <p/>
+ * The cache manager is configured through a {@link java.util.Properties} object passed to the C-tor (there are also
+ * "simplified" constructors that rely on default values). Bellow is the list of supported configuration elements:
  * <ul>
- *  <li>
- *  hotrod-servers - the initial list of hotrod servers to connect to, specified in the following format: host1:port1;host2:port2...
- *  At least one host:port must be specified.
- *  </li>
- *  <li>
- *  request-balancing-strategy - for replicated (vs distributed) hotrod server clusters, the client balances requests to the
- *  servers according to this strategy. Defaults to {@link org.infinispan.client.hotrod.impl.transport.tcp.RoundRobinBalancingStrategy}
- *  </li>
- *  <li>
+ * <li>
+ * hotrod-servers - the initial list of hotrod servers to connect to, specified in the following format: host1:port1;host2:port2...
+ * At least one host:port must be specified.
+ * </li>
+ * <li>
+ * request-balancing-strategy - for replicated (vs distributed) hotrod server clusters, the client balances requests to the
+ * servers according to this strategy. Defaults to {@link org.infinispan.client.hotrod.impl.transport.tcp.RoundRobinBalancingStrategy}
+ * </li>
+ * <li>
  * force-return-value - weather or not to implicitly {@link org.infinispan.client.hotrod.Flag#FORCE_RETURN_VALUE} for all calls.
  * Defaults to false.
  * </li>
- *  <li>
+ * <li>
  * tcp-no-delay - TCP no delay flag switch. Defaults to true.
-    * </li>
+ * </li>
  *  <li>
  * ping-on-startup - if true, a ping request is sent to a back end server in order to fetch cluster's topology. True by default.
-    </li>
+ * </li>
  * <br/>
  * <i>below is connection pooling config</i>:
  * <p/>
- *  <li>maxActive - controls the maximum number of connections per server that are allocated (checked out to client threads, or idle in
+ * <li>maxActive - controls the maximum number of connections per server that are allocated (checked out to client threads, or idle in
  * the pool) at one time. When non-positive, there is no limit to the number of connections per server. When maxActive
  * is reached, the connection pool for that server is said to be exhausted. The default setting for this parameter is
  * -1, i.e. there is no limit.</li>
@@ -76,41 +82,41 @@
  * servers. When non-positive, there is no limit to the total number of persistent connections in circulation. When
  * maxTotal is exceeded, all connections pools are exhausted. The default setting for this parameter is -1 (no limit).
  * </li>
- *
+ * <p/>
  * <li>maxIdle - controls the maximum number of idle persistent connections, per server, at any time. When negative, there is no limit
  * to the number of connections that may be idle per server. The default setting for this parameter is -1.</li>
- *
+ * <p/>
  * <li>
- *   whenExhaustedAction - specifies what happens when asking for a connection from a server's pool, and that pool is exhausted. Possible values:
- *   <ul>
- *     <li> 0 - an exception will be thrown to the calling user</li>
- *     <li> 1 - the caller will block (invoke waits until a new or idle connections is available.
- *     <li> 2 - a new persistent connection will be created and and returned (essentially making maxActive meaningless.) </li>
- *   </ul>
- *   The default whenExhaustedAction setting is 1.
+ * whenExhaustedAction - specifies what happens when asking for a connection from a server's pool, and that pool is exhausted. Possible values:
+ * <ul>
+ * <li> 0 - an exception will be thrown to the calling user</li>
+ * <li> 1 - the caller will block (invoke waits until a new or idle connections is available.
+ * <li> 2 - a new persistent connection will be created and and returned (essentially making maxActive meaningless.) </li>
+ * </ul>
+ * The default whenExhaustedAction setting is 1.
  * </li>
- *
+ * <p/>
  * <li>
  * Optionally, one may configure the pool to examine and possibly evict connections as they sit idle in the pool and to
  * ensure that a minimum number of idle connections is maintained for each server. This is performed by an "idle connection
  * eviction" thread, which runs asynchronously. The idle object evictor does not lock the pool
  * throughout its execution.  The idle connection eviction thread may be configured using the following attributes:
  * <ul>
- *  <li>timeBetweenEvictionRunsMillis - indicates how long the eviction thread should sleep before "runs" of examining idle
- *  connections. When non-positive, no eviction thread will be launched. The default setting for this parameter is
- *  2 minutes </li>
- *   <li> minEvictableIdleTimeMillis - specifies the minimum amount of time that an connection may sit idle in the pool before it
- *   is eligible for eviction due to idle time. When non-positive, no connection will be dropped from the pool due to
- *   idle time alone. This setting has no effect unless timeBetweenEvictionRunsMillis > 0. The default setting for this
- *   parameter is 1800000(30 minutes). </li>
- *   <li> testWhileIdle - indicates whether or not idle connections should be validated by sending an TCP packet to the server,
- *   during idle connection eviction runs.  Connections that fail to validate will be dropped from the pool. This setting
- *   has no effect unless timeBetweenEvictionRunsMillis > 0.  The default setting for this parameter is true.
- *   </li>
- *   <li>minIdle - sets a target value for the minimum number of idle connections (per server) that should always be available.
- *   If this parameter is set to a positive number and timeBetweenEvictionRunsMillis > 0, each time the idle connection
- *   eviction thread runs, it will try to create enough idle instances so that there will be minIdle idle instances
- *   available for each server.  The default setting for this parameter is 1. </li>
+ * <li>timeBetweenEvictionRunsMillis - indicates how long the eviction thread should sleep before "runs" of examining idle
+ * connections. When non-positive, no eviction thread will be launched. The default setting for this parameter is
+ * 2 minutes </li>
+ * <li> minEvictableIdleTimeMillis - specifies the minimum amount of time that an connection may sit idle in the pool before it
+ * is eligible for eviction due to idle time. When non-positive, no connection will be dropped from the pool due to
+ * idle time alone. This setting has no effect unless timeBetweenEvictionRunsMillis > 0. The default setting for this
+ * parameter is 1800000(30 minutes). </li>
+ * <li> testWhileIdle - indicates whether or not idle connections should be validated by sending an TCP packet to the server,
+ * during idle connection eviction runs.  Connections that fail to validate will be dropped from the pool. This setting
+ * has no effect unless timeBetweenEvictionRunsMillis > 0.  The default setting for this parameter is true.
+ * </li>
+ * <li>minIdle - sets a target value for the minimum number of idle connections (per server) that should always be available.
+ * If this parameter is set to a positive number and timeBetweenEvictionRunsMillis > 0, each time the idle connection
+ * eviction thread runs, it will try to create enough idle instances so that there will be minIdle idle instances
+ * available for each server.  The default setting for this parameter is 1. </li>
  * </ul>
  * </li>
  * <li>
@@ -137,45 +143,49 @@
 
    public static final String OVERRIDE_HOTROD_SERVERS = "infinispan.hotrod.client.servers";
 
+   private static final String KEY_SIZE = "marshaller.default-array-size.key";
+   private static final String VALUE_SIZE = "marshaller.default-array-size.value";
 
-   private Properties props;
+   private TypedProperties props;
    private TransportFactory transportFactory;
-   private HotRodMarshaller hotRodMarshaller;
+   private Marshaller marshaller;
    private boolean started = false;
    private boolean forceReturnValueDefault = false;
    private ExecutorService asyncExecutorService;
    private final Map<String, RemoteCacheImpl> cacheName2RemoteCache = new HashMap<String, RemoteCacheImpl>();
    private AtomicInteger topologyId = new AtomicInteger();
+   private static final int DEFAULT_KEY_SIZE = 64;
+   private static final int DEFAULT_VALUE_SIZE = 512;
 
 
    /**
-    * Builds a remote cache manager that relies on the provided {@link org.infinispan.client.hotrod.HotRodMarshaller} for marshalling
-    * keys and values to be send over to the remote infinispan cluster.
-    * @param hotRodMarshaller marshaller implementation to be used. This will overwrite the marshaller from the properties (if any).
-    * @param props other properties
-    * @param start weather or not to start the manager on return from the constructor.
+    * Builds a remote cache manager that relies on the provided {@link Marshaller} for marshalling
+    * keys and values to be send over to the remote Infinispan cluster.
+    *
+    * @param marshaller marshaller implementation to be used
+    * @param props      other properties
+    * @param start      weather or not to start the manager on return from the constructor.
     */
-   public RemoteCacheManager(HotRodMarshaller hotRodMarshaller, Properties props, boolean start) {
+   public RemoteCacheManager(Marshaller marshaller, Properties props, boolean start) {
       this(props);
-      setHotRodMarshaller(hotRodMarshaller);
-      if (log.isTraceEnabled()) {
-         log.trace("Using explicitly set marshaller: " + hotRodMarshaller);
-      }
+      setMarshaller(marshaller);
+      if (log.isTraceEnabled())
+         log.trace("Using explicitly set marshaller type: " + marshaller.getClass().getName());
       if (start) start();
    }
 
    /**
     * Same as {@link org.infinispan.client.hotrod.RemoteCacheManager#RemoteCacheManager(HotRodMarshaller, java.util.Properties, boolean)} with start = true.
     */
-   public RemoteCacheManager(HotRodMarshaller hotRodMarshaller, Properties props) {
-      this(hotRodMarshaller, props, false);
+   public RemoteCacheManager(Marshaller marshaller, Properties props) {
+      this(marshaller, props, false);
    }
 
    /**
     * Build a cache manager based on supplied properties.
     */
    public RemoteCacheManager(Properties props, boolean start) {
-      this.props = props;
+      this.props = TypedProperties.toTypedProperties(props);
       if (start) start();
    }
 
@@ -199,7 +209,7 @@
       InputStream stream = loader.getResourceAsStream(HOTROD_CLIENT_PROPERTIES);
       if (stream == null) {
          log.warn("Could not find '" + HOTROD_CLIENT_PROPERTIES + "' file in classpath, using defaults.");
-         props = new Properties();
+         props = new TypedProperties();
       } else {
          loadFromStream(stream);
       }
@@ -219,7 +229,7 @@
     * @param start weather or not to start the RemoteCacheManager.
     */
    public RemoteCacheManager(String host, int port, boolean start) {
-      props = new Properties();
+      props = new TypedProperties();
       props.put(TransportFactory.CONF_HOTROD_SERVERS, host + ":" + port);
       if (start) start();
    }
@@ -236,7 +246,7 @@
     * server.
     */
    public RemoteCacheManager(String servers, boolean start) {
-      props = new Properties();
+      props = new TypedProperties();
       props.put(TransportFactory.CONF_HOTROD_SERVERS, servers);
       if (start) start();
    }
@@ -299,23 +309,24 @@
          factory = TcpTransportFactory.class.getName();
          log.info("'transport-factory' factory not specified, using " + factory);
       }
-      transportFactory = (TransportFactory) VHelper.newInstance(factory);
+      transportFactory = (TransportFactory) getInstance(factory);
       String servers = props.getProperty(CONF_HOTROD_SERVERS);
       transportFactory.start(props, getStaticConfiguredServers(servers), topologyId);
-      if (hotRodMarshaller == null) {
-         String hotrodMarshallerClass = props.getProperty("marshaller");
-         if (hotrodMarshallerClass == null) {
-            hotrodMarshallerClass = SerializationMarshaller.class.getName();
-            log.info("'marshaller' not specified, using " + hotrodMarshallerClass);
+      if (marshaller == null) {
+         String marshaller = props.getProperty("marshaller");
+         if (marshaller == null) {
+            marshaller = JBossMarshaller.class.getName();
+            log.info("'marshaller' not specified, using " + marshaller);
          }
-         setHotRodMarshaller((HotRodMarshaller)VHelper.newInstance(hotrodMarshallerClass));
+         setMarshaller((Marshaller) getInstance(marshaller));
       }
 
       String asyncExecutorClass = DefaultAsyncExecutorFactory.class.getName();
       if (props.contains("asyn-executor-factory")) {
          asyncExecutorClass = props.getProperty("asyn-executor-factory");
       }
-      ExecutorFactory executorFactory = (ExecutorFactory) VHelper.newInstance(asyncExecutorClass);
+      ExecutorFactory executorFactory = null;
+      executorFactory = (ExecutorFactory) getInstance(asyncExecutorClass);
       asyncExecutorService = executorFactory.getExecutor(props);
 
 
@@ -341,7 +352,7 @@
    }
 
    private void loadFromStream(InputStream stream) {
-      props = new Properties();
+      props = new TypedProperties();
       try {
          props.load(stream);
       } catch (IOException e) {
@@ -366,7 +377,9 @@
 
    private <K, V> void startRemoteCache(RemoteCacheImpl<K, V> result) {
       HotRodOperations hotRodOperations = new HotRodOperationsImpl(result.getName(), transportFactory, topologyId);
-      result.init(hotRodOperations, hotRodMarshaller, asyncExecutorService);
+      result.init(hotRodOperations, marshaller, asyncExecutorService,
+              props.getIntProperty(KEY_SIZE, DEFAULT_KEY_SIZE),
+              props.getIntProperty(VALUE_SIZE, DEFAULT_VALUE_SIZE));
    }
 
    private Set<InetSocketAddress> getStaticConfiguredServers(String servers) {
@@ -399,8 +412,7 @@
       return new String[]{t.nextToken(), t.nextToken()};
    }
 
-   private void setHotRodMarshaller(HotRodMarshaller hotRodMarshaller) {
-      this.hotRodMarshaller = hotRodMarshaller;
-      hotRodMarshaller.init(props);
+   private void setMarshaller(Marshaller marshaller) {
+      this.marshaller = marshaller;
    }
 }

Modified: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/RemoteCacheImpl.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/RemoteCacheImpl.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/RemoteCacheImpl.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,19 +1,21 @@
 package org.infinispan.client.hotrod.impl;
 
 import org.infinispan.client.hotrod.Flag;
-import org.infinispan.client.hotrod.HotRodMarshaller;
 import org.infinispan.client.hotrod.RemoteCache;
 import org.infinispan.client.hotrod.RemoteCacheManager;
 import org.infinispan.client.hotrod.ServerStatistics;
 import org.infinispan.client.hotrod.Version;
 import org.infinispan.client.hotrod.VersionedValue;
 import org.infinispan.client.hotrod.exceptions.RemoteCacheManagerNotStartedException;
+import org.infinispan.client.hotrod.exceptions.TransportException;
 import org.infinispan.client.hotrod.impl.async.NotifyingFutureImpl;
 import org.infinispan.client.hotrod.impl.protocol.HotRodOperations;
+import org.infinispan.marshall.Marshaller;
 import org.infinispan.util.concurrent.NotifyingFuture;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
+import java.io.IOException;
 import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
@@ -32,11 +34,13 @@
 
    private ThreadLocal<Flag[]> flagsMap = new ThreadLocal<Flag[]>();
    private HotRodOperations operations;
-   private HotRodMarshaller marshaller;
+   private Marshaller marshaller;
    private final String name;
    private final RemoteCacheManager remoteCacheManager;
    private volatile ExecutorService executorService;
    private volatile boolean forceReturnValue;
+   private int estimateKeySize;
+   private int estimateValueSize;
 
    public RemoteCacheImpl(RemoteCacheManager rcm, String name, boolean forceReturnValue) {
       if (log.isTraceEnabled()) {
@@ -47,16 +51,26 @@
       this.remoteCacheManager = rcm;
    }
 
-   public void init(HotRodOperations operations, HotRodMarshaller marshaller, ExecutorService executorService) {
+   public void init(HotRodOperations operations, Marshaller marshaller, ExecutorService executorService, int estimateKeySize, int estimateValueSize) {
       this.operations = operations;
       this.marshaller = marshaller;
       this.executorService = executorService;
+      this.estimateKeySize = estimateKeySize;
+      this.estimateValueSize = estimateValueSize;
    }
 
    public RemoteCacheManager getRemoteCacheManager() {
       return remoteCacheManager;
    }
 
+   private byte[] obj2bytes(Object o, boolean isKey) {
+      try {
+         return marshaller.objectToByteBuffer(o, isKey ? estimateKeySize : estimateValueSize);
+      } catch (IOException ioe) {
+         throw new TransportException("Unable to marshall object of type [" + o.getClass().getName() + "]", ioe);
+      }
+   }
+
    @Override
    public boolean removeWithVersion(K key, long version) {
       assertRemoteCacheManagerIsStarted();
@@ -323,15 +337,13 @@
       return flags;
    }
 
-   private byte[] obj2bytes(Object obj, boolean isKey) {
-      return this.marshaller.marshallObject(obj, isKey);
-   }
-
    private Object bytes2obj(byte[] bytes) {
-      if (bytes == null) {
-         return null;
+      if (bytes == null) return null;
+      try {
+         return marshaller.objectFromByteBuffer(bytes);
+      } catch (Exception e) {
+         throw new TransportException("Unable to unmarshall byte stream", e);
       }
-      return this.marshaller.readObject(bytes);
    }
 
    private VersionedValue<V> binary2VersionedValue(BinaryVersionedValue value) {

Deleted: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/SerializationMarshaller.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/SerializationMarshaller.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/SerializationMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,81 +0,0 @@
-package org.infinispan.client.hotrod.impl;
-
-import org.infinispan.client.hotrod.HotRodMarshaller;
-import org.infinispan.client.hotrod.exceptions.HotRodClientException;
-import org.infinispan.io.ExposedByteArrayOutputStream;
-import org.infinispan.util.Util;
-import org.infinispan.util.logging.Log;
-import org.infinispan.util.logging.LogFactory;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Arrays;
-import java.util.Properties;
-
-/**
- * Default marshaller implementation based on object serialization.
- * Supports two configuration elements:
- * <ul>
- *  <li>marshaller.default-array-size.key - the size of the {@link ExposedByteArrayOutputStream} that will be
- *   created for marshalling keys</li>
- *  <li> marshaller.default-array-size.value - the size of the {@link ExposedByteArrayOutputStream} that will be
- *   created for marshalling values
- *  </li>
- * </ul>
- *
- * @author Mircea.Markus at jboss.com
- * @since 4.1
- */
-public class SerializationMarshaller implements HotRodMarshaller {
-
-   private static Log log = LogFactory.getLog(SerializationMarshaller.class);
-
-   private volatile int defaultArraySizeForKey = 128;
-   private volatile int defaultArraySizeForValue = 256;
-
-   @Override
-   public void init(Properties config) {
-      if (config.contains("marshaller.default-array-size.key")) {
-         defaultArraySizeForKey = Integer.parseInt(config.getProperty("marshaller.default-array-size.key"));
-      }
-      if (config.contains("marshaller.default-array-size.value")) {
-         defaultArraySizeForValue = Integer.parseInt(config.getProperty("marshaller.default-array-size.value"));
-      }
-   }
-
-   @Override
-   public byte[] marshallObject(Object toMarshall, boolean isKeyHint) {
-      ExposedByteArrayOutputStream result = getByteArray(isKeyHint);
-      try {
-         ObjectOutputStream oos = new ObjectOutputStream(result);
-         oos.writeObject(toMarshall);
-         return result.toByteArray();
-      } catch (IOException e) {
-         throw new HotRodClientException("Unexpected!", e);
-      }
-   }
-
-   private ExposedByteArrayOutputStream getByteArray(boolean keyHint) {
-      if (keyHint) {
-         return new ExposedByteArrayOutputStream(defaultArraySizeForKey);
-      } else {
-         return new ExposedByteArrayOutputStream(defaultArraySizeForValue);
-      }
-   }
-
-   @Override
-   public Object readObject(byte[] bytes) {
-      try {
-         ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
-         Object o = ois.readObject();
-         if (log.isTraceEnabled()) {
-            log.trace("Unmarshalled bytes: " + Util.printArray(bytes, false) + " and returning object: " + o);
-         }
-         return o;
-      } catch (Exception e) {
-         throw new HotRodClientException("Unexpected!", e);
-      }
-   }
-}

Modified: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/consistenthash/ConsistentHashFactory.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/consistenthash/ConsistentHashFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/consistenthash/ConsistentHashFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,6 +1,7 @@
 package org.infinispan.client.hotrod.impl.consistenthash;
 
-import org.infinispan.client.hotrod.impl.transport.VHelper;
+
+import org.infinispan.util.Util;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -12,13 +13,13 @@
 /**
  * Factory for {@link org.infinispan.client.hotrod.impl.consistenthash.ConsistentHash} function. It will try to look
  * into the configuration for consistent hash definitions as follows:
- *   consistent-hash.[version]=[fully qualified class implementing ConsistentHash]
+ * consistent-hash.[version]=[fully qualified class implementing ConsistentHash]
  * e.g.
  * consistent-hash.1=org.infinispan.client.hotrod.impl.consistenthash.ConsitentHashV1
  * <p/>
- *  If no CH function is defined for a certain version, then it will be defaulted to "org.infinispan.client.hotrod.impl.ConsistentHashV[version]".
+ * If no CH function is defined for a certain version, then it will be defaulted to "org.infinispan.client.hotrod.impl.ConsistentHashV[version]".
  * E.g. if the server indicates that in use CH is version 1, and it is not defined within the configuration, it will be defaulted to
- * org.infinispan.client.hotrod.impl.ConsistentHashV1. 
+ * org.infinispan.client.hotrod.impl.ConsistentHashV1.
  *
  * @author Mircea.Markus at jboss.com
  * @since 4.1
@@ -51,13 +52,7 @@
          hashFunctionClass = ConsistentHashFactory.class.getPackage().getName() + ".ConsistentHashV" + version;
          if (log.isTraceEnabled()) log.trace("Trying to use default value: " + hashFunctionClass);
       }
-      ConsistentHash consistentHash = null;
-      try {
-         consistentHash = (ConsistentHash) VHelper.newInstance(hashFunctionClass);
-      } catch (RuntimeException re) {
-         log.warn("Could not instantiate consistent hash for version " + version + ": " + hashFunctionClass, re);
-      }
-      return consistentHash;
+      return (ConsistentHash) Util.getInstance(hashFunctionClass);
    }
 
    public Map<Integer, String> getVersion2ConsistentHash() {

Deleted: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/VHelper.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/VHelper.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/VHelper.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,59 +0,0 @@
-package org.infinispan.client.hotrod.impl.transport;
-
-import org.infinispan.client.hotrod.exceptions.HotRodClientException;
-import org.infinispan.client.hotrod.exceptions.TransportException;
-import org.infinispan.io.UnsignedNumeric;
-import org.infinispan.util.Util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Helper for handling v-operations.
- *
- * @author Mircea.Markus at jboss.com
- * @since 4.1
- */
-public class VHelper {
-   public static int readVInt(InputStream is) {
-      try {
-         return UnsignedNumeric.readUnsignedInt(is);
-      } catch (IOException e) {
-         throw new TransportException(e);
-      }
-   }
-
-   public static void writeVInt(int toWrite, OutputStream os) {
-      try {
-         UnsignedNumeric.writeUnsignedInt(os, toWrite);
-      } catch (IOException e) {
-         throw new TransportException(e);
-      }
-   }
-
-   public static long readVLong(InputStream is) {
-      try {
-         return UnsignedNumeric.readUnsignedLong(is);
-      } catch (IOException e) {
-         throw new TransportException(e);
-      }
-   }
-
-
-   public static void writeVLong(long toWrite, OutputStream os) {
-      try {
-         UnsignedNumeric.writeUnsignedLong(os, toWrite);
-      } catch (IOException e) {
-         throw new TransportException(e);
-      }
-   }
-
-   public static Object newInstance(String clazz) {
-      try {
-         return Util.getInstance(clazz);
-      } catch (Exception e) {
-         throw new HotRodClientException("Could not instantiate class: " + clazz, e);
-      }
-   }
-}

Modified: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientDecoder.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientDecoder.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientDecoder.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,13 +1,16 @@
 package org.infinispan.client.hotrod.impl.transport.netty;
 
 import org.infinispan.client.hotrod.exceptions.TransportException;
-import org.infinispan.client.hotrod.impl.transport.VHelper;
+
+import org.infinispan.io.UnsignedNumeric;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.buffer.ChannelBuffers;
 import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.handler.codec.frame.FrameDecoder;
 
+import java.io.IOException;
+
 /**
  * @author Mircea.Markus at jboss.com
  * @since 4.1
@@ -15,7 +18,6 @@
 public class HotRodClientDecoder extends FrameDecoder {
 
    private final ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
-   private final InputStreamAdapter isa = new InputStreamAdapter(buffer);
 
    @Override
    protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
@@ -29,11 +31,19 @@
    }
 
    public long readVLong() {
-      return VHelper.readVLong(isa);
+      try {
+         return UnsignedNumeric.readUnsignedLong(buffer.toByteBuffer());
+      } catch (IOException e) {
+         throw new RuntimeException("Unable to read unsigned long", e);
+      }
    }
 
    public int readVInt() {
-      return VHelper.readVInt(isa);
+      try {
+         return UnsignedNumeric.readUnsignedInt(buffer.toByteBuffer());
+      } catch (IOException e) {
+         throw new RuntimeException("Unable to read unsigned int", e);
+      }
    }
 
    public void fillBuffer(byte[] bufferToFill) {

Modified: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientEncoder.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientEncoder.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/HotRodClientEncoder.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,13 +1,15 @@
 package org.infinispan.client.hotrod.impl.transport.netty;
 
 import org.infinispan.client.hotrod.exceptions.TransportException;
-import org.infinispan.client.hotrod.impl.transport.VHelper;
+
+import org.infinispan.io.UnsignedNumeric;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.buffer.ChannelBuffers;
 import org.jboss.netty.channel.Channel;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
 
+import static org.infinispan.io.UnsignedNumeric.*;
 import static org.jboss.netty.buffer.ChannelBuffers.*;
 
 /**
@@ -16,8 +18,6 @@
  */
 public class HotRodClientEncoder extends OneToOneEncoder {
 
-   private OutputStreamAdapter osa = new OutputStreamAdapter();
-
    @Override
    protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
       if (msg instanceof byte[]) {
@@ -25,12 +25,12 @@
       } else if (msg instanceof Integer) {
          int intMsg = (Integer) msg;
          ChannelBuffer buffer = getBuffer(channel);
-         VHelper.writeVInt(intMsg, osa);
+         writeUnsignedInt(buffer.toByteBuffer(), intMsg);
          return buffer;
       } else if (msg instanceof Long) {
          ChannelBuffer buffer = getBuffer(channel);
          long longMsg = (Long) msg;
-         VHelper.writeVLong(longMsg, osa);
+         writeUnsignedLong(buffer.toByteBuffer(), longMsg);
          return buffer;
       } else if (msg instanceof Short) {
          ChannelBuffer buffer = getBuffer(channel);
@@ -44,8 +44,6 @@
 
 
    private ChannelBuffer getBuffer(Channel channel) {
-      ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(channel.getConfig().getBufferFactory());
-      osa.setBuffer(buffer);
-      return buffer;
+      return ChannelBuffers.dynamicBuffer(channel.getConfig().getBufferFactory());
    }
 }

Deleted: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/InputStreamAdapter.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/InputStreamAdapter.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/InputStreamAdapter.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,34 +0,0 @@
-package org.infinispan.client.hotrod.impl.transport.netty;
-
-import org.infinispan.client.hotrod.exceptions.TransportException;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * @author Mircea.Markus at jboss.com
- * @since 4.1
- */
-public class InputStreamAdapter extends InputStream {
-
-   private final ChannelBuffer buffer;
-
-   public InputStreamAdapter(ChannelBuffer buffer) {
-      this.buffer = buffer;
-   }
-
-   @Override
-   public int read() throws IOException {
-      synchronized (buffer) {
-         if (buffer.readableBytes() == 0) {
-            try {
-               buffer.wait();
-            } catch (InterruptedException e) {
-               throw new TransportException(e);
-            }
-         }
-         return buffer.readUnsignedByte();
-      }
-   }
-}

Deleted: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/OutputStreamAdapter.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/OutputStreamAdapter.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/netty/OutputStreamAdapter.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,25 +0,0 @@
-package org.infinispan.client.hotrod.impl.transport.netty;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author Mircea.Markus at jboss.com
- * @since 4.1
- */
-public class OutputStreamAdapter extends OutputStream {
-
-   ChannelBuffer buffer;
-
-
-   public void setBuffer(ChannelBuffer buffer) {
-      this.buffer = buffer;
-   }
-
-   @Override
-   public void write(int b) throws IOException {
-      buffer.writeByte(b);
-   }
-}

Modified: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransport.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransport.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransport.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -4,7 +4,7 @@
 import org.infinispan.client.hotrod.impl.transport.AbstractTransport;
 import org.infinispan.client.hotrod.exceptions.TransportException;
 import org.infinispan.client.hotrod.impl.transport.TransportFactory;
-import org.infinispan.client.hotrod.impl.transport.VHelper;
+import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -14,6 +14,8 @@
 import java.nio.channels.SocketChannel;
 import java.util.concurrent.atomic.AtomicLong;
 
+import static org.infinispan.io.UnsignedNumeric.*;
+
 /**
  * Transport implementation based on TCP.
  *
@@ -27,6 +29,7 @@
    private static AtomicLong ID_COUNTER = new AtomicLong(0);
 
    private static Log log = LogFactory.getLog(TcpTransport.class);
+   private static final boolean trace = log.isTraceEnabled();
 
    private final Socket socket;
    private final InetSocketAddress serverAddress;
@@ -48,10 +51,7 @@
 
    public void writeVInt(int vInt) {
       try {
-         VHelper.writeVInt(vInt, socket.getOutputStream());
-         if (log.isTraceEnabled())
-            log.trace("VInt wrote " + vInt);
-         
+         writeUnsignedInt(socket.getOutputStream(), vInt);
       } catch (IOException e) {
          throw new TransportException(e);
       }
@@ -59,10 +59,7 @@
 
    public void writeVLong(long l) {
       try {
-         VHelper.writeVLong(l, socket.getOutputStream());
-         if (log.isTraceEnabled())
-            log.trace("VLong wrote " + l);        
-
+         writeUnsignedLong(socket.getOutputStream(), l);
       } catch (IOException e) {
          throw new TransportException(e);
       }
@@ -70,10 +67,7 @@
 
    public long readVLong() {
       try {
-         long result = VHelper.readVLong(socket.getInputStream());
-         if (log.isTraceEnabled())
-            log.trace("VLong read " + result);
-         return result;
+         return readUnsignedLong(socket.getInputStream());
       } catch (IOException e) {
          throw new TransportException(e);
       }
@@ -81,10 +75,7 @@
 
    public int readVInt() {
       try {
-         int result = VHelper.readVInt(socket.getInputStream());
-         if (log.isTraceEnabled())
-            log.trace("VInt read " + result);
-         return result;
+         return readUnsignedInt(socket.getInputStream());
       } catch (IOException e) {
          throw new TransportException(e);
       }
@@ -93,7 +84,7 @@
    protected void writeBytes(byte[] toAppend) {
       try {
          socket.getOutputStream().write(toAppend);
-         if (log.isTraceEnabled())
+         if (trace)
             log.trace("Wrote " + toAppend.length + " bytes");
       } catch (IOException e) {
          throw new TransportException("Problems writing data to stream", e);
@@ -104,7 +95,7 @@
    public void writeByte(short toWrite) {
       try {
          socket.getOutputStream().write(toWrite);
-         if (log.isTraceEnabled())
+         if (trace)
             log.trace("Wrote byte " + toWrite);
 
       } catch (IOException e) {
@@ -115,7 +106,7 @@
    public void flush() {
       try {
          socket.getOutputStream().flush();
-         if (log.isTraceEnabled())
+         if (trace)
             log.trace("Flushed socket: " + socket);
 
       } catch (IOException e) {
@@ -152,7 +143,7 @@
          int read;
          try {
             int len = size - offset;
-            if (log.isTraceEnabled()) {
+            if (trace) {
                log.trace("Offset: " + offset + ", len=" + len + ", size=" + size);
             }
             read = socket.getInputStream().read(result, offset, len);
@@ -169,23 +160,23 @@
             if (offset > result.length) throw new IllegalStateException("Assertion!");
          }
       } while (!done);
-      if (log.isTraceEnabled()) {
+      if (trace) {
          log.trace("Successfully read array with size: " + size);
       }
       return result;
    }
-   
+
    public InetSocketAddress getServerAddress() {
-     return serverAddress;
+      return serverAddress;
    }
 
    @Override
    public String toString() {
       return "TcpTransport{" +
-            "socket=" + socket +
-            ", serverAddress=" + serverAddress +
-            ", id =" + id +
-            "} ";
+              "socket=" + socket +
+              ", serverAddress=" + serverAddress +
+              ", id =" + id +
+              "} ";
    }
 
    @Override
@@ -211,7 +202,7 @@
    public void destroy() {
       try {
          socket.close();
-         if (log.isTraceEnabled()) {
+         if (trace) {
             log.trace("Successfully closed socket: " + socket);
          }
       } catch (IOException e) {

Modified: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TcpTransportFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -7,7 +7,8 @@
 import org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashFactory;
 import org.infinispan.client.hotrod.impl.transport.Transport;
 import org.infinispan.client.hotrod.impl.transport.TransportFactory;
-import org.infinispan.client.hotrod.impl.transport.VHelper;
+
+import org.infinispan.util.Util;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
@@ -45,7 +46,7 @@
       String pingOnStartup = props.getProperty("ping-on-startup");
       servers = staticConfiguredServers;
       String balancerClass = props.getProperty("request-balancing-strategy", RoundRobinBalancingStrategy.class.getName());
-      balancer = (RequestBalancingStrategy) VHelper.newInstance(balancerClass);
+      balancer = (RequestBalancingStrategy) Util.getInstance(balancerClass);
       tcpNoDelay = Boolean.valueOf(props.getProperty("tcp-no-delay", "true"));
       if (log.isDebugEnabled()) log.debug("TCP no delay flag value is: {0}", tcpNoDelay);
       boolean skipPingOnStartup = pingOnStartup != null && !Boolean.valueOf(pingOnStartup);

Modified: branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/HotRodIntegrationTest.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/HotRodIntegrationTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/HotRodIntegrationTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,9 +1,10 @@
 package org.infinispan.client.hotrod;
 
 import org.infinispan.Cache;
-import org.infinispan.client.hotrod.impl.SerializationMarshaller;
 import org.infinispan.config.Configuration;
 import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.jboss.JBossMarshaller;
 import org.infinispan.server.core.CacheValue;
 import org.infinispan.server.hotrod.HotRodServer;
 import org.infinispan.test.SingleCacheManagerTest;
@@ -14,6 +15,7 @@
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.Properties;
 
@@ -72,7 +74,7 @@
       hotrodServer.stop();
    }
 
-   public void testPut() {
+   public void testPut() throws IOException {
       assert null == remoteCache.put("aKey", "aValue");
       assertCacheContains(cache, "aKey", "aValue");
       assert null == defaultRemote.put("otherKey", "otherValue");
@@ -83,7 +85,7 @@
       assert defaultRemote.get("otherKey").equals("otherValue");
    }
 
-   public void testRemove() {
+   public void testRemove() throws IOException {
       assert null == remoteCache.put("aKey", "aValue");
       assertCacheContains(cache, "aKey", "aValue");
 
@@ -185,10 +187,10 @@
       assert cache.isEmpty();
    }
 
-   private void assertCacheContains(Cache cache, String key, String value) {
-      SerializationMarshaller marshaller = new SerializationMarshaller();
-      byte[] keyBytes = marshaller.marshallObject(key, true);
-      byte[] valueBytes = marshaller.marshallObject(value, false);
+   private void assertCacheContains(Cache cache, String key, String value) throws IOException {
+      Marshaller marshaller = new JBossMarshaller();
+      byte[] keyBytes = marshaller.objectToByteBuffer(key, 64);
+      byte[] valueBytes = marshaller.objectToByteBuffer(value, 64);
       ByteArrayKey cacheKey = new ByteArrayKey(keyBytes);
       CacheValue cacheValue = (CacheValue) cache.get(cacheKey);
       if (value == null) {

Deleted: branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/VHelperTest.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/VHelperTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/VHelperTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,262 +0,0 @@
-package org.infinispan.client.hotrod;
-
-import org.infinispan.client.hotrod.impl.transport.VHelper;
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.util.Arrays;
-
-/**
- * @author mmarkus
- * @since 4.1
- */
- at Test(testName = "client.hotrod.VHelperTest", groups = "unit, functional")
-public class VHelperTest {
-
-   public void testString2Byte() {
-      str2byte("00000001", (byte) 1);
-      str2byte("00001001", (byte) 9);
-      str2byte("01111111", (byte) 127);
-      str2byte("11111111", (byte) -1);
-      str2byte("11111110", (byte) -2);
-      str2byte("10000001", (byte) -127);
-      str2byte("10000000", (byte) -128);
-      str2byte("11111011", (byte) -5);
-   }
-
-   public void testByte2String() {
-      byte2str((byte) 9, "00001001");
-      byte2str((byte) 1, "00000001");
-      byte2str((byte) 127, "01111111");
-      byte2str((byte) -1, "11111111");
-      byte2str((byte) -2, "11111110");
-      byte2str((byte) -127, "10000001");
-      byte2str((byte) -128, "10000000");
-      byte2str((byte) -5, "11111011");
-   }
-
-   public void testReadVInt1() {
-      assert 0 == VHelper.readVInt(getInputStream((byte) 0));
-      assert 1 == VHelper.readVInt(getInputStream((byte) 1));
-      assert 2 == VHelper.readVInt(getInputStream((byte) 2));
-
-      assert 127 == VHelper.readVInt(getInputStream((byte) 127));
-
-
-      byte[] nr128 = new byte[]{str2byte("10000000"), str2byte("00000001")};
-      assert 128 == VHelper.readVInt(getInputStream(nr128));
-
-
-      byte[] nr129 = new byte[]{str2byte("10000001"), str2byte("00000001")};
-      assert 129 == VHelper.readVInt(getInputStream(nr129));
-
-      byte[] nr130 = new byte[]{str2byte("10000010"), str2byte("00000001")};
-      assert 130 == VHelper.readVInt(getInputStream(nr130));
-
-      byte[] nr16383 = new byte[]{str2byte("11111111"), str2byte("01111111")};
-      assert 16383 == VHelper.readVInt(getInputStream(nr16383));
-
-      byte[] nr16384 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("00000001")};
-      assert 16384 == VHelper.readVInt(getInputStream(nr16384));
-
-      byte[] nr16385 = new byte[]{str2byte("10000001"), str2byte("10000000"), str2byte("00000001")};
-      assert 16385 == VHelper.readVInt(getInputStream(nr16385));
-
-      byte[] nr16393 = new byte[]{str2byte("10001001"), str2byte("10000000"), str2byte("00000001")};
-      assert 16393 == VHelper.readVInt(getInputStream(nr16393));
-
-      byte[] nr2pow28 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000001")};
-      assert (1 << 28) == VHelper.readVInt(getInputStream(nr2pow28));
-
-      byte[] nr2pow30 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000100")};
-      assert (1 << 30) == VHelper.readVInt(getInputStream(nr2pow30));
-
-      byte[] nr2pow30plus2 = new byte[]{str2byte("10000010"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000100")};
-      assert (1 << 30) + 2 == VHelper.readVInt(getInputStream(nr2pow30plus2));
-   }
-
-   public void testWriteVint() {
-      String[] written = writeVInt(0);
-      assert Arrays.equals(written, new String[]{"00000000"});
-
-      written = writeVInt(1);
-      assert Arrays.equals(written, new String[]{"00000001"});
-
-      written = writeVInt(127);
-      assert Arrays.equals(written, new String[]{"01111111"});
-
-      written = writeVInt(129);
-      assert Arrays.equals(written, new String[]{"10000001", "00000001"});
-
-      written = writeVInt(130);
-      assert Arrays.equals(written, new String[]{"10000010", "00000001"});
-
-      written = writeVInt(16383);
-      assert Arrays.equals(written, new String[]{"11111111", "01111111"});
-
-      written = writeVInt(16384);
-      assert Arrays.equals(written, new String[]{"10000000", "10000000", "00000001"});
-
-      written = writeVInt(16385);
-      assert Arrays.equals(written, new String[]{"10000001", "10000000", "00000001"});
-
-      written = writeVInt(1 << 28);
-      assert Arrays.equals(written, new String[]{"10000000", "10000000", "10000000", "10000000", "00000001"});
-
-      written = writeVInt(1 << 30);
-      assert Arrays.equals(written, new String[]{"10000000", "10000000", "10000000", "10000000", "00000100"});
-
-      written = writeVInt((1 << 30) + 2);
-      assert Arrays.equals(written, new String[]{"10000010", "10000000", "10000000", "10000000", "00000100"});
-   }
-
-   public void testReadVLong() {
-      assert 0 == VHelper.readVLong(getInputStream((byte) 0));
-      assert 1 == VHelper.readVLong(getInputStream((byte) 1));
-      assert 2 == VHelper.readVLong(getInputStream((byte) 2));
-
-      assert 127 == VHelper.readVLong(getInputStream((byte) 127));
-
-
-      byte[] nr128 = new byte[]{str2byte("10000000"), str2byte("00000001")};
-      assert 128 == VHelper.readVLong(getInputStream(nr128));
-
-
-      byte[] nr129 = new byte[]{str2byte("10000001"), str2byte("00000001")};
-      assert 129 == VHelper.readVLong(getInputStream(nr129));
-
-      byte[] nr130 = new byte[]{str2byte("10000010"), str2byte("00000001")};
-      assert 130 == VHelper.readVLong(getInputStream(nr130));
-
-      byte[] nr16383 = new byte[]{str2byte("11111111"), str2byte("01111111")};
-      assert 16383 == VHelper.readVLong(getInputStream(nr16383));
-
-      byte[] nr16384 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("00000001")};
-      assert 16384 == VHelper.readVLong(getInputStream(nr16384));
-
-      byte[] nr16385 = new byte[]{str2byte("10000001"), str2byte("10000000"), str2byte("00000001")};
-      assert 16385 == VHelper.readVLong(getInputStream(nr16385));
-
-      byte[] nr2pow28 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000001")};
-      assert (1 << 28) == VHelper.readVLong(getInputStream(nr2pow28));
-
-      byte[] nr2pow30 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000100")};
-      assert (1 << 30) == VHelper.readVLong(getInputStream(nr2pow30));
-
-      byte[] nr2pow30plus2 = new byte[]{str2byte("10000010"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000100")};
-      assert (1 << 30) + 2 == VHelper.readVLong(getInputStream(nr2pow30plus2));
-
-      byte[] nr2pow35 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000001")};
-      long expected = 1l << 35;
-      long obtained = VHelper.readVLong(getInputStream(nr2pow35));
-      assert expected == obtained : "expected " + expected + " but received " + obtained;
-
-
-      byte[] nr2pow42 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000001")};
-      expected = (long) (1 << 22) * (long) (1 << 20);
-      obtained = VHelper.readVLong(getInputStream(nr2pow42));
-      assert expected == obtained : "Expected " + expected + " but obtained " + obtained;
-
-      byte[] nr2pow56 = new byte[]{str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("10000000"), str2byte("00000001")};
-      expected = 1l << 56;
-      obtained = VHelper.readVLong(getInputStream(nr2pow56));
-      assert expected == obtained : "Expected " + expected + " but obtained " + obtained;
-   }
-
-   public void testWriteVLong() {
-      String[] written = writeVLong(0);
-      assert Arrays.equals(written, new String[]{"00000000"});
-
-      written = writeVLong(1);
-      assert Arrays.equals(written, new String[]{"00000001"});
-
-      written = writeVLong(127);
-      assert Arrays.equals(written, new String[]{"01111111"});
-
-      written = writeVLong(129);
-      assert Arrays.equals(written, new String[]{"10000001", "00000001"});
-
-      written = writeVLong(130);
-      assert Arrays.equals(written, new String[]{"10000010", "00000001"});
-
-      written = writeVLong(16383);
-      assert Arrays.equals(written, new String[]{"11111111", "01111111"});
-
-      written = writeVLong(16384);
-      assert Arrays.equals(written, new String[]{"10000000", "10000000", "00000001"});
-
-      written = writeVLong(16385);
-      assert Arrays.equals(written, new String[]{"10000001", "10000000", "00000001"});
-
-      written = writeVLong(1 << 28);
-      assert Arrays.equals(written, new String[]{"10000000", "10000000", "10000000", "10000000", "00000001"});
-
-      written = writeVLong(1 << 30);
-      assert Arrays.equals(written, new String[]{"10000000", "10000000", "10000000", "10000000", "00000100"});
-
-      written = writeVLong((1 << 30) + 2);
-      assert Arrays.equals(written, new String[]{"10000010", "10000000", "10000000", "10000000", "00000100"});
-
-      written = writeVLong((1l << 56) + 2);
-      assert Arrays.equals(written, new String[]{"10000010", "10000000", "10000000", "10000000", "10000000", "10000000", "10000000", "10000000", "00000001"});
-   }
-
-
-   private String[] writeVInt(int toWrite) {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream(5);
-      VHelper.writeVInt(toWrite, baos);
-      byte[] result = baos.toByteArray();
-      return toStringArray(result);
-   }
-
-   private String[] writeVLong(long toWrite) {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream(9);
-      VHelper.writeVLong(toWrite, baos);
-      byte[] result = baos.toByteArray();
-      return toStringArray(result);
-   }
-
-   private String[] toStringArray(byte[] result) {
-      String[] resultStr = new String[result.length];
-      for (int i = 0; i < resultStr.length; i++) {
-         resultStr[i] = byte2str(result[i]);
-      }
-      return resultStr;
-   }
-
-
-   private InputStream getInputStream(byte... bytes) {
-      return new ByteArrayInputStream(bytes);
-   }
-
-
-   private byte str2byte(String str, byte... check) {
-      assert str.length() == 8;
-      byte result = 0;
-      for (int i = 7; i >= 0; i--) {
-         assert str.charAt(i) == '0' || str.charAt(i) == '1';
-         boolean isOne = str.charAt(i) == '1';
-         byte mask = isOne ? ((byte) (1 << (7 - i))) : (byte) 0;
-         result |= mask;
-      }
-      if (check != null && check.length > 0) {
-         assert result == check[0] : "Expected " + check[0] + " but received " + result;
-      }
-      return result;
-   }
-
-   private String byte2str(byte aByte, String... expectedValue) {
-      String result = "";
-      for (int i = 0; i <= 7; i++) {
-         byte mask = (byte) (1 << (7 - i));
-         boolean isOne = (mask & aByte) != 0;
-         result += isOne ? "1" : "0";
-      }
-      if (expectedValue != null && expectedValue.length > 0) {
-         assert result.equals(expectedValue[0]) : "Expected " + expectedValue[0] + " but received " + result;
-      }
-      return result;
-   }
-}

Modified: branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/retry/DistributionRetryTest.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/retry/DistributionRetryTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/client/hotrod-client/src/test/java/org/infinispan/client/hotrod/retry/DistributionRetryTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -5,15 +5,17 @@
 import org.infinispan.affinity.KeyAffinityServiceFactory;
 import org.infinispan.affinity.KeyGenerator;
 import org.infinispan.client.hotrod.VersionedValue;
-import org.infinispan.client.hotrod.impl.SerializationMarshaller;
 import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransport;
 import org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory;
 import org.infinispan.config.Configuration;
 import org.infinispan.distribution.BaseDistFunctionalTest;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.jboss.JBossMarshaller;
 import org.infinispan.remoting.transport.Address;
 import org.infinispan.test.TestingUtil;
 import org.testng.annotations.Test;
 
+import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.Random;
 import java.util.concurrent.Executors;
@@ -40,7 +42,7 @@
       BaseDistFunctionalTest.RehashWaiter.waitForInitRehashToComplete(cache(0), cache(1), cache(2));
    }
 
-   public void testGet() {
+   public void testGet() throws ClassNotFoundException, IOException {
       log.info("Starting actual test");
       Object key = generateKeyAndShutdownServer();
       //now make sure that next call won't fail
@@ -48,60 +50,60 @@
       assertEquals(remoteCache.get(key), "v");
    }
 
-   public void testPut() {
+   public void testPut() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       log.info("Here it starts");
       assertEquals(remoteCache.put(key, "v0"), "v");
    }
 
-   public void testRemove() {
+   public void testRemove() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       assertEquals("v", remoteCache.remove(key));
    }
 
-   public void testContains() {
+   public void testContains() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       resetStats();
       assertEquals(true, remoteCache.containsKey(key));
    }
 
-   public void testGetWithVersion() {
+   public void testGetWithVersion() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       resetStats();
       VersionedValue value = remoteCache.getVersioned(key);
       assertEquals("v", value.getValue());
    }
 
-   public void testPutIfAbsent() {
+   public void testPutIfAbsent() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       assertEquals(null, remoteCache.putIfAbsent("noSuchKey", "someValue"));
       assertEquals("someValue", remoteCache.get("noSuchKey"));
    }
 
-   public void testReplace() {
+   public void testReplace() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       assertEquals("v", remoteCache.replace(key, "v2"));
    }
 
-   public void testReplaceIfUnmodified() {
+   public void testReplaceIfUnmodified() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       assertEquals(false, remoteCache.replaceWithVersion(key, "v2", 12));
    }
 
-   public void testRemoveIfUnmodified() {
+   public void testRemoveIfUnmodified() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       resetStats();
       assertEquals(false, remoteCache.removeWithVersion(key, 12));
    }
 
-   public void testClear() {
+   public void testClear() throws ClassNotFoundException, IOException {
       Object key = generateKeyAndShutdownServer();
       resetStats();
       remoteCache.clear();
       assertEquals(false, remoteCache.containsKey(key));
    }
 
-   private Object generateKeyAndShutdownServer() {
+   private Object generateKeyAndShutdownServer() throws IOException, ClassNotFoundException {
       resetStats();
       Cache<Object,Object> cache = manager(1).getCache();
       KeyAffinityService kaf = KeyAffinityServiceFactory.newKeyAffinityService(cache, Executors.newSingleThreadExecutor(), new ByteKeyGenerator(), 2, true);
@@ -114,8 +116,8 @@
       assertOnlyServerHit(getAddress(hotRodServer2));
       TcpTransportFactory tcpTp = (TcpTransportFactory) TestingUtil.extractField(remoteCacheManager, "transportFactory");
 
-      SerializationMarshaller sm = new SerializationMarshaller();
-      TcpTransport transport = (TcpTransport) tcpTp.getTransport(sm.marshallObject(key, true));
+      Marshaller sm = new JBossMarshaller();
+      TcpTransport transport = (TcpTransport) tcpTp.getTransport(sm.objectToByteBuffer(key, 64));
       try {
       assertEquals(transport.getServerAddress(), new InetSocketAddress("localhost", hotRodServer2.getPort()));
       } finally {
@@ -135,13 +137,17 @@
       @Override
       public Object getKey() {
          String result = String.valueOf(r.nextLong());
-         SerializationMarshaller sm = new SerializationMarshaller();
-         return sm.marshallObject(result, true);
+         Marshaller sm = new JBossMarshaller();
+         try {
+            return sm.objectToByteBuffer(result, 64);
+         } catch (IOException e) {
+            throw new RuntimeException(e);
+         }
       }
 
-      static String getStringObject(byte[] bytes) {
-         SerializationMarshaller sm = new SerializationMarshaller();
-         return (String) sm.readObject(bytes);
+      static String getStringObject(byte[] bytes) throws ClassNotFoundException, IOException {
+         Marshaller sm = new JBossMarshaller();
+         return (String) sm.objectFromByteBuffer(bytes);
       }
    }
 

Modified: branches/4.1.x/core/src/main/java/org/infinispan/CacheDelegate.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/CacheDelegate.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/CacheDelegate.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -56,7 +56,7 @@
 import org.infinispan.manager.CacheContainer;
 import org.infinispan.manager.EmbeddedCacheManager;
 import org.infinispan.marshall.MarshalledValue;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.notifications.cachelistener.CacheNotifier;
 import org.infinispan.remoting.responses.ResponseGenerator;
 import org.infinispan.remoting.rpc.RpcManager;
@@ -104,7 +104,7 @@
    protected ComponentRegistry componentRegistry;
    protected TransactionManager transactionManager;
    protected RpcManager rpcManager;
-   protected Marshaller marshaller;
+   protected StreamingMarshaller marshaller;
    private String name;
    private EvictionManager evictionManager;
    private DataContainer dataContainer;
@@ -132,7 +132,7 @@
                                   TransactionManager transactionManager,
                                   BatchContainer batchContainer,
                                   RpcManager rpcManager, DataContainer dataContainer,
-                                  Marshaller marshaller, ResponseGenerator responseGenerator,
+                                  StreamingMarshaller marshaller, ResponseGenerator responseGenerator,
                                   DistributionManager distributionManager,
                                   EmbeddedCacheManager cacheManager, StateTransferManager stateTransferManager) {
       this.commandsFactory = commandsFactory;

Modified: branches/4.1.x/core/src/main/java/org/infinispan/affinity/KeyGenerator.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/affinity/KeyGenerator.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/affinity/KeyGenerator.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,5 +1,7 @@
 package org.infinispan.affinity;
 
+import java.io.IOException;
+
 /**
  * Used for generating keys; used by {@link org.infinispan.affinity.KeyAffinityService} to generate the affinity keys.
  * It offers the possibility to generate keys in a particular format.

Modified: branches/4.1.x/core/src/main/java/org/infinispan/config/GlobalConfiguration.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/config/GlobalConfiguration.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/config/GlobalConfiguration.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -670,7 +670,7 @@
 
       /**
        * @configRef desc="Fully qualified name of the marshaller to use. It must implement
-       * org.infinispan.marshall.Marshaller."
+       * org.infinispan.marshall.StreamingMarshaller."
        */
       protected String marshallerClass = VersionAwareMarshaller.class.getName(); // the default
 

Modified: branches/4.1.x/core/src/main/java/org/infinispan/distribution/ConsistentHashHelper.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/distribution/ConsistentHashHelper.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/distribution/ConsistentHashHelper.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,6 +1,7 @@
 package org.infinispan.distribution;
 
 import org.infinispan.config.Configuration;
+import org.infinispan.config.ConfigurationException;
 import org.infinispan.remoting.transport.Address;
 import org.infinispan.util.Util;
 
@@ -24,11 +25,8 @@
     * @param toRemove address to remove
     * @param c        configuration
     * @return a new consistent hash instance of the same type
-    * @throws ClassNotFoundException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws IllegalAccessException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws InstantiationException thrown if the consistent hash type cannot be constructed via reflection.
     */
-   public static ConsistentHash removeAddress(ConsistentHash ch, Address toRemove, Configuration c) throws IllegalAccessException, InstantiationException, ClassNotFoundException {
+   public static ConsistentHash removeAddress(ConsistentHash ch, Address toRemove, Configuration c) {
       if (ch instanceof UnionConsistentHash)
          return removeAddressFromUnionConsistentHash((UnionConsistentHash) ch, toRemove, c);
       else {
@@ -44,15 +42,12 @@
     * Creates a new UnionConsistentHash instance based on the old instance, removing the provided address from both
     * target consistent hash instances in the union.
     *
-    * @param uch union consistent hash instance
+    * @param uch      union consistent hash instance
     * @param toRemove address to remove
-    * @param c configuration
+    * @param c        configuration
     * @return a new UnionConsistentHash instance
-    * @throws ClassNotFoundException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws IllegalAccessException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws InstantiationException thrown if the consistent hash type cannot be constructed via reflection.
     */
-   public static UnionConsistentHash removeAddressFromUnionConsistentHash(UnionConsistentHash uch, Address toRemove, Configuration c) throws IllegalAccessException, ClassNotFoundException, InstantiationException {
+   public static UnionConsistentHash removeAddressFromUnionConsistentHash(UnionConsistentHash uch, Address toRemove, Configuration c) {
       ConsistentHash newFirstCH = removeAddress(uch.getOldConsistentHash(), toRemove, c);
       ConsistentHash newSecondCH = removeAddress(uch.getNewConsistentHash(), toRemove, c);
       return new UnionConsistentHash(newFirstCH, newSecondCH);
@@ -62,14 +57,11 @@
     * Creates a new consistent hash instance based on the user's configuration, and populates the consistent hash
     * with the collection of addresses passed in.
     *
-    * @param c configuration
+    * @param c         configuration
     * @param addresses with which to populate the consistent hash
     * @return a new consistent hash instance
-    * @throws ClassNotFoundException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws IllegalAccessException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws InstantiationException thrown if the consistent hash type cannot be constructed via reflection.
     */
-   public static ConsistentHash createConsistentHash(Configuration c, List<Address> addresses) throws IllegalAccessException, InstantiationException, ClassNotFoundException {
+   public static ConsistentHash createConsistentHash(Configuration c, List<Address> addresses) {
       ConsistentHash ch = (ConsistentHash) Util.getInstance(c.getConsistentHashClass());
       ch.setCaches(addresses);
       return ch;
@@ -79,15 +71,12 @@
     * Creates a new consistent hash instance based on the user's configuration, and populates the consistent hash
     * with the collection of addresses passed in.
     *
-    * @param c configuration
-    * @param addresses with which to populate the consistent hash
+    * @param c             configuration
+    * @param addresses     with which to populate the consistent hash
     * @param moreAddresses to add to the list of addresses
     * @return a new consistent hash instance
-    * @throws ClassNotFoundException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws IllegalAccessException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws InstantiationException thrown if the consistent hash type cannot be constructed via reflection.
     */
-   public static ConsistentHash createConsistentHash(Configuration c, List<Address> addresses, Address... moreAddresses) throws IllegalAccessException, ClassNotFoundException, InstantiationException {
+   public static ConsistentHash createConsistentHash(Configuration c, List<Address> addresses, Address... moreAddresses) {
       List<Address> list = new LinkedList<Address>(addresses);
       list.addAll(Arrays.asList(moreAddresses));
       return createConsistentHash(c, list);
@@ -97,15 +86,12 @@
     * Creates a new consistent hash instance based on the user's configuration, and populates the consistent hash
     * with the collection of addresses passed in.
     *
-    * @param c configuration
-    * @param addresses with which to populate the consistent hash
+    * @param c             configuration
+    * @param addresses     with which to populate the consistent hash
     * @param moreAddresses to add to the list of addresses
     * @return a new consistent hash instance
-    * @throws ClassNotFoundException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws IllegalAccessException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws InstantiationException thrown if the consistent hash type cannot be constructed via reflection.
     */
-   public static ConsistentHash createConsistentHash(Configuration c, List<Address> addresses, Collection<Address> moreAddresses) throws IllegalAccessException, ClassNotFoundException, InstantiationException {
+   public static ConsistentHash createConsistentHash(Configuration c, List<Address> addresses, Collection<Address> moreAddresses) {
       List<Address> list = new LinkedList<Address>(addresses);
       list.addAll(moreAddresses);
       return createConsistentHash(c, list);
@@ -115,15 +101,13 @@
     * Creates a new consistent hash instance based on the type specified, and populates the consistent hash
     * with the collection of addresses passed in.
     *
-    * @param clazz type of the consistent hash to create
+    * @param clazz     type of the consistent hash to create
     * @param addresses with which to populate the consistent hash
     * @return a new consistent hash instance
-    * @throws ClassNotFoundException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws IllegalAccessException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws InstantiationException thrown if the consistent hash type cannot be constructed via reflection.
     */
-   public static ConsistentHash createConsistentHash(Class<? extends ConsistentHash> clazz, List<Address> addresses) throws IllegalAccessException, InstantiationException, ClassNotFoundException {
-      ConsistentHash ch = Util.getInstance(clazz);
+   public static ConsistentHash createConsistentHash(Class<? extends ConsistentHash> clazz, List<Address> addresses) {
+      ConsistentHash ch;
+      ch = Util.getInstance(clazz);
       if (addresses != null && !addresses.isEmpty()) ch.setCaches(addresses);
       return ch;
    }
@@ -132,15 +116,12 @@
     * Creates a new consistent hash instance based on the type specified, and populates the consistent hash
     * with the collection of addresses passed in.
     *
-    * @param clazz type of the consistent hash to create
-    * @param addresses with which to populate the consistent hash
+    * @param clazz         type of the consistent hash to create
+    * @param addresses     with which to populate the consistent hash
     * @param moreAddresses to add to the list of addresses
     * @return a new consistent hash instance
-    * @throws ClassNotFoundException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws IllegalAccessException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws InstantiationException thrown if the consistent hash type cannot be constructed via reflection.
     */
-   public static ConsistentHash createConsistentHash(Class<? extends ConsistentHash> clazz, List<Address> addresses, Address... moreAddresses) throws IllegalAccessException, ClassNotFoundException, InstantiationException {
+   public static ConsistentHash createConsistentHash(Class<? extends ConsistentHash> clazz, List<Address> addresses, Address... moreAddresses) {
       List<Address> list = new LinkedList<Address>(addresses);
       list.addAll(Arrays.asList(moreAddresses));
       return createConsistentHash(clazz, list);
@@ -149,16 +130,13 @@
    /**
     * Creates a new consistent hash instance based on the type specified, and populates the consistent hash
     * with the collection of addresses passed in.
-    * 
-    * @param clazz type of the consistent hash to create
-    * @param addresses with which to populate the consistent hash
+    *
+    * @param clazz         type of the consistent hash to create
+    * @param addresses     with which to populate the consistent hash
     * @param moreAddresses to add to the list of addresses
     * @return a new consistent hash instance
-    * @throws ClassNotFoundException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws IllegalAccessException thrown if the consistent hash type cannot be constructed via reflection.
-    * @throws InstantiationException thrown if the consistent hash type cannot be constructed via reflection.
     */
-   public static ConsistentHash createConsistentHash(Class<? extends ConsistentHash> clazz, List<Address> addresses, Collection<Address> moreAddresses) throws IllegalAccessException, ClassNotFoundException, InstantiationException {
+   public static ConsistentHash createConsistentHash(Class<? extends ConsistentHash> clazz, List<Address> addresses, Collection<Address> moreAddresses) {
       List<Address> list = new LinkedList<Address>(addresses);
       list.addAll(moreAddresses);
       return createConsistentHash(clazz, list);

Modified: branches/4.1.x/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -141,10 +141,11 @@
    }
 
    private Address getMyAddress() {
-      return rpcManager != null? rpcManager.getAddress(): null;
+      return rpcManager != null ? rpcManager.getAddress() : null;
    }
 
    // To avoid blocking other components' start process, wait last, if necessary, for join to complete.
+
    @Start(priority = 1000)
    public void waitForJoinToComplete() throws Throwable {
       if (joinFuture != null) {
@@ -196,7 +197,7 @@
          boolean willReceiveLeaverState = willReceiveLeaverState(leaver);
          boolean willSendLeaverState = willSendLeaverState(leaver);
          List<Address> stateProviders = holdersOfLeaversState(newMembers, leaver);
-        
+
          try {
             if (!(consistentHash instanceof UnionConsistentHash)) oldConsistentHash = consistentHash;
             else oldConsistentHash = ((UnionConsistentHash) consistentHash).newCH;
@@ -204,20 +205,20 @@
          } catch (Exception e) {
             log.fatal("Unable to process leaver!!", e);
             throw new CacheException(e);
-         }       
+         }
 
          if (willReceiveLeaverState || willSendLeaverState) {
             log.info("I {0} am participating in rehash", rpcManager.getTransport().getAddress());
             transactionLogger.enable();
 
             if (leaveTaskFuture != null
-                     && (!leaveTaskFuture.isCancelled() || !leaveTaskFuture.isDone())) {
+                    && (!leaveTaskFuture.isCancelled() || !leaveTaskFuture.isDone())) {
                leaveTaskFuture.cancel(true);
             }
 
             leavers.add(leaver);
             InvertedLeaveTask task = new InvertedLeaveTask(this, rpcManager, configuration, cf,
-                     dataContainer, leavers, stateProviders, willReceiveLeaverState);
+                    dataContainer, leavers, stateProviders, willReceiveLeaverState);
             leaveTaskFuture = rehashExecutor.submit(task);
          } else {
             log.info("Not in same subspace, so ignoring leave event");
@@ -229,19 +230,19 @@
       ConsistentHash ch = consistentHash instanceof UnionConsistentHash ? oldConsistentHash : consistentHash;
       return ch.isAdjacent(leaver, self);
    }
-   
-    List<Address> holdersOfLeaversState(List<Address> members, Address leaver) {
-        ConsistentHash ch = consistentHash instanceof UnionConsistentHash ? oldConsistentHash: consistentHash;
-        Set<Address> holders = new HashSet<Address>();
-        for (Address address : members) {
-           
-            if (ch.isAdjacent(leaver, address)) {
-                holders.add(address);
-            }
-        }
-        return new ArrayList<Address>(holders);
-    }
 
+   List<Address> holdersOfLeaversState(List<Address> members, Address leaver) {
+      ConsistentHash ch = consistentHash instanceof UnionConsistentHash ? oldConsistentHash : consistentHash;
+      Set<Address> holders = new HashSet<Address>();
+      for (Address address : members) {
+
+         if (ch.isAdjacent(leaver, address)) {
+            holders.add(address);
+         }
+      }
+      return new ArrayList<Address>(holders);
+   }
+
    boolean willReceiveLeaverState(Address leaver) {
       ConsistentHash ch = consistentHash instanceof UnionConsistentHash ? oldConsistentHash : consistentHash;
       int dist = ch.getDistance(leaver, self);
@@ -345,11 +346,7 @@
          rehashInProgress = true;
 
          ConsistentHash chNew;
-         try {
-            chNew = (ConsistentHash) Util.getInstance(configuration.getConsistentHashClass());
-         } catch (Exception e) {
-            throw new CacheException("Unable to create instance of " + configuration.getConsistentHashClass(), e);
-         }
+         chNew = (ConsistentHash) Util.getInstance(configuration.getConsistentHashClass());
          List<Address> newAddresses = new LinkedList<Address>(chOld.getCaches());
          newAddresses.add(joiner);
          chNew.setCaches(newAddresses);

Modified: branches/4.1.x/core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/factories/EmptyConstructorFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,16 +22,10 @@
 @Scope(Scopes.GLOBAL)
 public class EmptyConstructorFactory extends AbstractComponentFactory implements AutoInstantiableFactory {
    public <T> T construct(Class<T> componentType) {
-      try {
-         if (componentType.isInterface()) { 
-            return componentType.cast(Util.getInstance(componentType.getName() + "Impl"));
-         } else {
-            return Util.getInstance(componentType);
-         }
+      if (componentType.isInterface()) {
+         return componentType.cast(Util.getInstance(componentType.getName() + "Impl"));
+      } else {
+         return Util.getInstance(componentType);
       }
-      catch (Exception e) {
-         throw new ConfigurationException("Unable to create component " + componentType, e);
-      }
-
    }
 }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/factories/EmptyConstructorNamedCacheFactory.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/factories/EmptyConstructorNamedCacheFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/factories/EmptyConstructorNamedCacheFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -24,13 +24,12 @@
 
 import org.infinispan.batch.BatchContainer;
 import org.infinispan.commands.CommandsFactory;
-import org.infinispan.config.ConfigurationException;
 import org.infinispan.context.InvocationContextContainer;
 import org.infinispan.context.InvocationContextContainerImpl;
 import org.infinispan.eviction.EvictionManager;
 import org.infinispan.factories.annotations.DefaultFactoryFor;
 import org.infinispan.loaders.CacheLoaderManager;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.infinispan.notifications.cachelistener.CacheNotifier;
 import org.infinispan.transaction.TransactionLog;
@@ -44,30 +43,25 @@
  * @since 4.0
  */
 @DefaultFactoryFor(classes = {CacheNotifier.class, EntryFactory.class, CommandsFactory.class,
-                              CacheLoaderManager.class, InvocationContextContainer.class,
-                              BatchContainer.class, TransactionLog.class, EvictionManager.class, InvocationContextContainer.class})
+        CacheLoaderManager.class, InvocationContextContainer.class,
+        BatchContainer.class, TransactionLog.class, EvictionManager.class, InvocationContextContainer.class})
 public class EmptyConstructorNamedCacheFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {
    @Override
    public <T> T construct(Class<T> componentType) {
-      try {
-         if (componentType.isInterface()) {
-            Class componentImpl;
-            if (componentType.equals(Marshaller.class)) {
-               VersionAwareMarshaller versionAwareMarshaller = Util.getInstance(VersionAwareMarshaller.class);
-               return componentType.cast(versionAwareMarshaller);
-            } else if (componentType.equals(InvocationContextContainer.class)) {
-               componentImpl = InvocationContextContainerImpl.class;
-            } else {
-               // add an "Impl" to the end of the class name and try again
-               componentImpl = Util.loadClass(componentType.getName() + "Impl");
-            }
-            return componentType.cast(Util.getInstance(componentImpl));
+      if (componentType.isInterface()) {
+         Class componentImpl;
+         if (componentType.equals(StreamingMarshaller.class)) {
+            VersionAwareMarshaller versionAwareMarshaller = Util.getInstance(VersionAwareMarshaller.class);
+            return componentType.cast(versionAwareMarshaller);
+         } else if (componentType.equals(InvocationContextContainer.class)) {
+            componentImpl = InvocationContextContainerImpl.class;
          } else {
-            return Util.getInstance(componentType);
+            // add an "Impl" to the end of the class name and try again
+            componentImpl = Util.loadClass(componentType.getName() + "Impl");
          }
+         return componentType.cast(Util.getInstance(componentImpl));
+      } else {
+         return Util.getInstance(componentType);
       }
-      catch (Exception e) {
-         throw new ConfigurationException("Unable to create component " + componentType, e);
-      }
    }
 }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/factories/InterceptorChainFactory.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/factories/InterceptorChainFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/factories/InterceptorChainFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -42,10 +42,10 @@
 @DefaultFactoryFor(classes = InterceptorChain.class)
 public class InterceptorChainFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {
 
-   public CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) throws IllegalAccessException, InstantiationException {
+   public CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) {
       CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
       if (chainedInterceptor == null) {
-         chainedInterceptor = clazz.newInstance();
+         chainedInterceptor = Util.getInstance(clazz);
          try {
             componentRegistry.registerComponent(chainedInterceptor, clazz);
          }
@@ -150,17 +150,17 @@
    }
 
    @SuppressWarnings("unchecked")
-   private Class<? extends CommandInterceptor> getCustomInterceptorType(CustomInterceptorConfig cfg) throws ClassNotFoundException {
+   private Class<? extends CommandInterceptor> getCustomInterceptorType(CustomInterceptorConfig cfg) {
       if (cfg.getInterceptor() != null) return cfg.getInterceptor().getClass();
       return Util.loadClass(cfg.getClassName());
    }
 
-   private CommandInterceptor getOrCreateCustomInterceptor(CustomInterceptorConfig cfg) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+   private CommandInterceptor getOrCreateCustomInterceptor(CustomInterceptorConfig cfg) {
       if (cfg.getInterceptor() != null) return cfg.getInterceptor();
       return (CommandInterceptor) Util.getInstance(cfg.getClassName());
    }
 
-   private void buildCustomInterceptors(InterceptorChain interceptorChain, List<CustomInterceptorConfig> customInterceptors) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+   private void buildCustomInterceptors(InterceptorChain interceptorChain, List<CustomInterceptorConfig> customInterceptors) {
 
       for (CustomInterceptorConfig config : customInterceptors) {
          if (interceptorChain.containsInterceptorType(getCustomInterceptorType(config))) continue;

Modified: branches/4.1.x/core/src/main/java/org/infinispan/factories/MarshallerFactory.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/factories/MarshallerFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/factories/MarshallerFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -23,23 +23,19 @@
 
 import org.infinispan.config.ConfigurationException;
 import org.infinispan.factories.annotations.DefaultFactoryFor;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.Util;
 
 /**
  * MarshallerFactory.
- * 
+ *
  * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @since 4.0
  */
- at DefaultFactoryFor(classes = Marshaller.class)
-public class MarshallerFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {   
+ at DefaultFactoryFor(classes = StreamingMarshaller.class)
+public class MarshallerFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {
    @Override
    public <T> T construct(Class<T> componentType) {
-      try {
-         return componentType.cast(Util.getInstance(globalConfiguration.getMarshallerClass()));
-      } catch (Exception e) {
-         throw new ConfigurationException("Unable to create component " + componentType, e);
-      }
+      return componentType.cast(Util.getInstance(globalConfiguration.getMarshallerClass()));
    }
 }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/factories/TransactionManagerFactory.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/factories/TransactionManagerFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/factories/TransactionManagerFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -46,15 +46,10 @@
       if (lookup == null) {
          // Nope. See if we can look it up from JNDI
          if (configuration.getTransactionManagerLookupClass() != null) {
-            try { 
-               lookup = (TransactionManagerLookup) Util.getInstance(configuration.getTransactionManagerLookupClass());
-            }
-            catch (Exception e) {
-               throw new ConfigurationException("Problems looking up transaction manager", e);
-            }
+            lookup = (TransactionManagerLookup) Util.getInstance(configuration.getTransactionManagerLookupClass());
          }
       }
-      
+
       try {
          if (lookup != null) {
             transactionManager = lookup.getTransactionManager();

Modified: branches/4.1.x/core/src/main/java/org/infinispan/factories/TransportFactory.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/factories/TransportFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/factories/TransportFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -17,11 +17,7 @@
    @SuppressWarnings("unchecked")
    public <T> T construct(Class<T> componentType) {
       String transportClass = globalConfiguration.getTransportClass();
-      try {
-         if (transportClass == null) return null;
-         return (T) Util.getInstance(transportClass);
-      } catch (Exception e) {
-         throw new CacheException("Unable to create transport of type " + transportClass, e);
-      }
+      if (transportClass == null) return null;
+      return (T) Util.getInstance(transportClass);
    }
 }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/interceptors/MarshalledValueInterceptor.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/interceptors/MarshalledValueInterceptor.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/interceptors/MarshalledValueInterceptor.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -34,7 +34,7 @@
 import org.infinispan.factories.annotations.Inject;
 import org.infinispan.interceptors.base.CommandInterceptor;
 import org.infinispan.marshall.MarshalledValue;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.Immutables;
 
 import java.io.IOException;
@@ -62,10 +62,10 @@
  * @since 4.0
  */
 public class MarshalledValueInterceptor extends CommandInterceptor {
-   private Marshaller marshaller;
+   private StreamingMarshaller marshaller;
    
    @Inject
-   protected void injectMarshaller(Marshaller marshaller) {
+   protected void injectMarshaller(StreamingMarshaller marshaller) {
       this.marshaller = marshaller;
    }
    

Modified: branches/4.1.x/core/src/main/java/org/infinispan/jmx/AbstractJmxRegistration.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/jmx/AbstractJmxRegistration.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/jmx/AbstractJmxRegistration.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -35,7 +35,7 @@
 
 /**
  * Parent class for top level JMX component registration.
- * 
+ *
  * @author Galder Zamarreño
  * @since 4.0
  */
@@ -44,31 +44,26 @@
    String jmxDomain;
    MBeanServer mBeanServer;
    GlobalConfiguration globalConfig;
-   
+
    protected abstract ComponentsJmxRegistration buildRegistrar(Set<AbstractComponentRegistry.Component> components);
-   
+
    protected void registerMBeans(Set<AbstractComponentRegistry.Component> components, GlobalConfiguration globalConfig) {
       mBeanServer = getMBeanServer(globalConfig);
       ComponentsJmxRegistration registrar = buildRegistrar(components);
       registrar.registerMBeans();
    }
-   
+
    protected void unregisterMBeans(Set<AbstractComponentRegistry.Component> components) {
       ComponentsJmxRegistration registrar = buildRegistrar(components);
       registrar.unregisterMBeans();
    }
-   
+
    protected MBeanServer getMBeanServer(GlobalConfiguration configuration) {
       String serverLookup = configuration.getMBeanServerLookup();
-      try {
-         MBeanServerLookup lookup = (MBeanServerLookup) Util.getInstance(serverLookup);
-         return lookup.getMBeanServer();
-      } catch (Exception e) {
-         log.error("Could not instantiate MBeanServerLookup('" + serverLookup + "')", e);
-         throw new CacheException(e);
-      }
+      MBeanServerLookup lookup = (MBeanServerLookup) Util.getInstance(serverLookup);
+      return lookup.getMBeanServer();
    }
-   
+
    protected String getJmxDomain(String jmxDomain, MBeanServer mBeanServer) {
       String[] registeredDomains = mBeanServer.getDomains();
       int index = 2;

Modified: branches/4.1.x/core/src/main/java/org/infinispan/jmx/ResourceDMBean.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/jmx/ResourceDMBean.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/jmx/ResourceDMBean.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -53,19 +53,19 @@
  * This class was entirely copied from jgroups 2.7 (same name there). Couldn't simply reuse it
  * because jgroups does not ship with MBean, ManagedAttribute and ManagedOperation. Once jgroups
  * will ship these classes, the code can be dinalmically reused from there.
- * 
- * The original JGroup's ResourceDMBean logic has been modified so that {@link #invoke()} method checks 
+ * <p/>
+ * The original JGroup's ResourceDMBean logic has been modified so that {@link #invoke()} method checks
  * whether the operation called has been exposed as a {@link ManagedOperation}, otherwise the call
- * fails. JGroups deviated from this logic on purpouse because they liked the fact that you could expose 
+ * fails. JGroups deviated from this logic on purpouse because they liked the fact that you could expose
  * all class methods by simply annotating class with {@link MBean} annotation.
- * 
+ *
  * @author Mircea.Markus at jboss.com
  * @author Galder Zamarreño
  * @since 4.0
  */
 public class ResourceDMBean implements DynamicMBean {
-   private static final Class<?>[] primitives = { int.class, byte.class, short.class, long.class,
-            float.class, double.class, boolean.class, char.class };
+   private static final Class<?>[] primitives = {int.class, byte.class, short.class, long.class,
+           float.class, double.class, boolean.class, char.class};
 
    private static final String MBEAN_DESCRITION = "Dynamic MBean Description";
 
@@ -98,7 +98,7 @@
          attrInfo[i++] = info;
          if (log.isInfoEnabled()) {
             log.trace("Attribute " + info.getName() + "[r=" + info.isReadable() + ",w="
-                     + info.isWritable() + ",is=" + info.isIs() + ",type=" + info.getType() + "]");
+                    + info.isWritable() + ",is=" + info.isIs() + ",type=" + info.getType() + "]");
          }
       }
 
@@ -126,10 +126,10 @@
             log.debug("@MBean description set - " + mbean.description());
          }
          MBeanAttributeInfo info = new MBeanAttributeInfo(MBEAN_DESCRITION, "java.lang.String",
-                  "@MBean description", true, false, false);
+                 "@MBean description", true, false, false);
          try {
             atts.put(MBEAN_DESCRITION, new FieldAttributeEntry(info, getClass().getDeclaredField(
-                     "description")));
+                    "description")));
          } catch (NoSuchFieldException e) {
             // this should not happen unless somebody removes description field
             log.warn("Could not reflect field description of this class. Was it removed?");
@@ -140,7 +140,7 @@
    public synchronized MBeanInfo getMBeanInfo() {
 
       return new MBeanInfo(getObject().getClass().getCanonicalName(), description, attrInfo, null,
-               opInfos, null);
+              opInfos, null);
    }
 
    public synchronized Object getAttribute(String name) throws AttributeNotFoundException {
@@ -150,7 +150,7 @@
       Attribute attr = getNamedAttribute(name);
       if (attr == null) {
          throw new AttributeNotFoundException("Unknown attribute '" + name
-                  + "'. Known attributes names are: " + atts.keySet());
+                 + "'. Known attributes names are: " + atts.keySet());
       }
       return attr.getValue();
    }
@@ -185,7 +185,7 @@
          } else {
             if (log.isWarnEnabled()) {
                log.warn("Failed to update attribute name " + attr.getName() + " with value "
-                     + attr.getValue());
+                       + attr.getValue());
             }
          }
       }
@@ -193,7 +193,7 @@
    }
 
    public Object invoke(String name, Object[] args, String[] sig) throws MBeanException,
-            ReflectionException {
+           ReflectionException {
       if (log.isDebugEnabled()) {
          log.debug("Invoke method called on " + name);
       }
@@ -225,7 +225,7 @@
 
    public static Class<?> getClassForName(String name) throws ClassNotFoundException {
       try {
-         return (Class<?>) Util.loadClass(name);
+         return (Class<?>) Util.loadClassStrict(name);
       } catch (ClassNotFoundException cnfe) {
          // Could be a primitive - let's check
          for (Class<?> primitive : primitives) if (name.equals(primitive.getName())) return primitive;
@@ -236,7 +236,7 @@
    private void findMethods() {
       // find all methods but don't include methods from Object class
       List<Method> methods = new ArrayList<Method>(Arrays.asList(getObject().getClass()
-               .getMethods()));
+              .getMethods()));
       List<Method> objectMethods = new ArrayList<Method>(Arrays.asList(Object.class.getMethods()));
       methods.removeAll(objectMethods);
 
@@ -246,11 +246,11 @@
          if (attr != null) {
             String methodName = method.getName();
             if (!methodName.startsWith("get") && !methodName.startsWith("set")
-                     && !methodName.startsWith("is")) {
+                    && !methodName.startsWith("is")) {
                if (log.isWarnEnabled())
                   log.warn("method name " + methodName
-                           + " doesn't start with \"get\", \"set\", or \"is\""
-                           + ", but is annotated with @ManagedAttribute: will be ignored");
+                          + " doesn't start with \"get\", \"set\", or \"is\""
+                          + ", but is annotated with @ManagedAttribute: will be ignored");
             } else {
                MBeanAttributeInfo info = null;
                String attributeName = null;
@@ -258,27 +258,27 @@
                if (isSetMethod(method)) { // setter
                   attributeName = methodName.substring(3);
                   info = new MBeanAttributeInfo(attributeName, method.getParameterTypes()[0]
-                           .getCanonicalName(), attr.description(), true, true, false);
+                          .getCanonicalName(), attr.description(), true, true, false);
                   writeAttribute = true;
                } else { // getter
                   if (method.getParameterTypes().length == 0
-                           && method.getReturnType() != java.lang.Void.TYPE) {
+                          && method.getReturnType() != java.lang.Void.TYPE) {
                      boolean hasSetter = atts.containsKey(attributeName);
                      // we found is method
                      if (methodName.startsWith("is")) {
                         attributeName = methodName.substring(2);
                         info = new MBeanAttributeInfo(attributeName, method.getReturnType()
-                                 .getCanonicalName(), attr.description(), true, hasSetter, true);
+                                .getCanonicalName(), attr.description(), true, hasSetter, true);
                      } else {
                         // this has to be get
                         attributeName = methodName.substring(3);
                         info = new MBeanAttributeInfo(attributeName, method.getReturnType()
-                                 .getCanonicalName(), attr.description(), true, hasSetter, false);
+                                .getCanonicalName(), attr.description(), true, hasSetter, false);
                      }
                   } else {
                      if (log.isWarnEnabled()) {
                         log.warn("Method " + method.getName()
-                                 + " must have a valid return type and zero parameters");
+                                + " must have a valid return type and zero parameters");
                      }
                      continue;
                   }
@@ -290,14 +290,14 @@
                   // we already have annotated field as read
                   if (ae instanceof FieldAttributeEntry && ae.getInfo().isReadable()) {
                      log.warn("not adding annotated method " + method
-                              + " since we already have read attribute");
+                             + " since we already have read attribute");
                   }
                   // we already have annotated set method
                   else if (ae instanceof MethodAttributeEntry) {
                      MethodAttributeEntry mae = (MethodAttributeEntry) ae;
                      if (mae.hasSetMethod()) {
                         atts.put(attributeName, new MethodAttributeEntry(mae.getInfo(), mae
-                                 .getSetMethod(), method));
+                                .getSetMethod(), method));
                      }
                   } // we don't have such entry
                   else {
@@ -309,14 +309,14 @@
                      // we already have annotated field as write
                      if (ae.getInfo().isWritable()) {
                         log.warn("Not adding annotated method " + methodName
-                                 + " since we already have writable attribute");
+                                + " since we already have writable attribute");
                      } else {
                         // we already have annotated field as read
                         // lets make the field writable
                         Field f = ((FieldAttributeEntry) ae).getField();
                         MBeanAttributeInfo i = new MBeanAttributeInfo(ae.getInfo().getName(), f
-                                 .getType().getCanonicalName(), attr.description(), true, Modifier
-                                 .isFinal(f.getModifiers()) ? false : true, false);
+                                .getType().getCanonicalName(), attr.description(), true, Modifier
+                                .isFinal(f.getModifiers()) ? false : true, false);
                         atts.put(attributeName, new FieldAttributeEntry(i, f));
                      }
                   }
@@ -325,7 +325,7 @@
                      MethodAttributeEntry mae = (MethodAttributeEntry) ae;
                      if (mae.hasIsOrGetMethod()) {
                         atts.put(attributeName, new MethodAttributeEntry(info, method, mae
-                                 .getIsOrGetMethod()));
+                                .getIsOrGetMethod()));
                      }
                   } // we don't have such entry
                   else {
@@ -352,19 +352,19 @@
 
    private boolean isSetMethod(Method method) {
       return (method.getName().startsWith("set") && method.getParameterTypes().length == 1 && method
-               .getReturnType() == java.lang.Void.TYPE);
+              .getReturnType() == java.lang.Void.TYPE);
    }
 
    private boolean isGetMethod(Method method) {
       return (method.getParameterTypes().length == 0
-               && method.getReturnType() != java.lang.Void.TYPE && method.getName().startsWith(
-               "get"));
+              && method.getReturnType() != java.lang.Void.TYPE && method.getName().startsWith(
+              "get"));
    }
 
    private boolean isIsMethod(Method method) {
       return (method.getParameterTypes().length == 0
-               && (method.getReturnType() == boolean.class || method.getReturnType() == Boolean.class) && method
-               .getName().startsWith("is"));
+              && (method.getReturnType() == boolean.class || method.getReturnType() == Boolean.class) && method
+              .getName().startsWith("is"));
    }
 
    private void findFields() {
@@ -377,8 +377,8 @@
             if (attr != null) {
                String fieldName = renameToJavaCodingConvention(field.getName());
                MBeanAttributeInfo info = new MBeanAttributeInfo(fieldName, field.getType()
-                        .getCanonicalName(), attr.description(), true, !Modifier.isFinal(field
-                     .getModifiers()) && attr.writable(), false);
+                       .getCanonicalName(), attr.description(), true, !Modifier.isFinal(field
+                       .getModifiers()) && attr.writable(), false);
 
                atts.put(fieldName, new FieldAttributeEntry(info, field));
             }
@@ -398,9 +398,9 @@
                result = new Attribute(name, entry.invoke(null));
                if (log.isDebugEnabled())
                   log
-                           .debug("Attribute " + name + " has r=" + i.isReadable() + ",w="
-                                    + i.isWritable() + ",is=" + i.isIs() + " and value "
-                                    + result.getValue());
+                          .debug("Attribute " + name + " has r=" + i.isReadable() + ",w="
+                                  + i.isWritable() + ",is=" + i.isIs() + " and value "
+                                  + result.getValue());
             } catch (Exception e) {
                log.debug("Exception while reading value of attribute " + name, e);
             }
@@ -415,7 +415,7 @@
       boolean result = false;
       if (log.isDebugEnabled())
          log.debug("Invoking set on attribute " + attribute.getName() + " with value "
-                  + attribute.getValue());
+                 + attribute.getValue());
 
       AttributeEntry entry = atts.get(attribute.getName());
       if (entry != null) {
@@ -427,7 +427,7 @@
          }
       } else {
          log.warn("Could not invoke set on attribute " + attribute.getName() + " with value "
-                  + attribute.getValue());
+                 + attribute.getValue());
       }
       return result;
    }
@@ -464,7 +464,7 @@
       final Method setMethod;
 
       public MethodAttributeEntry(final MBeanAttributeInfo info, final Method setMethod,
-               final Method isOrGetMethod) {
+                                  final Method isOrGetMethod) {
          super();
          this.info = info;
          this.setMethod = setMethod;
@@ -473,7 +473,7 @@
 
       public Object invoke(Attribute a) throws Exception {
          if (a == null && isOrGetmethod != null)
-            return isOrGetmethod.invoke(getObject() );
+            return isOrGetmethod.invoke(getObject());
          else if (a != null && setMethod != null)
             return setMethod.invoke(getObject(), a.getValue());
          else

Modified: branches/4.1.x/core/src/main/java/org/infinispan/lifecycle/ModuleLifecycle.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/lifecycle/ModuleLifecycle.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/lifecycle/ModuleLifecycle.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -27,7 +27,7 @@
 /**
  * ModuleLifecycle is an internal API hook for delegating lifecycle events to Infinispan sub-modules.
  * <p>
- * For example, the 'tree' module needs to register specific types with the Marshaller. The 'query'
+ * For example, the 'tree' module needs to register specific types with the StreamingMarshaller. The 'query'
  * module needs to register an interceptor with the Cache if the Cache has enabled querying etc etc.
  * <p />
  * To use this hook, you would need to implement this interface (or extend {@link AbstractModuleLifecycle})

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/AbstractCacheLoader.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/AbstractCacheLoader.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/AbstractCacheLoader.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,7 +1,7 @@
 package org.infinispan.loaders;
 
 import org.infinispan.Cache;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 
 /**
  * An abstract {@link org.infinispan.loaders.CacheLoader} that holds common implementations for some methods
@@ -12,7 +12,7 @@
  */
 public abstract class AbstractCacheLoader implements CacheLoader {
 
-   protected volatile Marshaller marshaller;
+   protected volatile StreamingMarshaller marshaller;
    protected volatile Cache cache;
 
    /**
@@ -24,7 +24,7 @@
    }
 
    @Override
-   public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache<?, ?> cache, StreamingMarshaller m) throws CacheLoaderException {
       this.marshaller = m;
       if (config == null) throw new IllegalStateException("Null config!!!");
       this.cache = cache;

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/AbstractCacheStore.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/AbstractCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/AbstractCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -4,7 +4,7 @@
 import org.infinispan.loaders.modifications.Modification;
 import org.infinispan.loaders.modifications.Remove;
 import org.infinispan.loaders.modifications.Store;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.util.concurrent.WithinThreadExecutor;
 import org.infinispan.util.logging.Log;
@@ -38,7 +38,7 @@
    private static final AtomicInteger THREAD_COUNTER = new AtomicInteger(0);
    protected boolean multiThreadedPurge = false;
 
-   public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException{
+   public void init(CacheLoaderConfig config, Cache<?, ?> cache, StreamingMarshaller m) throws CacheLoaderException{
       super.init(config, cache, m);
       this.config = (AbstractCacheStoreConfig) config;
    }
@@ -156,7 +156,7 @@
       }
    }
 
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       return marshaller;
    }
 }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheLoader.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheLoader.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheLoader.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -2,7 +2,7 @@
 
 import org.infinispan.Cache;
 import org.infinispan.container.entries.InternalCacheEntry;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 
 import java.util.Set;
 
@@ -23,7 +23,7 @@
     *               selecting where refer to state in storage, for example, a different database table name.
     * @param m      marshaller to use when loading state from a stream, if supported by the implementation.
     */
-   void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException;
+   void init(CacheLoaderConfig config, Cache<?, ?> cache, StreamingMarshaller m) throws CacheLoaderException;
 
    /**
     * Loads an entry mapped to by a given key.  Should return null if the entry does not exist.  Expired entries are not

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheLoaderManagerImpl.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheLoaderManagerImpl.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheLoaderManagerImpl.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -18,7 +18,7 @@
 import org.infinispan.loaders.decorators.ReadOnlyStore;
 import org.infinispan.loaders.decorators.SingletonStore;
 import org.infinispan.loaders.decorators.SingletonStoreConfig;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.ReflectionUtil;
 import org.infinispan.util.Util;
 import org.infinispan.util.logging.Log;
@@ -33,12 +33,12 @@
    Configuration configuration;
    CacheLoaderManagerConfig clmConfig;
    Cache<Object, Object> cache;
-   Marshaller m;
+   StreamingMarshaller m;
    CacheLoader loader;
    private static final Log log = LogFactory.getLog(CacheLoaderManagerImpl.class);
 
    @Inject
-   public void inject(Cache cache, Marshaller marshaller, Configuration configuration) {
+   public void inject(Cache cache, StreamingMarshaller marshaller, Configuration configuration) {
       this.cache = cache;
       this.m = marshaller;
       this.configuration = configuration;

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheStore.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/CacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -28,7 +28,7 @@
    /**
     * Writes contents of the stream to the store.  Implementations should expect that the stream contains data in an
     * implementation-specific format, typically generated using {@link #toStream(java.io.ObjectOutput)}.  While not a
-    * requirement, it is recommended that implementations make use of the {@link org.infinispan.marshall.Marshaller}
+    * requirement, it is recommended that implementations make use of the {@link org.infinispan.marshall.StreamingMarshaller}
     * when dealing with the stream to make use of efficient marshalling.
     * <p/>
     * It is imperative that implementations <b><i>do not</i></b> close the stream after finishing with it.
@@ -52,7 +52,7 @@
     * implementation. Typically read and parsed by {@link #fromStream(java.io.ObjectInput)}.
     * <p/>
     * While not a requirement, it is recommended that implementations make use of the {@link
-    * org.infinispan.marshall.Marshaller} when dealing with the stream to make use of efficient marshalling.
+    * org.infinispan.marshall.StreamingMarshaller} when dealing with the stream to make use of efficient marshalling.
     * <p/>
     * It is imperative that implementations <b><i>do not</i></b> flush or close the stream after finishing with it.
     * <p/>

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/LockSupportCacheStore.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/LockSupportCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/LockSupportCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -2,7 +2,7 @@
 
 import org.infinispan.Cache;
 import org.infinispan.container.entries.InternalCacheEntry;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.concurrent.locks.StripedLock;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
@@ -34,7 +34,7 @@
    private long globalLockTimeoutMillis;
    private LockSupportCacheStoreConfig config;
 
-   public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache<?, ?> cache, StreamingMarshaller m) throws CacheLoaderException {
       super.init(config, cache, m);
       this.config = (LockSupportCacheStoreConfig) config;
    }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/cluster/ClusterCacheLoader.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/cluster/ClusterCacheLoader.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/cluster/ClusterCacheLoader.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -11,7 +11,7 @@
 import org.infinispan.loaders.CacheLoaderConfig;
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheLoaderMetadata;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.remoting.responses.ClusteredGetResponseValidityFilter;
 import org.infinispan.remoting.responses.Response;
 import org.infinispan.remoting.responses.SuccessfulResponse;
@@ -22,7 +22,6 @@
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -43,7 +42,7 @@
    private RpcManager rpcManager;
    private AdvancedCache cache;
 
-   public void init(CacheLoaderConfig config, Cache cache, Marshaller m) {
+   public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) {
       this.config = (ClusterCacheLoaderConfig) config;
       this.cache = cache.getAdvancedCache();
       rpcManager = this.cache.getRpcManager();

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/AbstractDelegatingStore.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/AbstractDelegatingStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/AbstractDelegatingStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,6 +1,7 @@
 package org.infinispan.loaders.decorators;
 
 import org.infinispan.Cache;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.container.entries.InternalCacheEntry;
 import org.infinispan.loaders.CacheLoaderConfig;
@@ -8,7 +9,6 @@
 import org.infinispan.loaders.CacheStore;
 import org.infinispan.loaders.CacheStoreConfig;
 import org.infinispan.loaders.modifications.Modification;
-import org.infinispan.marshall.Marshaller;
 
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -78,7 +78,7 @@
       delegate.prepare(list, tx, isOnePhase);
    }
 
-   public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache<?, ?> cache, StreamingMarshaller m) throws CacheLoaderException {
       delegate.init(config, cache, m);
    }
 

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/AsyncStore.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/AsyncStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/AsyncStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -14,7 +14,7 @@
 import org.infinispan.loaders.modifications.PurgeExpired;
 import org.infinispan.loaders.modifications.Remove;
 import org.infinispan.loaders.modifications.Store;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.util.concurrent.locks.containers.ReentrantPerEntryLockContainer;
 import org.infinispan.util.logging.Log;
@@ -93,7 +93,7 @@
    }
 
    @Override
-   public void init(CacheLoaderConfig config, Cache<?, ?> cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache<?, ?> cache, StreamingMarshaller m) throws CacheLoaderException {
       super.init(config, cache, m);
       concurrencyLevel = cache == null || cache.getConfiguration() == null ? 16 : cache.getConfiguration().getConcurrencyLevel();
       lockContainer = new ReleaseAllLockContainer(concurrencyLevel);

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/ChainingCacheStore.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/ChainingCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/decorators/ChainingCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,6 +1,7 @@
 package org.infinispan.loaders.decorators;
 
 import org.infinispan.Cache;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.container.entries.InternalCacheEntry;
 import org.infinispan.loaders.CacheLoader;
@@ -9,7 +10,6 @@
 import org.infinispan.loaders.CacheStore;
 import org.infinispan.loaders.CacheStoreConfig;
 import org.infinispan.loaders.modifications.Modification;
-import org.infinispan.marshall.Marshaller;
 
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -95,7 +95,7 @@
       for (CacheStore s : stores.keySet()) s.prepare(list, tx, isOnePhase);
    }
 
-   public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       for (Map.Entry<CacheLoader, CacheLoaderConfig> e : loaders.entrySet()) {
          e.getKey().init(e.getValue(), cache, m);
       }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/loaders/file/FileCacheStore.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/loaders/file/FileCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/loaders/file/FileCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -8,7 +8,7 @@
 import org.infinispan.loaders.CacheLoaderMetadata;
 import org.infinispan.loaders.bucket.Bucket;
 import org.infinispan.loaders.bucket.BucketBasedCacheStore;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.Util;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
@@ -41,7 +41,7 @@
    }
 
    @Override
-   public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       super.init(config, cache, m);
       this.config = (FileCacheStoreConfig) config;
    }

Deleted: branches/4.1.x/core/src/main/java/org/infinispan/marshall/AbstractMarshaller.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/AbstractMarshaller.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/AbstractMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,26 +0,0 @@
-package org.infinispan.marshall;
-
-import org.infinispan.io.ExposedByteArrayOutputStream;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Abstract marshaller
- *
- * @author Manik Surtani
- * @since 4.0
- */
-public abstract class AbstractMarshaller implements Marshaller {
-
-   public Object objectFromInputStream(InputStream inputStream) throws IOException, ClassNotFoundException {
-      // TODO: available() call commented until https://issues.apache.org/jira/browse/HTTPCORE-199 httpcore-nio issue is fixed. 
-      // int len = inputStream.available();
-      int len = 1024;
-      ExposedByteArrayOutputStream bytes = new ExposedByteArrayOutputStream(len);
-      byte[] buf = new byte[Math.min(len, 1024)];
-      int bytesRead;
-      while ((bytesRead = inputStream.read(buf, 0, buf.length)) != -1) bytes.write(buf, 0, bytesRead);
-      return objectFromByteBuffer(bytes.getRawBuffer(), 0, bytes.size());
-   }
-}

Copied: branches/4.1.x/core/src/main/java/org/infinispan/marshall/AbstractStreamingMarshaller.java (from rev 2029, trunk/core/src/main/java/org/infinispan/marshall/AbstractStreamingMarshaller.java)
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/AbstractStreamingMarshaller.java	                        (rev 0)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/AbstractStreamingMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -0,0 +1,31 @@
+package org.infinispan.marshall;
+
+import org.infinispan.io.ByteBuffer;
+import org.infinispan.io.ExposedByteArrayOutputStream;
+
+import java.io.*;
+
+/**
+ * Abstract marshaller
+ *
+ * @author Manik Surtani
+ * @since 4.0
+ */
+public abstract class AbstractStreamingMarshaller implements StreamingMarshaller {
+
+   protected static final int DEFAULT_BUF_SIZE = 512;
+
+   public Object objectFromInputStream(InputStream inputStream) throws IOException, ClassNotFoundException {
+      // TODO: available() call commented until https://issues.apache.org/jira/browse/HTTPCORE-199 httpcore-nio issue is fixed. 
+      // int len = inputStream.available();
+      ExposedByteArrayOutputStream bytes = new ExposedByteArrayOutputStream(DEFAULT_BUF_SIZE);
+      byte[] buf = new byte[Math.min(DEFAULT_BUF_SIZE, 1024)];
+      int bytesRead;
+      while ((bytesRead = inputStream.read(buf, 0, buf.length)) != -1) bytes.write(buf, 0, bytesRead);
+      return objectFromByteBuffer(bytes.getRawBuffer(), 0, bytes.size());
+   }
+
+   public byte[] objectToByteBuffer(Object o) throws IOException {
+      return objectToByteBuffer(o, DEFAULT_BUF_SIZE);
+   }
+}

Modified: branches/4.1.x/core/src/main/java/org/infinispan/marshall/MarshalledValue.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/MarshalledValue.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/MarshalledValue.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -56,9 +56,9 @@
    volatile private int cachedHashCode = 0;
    // by default equals() will test on the instance rather than the byte array if conversion is required.
    private transient boolean equalityPreferenceForInstance = true;
-   private final Marshaller marshaller;
+   private final StreamingMarshaller marshaller;
 
-   public MarshalledValue(Object instance, boolean equalityPreferenceForInstance, Marshaller marshaller) throws NotSerializableException {
+   public MarshalledValue(Object instance, boolean equalityPreferenceForInstance, StreamingMarshaller marshaller) throws NotSerializableException {
       if (instance == null) throw new NullPointerException("Null values cannot be wrapped as MarshalledValues!");
 
       if (instance instanceof Serializable)
@@ -69,7 +69,7 @@
       this.marshaller = marshaller;
    }
 
-   public MarshalledValue(byte[] raw, int cachedHashCode, Marshaller marshaller) {
+   public MarshalledValue(byte[] raw, int cachedHashCode, StreamingMarshaller marshaller) {
       init(raw, cachedHashCode);
       this.marshaller = marshaller;
    }
@@ -107,7 +107,7 @@
    public synchronized void deserialize() {
       if (instance == null) {
          try {
-            // Marshaller underneath deals with making sure the right classloader is set.
+            // StreamingMarshaller underneath deals with making sure the right classloader is set.
             instance = marshaller.objectFromByteBuffer(raw);
          }
          catch (Exception e) {
@@ -232,9 +232,9 @@
    }
    
    public static class Externalizer implements org.infinispan.marshall.Externalizer {
-      private Marshaller marshaller;
+      private StreamingMarshaller marshaller;
       
-      public void inject(Marshaller marshaller) {
+      public void inject(StreamingMarshaller marshaller) {
          this.marshaller = marshaller;
       }
       

Deleted: branches/4.1.x/core/src/main/java/org/infinispan/marshall/Marshaller.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/Marshaller.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/Marshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,157 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, 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;
-
-import org.infinispan.factories.scopes.Scope;
-import org.infinispan.factories.scopes.Scopes;
-import org.infinispan.io.ByteBuffer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.OutputStream;
-
-/**
- * A marshaller is a class that is able to marshall and unmarshall objects efficiently.
- * <p/>
- * The reason why this is implemented specially in Infinispan rather than resorting to Java serialization or even the
- * more efficient JBoss serialization is that a lot of efficiency can be gained when a majority of the serialization
- * that occurs has to do with a small set of known types such as {@link org.infinispan.transaction.GlobalTransaction} or
- * {@link org.infinispan.commands.ReplicableCommand}, and class type information can be replaced with simple magic
- * numbers.
- * <p/>
- * Unknown types (typically user data) falls back to JBoss serialization.
- * <p/>
- * In addition, using a marshaller allows adding additional data to the byte stream, such as context class loader
- * information on which class loader to use to deserialize the object stream, or versioning information to allow streams
- * to interoperate between different versions of Infinispan (see {@link VersionAwareMarshaller}
- * <p/>
- * This interface is used to marshall {@link org.infinispan.commands.ReplicableCommand}s, their parameters and their
- * response values.
- * <p/>
- * The interface is also used by the {@link org.infinispan.loaders.CacheStore} framework to efficiently serialize data
- * to be persisted, as well as the {@link org.infinispan.statetransfer.StateTransferManager} when serializing the cache
- * for transferring state en-masse.
- *
- * @author <a href="mailto://manik@jboss.org">Manik Surtani</a>
- * @author Galder Zamarreño
- * @since 4.0
- */
- at Scope(Scopes.GLOBAL)
-public interface Marshaller {
-
-   /**
-    * <p>Create and open an ObjectOutput instance for the given output stream. This method should be used for opening data 
-    * outputs when multiple objectToObjectStream() calls will be made before the stream is closed by calling finishObjectOutput().</p>
-    * 
-    * <p>This method also takes a boolean that represents whether this particular call to startObjectOutput() is reentrant 
-    * or not. A call to startObjectOutput() should be marked reentrant whenever a 2nd or more calls to this method are made 
-    * without having called finishObjectOutput() first.     
-    * 
-    * <p>To potentially speed up calling startObjectOutput multiple times in a non-reentrant way, i.e. 
-    * startObjectOutput/finishObjectOutput...startObjectOutput/finishObjectOutput...etc, which is is the most common case, the 
-    * Marshaller implementation could potentially use some mechanisms to speed up this startObjectOutput call. 
-    *  
-    * <p>On the other hand, when a call is reentrant, i.e. startObjectOutput/startObjectOutput(reentrant)...finishObjectOutput/finishObjectOutput, 
-    * the Marshaller implementation might treat it differently. An example of reentrancy would be marshalling of {@link MarshalledValue}. 
-    * When sending or storing a MarshalledValue, a call to startObjectOutput() would occur so that the stream is open and 
-    * following, a 2nd call could occur so that MarshalledValue's raw byte array version is calculated and sent accross. 
-    * This enables lazy deserialization on the receiver side which is performance gain. The Marshaller implementation could decide 
-    * that it needs a separate ObjectOutput or similar for the 2nd call since it's aim is only to get the raw byte array version 
-    * and the close finish with it.</p>
-    *
-    * @param os output stream
-    * @param isReentrant whether the call is reentrant or not. 
-    * @return ObjectOutput to write to
-    * @throws IOException
-    */
-   ObjectOutput startObjectOutput(OutputStream os, boolean isReentrant) throws IOException;
-
-   /**
-    * Finish using the given ObjectOutput. After opening a ObjectOutput and calling objectToObjectStream() mutliple
-    * times, use this method to flush the data and close if necessary
-    *
-    * @param oo data output that finished using
-    */
-   void finishObjectOutput(ObjectOutput oo);
-
-   /**
-    * Marshalls an object to a given {@link java.io.ObjectOutput}
-    *
-    * @param obj object to marshall
-    * @param out stream to marshall to
-    */
-   void objectToObjectStream(Object obj, ObjectOutput out) throws IOException;
-
-   /**
-    * <p>Create and open a new ObjectInput for the given input stream. This method should be used for opening data inputs
-    * when multiple objectFromObjectStream() calls will be made before the stream is closed.</p>
-    * 
-    * <p>This method also takes a boolean that represents whether this particular call to startObjectInput() is reentrant 
-    * or not. A call to startObjectInput() should be marked reentrant whenever a 2nd or more calls to this method are made 
-    * without having called finishObjectInput() first.</p>     
-    * 
-    * <p>To potentially speed up calling startObjectInput multiple times in a non-reentrant way, i.e. 
-    * startObjectInput/finishObjectInput...startObjectInput/finishObjectInput...etc, which is is the most common case, the 
-    * Marshaller implementation could potentially use some mechanisms to speed up this startObjectInput call.</p> 
-    *  
-    * @param is input stream
-    * @param isReentrant whether the call is reentrant or not. 
-    * @return ObjectInput to read from
-    * @throws IOException
-    */
-   ObjectInput startObjectInput(InputStream is, boolean isReentrant) throws IOException;
-
-   /**
-    * Finish using the given ObjectInput. After opening a ObjectInput and calling objectFromObjectStream() mutliple
-    * times, use this method to flush the data and close if necessary
-    *
-    * @param oi data input that finished using
-    */
-   void finishObjectInput(ObjectInput oi);
-
-   /**
-    * Unmarshalls an object from an {@link java.io.ObjectInput}
-    *
-    * @param in stream to unmarshall from
-    */
-   Object objectFromObjectStream(ObjectInput in) throws IOException, ClassNotFoundException;
-
-   /**
-    * A method that returns an instance of {@link org.infinispan.io.ByteBuffer}, which allows direct access to the byte
-    * array with minimal array copying
-    *
-    * @param o object to marshall
-    * @return a ByteBuffer
-    * @throws Exception
-    */
-   ByteBuffer objectToBuffer(Object o) throws IOException;
-
-   Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException, ClassNotFoundException;
-
-   byte[] objectToByteBuffer(Object obj) throws IOException;
-
-   Object objectFromByteBuffer(byte[] buf) throws IOException, ClassNotFoundException;
-
-   Object objectFromInputStream(InputStream is) throws IOException, ClassNotFoundException;
-}
\ No newline at end of file

Copied: branches/4.1.x/core/src/main/java/org/infinispan/marshall/Marshaller.java (from rev 2029, trunk/core/src/main/java/org/infinispan/marshall/Marshaller.java)
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/Marshaller.java	                        (rev 0)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/Marshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -0,0 +1,68 @@
+package org.infinispan.marshall;
+
+import net.jcip.annotations.ThreadSafe;
+
+import java.io.IOException;
+
+/**
+ * A marshaller is a class that is able to marshall and unmarshall objects efficiently.
+ * <p/>
+ * This interface is used to marshall {@link org.infinispan.commands.ReplicableCommand}s, their parameters and their
+ * response values, as well as any other arbitraty Object <--> byte[] conversions, such as those used in client/server
+ * communications.
+ * <p/>
+ * The interface is also used by the {@link org.infinispan.loaders.CacheStore} framework to efficiently serialize data
+ * to be persisted, as well as the {@link org.infinispan.statetransfer.StateTransferManager} when serializing the cache
+ * for transferring state en-masse.
+ * <p />
+ * A single instance of any implementation is shared by multiple threads, so implementations <i>need</i> to be threadsafe,
+ * and preferably immutable.
+ *
+ * @author Manik Surtani
+ * @version 4.1
+ */
+ at ThreadSafe
+public interface Marshaller {
+
+   /**
+    * Marshalls an object to a byte array.  The estimatedSize parameter is a hint that can be passed in to allow for
+    * efficient sizing of the byte array before attempting to marshall the object.  The more accurate this estimate is,
+    * the less likely byte[]s will need to be resized to hold the byte stream generated by marshalling the object.
+    *
+    * @param obj object to convert to a byte array.  Must not be null.
+    * @param estimatedSize an estimate of how large the resulting byte array may be
+    * @return a byte array
+    * @throws IOException
+    */
+   byte[] objectToByteBuffer(Object obj, int estimatedSize) throws IOException;
+
+   /**
+    * Marshalls an object to a byte array.
+    *
+    * @param obj object to convert to a byte array.  Must not be null.
+    * @return a byte array
+    * @throws IOException
+    */
+   byte[] objectToByteBuffer(Object obj) throws IOException;
+
+   /**
+    * Unmarshalls an object from a byte array.
+    * @param buf byte array containing the binary representation of an object.  Must not be null.
+    * @return an object
+    * @throws IOException
+    * @throws ClassNotFoundException
+    */
+   Object objectFromByteBuffer(byte[] buf) throws IOException, ClassNotFoundException;
+
+   /**
+    * Unmarshalls an object from a specific portion of a byte array.
+    * @param buf byte array containing the binary representation of an object.  Must not be null.
+    * @param offset point in buffer to start reading
+    * @param length number of bytes to consider
+    * @return an object
+    * @throws IOException
+    * @throws ClassNotFoundException
+    */
+   Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException, ClassNotFoundException;
+}
+

Copied: branches/4.1.x/core/src/main/java/org/infinispan/marshall/StreamingMarshaller.java (from rev 2029, trunk/core/src/main/java/org/infinispan/marshall/StreamingMarshaller.java)
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/StreamingMarshaller.java	                        (rev 0)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/StreamingMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, 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;
+
+import net.jcip.annotations.ThreadSafe;
+import org.infinispan.factories.scopes.Scope;
+import org.infinispan.factories.scopes.Scopes;
+import org.infinispan.io.ByteBuffer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.OutputStream;
+
+/**
+ * A specialization of {@link Marshaller} that supports streams.
+ * <p/>
+ * A single instance of any implementation is shared by multiple threads, so implementations <i>need</i> to be threadsafe,
+ * and preferably immutable.
+ *
+ * @author Manik Surtani
+ * @author Galder Zamarreño
+ * @since 4.0
+ *
+ * @see Marshaller
+ */
+ at Scope(Scopes.GLOBAL)
+ at ThreadSafe
+public interface StreamingMarshaller extends Marshaller {
+
+   /**
+    * <p>Create and open an ObjectOutput instance for the given output stream. This method should be used for opening data 
+    * outputs when multiple objectToObjectStream() calls will be made before the stream is closed by calling finishObjectOutput().</p>
+    * 
+    * <p>This method also takes a boolean that represents whether this particular call to startObjectOutput() is reentrant 
+    * or not. A call to startObjectOutput() should be marked reentrant whenever a 2nd or more calls to this method are made 
+    * without having called finishObjectOutput() first.     
+    * 
+    * <p>To potentially speed up calling startObjectOutput multiple times in a non-reentrant way, i.e. 
+    * startObjectOutput/finishObjectOutput...startObjectOutput/finishObjectOutput...etc, which is is the most common case, the 
+    * StreamingMarshaller implementation could potentially use some mechanisms to speed up this startObjectOutput call.
+    *  
+    * <p>On the other hand, when a call is reentrant, i.e. startObjectOutput/startObjectOutput(reentrant)...finishObjectOutput/finishObjectOutput, 
+    * the StreamingMarshaller implementation might treat it differently. An example of reentrancy would be marshalling of {@link MarshalledValue}.
+    * When sending or storing a MarshalledValue, a call to startObjectOutput() would occur so that the stream is open and 
+    * following, a 2nd call could occur so that MarshalledValue's raw byte array version is calculated and sent accross. 
+    * This enables lazy deserialization on the receiver side which is performance gain. The StreamingMarshaller implementation could decide
+    * that it needs a separate ObjectOutput or similar for the 2nd call since it's aim is only to get the raw byte array version 
+    * and the close finish with it.</p>
+    *
+    * @param os output stream
+    * @param isReentrant whether the call is reentrant or not. 
+    * @return ObjectOutput to write to
+    * @throws IOException
+    */
+   ObjectOutput startObjectOutput(OutputStream os, boolean isReentrant) throws IOException;
+
+   /**
+    * Finish using the given ObjectOutput. After opening a ObjectOutput and calling objectToObjectStream() mutliple
+    * times, use this method to flush the data and close if necessary
+    *
+    * @param oo data output that finished using
+    */
+   void finishObjectOutput(ObjectOutput oo);
+
+   /**
+    * Marshalls an object to a given {@link java.io.ObjectOutput}
+    *
+    * @param obj object to marshall
+    * @param out stream to marshall to
+    */
+   void objectToObjectStream(Object obj, ObjectOutput out) throws IOException;
+
+   /**
+    * <p>Create and open a new ObjectInput for the given input stream. This method should be used for opening data inputs
+    * when multiple objectFromObjectStream() calls will be made before the stream is closed.</p>
+    * 
+    * <p>This method also takes a boolean that represents whether this particular call to startObjectInput() is reentrant 
+    * or not. A call to startObjectInput() should be marked reentrant whenever a 2nd or more calls to this method are made 
+    * without having called finishObjectInput() first.</p>     
+    * 
+    * <p>To potentially speed up calling startObjectInput multiple times in a non-reentrant way, i.e. 
+    * startObjectInput/finishObjectInput...startObjectInput/finishObjectInput...etc, which is is the most common case, the 
+    * StreamingMarshaller implementation could potentially use some mechanisms to speed up this startObjectInput call.</p> 
+    *  
+    * @param is input stream
+    * @param isReentrant whether the call is reentrant or not. 
+    * @return ObjectInput to read from
+    * @throws IOException
+    */
+   ObjectInput startObjectInput(InputStream is, boolean isReentrant) throws IOException;
+
+   /**
+    * Finish using the given ObjectInput. After opening a ObjectInput and calling objectFromObjectStream() mutliple
+    * times, use this method to flush the data and close if necessary
+    *
+    * @param oi data input that finished using
+    */
+   void finishObjectInput(ObjectInput oi);
+
+   /**
+    * Unmarshalls an object from an {@link java.io.ObjectInput}
+    *
+    * @param in stream to unmarshall from
+    */
+   Object objectFromObjectStream(ObjectInput in) throws IOException, ClassNotFoundException;
+
+   /**
+    * A method that returns an instance of {@link org.infinispan.io.ByteBuffer}, which allows direct access to the byte
+    * array with minimal array copying
+    *
+    * @param o object to marshall
+    * @return a ByteBuffer
+    * @throws Exception
+    */
+   ByteBuffer objectToBuffer(Object o) throws IOException;
+
+   Object objectFromInputStream(InputStream is) throws IOException, ClassNotFoundException;
+}
\ No newline at end of file

Modified: branches/4.1.x/core/src/main/java/org/infinispan/marshall/VersionAwareMarshaller.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/VersionAwareMarshaller.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/VersionAwareMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -48,7 +48,7 @@
  * @author Galder Zamarreño
  * @since 4.0
  */
-public class VersionAwareMarshaller extends AbstractMarshaller {
+public class VersionAwareMarshaller extends AbstractStreamingMarshaller {
    private static final Log log = LogFactory.getLog(VersionAwareMarshaller.class);
    private boolean trace = log.isTraceEnabled();
 
@@ -85,15 +85,16 @@
       return CUSTOM_MARSHALLER;
    }
 
-   public ByteBuffer objectToBuffer(Object obj) throws IOException {
-      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
+   private ByteBuffer objectToBuffer(Object obj, int estimatedSize) throws IOException {
+      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(estimatedSize);
       ObjectOutput out = startObjectOutput(baos, false);
       try {
          defaultMarshaller.objectToObjectStream(obj, out);
-      } catch(NotSerializableException nse) {
+      } catch (
+              java.io.NotSerializableException nse) {
          if (log.isTraceEnabled()) log.trace("Object is not serializable", nse);
          throw new org.infinispan.marshall.NotSerializableException(nse.getMessage(), nse.getCause());
-      } catch(IOException ioe) {
+      } catch (IOException ioe) {
          if (log.isTraceEnabled()) log.trace("Exception while marshalling object", ioe);
          throw ioe;
       } finally {
@@ -102,6 +103,10 @@
       return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
    }
 
+   public ByteBuffer objectToBuffer(Object obj) throws IOException {
+      return objectToBuffer(obj, DEFAULT_BUF_SIZE);
+   }
+
    public Object objectFromByteBuffer(byte[] bytes, int offset, int len) throws IOException, ClassNotFoundException {
       ByteArrayInputStream is = new ByteArrayInputStream(bytes, offset, len);
       ObjectInput in = startObjectInput(is, false);
@@ -172,8 +177,8 @@
       return defaultMarshaller.objectFromObjectStream(in);
    }
 
-   public byte[] objectToByteBuffer(Object obj) throws IOException {
-      ByteBuffer b = objectToBuffer(obj);
+   public byte[] objectToByteBuffer(Object obj, int estimatedSize) throws IOException {
+      ByteBuffer b = objectToBuffer(obj, estimatedSize);
       byte[] bytes = new byte[b.getLength()];
       System.arraycopy(b.getBuf(), b.getOffset(), bytes, 0, b.getLength());
       return bytes;

Modified: branches/4.1.x/core/src/main/java/org/infinispan/marshall/jboss/ConstantObjectTable.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/jboss/ConstantObjectTable.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/jboss/ConstantObjectTable.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -59,6 +59,7 @@
 import org.infinispan.marshall.Externalizer;
 import org.infinispan.marshall.Marshallable;
 import org.infinispan.marshall.MarshalledValue;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.exts.ArrayListExternalizer;
 import org.infinispan.marshall.exts.LinkedListExternalizer;
 import org.infinispan.marshall.exts.MapExternalizer;
@@ -130,7 +131,7 @@
       MARSHALLABLES.add(ExceptionResponse.class.getName());
       MARSHALLABLES.add(RequestIgnoredResponse.class.getName());
       MARSHALLABLES.add(UnsuccessfulResponse.class.getName());
-      MARSHALLABLES.add(UnsureResponse.class.getName());      
+      MARSHALLABLES.add(UnsureResponse.class.getName());
 
       MARSHALLABLES.add(StateTransferControlCommand.class.getName());
       MARSHALLABLES.add(ClusteredGetCommand.class.getName());
@@ -188,42 +189,35 @@
     */
    private final Map<Integer, ExternalizerAdapter> readers = new HashMap<Integer, ExternalizerAdapter>();
 
-   public void start(RemoteCommandsFactory cmdFactory, org.infinispan.marshall.Marshaller ispnMarshaller) {
+   public void start(RemoteCommandsFactory cmdFactory, StreamingMarshaller ispnMarshaller) {
       HashSet<Integer> ids = new HashSet<Integer>();
 
       for (Map.Entry<String, String> entry : JDK_EXTERNALIZERS.entrySet()) {
          try {
-            Class clazz = Util.loadClass(entry.getKey());
+            Class clazz = Util.loadClassStrict(entry.getKey());
             Externalizer ext = null;
-            try {
-               ext = (Externalizer) Util.getInstance(entry.getValue());
-            } catch (Exception e) {
-               throw new CacheException("Could not instantiate entry: " + entry, e);
-            }
+            ext = (Externalizer) Util.getInstanceStrict(entry.getValue());
             Marshallable marshallable = ReflectionUtil.getAnnotation(ext.getClass(), Marshallable.class);
             int id = marshallable.id();
             ids.add(id);
             ExternalizerAdapter adapter = new ExternalizerAdapter(id, ext);
             writers.put(clazz, adapter);
             readers.put(id, adapter);
-         } catch (ClassNotFoundException e) {
-            if (log.isDebugEnabled())
+         } catch (Exception e) {
+            if (log.isDebugEnabled()) {
                log.debug("Unable to load class {0}", e.getMessage());
+            }
          }
       }
 
       for (String marshallableClass : MARSHALLABLES) {
          try {
-            Class clazz = Util.loadClass(marshallableClass);
+            Class clazz = Util.loadClassStrict(marshallableClass);
             Marshallable marshallable = ReflectionUtil.getAnnotation(clazz, Marshallable.class);
             if (marshallable != null && !marshallable.externalizer().equals(Externalizer.class)) {
                int id = marshallable.id();
                Externalizer ext = null;
-               try {
-                  ext = Util.getInstance(marshallable.externalizer());
-               } catch (Exception e) {
-                  throw new CacheException("Could not instantiate the externalizer: " + marshallable.externalizer(), e);
-               }
+               ext = Util.getInstance(marshallable.externalizer());
                if (!ids.add(id))
                   throw new CacheException("Duplicate id found! id=" + id + " in " + ext.getClass().getName() + " is shared by another marshallable class.");
                if (ext instanceof ReplicableCommandExternalizer) {

Modified: branches/4.1.x/core/src/main/java/org/infinispan/marshall/jboss/JBossMarshaller.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/marshall/jboss/JBossMarshaller.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/marshall/jboss/JBossMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -25,7 +25,8 @@
 import org.infinispan.commands.RemoteCommandsFactory;
 import org.infinispan.io.ByteBuffer;
 import org.infinispan.io.ExposedByteArrayOutputStream;
-import org.infinispan.marshall.AbstractMarshaller;
+import org.infinispan.marshall.AbstractStreamingMarshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.util.Util;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
@@ -48,12 +49,18 @@
 import java.net.URL;
 
 /**
- * JBossMarshaller.
+ * The reason why this is implemented specially in Infinispan rather than resorting to Java serialization or even the
+ * more efficient JBoss serialization is that a lot of efficiency can be gained when a majority of the serialization
+ * that occurs has to do with a small set of known types such as {@link org.infinispan.transaction.GlobalTransaction} or
+ * {@link org.infinispan.commands.ReplicableCommand}, and class type information can be replaced with simple magic
+ * numbers.
+ * <p/>
+ * Unknown types (typically user data) falls back to JBoss serialization.
  *
  * @author Galder Zamarreño
  * @since 4.0
  */
-public class JBossMarshaller extends AbstractMarshaller {
+public class JBossMarshaller extends AbstractStreamingMarshaller {
    private static final Log log = LogFactory.getLog(JBossMarshaller.class);
    private static final String DEFAULT_MARSHALLER_FACTORY = "org.jboss.marshalling.river.RiverMarshallerFactory";
    private ClassLoader defaultCl;
@@ -62,7 +69,7 @@
    private ConstantObjectTable objectTable;
 
    /**
-    * Marshaller thread local. JBossMarshaller is a singleton shared by all caches (global component), so no urgent need
+    * StreamingMarshaller thread local. JBossMarshaller is a singleton shared by all caches (global component), so no urgent need
     * for static here. JBMAR clears pretty much any state during finish(), so no urgent need to clear the thread local
     * since it shouldn't be leaking.
     */
@@ -93,14 +100,10 @@
       }
    };
 
-   public void start(ClassLoader defaultCl, RemoteCommandsFactory cmdFactory, org.infinispan.marshall.Marshaller ispnMarshaller) {
+   public void start(ClassLoader defaultCl, RemoteCommandsFactory cmdFactory, StreamingMarshaller ispnMarshaller) {
       if (log.isDebugEnabled()) log.debug("Using JBoss Marshalling");
       this.defaultCl = defaultCl;
-      try {
-         factory = (MarshallerFactory) Util.getInstance(DEFAULT_MARSHALLER_FACTORY);
-      } catch (Exception e) {
-         throw new CacheException("Unable to load JBoss Marshalling marshaller factory " + DEFAULT_MARSHALLER_FACTORY, e);
-      }
+      factory = (MarshallerFactory) Util.getInstance(DEFAULT_MARSHALLER_FACTORY);
 
       objectTable = createCustomObjectTable(cmdFactory, ispnMarshaller);
       configuration = new MarshallingConfiguration();
@@ -118,15 +121,19 @@
       if (objectTable != null) objectTable.stop();
    }
 
-   public byte[] objectToByteBuffer(Object obj) throws IOException {
-      ByteBuffer b = objectToBuffer(obj);
+   public byte[] objectToByteBuffer(Object obj, int estimatedSize) throws IOException {
+      ByteBuffer b = objectToBuffer(obj, estimatedSize);
       byte[] bytes = new byte[b.getLength()];
       System.arraycopy(b.getBuf(), b.getOffset(), bytes, 0, b.getLength());
       return bytes;
    }
 
    public ByteBuffer objectToBuffer(Object o) throws IOException {
-      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
+      return objectToBuffer(o, DEFAULT_BUF_SIZE);
+   }
+
+   private ByteBuffer objectToBuffer(Object o, int estimatedSize) throws IOException {
+      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(estimatedSize);
       ObjectOutput marshaller = startObjectOutput(baos, false);
       try {
          objectToObjectStream(o, marshaller);
@@ -174,7 +181,7 @@
    }
 
    public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException,
-                                                                                 ClassNotFoundException {
+           ClassNotFoundException {
       ByteArrayInputStream is = new ByteArrayInputStream(buf, offset, length);
       ObjectInput unmarshaller = startObjectInput(is, false);
       Object o = null;
@@ -208,7 +215,7 @@
       return in.readObject();
    }
 
-   private ConstantObjectTable createCustomObjectTable(RemoteCommandsFactory cmdFactory, org.infinispan.marshall.Marshaller ispnMarshaller) {
+   private ConstantObjectTable createCustomObjectTable(RemoteCommandsFactory cmdFactory, StreamingMarshaller ispnMarshaller) {
       ConstantObjectTable objectTable = new ConstantObjectTable();
       objectTable.start(cmdFactory, ispnMarshaller);
       return objectTable;
@@ -263,7 +270,8 @@
                Object[] args = EMPTY_OBJECTS;
                urls = (URL[]) getURLs.invoke(cl, args);
             }
-         } catch (Exception ignore) {}
+         } catch (Exception ignore) {
+         }
          return urls;
       }
 

Modified: branches/4.1.x/core/src/main/java/org/infinispan/remoting/InboundInvocationHandlerImpl.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/remoting/InboundInvocationHandlerImpl.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/remoting/InboundInvocationHandlerImpl.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -9,7 +9,7 @@
 import org.infinispan.factories.scopes.Scope;
 import org.infinispan.factories.scopes.Scopes;
 import org.infinispan.manager.NamedCacheNotFoundException;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.remoting.responses.ExceptionResponse;
 import org.infinispan.remoting.responses.RequestIgnoredResponse;
 import org.infinispan.remoting.responses.Response;
@@ -33,10 +33,10 @@
 public class InboundInvocationHandlerImpl implements InboundInvocationHandler {
    GlobalComponentRegistry gcr;
    private static final Log log = LogFactory.getLog(InboundInvocationHandlerImpl.class);
-   private Marshaller marshaller;
+   private StreamingMarshaller marshaller;
 
    @Inject
-   public void inject(GlobalComponentRegistry gcr, Marshaller marshaller) {
+   public void inject(GlobalComponentRegistry gcr, StreamingMarshaller marshaller) {
       this.gcr = gcr;
       this.marshaller = marshaller;
    }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/Transport.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/Transport.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/Transport.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -10,7 +10,7 @@
 import org.infinispan.factories.scopes.Scope;
 import org.infinispan.factories.scopes.Scopes;
 import org.infinispan.lifecycle.Lifecycle;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.notifications.cachemanagerlistener.CacheManagerNotifier;
 import org.infinispan.remoting.InboundInvocationHandler;
 import org.infinispan.remoting.responses.Response;
@@ -44,7 +44,7 @@
     * @param notifier      notifier to use
     */
    @Inject
-   void initialize(GlobalConfiguration c, Marshaller marshaller,
+   void initialize(GlobalConfiguration c, StreamingMarshaller marshaller,
                    @ComponentName(KnownComponentNames.ASYNC_TRANSPORT_EXECUTOR) ExecutorService asyncExecutor,
                    InboundInvocationHandler handler, CacheManagerNotifier notifier);
 

Modified: branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -27,7 +27,7 @@
 import org.infinispan.config.ConfigurationException;
 import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.config.parsing.XmlConfigHelper;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.notifications.cachemanagerlistener.CacheManagerNotifier;
 import org.infinispan.remoting.InboundInvocationHandler;
 import org.infinispan.remoting.ReplicationException;
@@ -68,7 +68,6 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-import java.util.Properties;
 import java.util.Vector;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -112,7 +111,7 @@
    protected GlobalConfiguration c;
    protected TypedProperties props;
    protected InboundInvocationHandler inboundInvocationHandler;
-   protected Marshaller marshaller;
+   protected StreamingMarshaller marshaller;
    protected ExecutorService asyncExecutor;
    protected CacheManagerNotifier notifier;
    final ConcurrentMap<String, StateTransferMonitor> stateTransfersInProgress = new ConcurrentHashMap<String, StateTransferMonitor>();
@@ -137,7 +136,7 @@
    // Lifecycle and setup stuff
    // ------------------------------------------------------------------------------------------------------------------
 
-   public void initialize(GlobalConfiguration c, Marshaller marshaller, ExecutorService asyncExecutor,
+   public void initialize(GlobalConfiguration c, StreamingMarshaller marshaller, ExecutorService asyncExecutor,
                           InboundInvocationHandler inboundInvocationHandler, CacheManagerNotifier notifier) {
       this.c = c;
       this.marshaller = marshaller;

Modified: branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/jgroups/MarshallerAdapter.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/jgroups/MarshallerAdapter.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/remoting/transport/jgroups/MarshallerAdapter.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -1,7 +1,7 @@
 package org.infinispan.remoting.transport.jgroups;
 
 import org.infinispan.io.ByteBuffer;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.jgroups.blocks.RpcDispatcher;
 import org.jgroups.util.Buffer;
 
@@ -12,9 +12,9 @@
  * @since 4.0
  */
 public class MarshallerAdapter implements RpcDispatcher.Marshaller2 {
-   Marshaller m;
+   StreamingMarshaller m;
 
-   public MarshallerAdapter(Marshaller m) {
+   public MarshallerAdapter(StreamingMarshaller m) {
       this.m = m;
    }
 

Modified: branches/4.1.x/core/src/main/java/org/infinispan/statetransfer/StateTransferManagerImpl.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/statetransfer/StateTransferManagerImpl.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/statetransfer/StateTransferManagerImpl.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -42,7 +42,7 @@
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheLoaderManager;
 import org.infinispan.loaders.CacheStore;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.remoting.rpc.ResponseMode;
 import org.infinispan.remoting.rpc.RpcManager;
 import org.infinispan.remoting.transport.Address;
@@ -73,7 +73,7 @@
    DataContainer dataContainer;
    CacheLoaderManager clm;
    CacheStore cs;
-   Marshaller marshaller;
+   StreamingMarshaller marshaller;
    TransactionLog transactionLog;
    InvocationContextContainer invocationContextContainer;
    InterceptorChain interceptorChain;
@@ -90,7 +90,7 @@
    @Inject
    @SuppressWarnings("unchecked")
    public void injectDependencies(RpcManager rpcManager, AdvancedCache cache, Configuration configuration,
-                                  DataContainer dataContainer, CacheLoaderManager clm, Marshaller marshaller,
+                                  DataContainer dataContainer, CacheLoaderManager clm, StreamingMarshaller marshaller,
                                   TransactionLog transactionLog, InterceptorChain interceptorChain, InvocationContextContainer invocationContextContainer,
                                   CommandsFactory commandsFactory, TransactionTable txTable) {
       this.rpcManager = rpcManager;

Modified: branches/4.1.x/core/src/main/java/org/infinispan/transaction/TransactionLog.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/transaction/TransactionLog.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/transaction/TransactionLog.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -26,7 +26,7 @@
 import org.infinispan.io.UnsignedNumeric;
 import org.infinispan.marshall.Ids;
 import org.infinispan.marshall.Marshallable;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
@@ -153,7 +153,7 @@
       return entries.size();
    }
 
-   public void writeCommitLog(Marshaller marshaller, ObjectOutput out) throws Exception {
+   public void writeCommitLog(StreamingMarshaller marshaller, ObjectOutput out) throws Exception {
       List<LogEntry> buffer = new ArrayList<LogEntry>(10);
 
       while (entries.drainTo(buffer, 10) > 0) {
@@ -164,7 +164,7 @@
       }
    }
 
-   public void writePendingPrepares(Marshaller marshaller, ObjectOutput out) throws Exception {
+   public void writePendingPrepares(StreamingMarshaller marshaller, ObjectOutput out) throws Exception {
       if (log.isTraceEnabled()) log.trace("Writing {0} pending prepares to the stream", pendingPrepares.size());
       for (PrepareCommand entry : pendingPrepares.values()) marshaller.objectToObjectStream(entry, out);
    }

Modified: branches/4.1.x/core/src/main/java/org/infinispan/transaction/lookup/GenericTransactionManagerLookup.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/transaction/lookup/GenericTransactionManagerLookup.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/transaction/lookup/GenericTransactionManagerLookup.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -143,19 +143,19 @@
       Class clazz;
       try {
          log.debug("Trying WebSphere 5.1: " + WS_FACTORY_CLASS_5_1);
-         clazz = Util.loadClass(WS_FACTORY_CLASS_5_1);
+         clazz = Util.loadClassStrict(WS_FACTORY_CLASS_5_1);
          log.debug("Found WebSphere 5.1: " + WS_FACTORY_CLASS_5_1);
       }
       catch (ClassNotFoundException ex) {
          try {
             log.debug("Trying WebSphere 5.0: " + WS_FACTORY_CLASS_5_0);
-            clazz = Util.loadClass(WS_FACTORY_CLASS_5_0);
+            clazz = Util.loadClassStrict(WS_FACTORY_CLASS_5_0);
             log.debug("Found WebSphere 5.0: " + WS_FACTORY_CLASS_5_0);
          }
          catch (ClassNotFoundException ex2) {
             try {
                log.debug("Trying WebSphere 4: " + WS_FACTORY_CLASS_4);
-               clazz = Util.loadClass(WS_FACTORY_CLASS_4);
+               clazz = Util.loadClassStrict(WS_FACTORY_CLASS_4);
                log.debug("Found WebSphere 4: " + WS_FACTORY_CLASS_4);
             }
             catch (ClassNotFoundException ex3) {

Modified: branches/4.1.x/core/src/main/java/org/infinispan/transaction/lookup/JBossStandaloneJTAManagerLookup.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/transaction/lookup/JBossStandaloneJTAManagerLookup.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/transaction/lookup/JBossStandaloneJTAManagerLookup.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -42,8 +42,8 @@
 
    public JBossStandaloneJTAManagerLookup() {
       try {
-         manager = Util.loadClass("com.arjuna.ats.jta.TransactionManager").getMethod("transactionManager");
-         user = Util.loadClass("com.arjuna.ats.jta.UserTransaction").getMethod("userTransaction");
+         manager = Util.loadClassStrict("com.arjuna.ats.jta.TransactionManager").getMethod("transactionManager");
+         user = Util.loadClassStrict("com.arjuna.ats.jta.UserTransaction").getMethod("userTransaction");
       }
       catch (Exception e) {
          throw new RuntimeException(e);

Modified: branches/4.1.x/core/src/main/java/org/infinispan/util/ClassFinder.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/util/ClassFinder.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/util/ClassFinder.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -124,7 +124,7 @@
             String clazz = null;
             try {
                clazz = toClassName(cf.getAbsolutePath());
-               claz = Util.loadClass(clazz);
+               claz = Util.loadClassStrict(clazz);
                classes.add(claz);
             } catch (NoClassDefFoundError ncdfe) {
                log.warn(cf.getAbsolutePath() + " has reference to a class "
@@ -150,7 +150,7 @@
                   String clazz = null;
                   try {
                      clazz = toClassName(entry.getName());
-                     claz = Util.loadClass(clazz);
+                     claz = Util.loadClassStrict(clazz);
                      classes.add(claz);
                   } catch (NoClassDefFoundError ncdfe) {
                      log.warn(entry.getName() + " has reference to a class " + ncdfe.getMessage()

Modified: branches/4.1.x/core/src/main/java/org/infinispan/util/ModuleProperties.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/util/ModuleProperties.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/util/ModuleProperties.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -113,7 +113,7 @@
       for (Map.Entry<String, ModuleProperties> m : p.entrySet()) {
          try {
             String lifecycleClassName = m.getValue().getLifecycleClassName();
-            Class<?> loadClass = Util.loadClass(lifecycleClassName);
+            Class<?> loadClass = Util.loadClassStrict(lifecycleClassName);
             Object proxy = Proxies.newCatchThrowableProxy((ModuleLifecycle) loadClass.newInstance());
             ModuleLifecycle ml = (ModuleLifecycle) proxy;
             lifecycles.add(ml);

Modified: branches/4.1.x/core/src/main/java/org/infinispan/util/Util.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/util/Util.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/util/Util.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -21,9 +21,10 @@
  */
 package org.infinispan.util;
 
+import org.infinispan.config.ConfigurationException;
+
 import java.io.Closeable;
 import java.io.InputStream;
-import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.OutputStream;
 import java.lang.reflect.Method;
@@ -49,13 +50,30 @@
    /**
     * Loads the specified class using this class's classloader, or, if it is <code>null</code> (i.e. this class was
     * loaded by the bootstrap classloader), the system classloader. <p/> If loadtime instrumentation via
-    * GenerateInstrumentedClassLoader is used, this class may be loaded by the bootstrap classloader. </p>
+    * GenerateInstrumentedClassLoader is used, this class may be loaded by the bootstrap classloader. <p/>
+    * If the class is not found, the {@link ClassNotFoundException} is wrapped as a {@link ConfigurationException} and
+    * is re-thrown.
     *
     * @param classname name of the class to load
     * @return the class
+    */
+   public static Class loadClass(String classname) {
+      try {
+         return loadClassStrict(classname);
+      } catch (Exception e) {
+         throw new ConfigurationException("Unable to instantiate class " + classname, e);
+      }
+   }
+
+   /**
+    * Similar to {@link #loadClass(String)} except that any {@link ClassNotFoundException}s experienced is propagated
+    * to the caller.
+    *
+    * @param classname name of the class to load
+    * @return the class
     * @throws ClassNotFoundException
     */
-   public static Class loadClass(String classname) throws ClassNotFoundException {
+   public static Class loadClassStrict(String classname) throws ClassNotFoundException {
       ClassLoader cl = Thread.currentThread().getContextClassLoader();
       if (cl == null)
          cl = ClassLoader.getSystemClassLoader();
@@ -70,8 +88,36 @@
       return null;
    }
 
+   /**
+    * Instantiates a class by first attempting a static <i>factory method</i> named <tt>getInstance()</tt> on the class
+    * and then falling back to an empty constructor.
+    * <p/>
+    * Any exceptions encountered are wrapped in a {@link ConfigurationException} and rethrown.
+    *
+    * @param clazz class to instantiate
+    * @return an instance of the class
+    */
    @SuppressWarnings("unchecked")
-   public static <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException {
+   public static <T> T getInstance(Class<T> clazz) {
+      try {
+         return getInstanceStrict(clazz);
+      } catch (IllegalAccessException iae) {
+         throw new ConfigurationException("Unable to instantiate class " + clazz.getName(), iae);
+      } catch (InstantiationException ie) {
+         throw new ConfigurationException("Unable to instantiate class " + clazz.getName(), ie);
+      }
+   }
+
+   /**
+    * Similar to {@link #getInstance(Class)} except that exceptions are propagated to the caller.
+    *
+    * @param clazz class to instantiate
+    * @return an instance of the class
+    * @throws IllegalAccessException
+    * @throws InstantiationException
+    */
+   @SuppressWarnings("unchecked")
+   public static <T> T getInstanceStrict(Class<T> clazz) throws IllegalAccessException, InstantiationException {
       // first look for a getInstance() constructor
       T instance = null;
       try {
@@ -82,18 +128,47 @@
          // no factory method or factory method failed.  Try a constructor.
          instance = null;
       }
-      if (instance == null) instance = clazz.newInstance();
-      return instance;
+      if (instance == null) {
+         instance = clazz.newInstance();
+      }
+      return instance == null ? null : instance;
    }
 
+   /**
+    * Instantiates a class based on the class name provided.  Instatiation is attempted via an appropriate, static
+    * factory method named <tt>getInstance()</tt> first, and failing the existence of an appropriate factory, falls
+    * back to an empty constructor.
+    * <p />
+    * Any exceptions encountered loading and instantiating the class is wrapped in a {@link ConfigurationException}.
+    *
+    * @param classname class to instantiate
+    * @return an instance of classname
+    */
    @SuppressWarnings("unchecked")
-   public static Object getInstance(String classname) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+   public static Object getInstance(String classname) {
       if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
       Class clazz = loadClass(classname);
       return getInstance(clazz);
    }
 
    /**
+    * Similar to {@link #getInstance(String)} except that exceptions are propagated to the caller.
+    *
+    * @param classname class to instantiate
+    * @return an instance of classname
+    * @throws ClassNotFoundException
+    * @throws InstantiationException
+    * @throws IllegalAccessException
+    */
+   @SuppressWarnings("unchecked")
+   public static Object getInstanceStrict(String classname) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+      if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
+      Class clazz = loadClassStrict(classname);
+      return getInstanceStrict(clazz);
+   }
+
+
+   /**
     * Prevent instantiation
     */
    private Util() {

Modified: branches/4.1.x/core/src/main/java/org/infinispan/util/logging/LogFactory.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/util/logging/LogFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/main/java/org/infinispan/util/logging/LogFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -15,7 +15,7 @@
    static {
       boolean available;
       try {
-         Util.loadClass("org.apache.log4j.Logger");
+         Util.loadClassStrict("org.apache.log4j.Logger");
          available = true;
       }
       catch (ClassNotFoundException cnfe) {

Modified: branches/4.1.x/core/src/test/java/org/infinispan/eviction/MarshalledValuesEvictionTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/eviction/MarshalledValuesEvictionTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/eviction/MarshalledValuesEvictionTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -31,7 +31,7 @@
 import org.infinispan.manager.EmbeddedCacheManager;
 import org.infinispan.marshall.MarshalledValue;
 import org.infinispan.marshall.MarshalledValueTest;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.test.SingleCacheManagerTest;
 import org.infinispan.test.TestingUtil;
 import org.infinispan.test.fwk.TestCacheManagerFactory;
@@ -54,7 +54,7 @@
       cfg.setUseLazyDeserialization(true);
       EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(cfg);
       cache = cm.getCache();
-      Marshaller marshaller = TestingUtil.extractComponent(cache, Marshaller.class);
+      StreamingMarshaller marshaller = TestingUtil.extractComponent(cache, StreamingMarshaller.class);
       MockMarshalledValueInterceptor interceptor = new MockMarshalledValueInterceptor(marshaller);
       assert TestingUtil.replaceInterceptor(cache, interceptor, MarshalledValueInterceptor.class);
       return cm;
@@ -108,7 +108,7 @@
    static class MockMarshalledValueInterceptor extends MarshalledValueInterceptor {
       boolean marshalledValueCreated;
       
-      MockMarshalledValueInterceptor(Marshaller marshaller) {
+      MockMarshalledValueInterceptor(StreamingMarshaller marshaller) {
          injectMarshaller(marshaller);
       }
 

Modified: branches/4.1.x/core/src/test/java/org/infinispan/eviction/MarshalledValuesManualEvictionTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/eviction/MarshalledValuesManualEvictionTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/eviction/MarshalledValuesManualEvictionTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -27,7 +27,7 @@
 import org.infinispan.interceptors.MarshalledValueInterceptor;
 import org.infinispan.manager.EmbeddedCacheManager;
 import org.infinispan.marshall.MarshalledValueTest;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.test.SingleCacheManagerTest;
 import org.infinispan.test.TestingUtil;
 import org.infinispan.test.fwk.TestCacheManagerFactory;
@@ -43,7 +43,7 @@
       cfg.setUseLazyDeserialization(true);
       EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(cfg);
       cache = cm.getCache();
-      Marshaller marshaller = TestingUtil.extractComponent(cache, Marshaller.class);
+      StreamingMarshaller marshaller = TestingUtil.extractComponent(cache, StreamingMarshaller.class);
       MockMarshalledValueInterceptor interceptor = new MockMarshalledValueInterceptor(marshaller);
       assert TestingUtil.replaceInterceptor(cache, interceptor, MarshalledValueInterceptor.class);
       return cm;

Modified: branches/4.1.x/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -10,15 +10,12 @@
 import org.infinispan.loaders.modifications.Modification;
 import org.infinispan.loaders.modifications.Remove;
 import org.infinispan.loaders.modifications.Store;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.TestObjectStreamMarshaller;
 import org.infinispan.test.AbstractInfinispanTest;
-import org.infinispan.test.TestingUtil;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.transaction.xa.GlobalTransactionFactory;
 import org.infinispan.util.Util;
-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;
@@ -29,7 +26,6 @@
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -38,7 +34,6 @@
 import java.util.Set;
 
 import static java.util.Collections.emptySet;
-import static java.util.Collections.singleton;
 
 /**
  * This is a base class containing various unit tests for each and every different CacheStore implementations. 
@@ -102,7 +97,7 @@
    /**
     * @return a mock marshaller for use with the cache store impls
     */
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       return new TestObjectStreamMarshaller(false);
    }
 
@@ -519,7 +514,7 @@
       cs.store(InternalEntryFactory.create("k2", "v2"));
       cs.store(InternalEntryFactory.create("k3", "v3"));
 
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       ObjectOutput oo = marshaller.startObjectOutput(out, false);
       try {
@@ -554,7 +549,7 @@
       cs.store(InternalEntryFactory.create("k2", "v2"));
       cs.store(InternalEntryFactory.create("k3", "v3"));
 
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       byte[] dummyStartBytes = {1, 2, 3, 4, 5, 6, 7, 8};
       byte[] dummyEndBytes = {8, 7, 6, 5, 4, 3, 2, 1};

Modified: branches/4.1.x/core/src/test/java/org/infinispan/loaders/dummy/DummyInMemoryCacheStore.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/loaders/dummy/DummyInMemoryCacheStore.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/loaders/dummy/DummyInMemoryCacheStore.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -6,15 +6,13 @@
 import org.infinispan.loaders.AbstractCacheStoreConfig;
 import org.infinispan.loaders.CacheLoaderConfig;
 import org.infinispan.loaders.CacheLoaderException;
-import org.infinispan.loaders.CacheLoaderMetadata;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.TestObjectStreamMarshaller;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import java.util.AbstractSet;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
@@ -77,7 +75,7 @@
       }
    }
 
-   public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException {
+   public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) throws CacheLoaderException {
       super.init(config, cache, m);
       this.config = (Cfg) config;
       if (marshaller == null) marshaller = new TestObjectStreamMarshaller();

Modified: branches/4.1.x/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -8,11 +8,10 @@
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheStore;
 import org.infinispan.loaders.bucket.Bucket;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.test.TestingUtil;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Optional;
 import org.testng.annotations.Parameters;
 import org.testng.annotations.Test;
@@ -97,7 +96,7 @@
    public void testToStream() throws Exception {
       cs.store(InternalEntryFactory.create("k1", "v1", -1, -1));
 
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       ObjectOutput oo = marshaller.startObjectOutput(out, false);
       try {
@@ -126,7 +125,7 @@
       cs.store(InternalEntryFactory.create(k1, v1));
       cs.store(InternalEntryFactory.create(k2, v2));
 
-      Marshaller marshaller = getMarshaller();
+      StreamingMarshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       ObjectOutput oo = marshaller.startObjectOutput(out, false);
       try {

Modified: branches/4.1.x/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreVamTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreVamTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreVamTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -22,7 +22,7 @@
 package org.infinispan.loaders.file;
 
 import org.infinispan.commands.RemoteCommandsFactory;
-import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.testng.annotations.Test;
 
@@ -35,7 +35,7 @@
 @Test(groups = "unit", testName = "loaders.file.FileCacheStoreVamTest")
 public class FileCacheStoreVamTest extends FileCacheStoreTest {
    @Override
-   protected Marshaller getMarshaller() {
+   protected StreamingMarshaller getMarshaller() {
       VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
       marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandsFactory());
       marshaller.start();

Modified: branches/4.1.x/core/src/test/java/org/infinispan/marshall/TestObjectStreamMarshaller.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/marshall/TestObjectStreamMarshaller.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/marshall/TestObjectStreamMarshaller.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -2,6 +2,7 @@
 
 import com.thoughtworks.xstream.XStream;
 import org.infinispan.io.ByteBuffer;
+import org.infinispan.io.ExposedByteArrayOutputStream;
 import org.infinispan.util.Util;
 
 import java.io.ByteArrayInputStream;
@@ -20,7 +21,7 @@
  *
  * @author Manik Surtani
  */
-public class TestObjectStreamMarshaller extends AbstractMarshaller {
+public class TestObjectStreamMarshaller extends AbstractStreamingMarshaller {
    XStream xs = new XStream();
    boolean debugXml = false;
 
@@ -75,8 +76,8 @@
       return objectFromByteBuffer(newBytes);
    }
 
-   public byte[] objectToByteBuffer(Object obj) throws IOException {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+   public byte[] objectToByteBuffer(Object obj, int estimatedSize) throws IOException {
+      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(estimatedSize);
       ObjectOutputStream oos = new ObjectOutputStream(baos);
       objectToObjectStream(obj, oos);
       oos.flush();

Modified: branches/4.1.x/core/src/test/java/org/infinispan/marshall/jboss/JBossMarshallerTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/marshall/jboss/JBossMarshallerTest.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/marshall/jboss/JBossMarshallerTest.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -26,7 +26,6 @@
 import org.infinispan.commands.RemoteCommandsFactory;
 import org.infinispan.marshall.Ids;
 import org.infinispan.marshall.Marshallable;
-import org.infinispan.marshall.Marshaller;
 import org.infinispan.marshall.VersionAwareMarshaller;
 import org.infinispan.test.AbstractInfinispanTest;
 import org.infinispan.transaction.xa.GlobalTransactionFactory;
@@ -39,7 +38,7 @@
 import java.io.ObjectOutput;
 
 /**
- * Test the behaviour of JBoss Marshalling based {@link Marshaller} implementation 
+ * Test the behaviour of JBoss Marshalling based {@link org.infinispan.marshall.StreamingMarshaller} implementation
  * which is {@link JBossMarshaller}}. This class should contain methods that exercise
  * logic in this particular implementation.
  */

Modified: branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -251,7 +251,7 @@
    public static void amendMarshaller(GlobalConfiguration configuration) {
       if (MARSHALLER != null) {
          try {
-            Util.loadClass(MARSHALLER);
+            Util.loadClassStrict(MARSHALLER);
             configuration.setMarshallerClass(MARSHALLER);
          } catch (ClassNotFoundException e) {
             // No-op, stick to GlobalConfiguration default.

Modified: branches/4.1.x/jopr-plugin/src/main/java/org/infinispan/jopr/ConnectionHelper.java
===================================================================
--- branches/4.1.x/jopr-plugin/src/main/java/org/infinispan/jopr/ConnectionHelper.java	2010-07-12 18:50:00 UTC (rev 2029)
+++ branches/4.1.x/jopr-plugin/src/main/java/org/infinispan/jopr/ConnectionHelper.java	2010-07-13 08:52:33 UTC (rev 2030)
@@ -90,8 +90,7 @@
             PropertySimple serverUrl = pluginConfig
                   .getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY);
 
-            connectionSettings.initializeConnectionType((ConnectionTypeDescriptor) Util.getInstance(
-                  connectionTypeDescriptorClass));
+            connectionSettings.initializeConnectionType((ConnectionTypeDescriptor) Util.getInstance(connectionTypeDescriptorClass));
             // if not provided use the default serverUrl
             if (null != serverUrl) {
                connectionSettings.setServerUrl(serverUrl.getStringValue());



More information about the infinispan-commits mailing list