[exo-jcr-commits] exo-jcr SVN: r3533 - in kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4: src and 11 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Nov 24 08:04:23 EST 2010


Author: nzamosenchuk
Date: 2010-11-24 08:04:21 -0500 (Wed, 24 Nov 2010)
New Revision: 3533

Added:
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheConfig.java
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/cache-configuration-template.xml
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
   kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/test-configuration.xml
Log:
EXOJCR-1054 : porting ISPN code of Kernel project. Attention: RPCService test added to excludes, since int fails with newer JGroups.

Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java	                        (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestAbstractExoCache.java	2010-11-24 13:04:21 UTC (rev 3533)
@@ -0,0 +1,731 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * 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.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheListenerContext;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheFactory;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.test.BasicTestCase;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author <a href="mailto:nicolas.filotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestAbstractExoCache extends BasicTestCase
+{
+
+   CacheService service;
+
+   AbstractExoCache<Serializable, Object> cache;
+
+   public TestAbstractExoCache(String name)
+   {
+      super(name);
+   }
+
+   public void setUp() throws Exception
+   {
+      this.service = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+      this.cache = (AbstractExoCache<Serializable, Object>)service.getCacheInstance("myCache");
+   }
+
+   protected void tearDown() throws Exception
+   {
+      cache.clearCache();
+   }
+
+   public void testPut() throws Exception
+   {
+      cache.put(new MyKey("a"), "a");
+      cache.put(new MyKey("b"), "b");
+      cache.put(new MyKey("c"), "c");
+      assertEquals(3, cache.getCacheSize());
+      cache.put(new MyKey("a"), "c");
+      assertEquals(3, cache.getCacheSize());
+      cache.put(new MyKey("d"), "c");
+      assertEquals(4, cache.getCacheSize());
+   }
+
+   public void testClearCache() throws Exception
+   {
+      cache.put(new MyKey("a"), "a");
+      cache.put(new MyKey("b"), "b");
+      cache.put(new MyKey("c"), "c");
+      assertTrue(cache.getCacheSize() > 0);
+      cache.clearCache();
+      assertTrue(cache.getCacheSize() == 0);
+   }
+
+   public void testGet() throws Exception
+   {
+      cache.put(new MyKey("a"), "a");
+      assertEquals("a", cache.get(new MyKey("a")));
+      cache.put(new MyKey("a"), "c");
+      assertEquals("c", cache.get(new MyKey("a")));
+      cache.remove(new MyKey("a"));
+      assertEquals(null, cache.get(new MyKey("a")));
+      assertEquals(null, cache.get(new MyKey("x")));
+   }
+
+   public void testRemove() throws Exception
+   {
+      cache.put(new MyKey("a"), 1);
+      cache.put(new MyKey("b"), 2);
+      cache.put(new MyKey("c"), 3);
+      assertEquals(3, cache.getCacheSize());
+      assertEquals(1, cache.remove(new MyKey("a")));
+      assertEquals(2, cache.getCacheSize());
+      assertEquals(2, cache.remove(new MyKey("b")));
+      assertEquals(1, cache.getCacheSize());
+      assertEquals(null, cache.remove(new MyKey("x")));
+      assertEquals(1, cache.getCacheSize());
+   }
+
+   public void testPutMap() throws Exception
+   {
+      Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+      values.put(new MyKey("a"), "a");
+      values.put(new MyKey("b"), "b");
+      assertEquals(0, cache.getCacheSize());
+      cache.putMap(values);
+      assertEquals(2, cache.getCacheSize());
+      values = new HashMap<Serializable, Object>()
+      {
+         private static final long serialVersionUID = 1L;
+
+         public Set<Entry<Serializable, Object>> entrySet()
+         {
+            Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+            set.add(new Entry<Serializable, Object>()
+            {
+
+               public Object setValue(Object paramV)
+               {
+                  return null;
+               }
+
+               public Object getValue()
+               {
+                  throw new RuntimeException("An exception");
+               }
+
+               public Serializable getKey()
+               {
+                  return "c";
+               }
+            });
+            return set;
+         }
+      };
+      values.put(new MyKey("e"), "e");
+      values.put(new MyKey("d"), "d");
+      cache.putMap(values);
+      assertEquals(2, cache.getCacheSize());
+   }
+
+   public void testGetCachedObjects() throws Exception
+   {
+      cache.put(new MyKey("a"), "a");
+      cache.put(new MyKey("b"), "b");
+      cache.put(new MyKey("c"), "c");
+      cache.put(new MyKey("d"), null);
+      assertEquals(3, cache.getCacheSize());
+      List<Object> values = cache.getCachedObjects();
+      assertEquals(3, values.size());
+      assertTrue(values.contains("a"));
+      assertTrue(values.contains("b"));
+      assertTrue(values.contains("c"));
+   }
+
+   public void testRemoveCachedObjects() throws Exception
+   {
+      cache.put(new MyKey("a"), "a");
+      cache.put(new MyKey("b"), "b");
+      cache.put(new MyKey("c"), "c");
+      cache.put(new MyKey("d"), null);
+      assertEquals(3, cache.getCacheSize());
+      List<Object> values = cache.removeCachedObjects();
+      assertEquals(3, values.size());
+      assertTrue(values.contains("a"));
+      assertTrue(values.contains("b"));
+      assertTrue(values.contains("c"));
+      assertEquals(0, cache.getCacheSize());
+   }
+
+   public void testSelect() throws Exception
+   {
+      cache.put(new MyKey("a"), 1);
+      cache.put(new MyKey("b"), 2);
+      cache.put(new MyKey("c"), 3);
+      final AtomicInteger count = new AtomicInteger();
+      CachedObjectSelector<Serializable, Object> selector = new CachedObjectSelector<Serializable, Object>()
+      {
+
+         public void onSelect(ExoCache<? extends Serializable, ? extends Object> cache, Serializable key,
+            ObjectCacheInfo<? extends Object> ocinfo) throws Exception
+         {
+            assertTrue(key.equals(new MyKey("a")) || key.equals(new MyKey("b")) || key.equals(new MyKey("c")));
+            assertTrue(ocinfo.get().equals(1) || ocinfo.get().equals(2) || ocinfo.get().equals(3));
+            count.incrementAndGet();
+         }
+
+         public boolean select(Serializable key, ObjectCacheInfo<? extends Object> ocinfo)
+         {
+            return true;
+         }
+      };
+      cache.select(selector);
+      assertEquals(3, count.intValue());
+   }
+
+   public void testGetHitsNMisses() throws Exception
+   {
+      int hits = cache.getCacheHit();
+      int misses = cache.getCacheMiss();
+      cache.put(new MyKey("a"), "a");
+      cache.get(new MyKey("a"));
+      cache.remove(new MyKey("a"));
+      cache.get(new MyKey("a"));
+      cache.get(new MyKey("z"));
+      assertEquals(1, cache.getCacheHit() - hits);
+      assertEquals(2, cache.getCacheMiss() - misses);
+   }
+
+   private ExoCacheFactory getExoCacheFactoryInstance() throws ExoCacheInitException
+   {
+      PortalContainer pc = PortalContainer.getInstance();
+      return new ExoCacheFactoryImpl((ExoContainerContext)pc.getComponentInstanceOfType(ExoContainerContext.class),
+         "jar:/conf/portal/cache-configuration-template.xml", (ConfigurationManager)pc
+            .getComponentInstanceOfType(ConfigurationManager.class));
+   }
+
+   public void testMultiThreading() throws Exception
+   {
+      long time = System.currentTimeMillis();
+      final ExoCache<Serializable, Object> cache = service.getCacheInstance("test-multi-threading");
+      final int totalElement = 100;
+      final int totalTimes = 20;
+      int reader = 20;
+      int writer = 10;
+      int remover = 5;
+      int cleaner = 1;
+      final CountDownLatch startSignalWriter = new CountDownLatch(1);
+      final CountDownLatch startSignalOthers = new CountDownLatch(1);
+      final CountDownLatch doneSignal = new CountDownLatch(reader + writer + remover);
+      final List<Exception> errors = Collections.synchronizedList(new ArrayList<Exception>());
+      for (int i = 0; i < writer; i++)
+      {
+         final int index = i;
+         Thread thread = new Thread()
+         {
+            public void run()
+            {
+               try
+               {
+                  startSignalWriter.await();
+                  for (int j = 0; j < totalTimes; j++)
+                  {
+                     for (int i = 0; i < totalElement; i++)
+                     {
+                        cache.put(new MyKey("key" + i), "value" + i);
+                     }
+                     if (index == 0 && j == 0)
+                     {
+                        // The cache is full, we can launch the others
+                        startSignalOthers.countDown();
+                     }
+                     sleep(50);
+                  }
+               }
+               catch (Exception e)
+               {
+                  errors.add(e);
+               }
+               finally
+               {
+                  doneSignal.countDown();
+               }
+            }
+         };
+         thread.start();
+      }
+      startSignalWriter.countDown();
+      for (int i = 0; i < reader; i++)
+      {
+         Thread thread = new Thread()
+         {
+            public void run()
+            {
+               try
+               {
+                  startSignalOthers.await();
+                  for (int j = 0; j < totalTimes; j++)
+                  {
+                     for (int i = 0; i < totalElement; i++)
+                     {
+                        cache.get(new MyKey("key" + i));
+                     }
+                     sleep(50);
+                  }
+               }
+               catch (Exception e)
+               {
+                  errors.add(e);
+               }
+               finally
+               {
+                  doneSignal.countDown();
+               }
+            }
+         };
+         thread.start();
+      }
+      for (int i = 0; i < remover; i++)
+      {
+         Thread thread = new Thread()
+         {
+            public void run()
+            {
+               try
+               {
+                  startSignalOthers.await();
+                  for (int j = 0; j < totalTimes; j++)
+                  {
+                     for (int i = 0; i < totalElement; i++)
+                     {
+                        cache.remove(new MyKey("key" + i));
+                     }
+                     sleep(50);
+                  }
+               }
+               catch (Exception e)
+               {
+                  errors.add(e);
+               }
+               finally
+               {
+                  doneSignal.countDown();
+               }
+            }
+         };
+         thread.start();
+      }
+      doneSignal.await();
+      for (int i = 0; i < totalElement; i++)
+      {
+         cache.put(new MyKey("key" + i), "value" + i);
+      }
+      assertEquals(totalElement, cache.getCacheSize());
+      final CountDownLatch startSignal = new CountDownLatch(1);
+      final CountDownLatch doneSignal2 = new CountDownLatch(writer + cleaner);
+      for (int i = 0; i < writer; i++)
+      {
+         Thread thread = new Thread()
+         {
+            public void run()
+            {
+               try
+               {
+                  startSignal.await();
+                  for (int j = 0; j < totalTimes; j++)
+                  {
+                     for (int i = 0; i < totalElement; i++)
+                     {
+                        cache.put(new MyKey("key" + i), "value" + i);
+                     }
+                     sleep(50);
+                  }
+               }
+               catch (Exception e)
+               {
+                  errors.add(e);
+               }
+               finally
+               {
+                  doneSignal2.countDown();
+               }
+            }
+         };
+         thread.start();
+      }
+      for (int i = 0; i < cleaner; i++)
+      {
+         Thread thread = new Thread()
+         {
+            public void run()
+            {
+               try
+               {
+                  startSignal.await();
+                  for (int j = 0; j < totalTimes; j++)
+                  {
+                     sleep(150);
+                     cache.clearCache();
+                  }
+               }
+               catch (Exception e)
+               {
+                  errors.add(e);
+               }
+               finally
+               {
+                  doneSignal2.countDown();
+               }
+            }
+         };
+         thread.start();
+      }
+      cache.clearCache();
+      assertEquals(0, cache.getCacheSize());
+      if (!errors.isEmpty())
+      {
+         for (Exception e : errors)
+         {
+            e.printStackTrace();
+         }
+         throw errors.get(0);
+      }
+      System.out.println("Total Time = " + (System.currentTimeMillis() - time));
+   }
+
+   public static class MyCacheListener implements CacheListener<Serializable, Object>
+   {
+
+      public int clearCache;
+
+      public int expire;
+
+      public int get;
+
+      public int put;
+
+      public int remove;
+
+      public void onClearCache(ExoCache<Serializable, Object> cache) throws Exception
+      {
+         clearCache++;
+      }
+
+      public void onExpire(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+      {
+         expire++;
+      }
+
+      public void onGet(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+      {
+         get++;
+      }
+
+      public void onPut(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+      {
+         put++;
+      }
+
+      public void onRemove(ExoCache<Serializable, Object> cache, Serializable key, Object obj) throws Exception
+      {
+         remove++;
+      }
+
+      public void onClearCache(CacheListenerContext context) throws Exception
+      {
+         clearCache++;
+      }
+
+      public void onExpire(CacheListenerContext context, Serializable key, Object obj) throws Exception
+      {
+         expire++;
+      }
+
+      public void onGet(CacheListenerContext context, Serializable key, Object obj) throws Exception
+      {
+         get++;
+      }
+
+      public void onPut(CacheListenerContext context, Serializable key, Object obj) throws Exception
+      {
+         put++;
+      }
+
+      public void onRemove(CacheListenerContext context, Serializable key, Object obj) throws Exception
+      {
+         remove++;
+      }
+   }
+
+   public static class MyKey implements Serializable
+   {
+      private static final long serialVersionUID = 1L;
+
+      public String value;
+
+      public MyKey(String value)
+      {
+         this.value = value;
+      }
+
+      @Override
+      public boolean equals(Object paramObject)
+      {
+         return paramObject instanceof MyKey && ((MyKey)paramObject).value.endsWith(value);
+      }
+
+      @Override
+      public int hashCode()
+      {
+         return value.hashCode();
+      }
+
+      @Override
+      public String toString()
+      {
+         return value;
+      }
+   }   
+
+   @SuppressWarnings("unchecked")
+   public void testDistributedCache() throws Exception
+   {
+      // If the cache is still alive this test fails due to a TimeoutException.
+      cache.cache.getCacheManager().stop();
+      
+      System.out
+         .println("WARNING: For Linux distributions the following JVM parameter must be set to true, java.net.preferIPv4Stack = "
+            + System.getProperty("java.net.preferIPv4Stack"));
+      ExoCacheConfig config = new ExoCacheConfig();
+      config.setName("MyCacheDistributed");
+      config.setMaxSize(5);
+      config.setLiveTime(1);
+      config.setImplementation("LRU");
+      config.setDistributed(true);
+      ExoCacheConfig config2 = new ExoCacheConfig();
+      config2.setName("MyCacheDistributed2");
+      config2.setMaxSize(5);
+      config2.setLiveTime(1);
+      config2.setImplementation("LRU");
+      config2.setDistributed(true);
+      AbstractExoCache<Serializable, Object> cache1 =
+         (AbstractExoCache<Serializable, Object>)getExoCacheFactoryInstance().createCache(config);
+      MyCacheListener listener1 = new MyCacheListener();
+      cache1.addCacheListener(listener1);
+      AbstractExoCache<Serializable, Object> cache2 =
+         (AbstractExoCache<Serializable, Object>)getExoCacheFactoryInstance().createCache(config);
+      MyCacheListener listener2 = new MyCacheListener();
+      cache2.addCacheListener(listener2);
+// Cache 3 creates a conflict with cache 1 and 2      
+//      AbstractExoCache<Serializable, Object> cache3 =
+//         (AbstractExoCache<Serializable, Object>)getExoCacheFactoryInstance().createCache(config2);
+//      MyCacheListener listener3 = new MyCacheListener();
+//      cache3.addCacheListener(listener3);
+      try
+      {
+         cache1.put(new MyKey("a"), "b");
+         assertEquals(1, cache1.getCacheSize());
+         assertEquals("b", cache2.get(new MyKey("a")));
+         assertEquals(1, cache2.getCacheSize());
+//         assertEquals(0, cache3.getCacheSize());
+         assertEquals(1, listener1.put);
+         assertEquals(1, listener2.put);
+//         assertEquals(0, listener3.put);
+         assertEquals(0, listener1.get);
+         assertEquals(1, listener2.get);
+//         assertEquals(0, listener3.get);
+         cache2.put(new MyKey("b"), "c");
+         assertEquals(2, cache1.getCacheSize());
+         assertEquals(2, cache2.getCacheSize());
+         assertEquals("c", cache1.get(new MyKey("b")));
+//         assertEquals(0, cache3.getCacheSize());
+         assertEquals(2, listener1.put);
+         assertEquals(2, listener2.put);
+//         assertEquals(0, listener3.put);
+         assertEquals(1, listener1.get);
+         assertEquals(1, listener2.get);
+//         assertEquals(0, listener3.get);
+//         cache3.put(new MyKey("c"), "d");
+         assertEquals(2, cache1.getCacheSize());
+         assertEquals(2, cache2.getCacheSize());
+//         assertEquals(1, cache3.getCacheSize());
+//         assertEquals("d", cache3.get(new MyKey("c")));
+         assertEquals(2, listener1.put);
+         assertEquals(2, listener2.put);
+//         assertEquals(1, listener3.put);
+         assertEquals(1, listener1.get);
+         assertEquals(1, listener2.get);
+//         assertEquals(1, listener3.get);
+         cache2.put(new MyKey("a"), "a");
+         assertEquals(2, cache1.getCacheSize());
+         assertEquals(2, cache2.getCacheSize());
+         assertEquals("a", cache1.get(new MyKey("a")));
+         assertEquals(3, listener1.put);
+         assertEquals(3, listener2.put);
+//         assertEquals(1, listener3.put);
+         assertEquals(2, listener1.get);
+         assertEquals(1, listener2.get);
+//         assertEquals(1, listener3.get);
+         cache2.remove(new MyKey("a"));
+         assertEquals(1, cache1.getCacheSize());
+         assertEquals(1, cache2.getCacheSize());
+         assertEquals(3, listener1.put);
+         assertEquals(3, listener2.put);
+//         assertEquals(1, listener3.put);
+         assertEquals(2, listener1.get);
+         assertEquals(1, listener2.get);
+//         assertEquals(1, listener3.get);
+         assertEquals(1, listener1.remove);
+         assertEquals(1, listener2.remove);
+//         assertEquals(0, listener3.remove);
+         cache1.put(new MyKey("c"), "c");
+         cache1.clearCache();
+         assertEquals(0, cache1.getCacheSize());
+         assertEquals(null, cache1.get(new MyKey("b")));
+         assertEquals("c", cache2.get(new MyKey("b")));
+         assertEquals("c", cache2.get(new MyKey("c")));
+         assertEquals(2, cache2.getCacheSize());
+         assertEquals(4, listener1.put);
+         assertEquals(4, listener2.put);
+//         assertEquals(1, listener3.put);
+         assertEquals(3, listener1.get);
+         assertEquals(3, listener2.get);
+//         assertEquals(1, listener3.get);
+         assertEquals(1, listener1.remove);
+         assertEquals(1, listener2.remove);
+//         assertEquals(0, listener3.remove);
+         assertEquals(1, listener1.clearCache);
+         assertEquals(0, listener2.clearCache);
+//         assertEquals(0, listener3.clearCache);
+         Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+         values.put(new MyKey("a"), "a");
+         values.put(new MyKey("b"), "b");
+         cache1.putMap(values);
+         assertEquals(2, cache1.getCacheSize());
+         Thread.sleep(40);
+         assertEquals("a", cache2.get(new MyKey("a")));
+         assertEquals("b", cache2.get(new MyKey("b")));
+         assertEquals(3, cache2.getCacheSize());
+         assertEquals(6, listener1.put);
+         assertEquals(6, listener2.put);
+//         assertEquals(1, listener3.put);
+         assertEquals(3, listener1.get);
+         assertEquals(5, listener2.get);
+//         assertEquals(1, listener3.get);
+         assertEquals(1, listener1.remove);
+         assertEquals(1, listener2.remove);
+//         assertEquals(0, listener3.remove);
+         assertEquals(1, listener1.clearCache);
+         assertEquals(0, listener2.clearCache);
+//         assertEquals(0, listener3.clearCache);
+         values = new HashMap<Serializable, Object>()
+         {
+            private static final long serialVersionUID = 1L;
+
+            public Set<Entry<Serializable, Object>> entrySet()
+            {
+               Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+               set.add(new Entry<Serializable, Object>()
+               {
+
+                  public Object setValue(Object paramV)
+                  {
+                     return null;
+                  }
+
+                  public Object getValue()
+                  {
+                     throw new RuntimeException("An exception");
+                  }
+
+                  public Serializable getKey()
+                  {
+                     return "c";
+                  }
+               });
+               return set;
+            }
+         };
+         values.put(new MyKey("e"), "e");
+         values.put(new MyKey("d"), "d");
+         cache1.putMap(values);
+         assertEquals(2, cache1.getCacheSize());
+         assertEquals(3, cache2.getCacheSize());
+//         assertEquals(1, cache3.getCacheSize());
+         assertEquals(6, listener1.put);
+         assertEquals(6, listener2.put);
+//         assertEquals(1, listener3.put);
+         assertEquals(3, listener1.get);
+         assertEquals(5, listener2.get);
+//         assertEquals(1, listener3.get);
+         assertEquals(1, listener1.remove);
+         assertEquals(1, listener2.remove);
+//         assertEquals(0, listener3.remove);
+         assertEquals(1, listener1.clearCache);
+         assertEquals(0, listener2.clearCache);
+//         assertEquals(0, listener3.clearCache);
+         assertEquals(0, listener1.expire);
+         assertEquals(0, listener2.expire);
+//         assertEquals(0, listener3.expire);
+         Thread.sleep(5600);
+         assertEquals(0, cache1.getCacheSize());
+         assertEquals(0, cache2.getCacheSize());
+//         assertEquals(0, cache3.getCacheSize());
+         assertEquals(6, listener1.put);
+         assertEquals(6, listener2.put);
+//         assertEquals(1, listener3.put);
+         assertEquals(3, listener1.get);
+         assertEquals(5, listener2.get);
+//         assertEquals(1, listener3.get);
+         assertEquals(1, listener1.remove);
+         assertEquals(1, listener2.remove);
+//         assertEquals(0, listener3.remove);
+         assertEquals(1, listener1.clearCache);
+         assertEquals(0, listener2.clearCache);
+//         assertEquals(0, listener3.clearCache);
+// Expiration events are not triggered in infinispan         
+//         assertEquals(2, listener1.expire);
+//         assertEquals(3, listener2.expire);
+//         assertEquals(1, listener3.expire);
+      }
+      finally
+      {
+         cache1.cache.getCacheManager().stop();
+         cache2.cache.getCacheManager().stop();
+//         cache3.cache.getCacheManager().stop();
+      }
+   }   
+}

Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheConfig.java	                        (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheConfig.java	2010-11-24 13:04:21 UTC (rev 3533)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * 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.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * @author <a href="mailto:nicolas.filotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestExoCacheConfig extends ExoCacheConfig
+{
+
+}

Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java	                        (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheCreator.java	2010-11-24 13:04:21 UTC (rev 3533)
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * 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.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:nicolas.filotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestExoCacheCreator implements ExoCacheCreator
+{
+
+   /**
+    * @see org.exoplatform.services.cache.impl.infinispan.ExoCacheCreator#create(org.exoplatform.services.cache.ExoCacheConfig, org.infinispan.config.Configuration, java.util.concurrent.Callable)
+    */
+   @Override
+   public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+      Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException
+   {
+      return new TestExoCache();
+   }
+
+   public Class<? extends ExoCacheConfig> getExpectedConfigType()
+   {
+      return TestExoCacheConfig.class;
+   }
+
+   public Set<String> getExpectedImplementations()
+   {
+      return Collections.singleton("TEST");
+   }
+
+   public static class TestExoCache implements ExoCache<Serializable, Object>
+   {
+
+      public void addCacheListener(CacheListener listener)
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+
+      public int getCacheHit()
+      {
+         // TODO Auto-generated method stub
+         return 0;
+      }
+
+      public int getCacheMiss()
+      {
+         // TODO Auto-generated method stub
+         return 0;
+      }
+
+      public int getCacheSize()
+      {
+         // TODO Auto-generated method stub
+         return 0;
+      }
+
+      public List getCachedObjects()
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+
+      public String getLabel()
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+
+      public long getLiveTime()
+      {
+         // TODO Auto-generated method stub
+         return 0;
+      }
+
+      public int getMaxSize()
+      {
+         // TODO Auto-generated method stub
+         return 0;
+      }
+
+      public String getName()
+      {
+         return "name";
+      }
+
+      public boolean isDistributed()
+      {
+         // TODO Auto-generated method stub
+         return false;
+      }
+
+      public boolean isLogEnabled()
+      {
+         // TODO Auto-generated method stub
+         return false;
+      }
+
+      public boolean isReplicated()
+      {
+         // TODO Auto-generated method stub
+         return false;
+      }
+
+
+      public void select(CachedObjectSelector selector) throws Exception
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+      public void setDistributed(boolean b)
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+      public void setLabel(String s)
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+      public void setLiveTime(long period)
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+      public void setLogEnabled(boolean b)
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+      public void setMaxSize(int max)
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+      public void setName(String name)
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+      public void setReplicated(boolean b)
+      {
+         // TODO Auto-generated method stub
+
+      }
+
+      public void clearCache()
+      {
+         // TODO Auto-generated method stub
+         
+      }
+
+      public Object get(Serializable key)
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+
+      public void put(Serializable key, Object value) throws NullPointerException
+      {
+         // TODO Auto-generated method stub
+         
+      }
+
+      public void putMap(Map objs) throws NullPointerException, IllegalArgumentException
+      {
+         // TODO Auto-generated method stub
+         
+      }
+
+      public Object remove(Serializable key) throws NullPointerException
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+
+      public List removeCachedObjects()
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+
+   }
+}

Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java	                        (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/java/org/exoplatform/services/cache/impl/infinispan/TestExoCacheFactoryImpl.java	2010-11-24 13:04:21 UTC (rev 3533)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * 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.exoplatform.services.cache.impl.infinispan;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.impl.infinispan.TestExoCacheCreator.TestExoCache;
+import org.exoplatform.test.BasicTestCase;
+import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.manager.CacheContainer;
+
+/**
+ * @author <a href="mailto:nicolas.filotto at exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TestExoCacheFactoryImpl extends BasicTestCase
+{
+
+   CacheService service_;
+
+   public TestExoCacheFactoryImpl(String name)
+   {
+      super(name);
+   }
+
+   public void setUp() throws Exception
+   {
+      service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+   }
+
+   public void testCacheFactory()
+   {
+      ExoCache cache = service_.getCacheInstance("myCache");
+      assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+      AbstractExoCache aCache = (AbstractExoCache)cache;
+      assertTrue("expect a local cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.LOCAL);
+      aCache.cache.stop();
+      cache = service_.getCacheInstance("cacheDistributed");
+      assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+      aCache = (AbstractExoCache)cache;
+      assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+      aCache.cache.stop();
+      cache = service_.getCacheInstance("myCustomCache");
+      assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+      aCache = (AbstractExoCache)cache;
+      assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+      aCache.cache.stop();
+   }
+
+   public void testExoCacheCreator()
+   {
+      ExoCache cache = service_.getCacheInstance("test-default-impl");
+      assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+      AbstractExoCache aCache = (AbstractExoCache)cache;
+      aCache.cache.stop();
+      cache = service_.getCacheInstance("test-custom-impl-with-old-config");
+      assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
+      cache = service_.getCacheInstance("test-custom-impl-with-new-config");
+      assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
+   }
+   
+   public void testSameCacheManager()
+   {
+      ExoCache cache1 = service_.getCacheInstance("myCustomCache");
+      assertTrue("expect an instance of AbstractExoCache", cache1 instanceof AbstractExoCache);
+      AbstractExoCache aCache1 = (AbstractExoCache)cache1;
+      CacheContainer cacheContainer1 = aCache1.cache.getCacheManager();
+      
+      ExoCache cache2 = service_.getCacheInstance("myCustomCache-Bis");
+      assertTrue("expect an instance of AbstractExoCache", cache2 instanceof AbstractExoCache);
+      AbstractExoCache aCache2 = (AbstractExoCache)cache2;
+      CacheContainer cacheContainer2 = aCache2.cache.getCacheManager();
+      assertTrue("The CacheContainer should be the same", cacheContainer1 == cacheContainer2);
+      
+      ExoCache cache3 = service_.getCacheInstance("myCustomCache-Bis2");
+      assertTrue("expect an instance of AbstractExoCache", cache3 instanceof AbstractExoCache);
+      AbstractExoCache aCache3 = (AbstractExoCache)cache3;
+      CacheContainer cacheContainer3 = aCache3.cache.getCacheManager();
+      assertTrue("The CacheContainer should be the same", cacheContainer1 == cacheContainer3);
+      
+      aCache1.cache.stop();
+      aCache2.cache.stop();      
+   }
+}

Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/cache-configuration-template.xml	                        (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/cache-configuration-template.xml	2010-11-24 13:04:21 UTC (rev 3533)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2010 eXo Platform SAS.
+
+    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.
+
+-->
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.0.xsd"
+	xmlns="urn:infinispan:config:4.0">
+   <global>
+      <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="maxThreads" value="1"/>
+            <property name="queueSize" value="100000"/>
+            <property name="threadNamePrefix" value="AsyncListenerThread"/>
+         </properties>
+      </asyncListenerExecutor>
+      <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="AsyncSerializationThread"/>
+         </properties>
+      </asyncTransportExecutor>
+      <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="EvictionThread"/>
+         </properties>
+      </evictionScheduledExecutor>
+      <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="ReplicationQueueThread"/>
+         </properties>
+      </replicationQueueScheduledExecutor>
+      <globalJmxStatistics jmxDomain="infinispan" enabled="false"/>
+      <transport transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport" clusterName="Infinispan-cluster" distributedSyncTimeout="20000">
+      	<properties>
+         <property name="configurationFile" value="flush-udp.xml"/>
+      	</properties>
+      </transport>
+      <shutdown hookBehavior="DEFAULT"/>
+   </global>
+   <default>
+      <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="10000" writeSkewCheck="false" concurrencyLevel="500"/>
+      <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/>
+      <jmxStatistics enabled="false"/>
+      <clustering mode="replication">
+         <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+         <sync replTimeout="20000"/>
+      </clustering>
+   </default>
+</infinispan>
\ No newline at end of file

Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/distributed-cache-configuration-template.xml	                        (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/distributed-cache-configuration-template.xml	2010-11-24 13:04:21 UTC (rev 3533)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2010 eXo Platform SAS.
+
+    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.
+
+-->
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.0.xsd"
+	xmlns="urn:infinispan:config:4.0">
+   <global>
+      <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="maxThreads" value="1"/>
+            <property name="queueSize" value="100000"/>
+            <property name="threadNamePrefix" value="AsyncListenerThread"/>
+         </properties>
+      </asyncListenerExecutor>
+      <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="AsyncSerializationThread"/>
+         </properties>
+      </asyncTransportExecutor>
+      <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="EvictionThread"/>
+         </properties>
+      </evictionScheduledExecutor>
+      <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="ReplicationQueueThread"/>
+         </properties>
+      </replicationQueueScheduledExecutor>
+      <globalJmxStatistics jmxDomain="infinispan" enabled="false"/>
+      <transport transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport" clusterName="Infinispan-cluster" distributedSyncTimeout="20000">
+      	<properties>
+         <property name="configurationFile" value="flush-udp.xml"/>
+      	</properties>
+      </transport>
+      <shutdown hookBehavior="DEFAULT"/>
+   </global>
+   <default>
+      <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500"/>
+      <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/>
+      <jmxStatistics enabled="true"/>
+      <clustering mode="replication">
+         <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+         <sync replTimeout="20000"/>
+      </clustering>
+   </default>
+</infinispan>
\ No newline at end of file

Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/test-configuration.xml	                        (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/test/resources/conf/portal/test-configuration.xml	2010-11-24 13:04:21 UTC (rev 3533)
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (C) 2009 eXo Platform SAS.
+
+    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.
+
+-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+   xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+  
+  <component>
+    <key>org.exoplatform.services.cache.CacheService</key>
+    <type>org.exoplatform.services.cache.impl.CacheServiceImpl</type>
+
+  	<init-params>
+      <object-param>
+        <name>cache.config.default</name>
+        <description>The default cache configuration</description>
+        <object type="org.exoplatform.services.cache.ExoCacheConfig">
+          <field  name="name"><string>default</string></field>
+          <field  name="maxSize"><int>5</int></field>
+          <field  name="liveTime"><long>2</long></field>
+        </object>
+      </object-param>
+      <object-param>
+        <name>test-multi-threading</name>
+        <description>The default cache configuration</description>
+        <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">
+          <field name="name"><string>test-multi-threading</string></field>
+          <field name="strategy"><string>NONE</string></field>
+          <field name="maxEntries"><int>-1</int></field>
+          <field name="lifespan"><long>-1</long></field>
+        </object>        
+      </object-param>      
+      <object-param>
+        <name>cacheDistributed</name>
+        <description>The default cache configuration</description>
+        <object type="org.exoplatform.services.cache.ExoCacheConfig">
+          <field  name="name"><string>cacheDistributed</string></field>
+          <field  name="maxSize"><int>5</int></field>
+          <field  name="liveTime"><long>2</long></field>
+          <field  name="distributed"><boolean>true</boolean></field>
+        </object>
+      </object-param>                
+      <object-param>
+        <name>test-default-impl</name>
+        <description>The default cache configuration</description>
+        <object type="org.exoplatform.services.cache.ExoCacheConfig">
+          <field  name="name"><string>test-default-impl</string></field>
+          <field  name="maxSize"><int>5</int></field>
+          <field  name="liveTime"><long>2</long></field>
+        </object>
+      </object-param>                
+      <object-param>
+        <name>test-custom-impl-with-old-config</name>
+        <description>The default cache configuration</description>
+        <object type="org.exoplatform.services.cache.ExoCacheConfig">
+          <field  name="name"><string>test-custom-impl-with-old-config</string></field>
+          <field  name="maxSize"><int>5</int></field>
+          <field  name="liveTime"><long>2</long></field>
+          <field  name="implementation"><string>TEST</string></field>
+        </object>
+      </object-param>                
+      <object-param>
+        <name>test-custom-impl-with-new-config</name>
+        <description>The default cache configuration</description>
+        <object type="org.exoplatform.services.cache.impl.infinispan.TestExoCacheConfig">
+          <field  name="name"><string>test-custom-impl-with-new-config</string></field>
+          <field  name="maxSize"><int>5</int></field>
+          <field  name="liveTime"><long>2</long></field>
+        </object>
+      </object-param>
+<!--       <object-param>-->
+<!--        <name>test-fifo-with-old-config</name>-->
+<!--        <description>The default cache configuration</description>-->
+<!--        <object type="org.exoplatform.services.cache.ExoCacheConfig">-->
+<!--          <field name="name"><string>test-fifo-with-old-config</string></field>-->
+<!--          <field name="maxSize"><int>5</int></field>-->
+<!--          <field name="liveTime"><long>1</long></field>-->
+<!--          <field name="implementation"><string>FIFO</string></field>-->
+<!--        </object>-->
+<!--      </object-param>      -->
+<!--       <object-param>-->
+<!--        <name>test-fifo</name>-->
+<!--        <description>The default cache configuration</description>-->
+<!--        <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">-->
+<!--          <field name="name"><string>test-fifo</string></field>-->
+<!--          <field name="strategy"><string>FIFO</string></field>-->
+<!--          <field name="maxEntries"><int>5</int></field>-->
+<!--          <field name="lifespan"><long>1000</long></field>-->
+<!--        </object>-->
+<!--      </object-param>    -->
+<!--      <object-param>-->
+<!--        <name>test-lru-with-old-config</name>-->
+<!--        <description>The default cache configuration</description>-->
+<!--        <object type="org.exoplatform.services.cache.ExoCacheConfig">-->
+<!--          <field name="name"><string>test-lru-with-old-config</string></field>-->
+<!--          <field name="maxSize"><int>4</int></field>-->
+<!--          <field name="liveTime"><long>1</long></field>-->
+<!--          <field name="implementation"><string>LRU</string></field>-->
+<!--        </object>-->
+<!--      </object-param> -->
+<!--       <object-param>-->
+<!--        <name>test-lru</name>-->
+<!--        <description>The default cache configuration</description>-->
+<!--        <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">-->
+<!--          <field name="name"><string>test-lru</string></field>-->
+<!--          <field name="strategy"><string>LRU</string></field>-->
+<!--          <field name="maxEntries"><int>4</int></field>-->
+<!--          <field name="lifespan"><long>1000</long></field>-->
+<!--          <field name="maxIdle"><long>-1</long></field>-->
+<!--        </object>-->
+<!--      </object-param>    -->
+<!--       <object-param>-->
+<!--        <name>test-ea-with-old-config</name>-->
+<!--        <description>The default cache configuration</description>-->
+<!--        <object type="org.exoplatform.services.cache.ExoCacheConfig">-->
+<!--          <field name="name"><string>test-ea-with-old-config</string></field>-->
+<!--          <field name="maxSize"><int>5</int></field>-->
+<!--          <field name="liveTime"><long>1</long></field>-->
+<!--          <field name="implementation"><string>NONE</string></field>-->
+<!--        </object>-->
+<!--      </object-param> -->
+<!--       <object-param>-->
+<!--        <name>test-ea</name>-->
+<!--        <description>The default cache configuration</description>-->
+<!--        <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">-->
+<!--          <field name="name"><string>test-ea</string></field>-->
+<!--          <field name="strategy"><string>NONE</string></field>-->
+<!--          <field name="maxEntries"><int>5</int></field>-->
+<!--          <field name="maxIdle"><long>1000</long></field>-->
+<!--          <field name="lifespan"><long>2000</long></field>-->
+<!--        </object>-->
+<!--      </object-param>                                   -->
+    </init-params>	
+  </component>  
+  
+  <component>
+    <key>org.exoplatform.services.cache.ExoCacheFactory</key>
+    <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryImpl</type>
+    <init-params>
+      <value-param>
+        <name>cache.config.template</name>
+        <value>jar:/conf/portal/cache-configuration-template.xml</value>
+      </value-param>
+    </init-params>
+  </component>  
+    
+  <external-component-plugins>
+    <target-component>org.exoplatform.services.cache.ExoCacheFactory</target-component>
+    <component-plugin>
+      <name>addConfig</name>
+      <set-method>addConfig</set-method>
+      <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryConfigPlugin</type>
+      <description>add Custom Configurations</description>
+      <init-params>	
+	      <value-param>
+	        <name>myCustomCache</name>
+	        <value>jar:/conf/portal/distributed-cache-configuration-template.xml</value>
+	      </value-param>    		          
+	      <value-param>
+	        <name>myCustomCache-Bis</name>
+	        <value>classpath:/conf/portal/distributed-cache-configuration-template.xml</value>
+	      </value-param>    		          
+      </init-params>	
+    </component-plugin>    
+    <component-plugin>
+      <name>addCreator</name>
+      <set-method>addCreator</set-method>
+      <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheCreatorPlugin</type>
+      <description>add Exo Cache Creator</description>
+      <init-params>	
+	      <object-param>
+		        <name>Test</name>
+		        <description>The cache creator for testing purpose</description>
+		        <object type="org.exoplatform.services.cache.impl.infinispan.TestExoCacheCreator"></object>
+		    </object-param>      
+	      <object-param>
+		        <name>GENERIC</name>
+		        <description>The generic cache creator</description>
+		        <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheCreator">
+		        	<field name="implementations">
+	                  <collection type="java.util.HashSet">
+	                     <value>
+	                        <string>NONE</string>
+	                     </value>
+	                     <value>
+	                        <string>FIFO</string>
+	                     </value>
+	                     <value>
+	                        <string>LRU</string>
+	                     </value>
+	                     <value>
+	                        <string>UNORDERED</string>
+	                     </value>
+	                     <value>
+	                        <string>LIRS</string>
+	                     </value>
+	                  </collection>		        	
+		        	</field>
+		        	<field name="defaultStrategy"><string>LRU</string></field>
+		        	<field name="defaultMaxIdle"><long>-1</long></field>
+		        	<field name="defaultWakeUpInterval"><long>500</long></field>	
+		        </object>
+		    </object-param>  		    		          
+      </init-params>	
+    </component-plugin>
+  </external-component-plugins>  
+</configuration>



More information about the exo-jcr-commits mailing list