exo-jcr SVN: r3538 - in kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src: main and 11 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-11-24 09:02:56 -0500 (Wed, 24 Nov 2010)
New Revision: 3538
Added:
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreatorPlugin.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryConfigPlugin.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheConfig.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/portal/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/portal/cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/portal/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/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,576 @@
+/*
+ * 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.CacheInfo;
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheListenerContext;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.infinispan.AdvancedCache;
+import org.infinispan.Cache;
+import org.infinispan.context.Flag;
+import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * An {@link org.exoplatform.services.cache.ExoCache} implementation based on {@link Cache}.
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public abstract class AbstractExoCache<K extends Serializable, V> implements ExoCache<K, V>
+{
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger("exo.kernel.component.ext.cache.impl.infinispan.v4.AbstractExoCache");
+
+ private final AtomicInteger hits = new AtomicInteger(0);
+
+ private final AtomicInteger misses = new AtomicInteger(0);
+
+ private String label;
+
+ private String name;
+
+ private boolean distributed;
+
+ private boolean replicated;
+
+ private boolean logEnabled;
+
+ private final CopyOnWriteArrayList<ListenerContext<K, V>> listeners;
+
+ protected final AdvancedCache<K, V> cache;
+
+ public AbstractExoCache(ExoCacheConfig config, Cache<K, V> cache)
+ {
+ this.cache = cache.getAdvancedCache();
+ this.listeners = new CopyOnWriteArrayList<ListenerContext<K, V>>();
+ setDistributed(config.isDistributed());
+ setLabel(config.getLabel());
+ setName(config.getName());
+ setLogEnabled(config.isLogEnabled());
+ setReplicated(config.isRepicated());
+ cache.addListener(new CacheEventListener());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addCacheListener(CacheListener<? super K, ? super V> listener)
+ {
+ if (listener == null)
+ {
+ throw new NullPointerException();
+ }
+ listeners.add(new ListenerContext<K, V>(listener, this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clearCache()
+ {
+ cache.withFlags(Flag.CACHE_MODE_LOCAL).clear();
+ onClearCache();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public V get(Serializable name)
+ {
+ if (name == null)
+ {
+ return null;
+ }
+ final V result = cache.get(name);
+ if (result == null)
+ {
+ misses.incrementAndGet();
+ }
+ else
+ {
+ hits.incrementAndGet();
+ }
+ onGet((K)name, result);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheHit()
+ {
+ return hits.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheMiss()
+ {
+ return misses.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheSize()
+ {
+ return cache.size();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<V> getCachedObjects()
+ {
+ Collection<V> values = cache.values();
+ if (values == null || values.isEmpty())
+ {
+ return Collections.emptyList();
+ }
+ else
+ {
+ return new ArrayList<V>(values);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLabel()
+ {
+ return label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDistributed()
+ {
+ return distributed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLogEnabled()
+ {
+ return logEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isReplicated()
+ {
+ return replicated;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(K key, V value) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null cache key accepted");
+ }
+ putOnly(key, value);
+ onPut(key, value);
+ }
+
+ /**
+ * Only puts the data into the cache nothing more
+ */
+ protected void putOnly(K key, V value)
+ {
+ cache.withFlags(Flag.SKIP_REMOTE_LOOKUP).put(key, value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void putMap(Map<? extends K, ? extends V> objs) throws NullPointerException, IllegalArgumentException
+ {
+ if (objs == null)
+ {
+ throw new NullPointerException("No null map accepted");
+ }
+ for (Serializable name : objs.keySet())
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null cache key accepted");
+ }
+ }
+ cache.startBatch();
+ try
+ {
+ // Start transaction
+ for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet())
+ {
+ putOnly(entry.getKey(), entry.getValue());
+ }
+ cache.endBatch(true);
+ // End transaction
+ for (Map.Entry<? extends K, ? extends V> entry : objs.entrySet())
+ {
+ onPut(entry.getKey(), entry.getValue());
+ }
+ }
+ catch (Exception e)
+ {
+ cache.endBatch(false);
+ LOG.warn("An error occurs while executing the putMap method", e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public V remove(Serializable name) throws NullPointerException
+ {
+ if (name == null)
+ {
+ throw new NullPointerException("No null cache key accepted");
+ }
+ V result = cache.remove(name);
+ onRemove((K)name, result);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<V> removeCachedObjects()
+ {
+ final List<V> list = getCachedObjects();
+ clearCache();
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void select(CachedObjectSelector<? super K, ? super V> selector) throws Exception
+ {
+ if (selector == null)
+ {
+ throw new IllegalArgumentException("No null selector");
+ }
+ for (K key : cache.keySet())
+ {
+ if (key == null)
+ {
+ continue;
+ }
+ final V value = cache.withFlags(Flag.SKIP_LOCKING).get(key);
+ ObjectCacheInfo<V> info = new ObjectCacheInfo<V>()
+ {
+ public V get()
+ {
+ return value;
+ }
+
+ public long getExpireTime()
+ {
+ // Cannot know: The expire time is managed by Infinispan itself
+ return -1;
+ }
+ };
+ if (selector.select(key, info))
+ {
+ selector.onSelect(this, key, info);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDistributed(boolean distributed)
+ {
+ this.distributed = distributed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLogEnabled(boolean logEnabled)
+ {
+ this.logEnabled = logEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReplicated(boolean replicated)
+ {
+ this.replicated = replicated;
+ }
+
+ void onExpire(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ {
+ try
+ {
+ context.onExpire(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onRemove(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ {
+ try
+ {
+ context.onRemove(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onPut(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onPut(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onGet(K key, V obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onGet(key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onClearCache()
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (ListenerContext<K, V> context : listeners)
+ try
+ {
+ context.onClearCache();
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Listener
+ public class CacheEventListener
+ {
+// Infinispan triggers a CacheEntryEvictedEvent only at explicit eviction which is
+// not what we want here. So it will be considered as non supported
+// @CacheEntryEvicted
+// public void cacheEntryEvicted(CacheEntryEvictedEvent evt)
+// {
+// if (evt.isPre())
+// {
+// final K key = (K)evt.getKey();
+// final V value = cache.withFlags(Flag.SKIP_LOCKING).get(key);
+// onExpire(key, value);
+// }
+// }
+
+ @CacheEntryRemoved
+ public void cacheEntryRemoved(CacheEntryRemovedEvent evt)
+ {
+ if (evt.isPre() && !evt.isOriginLocal())
+ {
+ final K key = (K)evt.getKey();
+ final V value = (V)evt.getValue();
+ onRemove(key, value);
+ }
+ }
+
+ @CacheEntryModified
+ public void cacheEntryModified(CacheEntryModifiedEvent evt)
+ {
+ if (!evt.isOriginLocal() && !evt.isPre())
+ {
+ final K key = (K)evt.getKey();
+ final V value = (V)evt.getValue();
+ onPut(key, value);
+ }
+ }
+ }
+
+ private static class ListenerContext<K extends Serializable, V> implements CacheListenerContext, CacheInfo
+ {
+
+ /** . */
+ private final ExoCache<K, V> cache;
+
+ /** . */
+ final CacheListener<? super K, ? super V> listener;
+
+ public ListenerContext(CacheListener<? super K, ? super V> listener, ExoCache<K, V> cache)
+ {
+ this.listener = listener;
+ this.cache = cache;
+ }
+
+ public CacheInfo getCacheInfo()
+ {
+ return this;
+ }
+
+ public String getName()
+ {
+ return cache.getName();
+ }
+
+ public int getMaxSize()
+ {
+ return cache.getMaxSize();
+ }
+
+ public long getLiveTime()
+ {
+ return cache.getLiveTime();
+ }
+
+ public int getSize()
+ {
+ return cache.getCacheSize();
+ }
+
+ void onExpire(K key, V obj) throws Exception
+ {
+ listener.onExpire(this, key, obj);
+ }
+
+ void onRemove(K key, V obj) throws Exception
+ {
+ listener.onRemove(this, key, obj);
+ }
+
+ void onPut(K key, V obj) throws Exception
+ {
+ listener.onPut(this, key, obj);
+ }
+
+ void onGet(K key, V obj) throws Exception
+ {
+ listener.onGet(this, key, obj);
+ }
+
+ void onClearCache() throws Exception
+ {
+ listener.onClearCache(this);
+ }
+ }
+}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreator.java 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,61 @@
+/*
+ * 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.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.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * This class is used to create the cache according to the given
+ * configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ */
+public interface ExoCacheCreator
+{
+
+ /**
+ * Creates an eXo cache according to the given configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ * @param config the configuration of the cache to apply
+ * @param cacheConfig the configuration of the infinispan cache
+ * @param cacheGetter a {@link Callable} instance from which we can get the cache
+ * @exception ExoCacheInitException if an exception happens while initializing the cache
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig, Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException;
+
+ /**
+ * Returns the type of {@link org.exoplatform.services.cache.ExoCacheConfig} expected by the creator
+ * @return the expected type
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType();
+
+ /**
+ * Returns a set of all the implementations expected by the creator. This is mainly used to be backward compatible
+ * @return the expected by the creator
+ */
+ public Set<String> getExpectedImplementations();
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreatorPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreatorPlugin.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheCreatorPlugin.java 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,58 @@
+/*
+ * 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.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class allows us to define new creators
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ */
+public class ExoCacheCreatorPlugin extends BaseComponentPlugin
+{
+
+ /**
+ * The list of all the creators defined for this ComponentPlugin
+ */
+ private final List<ExoCacheCreator> creators;
+
+ public ExoCacheCreatorPlugin(InitParams params)
+ {
+ creators = new ArrayList<ExoCacheCreator>();
+ List<?> configs = params.getObjectParamValues(ExoCacheCreator.class);
+ for (int i = 0; i < configs.size(); i++)
+ {
+ ExoCacheCreator config = (ExoCacheCreator)configs.get(i);
+ creators.add(config);
+ }
+ }
+
+ /**
+ * Returns all the creators defined for this ComponentPlugin
+ */
+ public List<ExoCacheCreator> getCreators()
+ {
+ return creators;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryConfigPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryConfigPlugin.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryConfigPlugin.java 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,60 @@
+/*
+ * 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.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This class is used to define custom configurations
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ */
+public class ExoCacheFactoryConfigPlugin extends BaseComponentPlugin
+{
+
+ /**
+ * The map of all the creators defined for this ComponentPlugin
+ */
+ private final Map<String, String> configs;
+
+ public ExoCacheFactoryConfigPlugin(InitParams params)
+ {
+ configs = new HashMap<String, String>();
+ for (Iterator<ValueParam> iterator = params.getValueParamIterator(); iterator.hasNext();)
+ {
+ ValueParam vParam = iterator.next();
+ configs.put(vParam.getName(), vParam.getValue());
+ }
+ }
+
+ /**
+ * Returns all the configurations defined for this ComponentPlugin
+ */
+ public Map<String, String> getConfigs()
+ {
+ return configs;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/ExoCacheFactoryImpl.java 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,430 @@
+/*
+ * 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.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+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.impl.infinispan.generic.GenericExoCacheCreator;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.eviction.EvictionStrategy;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * This class is the Infinispan implementation of the {@link org.exoplatform.services.cache.ExoCacheFactory}
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class ExoCacheFactoryImpl implements ExoCacheFactory
+{
+
+ /**
+ * The logger
+ */
+ private static final Log LOG =
+ ExoLogger.getLogger("exo.kernel.component.ext.cache.impl.infinispan.v4.ExoCacheFactoryImpl");
+
+ /**
+ * The initial parameter key that defines the full path of the configuration template
+ */
+ private static final String CACHE_CONFIG_TEMPLATE_KEY = "cache.config.template";
+
+ /**
+ * The current {@link ExoContainerContext}
+ */
+ private final ExoContainerContext ctx;
+
+ /**
+ * The configuration manager that allows us to retrieve a configuration file in several different
+ * manners
+ */
+ private final ConfigurationManager configManager;
+
+ /**
+ * The {@link DefaultCacheManager} used for all the cache regions
+ */
+ private final DefaultCacheManager cacheManager;
+
+ /**
+ * The mapping between the configuration types and the creators
+ */
+ private final Map<Class<? extends ExoCacheConfig>, ExoCacheCreator> mappingConfigTypeCreators =
+ new HashMap<Class<? extends ExoCacheConfig>, ExoCacheCreator>();
+
+ /**
+ * The mapping between the implementations and the creators. This is mainly used for backward compatibility
+ */
+ private final Map<String, ExoCacheCreator> mappingImplCreators = new HashMap<String, ExoCacheCreator>();
+
+ /**
+ * The mapping between the cache names and the configuration paths
+ */
+ private final Map<String, String> mappingCacheNameConfig = new HashMap<String, String>();
+
+ /**
+ * The mapping between the global configuration and the cache managers
+ */
+ private final Map<GlobalConfiguration, DefaultCacheManager> mappingGlobalConfigCacheManager = new HashMap<GlobalConfiguration, DefaultCacheManager>();
+
+ /**
+ * The default creator
+ */
+ private final ExoCacheCreator defaultCreator = new GenericExoCacheCreator();
+
+ public ExoCacheFactoryImpl(ExoContainerContext ctx, InitParams params, ConfigurationManager configManager)
+ throws ExoCacheInitException
+ {
+ this(ctx, getValueParam(params, CACHE_CONFIG_TEMPLATE_KEY), configManager);
+ }
+
+ ExoCacheFactoryImpl(ExoContainerContext ctx, String cacheConfigTemplate, ConfigurationManager configManager)
+ throws ExoCacheInitException
+ {
+ this.ctx = ctx;
+ this.configManager = configManager;
+ if (cacheConfigTemplate == null)
+ {
+ throw new RuntimeException("The parameter '" + CACHE_CONFIG_TEMPLATE_KEY + "' must be set");
+ }
+ // Initialize the main cache manager
+ this.cacheManager = initCacheManager(cacheConfigTemplate);
+ // Register the main cache manager
+ mappingGlobalConfigCacheManager.put(cacheManager.getGlobalConfiguration(), cacheManager);
+ }
+
+ /**
+ * Initializes the {@link DefaultCacheManager}
+ * @throws ExoCacheInitException if the cache manager cannot be initialized
+ */
+ private DefaultCacheManager initCacheManager(String cacheConfigTemplate)
+ throws ExoCacheInitException
+ {
+ InputStream is = null;
+ try
+ {
+ // Read the configuration file of the cache
+ is = configManager.getInputStream(cacheConfigTemplate);
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("The configuration of the CacheManager cannot be loaded from '"
+ + cacheConfigTemplate + "'", e);
+ }
+ if (is == null)
+ {
+ throw new ExoCacheInitException("The configuration of the CacheManager cannot be found at '"
+ + cacheConfigTemplate + "'");
+ }
+ DefaultCacheManager cacheManager = null;
+ try
+ {
+ // Create the CacheManager from the input stream
+ cacheManager = new DefaultCacheManager(is, false);
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("Cannot initialize the CacheManager corresponding to the configuration '"
+ + cacheConfigTemplate + "'", e);
+ }
+
+ GlobalConfiguration config = cacheManager.getGlobalConfiguration();
+
+ configureJGroups(config);
+ return cacheManager;
+ }
+
+ /**
+ * If some JGoups properties has been set, it will load the configuration and set
+ * the cluster name by adding as suffix the name of the {@link ExoContainerContext}
+ *
+ * @param config the global configuration from which the JGroups config will be extracted
+ * @throws ExoCacheInitException if any exception occurs while configuring JGroups
+ */
+ private void configureJGroups(GlobalConfiguration config) throws ExoCacheInitException
+ {
+ if (loadJGroupsConfig(config))
+ {
+ // The JGroups Config could be loaded which means that the configuration is for a cluster
+ config.setClusterName(config.getClusterName() + "-" + ctx.getName());
+ }
+ }
+
+ /**
+ * Load the JGroups configuration file thanks to the {@link ConfigurationManager}
+ * @param config the global configuration from which the JGroups config will be extracted
+ * @return <code>true</code> if the JGoups config could be loaded successfully,
+ * <code>false</code> if there were no JGroups config to load
+ * @throws ExoCacheInitException if the JGroups config could not be loaded
+ */
+ private boolean loadJGroupsConfig(GlobalConfiguration config) throws ExoCacheInitException
+ {
+ Properties properties = config.getTransportProperties();
+ if (properties == null || !properties.containsKey(JGroupsTransport.CONFIGURATION_FILE))
+ {
+ return false;
+ }
+ InputStream is;
+ String jgroupsFileLocation = properties.getProperty(JGroupsTransport.CONFIGURATION_FILE);
+ try
+ {
+ // Read the jgroups configuration file
+ URL url = configManager.getURL(jgroupsFileLocation);
+ is = url == null ? null : url.openStream();
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("The jgroups configuration cannot be loaded from '" + jgroupsFileLocation
+ + "'", e);
+ }
+ if (is != null)
+ {
+ try
+ {
+ // Set the jgroups configuration as XML
+ properties.setProperty(JGroupsTransport.CONFIGURATION_XML, readStream(is));
+ }
+ catch (IOException e)
+ {
+ throw new ExoCacheInitException("The jgroups configuration cannot be read from '" + jgroupsFileLocation
+ + "'");
+ }
+ // Remove the property corresponding to the configuration file
+ properties.remove(JGroupsTransport.CONFIGURATION_FILE);
+ }
+ return true;
+ }
+
+ /**
+ * Reads bytes from input stream and builds a string from them
+ *
+ * @param inputStream
+ * @return
+ * @throws IOException
+ */
+ protected String readStream(InputStream inputStream) throws IOException
+ {
+ StringBuilder out = new StringBuilder(4096);
+ byte[] b = new byte[4096];
+ try
+ {
+ for (int length; (length = inputStream.read(b)) != -1;)
+ {
+ out.append(new String(b, 0, length));
+ }
+ }
+ finally
+ {
+ try
+ {
+ inputStream.close();
+ }
+ catch (Exception e)
+ {
+ LOG.debug("Cannot close stream", e);
+ }
+ }
+ return out.toString();
+ }
+
+ /**
+ * To create a new cache instance according to the given configuration, we follow the steps below:
+ *
+ * We first try to find if a specific location of the cache configuration has been defined thanks
+ * to an external component plugin of type ExoCacheFactoryConfigPlugin. If so we use the default cache
+ * configuration defined in this file otherwise we use the default cache configuration defined in
+ * "${CACHE_CONFIG_TEMPLATE_KEY}"
+ */
+ public ExoCache<Serializable, Object> createCache(ExoCacheConfig config) throws ExoCacheInitException
+ {
+ final String region = config.getName();
+ final String customConfig = mappingCacheNameConfig.get(region);
+ final ExoCache<Serializable, Object> eXoCache;
+ final DefaultCacheManager cacheManager;
+ try
+ {
+ final Configuration conf;
+ if (customConfig != null)
+ {
+ // A custom configuration has been set
+ if (LOG.isInfoEnabled())
+ LOG.info("A custom configuration has been set for the cache '" + region + "'.");
+ // Create the CacheManager by loading the configuration
+ DefaultCacheManager customCacheManager = new DefaultCacheManager(configManager.getInputStream(customConfig), false);
+ GlobalConfiguration gc = customCacheManager.getGlobalConfiguration();
+ // Configure JGroups since it could affect the state of the Global Config
+ configureJGroups(gc);
+ // Check if a CacheManager with the same GlobalConfiguration exists
+ DefaultCacheManager currentCacheManager = mappingGlobalConfigCacheManager.get(gc);
+ if (currentCacheManager == null)
+ {
+ // No cache manager has been defined so far for this Cache Configuration
+ currentCacheManager = customCacheManager;
+ // We register this new cache manager
+ mappingGlobalConfigCacheManager.put(gc, customCacheManager);
+ }
+ conf = currentCacheManager.getDefaultConfiguration().clone();
+ cacheManager = currentCacheManager;
+ }
+ else
+ {
+ cacheManager = this.cacheManager;
+ // No custom configuration has been found, a configuration template will be used
+ if (LOG.isInfoEnabled())
+ LOG.info("The configuration template will be used for the the cache '" + region + "'.");
+ conf = cacheManager.getDefaultConfiguration().clone();
+ if (!config.isDistributed() && !config.isRepicated())
+ {
+ // The cache is local
+ conf.setCacheMode(CacheMode.LOCAL);
+ }
+ }
+ // Reset the configuration to avoid conflicts
+ resetConfiguration(conf);
+ final ExoCacheCreator creator = getExoCacheCreator(config);
+ // Create the cache
+ eXoCache = creator.create(config, conf, new Callable<Cache<Serializable, Object>>()
+ {
+ @Override
+ public Cache<Serializable, Object> call() throws Exception
+ {
+ // Define the configuration
+ cacheManager.defineConfiguration(region, conf);
+ // create and start the cache
+ return cacheManager.getCache(region);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("The cache '" + region + "' could not be initialized", e);
+ }
+ return eXoCache;
+ }
+
+ /**
+ * Add a list of creators to register
+ * @param plugin the plugin that contains the creators
+ */
+ public void addCreator(ExoCacheCreatorPlugin plugin)
+ {
+ final List<ExoCacheCreator> creators = plugin.getCreators();
+ for (ExoCacheCreator creator : creators)
+ {
+ mappingConfigTypeCreators.put(creator.getExpectedConfigType(), creator);
+ Set<String> implementations = creator.getExpectedImplementations();
+ if (implementations == null)
+ {
+ throw new NullPointerException("The set of implementations cannot be null");
+ }
+ for (String imp : implementations)
+ {
+ mappingImplCreators.put(imp, creator);
+ }
+ }
+ }
+
+ /**
+ * Add a list of custom configuration to register
+ * @param plugin the plugin that contains the configs
+ */
+ public void addConfig(ExoCacheFactoryConfigPlugin plugin)
+ {
+ final Map<String, String> configs = plugin.getConfigs();
+ mappingCacheNameConfig.putAll(configs);
+ }
+
+ /**
+ * Returns the value of the ValueParam if and only if the value is not empty
+ */
+ private static String getValueParam(InitParams params, String key)
+ {
+ if (params == null)
+ {
+ return null;
+ }
+ final ValueParam vp = params.getValueParam(key);
+ String result;
+ if (vp == null || (result = vp.getValue()) == null || (result = result.trim()).length() == 0)
+ {
+ return null;
+ }
+ return result;
+ }
+
+ /**
+ * Returns the most relevant ExoCacheCreator according to the give configuration
+ */
+ protected ExoCacheCreator getExoCacheCreator(ExoCacheConfig config)
+ {
+ ExoCacheCreator creator = mappingConfigTypeCreators.get(config.getClass());
+ if (creator == null)
+ {
+ // No creator for this type has been found, let's try the implementation field
+ creator = mappingImplCreators.get(config.getImplementation());
+ if (creator == null)
+ {
+ // No creator can be found, we will use the default creator
+ if (LOG.isInfoEnabled())
+ LOG.info("No cache creator has been found for the the cache '" + config.getName()
+ + "', the default one will be used.");
+ return defaultCreator;
+ }
+ }
+ if (LOG.isInfoEnabled())
+ LOG.info("The cache '" + config.getName() + "' will be created with '" + creator.getClass() + "'.");
+ return creator;
+ }
+
+ /**
+ * Clean the configuration template to prevent conflicts
+ */
+ protected void resetConfiguration(Configuration config)
+ {
+ config.setInvocationBatchingEnabled(true);
+ config.setEvictionStrategy(EvictionStrategy.NONE);
+ config.setEvictionMaxEntries(-1);
+ config.setExpirationLifespan(-1);
+ config.setExpirationMaxIdle(-1);
+ config.setEvictionWakeUpInterval(5000);
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheConfig.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheConfig.java 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,123 @@
+/*
+ * 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.generic;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for all the eviction algorithms
+ * available in infinispan
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class GenericExoCacheConfig extends ExoCacheConfig
+{
+
+ private String strategy;
+
+ private int maxEntries;
+
+ private long lifespan;
+
+ private long maxIdle;
+
+ private long wakeUpInterval;
+
+ /**
+ * @return the strategy
+ */
+ public String getStrategy()
+ {
+ return strategy;
+ }
+
+ /**
+ * @param strategy the strategy to set
+ */
+ public void setStrategy(String strategy)
+ {
+ this.strategy = strategy;
+ }
+
+ /**
+ * @return the wakeUpInterval
+ */
+ public long getWakeUpInterval()
+ {
+ return wakeUpInterval;
+ }
+
+ /**
+ * @param wakeUpInterval the wakeUpInterval to set
+ */
+ public void setWakeUpInterval(long wakeUpInterval)
+ {
+ this.wakeUpInterval = wakeUpInterval;
+ }
+
+ /**
+ * @return the maxEntries
+ */
+ public int getMaxEntries()
+ {
+ return maxEntries;
+ }
+
+ /**
+ * @param maxEntries the maxEntries to set
+ */
+ public void setMaxEntries(int maxEntries)
+ {
+ this.maxEntries = maxEntries;
+ }
+
+ /**
+ * @return the lifespan
+ */
+ public long getLifespan()
+ {
+ return lifespan;
+ }
+
+ /**
+ * @param lifespan the lifespan to set
+ */
+ public void setLifespan(long lifespan)
+ {
+ this.lifespan = lifespan;
+ }
+
+ /**
+ * @return the maxIdle
+ */
+ public long getMaxIdle()
+ {
+ return maxIdle;
+ }
+
+ /**
+ * @param maxIdle the maxIdle to set
+ */
+ public void setMaxIdle(long maxIdle)
+ {
+ this.maxIdle = maxIdle;
+ }
+}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/java/org/exoplatform/services/cache/impl/infinispan/generic/GenericExoCacheCreator.java 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,191 @@
+/*
+ * 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.generic;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.infinispan.AbstractExoCache;
+import org.exoplatform.services.cache.impl.infinispan.ExoCacheCreator;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * The generic {@link ExoCacheCreator} for all the expiration available in infinispan.
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class GenericExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The default value for the eviction strategy
+ */
+ protected String defaultStrategy = "LRU";
+
+ /**
+ * The default value for maxIdle
+ */
+ protected long defaultMaxIdle = -1;
+
+ /**
+ * The default value for wakeUpInterval
+ */
+ protected long defaultWakeUpInterval = 5000;
+
+ /**
+ * A set of all the implementations supported by this creator
+ */
+ protected Set<String> implementations;
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<String> getExpectedImplementations()
+ {
+ return implementations;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return GenericExoCacheConfig.class;
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.impl.infinispan.ExoCacheCreator#create(org.exoplatform.services.cache.ExoCacheConfig, java.util.concurrent.Callable)
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException
+ {
+ if (config instanceof GenericExoCacheConfig)
+ {
+ final GenericExoCacheConfig gConfig = (GenericExoCacheConfig)config;
+ return create(config, cacheConfig, cacheGetter, gConfig.getStrategy(), gConfig.getMaxEntries(), gConfig
+ .getLifespan(), gConfig.getMaxIdle() == 0 ? defaultMaxIdle : gConfig.getMaxIdle(), gConfig
+ .getWakeUpInterval() == 0 ? defaultWakeUpInterval : gConfig.getWakeUpInterval());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cacheConfig, cacheGetter, config.getImplementation() == null ? defaultStrategy : config
+ .getImplementation(), config.getMaxSize(), period > 0 ? period * 1000 : -1, defaultMaxIdle,
+ defaultWakeUpInterval);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ * @throws ExoCacheInitException If any exception occurs while creating the cache
+ */
+ private ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig,
+ Callable<Cache<Serializable, Object>> cacheGetter, String strategy, int maxEntries, long lifespan, long maxIdle,
+ long wakeUpInterval) throws ExoCacheInitException
+ {
+ cacheConfig.setEvictionStrategy(strategy);
+ cacheConfig.setEvictionMaxEntries(maxEntries);
+ cacheConfig.setExpirationLifespan(lifespan);
+ cacheConfig.setExpirationMaxIdle(maxIdle);
+ cacheConfig.setEvictionWakeUpInterval(wakeUpInterval);
+ try
+ {
+ return new GenericExoCache(cacheConfig, config, cacheGetter.call());
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("Cannot create the cache '" + config.getName() + "'", e);
+ }
+ }
+
+ /**
+ * The Generic implementation of an ExoCache
+ */
+ public static class GenericExoCache extends AbstractExoCache<Serializable, Object>
+ {
+
+ private final Configuration cacheConfig;
+
+ public GenericExoCache(Configuration cacheConfig, ExoCacheConfig config, Cache<Serializable, Object> cache)
+ {
+ super(config, cache);
+ this.cacheConfig = cacheConfig;
+ }
+
+ public void setMaxSize(int max)
+ {
+ cacheConfig.setEvictionMaxEntries(max);
+ }
+
+ public void setLiveTime(long period)
+ {
+ cacheConfig.setExpirationLifespan(period);
+ }
+
+ public void setMaxIdle(long maxIdle)
+ {
+ cacheConfig.setExpirationMaxIdle(maxIdle);
+ }
+
+ public void setWakeUpInterval(long wakeUpInterval)
+ {
+ cacheConfig.setEvictionWakeUpInterval(wakeUpInterval);
+ }
+
+ @ManagedName("MaxEntries")
+ @ManagedDescription("Maximum number of entries in a cache instance. -1 means no limit.")
+ public int getMaxSize()
+ {
+ return cacheConfig.getEvictionMaxEntries();
+ }
+
+ @ManagedName("Lifespan")
+ @ManagedDescription("Maximum lifespan of a cache entry, after which the entry is expired cluster-wide. -1 means the entries never expire.")
+ public long getLiveTime()
+ {
+ return cacheConfig.getExpirationLifespan();
+ }
+
+ @Managed
+ @ManagedName("MaxIdle")
+ @ManagedDescription("Maximum idle time a cache entry will be maintained in the cache. If the idle time is exceeded, the entry will be expired cluster-wide. -1 means the entries never expire.")
+ public long getMaxIdle()
+ {
+ return cacheConfig.getExpirationMaxIdle();
+ }
+
+ @Managed
+ @ManagedName("WakeUpInterval")
+ @ManagedDescription("Interval between subsequent eviction runs. If you wish to disable the periodic eviction process altogether, set wakeupInterval to -1.")
+ public long getWakeUpInterval()
+ {
+ return cacheConfig.getEvictionWakeUpInterval();
+ }
+ }
+}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/portal/cache-configuration-template.xml 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,65 @@
+<?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="true"/>
+ <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="true"/>
+ <invocationBatching 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/main/resources/conf/portal/configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/portal/configuration.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main/resources/conf/portal/configuration.xml 2010-11-24 14:02:56 UTC (rev 3538)
@@ -0,0 +1,34 @@
+<?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.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>
+</configuration>
15 years, 8 months
exo-jcr SVN: r3537 - in jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: dataflow/session and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 08:59:40 -0500 (Wed, 24 Nov 2010)
New Revision: 3537
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
Log:
JCR-1523: Avoid iterating over a List thanks to its iterator when it is possible [Part #2]
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-11-24 13:43:49 UTC (rev 3536)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-11-24 13:59:40 UTC (rev 3537)
@@ -629,8 +629,9 @@
List<NodeData> refNodes = new ArrayList<NodeData>();
- for (ItemState changedItem : changes)
+ for (int i = 0, length = changes.size(); i < length; i++)
{
+ ItemState changedItem = changes.get(i);
if (changedItem.isNode())
{
NodeData refNode = (NodeData)changedItem.getData();
@@ -651,11 +652,13 @@
}
// check ref changes
- for (NodeData refNode : refNodes)
+ for (int i = 0, length = refNodes.size(); i < length; i++)
{
+ NodeData refNode = refNodes.get(i);
List<PropertyData> nodeRefs = dataManager.getReferencesData(refNode.getIdentifier(), true);
- for (PropertyData refProp : nodeRefs)
+ for (int j = 0, length2 = nodeRefs.size(); j < length2; j++)
{
+ PropertyData refProp = nodeRefs.get(j);
// if ref property is deleted in this session
ItemState refState = dataManager.getChangesLog().getItemState(refProp.getIdentifier());
if (refState != null && refState.isDeleted())
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2010-11-24 13:43:49 UTC (rev 3536)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2010-11-24 13:59:40 UTC (rev 3537)
@@ -85,9 +85,11 @@
public SessionChangesLog(List<ItemState> items, String sessionId)
{
super(items, sessionId);
-
- for (ItemState change : items)
+ for (int i = 0, length = items.size(); i < length; i++)
+ {
+ ItemState change = items.get(i);
addItem(change);
+ }
}
/**
@@ -109,9 +111,11 @@
public PlainChangesLog addAll(List<ItemState> changes)
{
super.addAll(changes);
- for (ItemState change : changes)
+ for (int i = 0, length = changes.size(); i < length; i++)
+ {
+ ItemState change = changes.get(i);
addItem(change);
-
+ }
return this;
}
@@ -200,8 +204,9 @@
private void traverseChangesByIdentifier(String identifier, List<ItemState> changesList)
{
- for (ItemState item : items)
+ for (int i = 0, length = items.size(); i < length; i++)
{
+ ItemState item = items.get(i);
if (item.getData().getIdentifier().equals(identifier))
{
changesList.add(item);
@@ -221,8 +226,9 @@
*/
public void eraseEventFire(String identifier)
{
- for (ItemState item : items)
+ for (int i = 0, length = items.size(); i < length; i++)
{
+ ItemState item = items.get(i);
if (item.getData().getIdentifier().equals(identifier))
{
// erase flag
@@ -242,11 +248,12 @@
public List<ItemState> getDescendantsChanges(QPath rootPath)
{
List<ItemState> list = new ArrayList<ItemState>();
- for (int i = 0; i < items.size(); i++)
+ for (int i = 0, length = items.size(); i < length; i++)
{
- if (items.get(i).isDescendantOf(rootPath))
+ ItemState item = items.get(i);
+ if (item.isDescendantOf(rootPath))
{
- list.add(items.get(i));
+ list.add(item);
}
}
return list;
@@ -261,8 +268,10 @@
public List<ItemState> getItemStates(String itemIdentifier)
{
List<ItemState> states = new ArrayList<ItemState>();
- for (ItemState state : getAllStates())
+ List<ItemState> currentStates = getAllStates();
+ for (int i = 0, length = currentStates.size(); i < length; i++)
{
+ ItemState state = currentStates.get(i);
if (state.getData().getIdentifier().equals(itemIdentifier))
{
states.add(state);
15 years, 8 months
exo-jcr SVN: r3536 - kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-11-24 08:43:49 -0500 (Wed, 24 Nov 2010)
New Revision: 3536
Modified:
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/pom.xml
Log:
EXOJCR-1054 : porting ISPN code of Kernel project. Fixing dependency.
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/pom.xml 2010-11-24 13:08:11 UTC (rev 3535)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/pom.xml 2010-11-24 13:43:49 UTC (rev 3536)
@@ -20,7 +20,7 @@
<parent>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>kernel-parent</artifactId>
- <version>2.3-ISPN-SNAPSHOT</version>
+ <version>2.3.0-CR1-SNAPSHOT</version>
</parent>
<artifactId>exo.kernel.component.ext.cache.impl.infinispan.v4</artifactId>
<name>eXo Kernel :: Cache Extension :: Infinispan Implementation</name>
15 years, 8 months
exo-jcr SVN: r3535 - in jcr/trunk/exo.jcr.component.ext: src/test/java/org/exoplatform/services/jcr/ext/backup and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 08:08:11 -0500 (Wed, 24 Nov 2010)
New Revision: 3535
Modified:
jcr/trunk/exo.jcr.component.ext/pom.xml
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
Log:
EXOJCR-852: add TestBackupManager to include list
Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml 2010-11-24 13:06:01 UTC (rev 3534)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml 2010-11-24 13:08:11 UTC (rev 3535)
@@ -185,6 +185,7 @@
<include>**/replication/*.java</include>
<include>**/replication/external/*.java</include>
<include>**/replication/async/**/*.java</include>
+ <include>**/**/TestBackupManager.java</include>
</includes>
<excludes>
<exclude>**/BaseStandaloneTest.java</exclude>
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-11-24 13:06:01 UTC (rev 3534)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-11-24 13:08:11 UTC (rev 3535)
@@ -1473,19 +1473,33 @@
public void testExistedRepositoryRestore() throws Exception
{
+ RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
+
+ for (String wsName : repositoryDB8.getWorkspaceNames())
+ {
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
+
+ Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
+ sessionWS.getRootNode().save();
+ addContent(wsTestRoot, 1, 10, 1);
+ sessionWS.getRootNode().save();
+ }
+
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, WS_NAME);
+
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repository.getName());
+ config.setRepository(repositoryDB8.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -1500,7 +1514,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1635,19 +1649,33 @@
public void testExistedRepositoryRestoreAsync() throws Exception
{
+ RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
+
+ for (String wsName : repositoryDB8.getWorkspaceNames())
+ {
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
+
+ Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
+ sessionWS.getRootNode().save();
+ addContent(wsTestRoot, 1, 10, 1);
+ sessionWS.getRootNode().save();
+ }
+
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, "ws1");
+
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repository.getName());
+ config.setRepository(repositoryDB8.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -1662,7 +1690,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1717,19 +1745,34 @@
public void testExistedRepositoryRestoreAsync2() throws Exception
{
+ RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
+
+ for (String wsName : repositoryDB8.getWorkspaceNames())
+ {
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
+
+ Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
+ sessionWS.getRootNode().save();
+ addContent(wsTestRoot, 1, 10, 1);
+ sessionWS.getRootNode().save();
+ }
+
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, "ws1");
+
+
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repository.getName());
+ config.setRepository(repositoryDB8.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -1744,7 +1787,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2010-11-24 13:06:01 UTC (rev 3534)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2010-11-24 13:08:11 UTC (rev 3535)
@@ -1955,7 +1955,6 @@
</properties-param>
</init-params>
</component-plugin>
-
<component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
@@ -1990,6 +1989,35 @@
<init-params>
<value-param>
<name>bind-name</name>
+ <value>jdbcjcr28</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr28" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+
+
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
<value>jdbcjcr_to_rest_repo_1</value>
</value-param>
<value-param>
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml 2010-11-24 13:06:01 UTC (rev 3534)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml 2010-11-24 13:08:11 UTC (rev 3535)
@@ -421,6 +421,82 @@
</query-handler>
</workspace>
</workspaces>
- </repository>
+ </repository>
+ <repository name="db8" system-workspace="ws" default-workspace="ws">
+ <security-domain>exo-domain</security-domain>
+ <access-control>optional</access-control>
+ <authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
+ <workspaces>
+ <workspace name="ws">
+ <!-- for system storage -->
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr28" />
+ <property name="dialect" value="hsqldb" />
+ <property name="multi-db" value="false" />
+ <property name="update-storage" value="true" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="target/temp/swap/db8_ws" />
+ </properties>
+ <value-storages>
+ <value-storage id="draft" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="../temp/values/db8_ws" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <cache enabled="true">
+ <properties>
+ <property name="max-size" value="5k" />
+ <property name="live-time" value="1h" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/index/db8_ws" />
+ </properties>
+ </query-handler>
+ </workspace>
+ <workspace name="ws1">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr28" />
+ <property name="dialect" value="hsqldb" />
+ <property name="multi-db" value="false" />
+ <property name="update-storage" value="true" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="target/temp/swap/db8_ws1" />
+ </properties>
+ <value-storages>
+ <value-storage id="draft" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="../temp/values/db8_ws1" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <cache enabled="true">
+ <properties>
+ <property name="max-size" value="5k" />
+ <property name="live-time" value="1h" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/index/db8_ws1" />
+ </properties>
+ </query-handler>
+ </workspace>
+ </workspaces>
+ </repository>
+
+
</repositories>
</repository-service>
15 years, 8 months
exo-jcr SVN: r3534 - kernel/trunk/exo.kernel.component.common.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-11-24 08:06:01 -0500 (Wed, 24 Nov 2010)
New Revision: 3534
Modified:
kernel/trunk/exo.kernel.component.common/pom.xml
Log:
EXOJCR-1054 : porting ISPN code of Kernel project. Attention: RPCService test added to excludes, since int fails with newer JGroups.
Modified: kernel/trunk/exo.kernel.component.common/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.common/pom.xml 2010-11-24 13:04:21 UTC (rev 3533)
+++ kernel/trunk/exo.kernel.component.common/pom.xml 2010-11-24 13:06:01 UTC (rev 3534)
@@ -98,7 +98,7 @@
<artifactId>jta</artifactId>
</dependency>
<dependency>
- <groupId>jgroups</groupId>
+ <groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
</dependency>
</dependencies>
@@ -128,6 +128,7 @@
</systemProperties>
<excludes>
<exclude>**/TransactionTest.java</exclude>
+ <exclude>**/TestRPCServiceImpl.java</exclude>
</excludes>
</configuration>
</plugin>
15 years, 8 months
exo-jcr SVN: r3533 - in kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4: src and 11 other directories.
by do-not-reply@jboss.org
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@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@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@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@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>
15 years, 8 months
exo-jcr SVN: r3532 - in kernel/trunk: exo.kernel.component.ext.cache.impl.infinispan.v4 and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-11-24 08:02:22 -0500 (Wed, 24 Nov 2010)
New Revision: 3532
Added:
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/
kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/pom.xml
Modified:
kernel/trunk/pom.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/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/pom.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/pom.xml 2010-11-24 13:02:22 UTC (rev 3532)
@@ -0,0 +1,80 @@
+
+ <!--
+
+ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>kernel-parent</artifactId>
+ <version>2.3-ISPN-SNAPSHOT</version>
+ </parent>
+ <artifactId>exo.kernel.component.ext.cache.impl.infinispan.v4</artifactId>
+ <name>eXo Kernel :: Cache Extension :: Infinispan Implementation</name>
+ <description>Infinispan Implementation for the Cache Service</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.cache</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <!--
+ We add this system property due to some incompatibility between
+ IPv6 and some JVM of Linux distributions such as Ubuntu and
+ Fedora
+ -->
+ <property>
+ <name>java.net.preferIPv4Stack</name>
+ <value>true</value>
+ </property>
+ <!-- Avoid the firewall -->
+ <property>
+ <name>bind.address</name>
+ <value>127.0.0.1</value>
+ </property>
+ <property>
+ <name>jgroups.stack</name>
+ <value>udp</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Modified: kernel/trunk/pom.xml
===================================================================
--- kernel/trunk/pom.xml 2010-11-24 11:03:28 UTC (rev 3531)
+++ kernel/trunk/pom.xml 2010-11-24 13:02:22 UTC (rev 3532)
@@ -55,6 +55,7 @@
<module>exo.kernel.component.common</module>
<module>exo.kernel.component.cache</module>
<module>exo.kernel.component.ext.cache.impl.jboss.v3</module>
+ <module>exo.kernel.component.ext.cache.impl.infinispan.v4</module>
<module>exo.kernel.component.command</module>
<module>exo.kernel.mc-integration</module>
<module>packaging/module</module>
@@ -178,9 +179,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>jgroups</groupId>
+ <groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.6.13.GA</version>
+ <version>2.10.0.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.cache</groupId>
@@ -188,6 +189,11 @@
<version>3.2.6.GA</version>
</dependency>
<dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-core</artifactId>
+ <version>4.1.0.FINAL</version>
+ </dependency>
+ <dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-bind</artifactId>
<version>${version.jibx.plugin}</version>
15 years, 8 months
exo-jcr SVN: r3531 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-11-24 06:03:28 -0500 (Wed, 24 Nov 2010)
New Revision: 3531
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
Log:
EXOJCR-929: RepositoryCreationServiceImpl RPC support added
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2010-11-24 09:56:16 UTC (rev 3530)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2010-11-24 11:03:28 UTC (rev 3531)
@@ -27,15 +27,29 @@
import org.exoplatform.services.jcr.ext.backup.BackupManager;
import org.exoplatform.services.jcr.ext.backup.BackupOperationException;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.naming.InitialContextInitializer;
+import org.exoplatform.services.rpc.RPCException;
import org.exoplatform.services.rpc.RPCService;
+import org.exoplatform.services.rpc.RemoteCommand;
+import org.exoplatform.ws.frameworks.json.JsonHandler;
+import org.exoplatform.ws.frameworks.json.JsonParser;
+import org.exoplatform.ws.frameworks.json.impl.BeanBuilder;
+import org.exoplatform.ws.frameworks.json.impl.JsonDefaultHandler;
+import org.exoplatform.ws.frameworks.json.impl.JsonException;
+import org.exoplatform.ws.frameworks.json.impl.JsonGeneratorImpl;
+import org.exoplatform.ws.frameworks.json.impl.JsonParserImpl;
+import org.exoplatform.ws.frameworks.json.value.JsonValue;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -64,20 +78,36 @@
private final RepositoryService repositoryService;
/**
- * The RPC Service used to communicate with other nodes
+ * The RPC Service used to communicate with other nodes.
*/
private final RPCService rpcService;
+ /**
+ * BackupManager used to restore repository from backup.
+ */
private final BackupManager backupManager;
+ /**
+ * DBCreator used to create database. Only database not tables, indexes, etc.
+ */
private final DBCreator dbCreator;
+ /**
+ * InitalContextInitalizer used to bind new datasource.
+ */
private final InitialContextInitializer initialContextInitializer;
+ /**
+ * Store of reserved repository names.
+ */
private final Set<String> pendingRepositories = new ConcurrentHashSet<String>();
- private final Set<String> namesUnderNegotiation = new ConcurrentHashSet<String>();
+ private RemoteCommand reserveRepositoryName;
+ private RemoteCommand createRepository;
+
+ private RemoteCommand startRepository;
+
public RepositoryCreationServiceImpl(RepositoryService repositoryService, BackupManager backupManager,
DBCreator dbCreator, InitialContextInitializer initialContextInitializer, final RPCService rpcService)
{
@@ -86,6 +116,121 @@
this.rpcService = rpcService;
this.dbCreator = dbCreator;
this.initialContextInitializer = initialContextInitializer;
+
+ if (rpcService == null)
+ {
+ LOG.warn("RepositoryCreationService initialized with null RPCService, so other cluser nodes will"
+ + " not be notified about new repositories.");
+ }
+ else
+ {
+ // register commands
+ reserveRepositoryName = rpcService.registerCommand(new RemoteCommand()
+ {
+
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-reserveRepositoryName";
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ System.out.println("EXECUTED reserveRepositoryName");
+
+ String repositoryName = (String)args[0];
+ if (!pendingRepositories.contains(repositoryName))
+ {
+ pendingRepositories.add(repositoryName);
+ }
+ else
+ {
+ throw new RepositoryCreationException("Repository name " + repositoryName + " already reserved.");
+ }
+ return repositoryName;
+ }
+ });
+ createRepository = rpcService.registerCommand(new RemoteCommand()
+ {
+
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-createRepository";
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ System.out.println("EXECUTED createRepository");
+ //String backupId, RepositoryEntry rEntry, String rToken
+ String backupId = (String)args[0];
+ String stringRepositoryEntry = (String)args[1];
+ String rToken = (String)args[2];
+
+ try
+ {
+ RepositoryEntry rEntry =
+ (RepositoryEntry)(getObject(RepositoryEntry.class, stringRepositoryEntry
+ .getBytes(Constants.DEFAULT_ENCODING)));
+
+ createRepo(backupId, rEntry, rToken);
+
+ // execute startRepository at all cluster nodes (coordinator will ignore this command)
+ try
+ {
+ rpcService.executeCommandOnAllNodes(startRepository, false, stringRepositoryEntry);
+ }
+ catch (RPCException e)
+ {
+ Throwable cause = e.getCause();
+ if (cause instanceof RepositoryCreationException)
+ {
+ throw new RepositoryCreationException(
+ "Repository " + rEntry.getName()
+ + " created on coordinator, can not be started at other cluster node: "
+ + cause.getMessage(), cause);
+ }
+ else
+ {
+ throw new RepositoryCreationException("Repository " + rEntry.getName()
+ + " created on coordinator, can not be started at other cluster node: " + e.getMessage(), e);
+ }
+ }
+ return null;
+ }
+ finally
+ {
+ // release tokens
+ pendingRepositories.remove(rToken);
+ }
+ }
+ });
+
+ startRepository = rpcService.registerCommand(new RemoteCommand()
+ {
+
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-startRepository";
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ System.out.println("EXECUTED startRepository");
+ // must not be executed on coordinator node, since coordinator node already created the repository
+ if (!rpcService.isCoordinator())
+ {
+ //RepositoryEntry (as String) rEntry
+ String stringRepositoryEntry = (String)args[0];
+ RepositoryEntry rEntry =
+ (RepositoryEntry)(getObject(RepositoryEntry.class, stringRepositoryEntry
+ .getBytes(Constants.DEFAULT_ENCODING)));
+
+ startRepository(rEntry);
+ }
+ return null;
+ }
+ });
+ }
+
}
/**
@@ -94,23 +239,126 @@
public void createRepository(String backupId, RepositoryEntry rEntry) throws RepositoryConfigurationException,
RepositoryCreationException
{
- reserveRepositoryName(rEntry.getName());
- // 1. check possibility to create repository locally
- // - check existing, pending repository and datasources with same names
+ String rToken = reserveRepositoryName(rEntry.getName());
+ createRepository(backupId, rEntry, rToken);
+ }
- // 2. reserve name and put additional information (ex. ip and port of current machine)
- // 3. check possibility to create repository on others nodes
- // - sending to all cluster nodes information about new repository and waiting for answers
- // - all cluster nodes receive information and check possibility to create repository locally
- // - send response
- // 4. reserve name on all nodes of cluster
+ /**
+ * {@inheritDoc}
+ */
+ public void createRepository(String backupId, RepositoryEntry rEntry, String rToken)
+ throws RepositoryConfigurationException, RepositoryCreationException
+ {
+ if (rpcService != null)
+ {
+ //TODO is is correct to use Json code here
+ String stringRepositoryEntry = null;
+ try
+ {
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json = generatorImpl.createJsonObject(rEntry);
+ stringRepositoryEntry = json.toString();
+ }
+ catch (JsonException e)
+ {
+ throw new RepositoryCreationException("Can not serialize repository entry: " + e.getMessage(), e);
+ }
+
+ try
+ {
+ Object result =
+ rpcService.executeCommandOnCoordinator(createRepository, true, backupId, stringRepositoryEntry, rToken);
+
+ if (result != null)
+ {
+ throw new RepositoryCreationException("ReserveRepositoryName command returns unknown command.");
+ }
+ }
+ catch (RPCException e)
+ {
+ Throwable cause = ((RPCException)e).getCause();
+ if (cause instanceof RepositoryCreationException)
+ {
+ throw (RepositoryCreationException)cause;
+ }
+ else if (cause instanceof RepositoryConfigurationException)
+ {
+ throw (RepositoryConfigurationException)cause;
+ }
+ else
+ {
+ throw new RepositoryCreationException(e.getMessage(), e);
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ createRepo(backupId, rEntry, rToken);
+ }
+ finally
+ {
+ pendingRepositories.remove(rEntry);
+ }
+ }
}
/**
* {@inheritDoc}
*/
- public void createRepository(String backupId, RepositoryEntry rEntry, String rToken)
+ public String reserveRepositoryName(String repositoryName) throws RepositoryCreationException
+ {
+
+ // check possibility to create repository locally
+ //check does repository already created
+ for (int i = 0; i < repositoryService.getConfig().getRepositoryConfigurations().size(); i++)
+ {
+ RepositoryEntry conf = repositoryService.getConfig().getRepositoryConfigurations().get(i);
+ if (conf.getName().equals(repositoryName))
+ {
+ throw new RepositoryCreationException("Repository " + repositoryName + " already exists.");
+ }
+ }
+
+ if (rpcService != null)
+ {
+ //ask other nodes does they have pending repositories
+ try
+ {
+ Object result = rpcService.executeCommandOnCoordinator(reserveRepositoryName, true, repositoryName);
+
+ if (result instanceof String)
+ {
+ return (String)result;
+ }
+ else
+ {
+ throw new RepositoryCreationException("ReserveRepositoryName command returns unknown type result.");
+ }
+ }
+ catch (RPCException e)
+ {
+ Throwable cause = ((RPCException)e).getCause();
+ if (cause instanceof RepositoryCreationException)
+ {
+ throw (RepositoryCreationException)cause;
+ }
+ else
+ {
+ throw new RepositoryCreationException(e.getMessage(), e);
+ }
+ }
+ }
+ else
+ {
+ pendingRepositories.add(repositoryName);
+ return repositoryName;
+ }
+ }
+
+ protected void createRepo(String backupId, RepositoryEntry rEntry, String rToken)
throws RepositoryConfigurationException, RepositoryCreationException
{
// check does token registered
@@ -232,66 +480,48 @@
throw new RepositoryCreationException("Backup log file by id " + backupId
+ (backLog != null ? (" and file path=" + backLog.getAbsolutePath()) : "") + " do not exists.");
}
- //TODO execute "clone repository" on other cluster nodes
- // release tokens
}
- /**
- * {@inheritDoc}
- */
- public String reserveRepositoryName(String repositoryName) throws RepositoryCreationException
+ protected void startRepository(RepositoryEntry repositoryEntry) throws RepositoryCreationException
{
- // 1. check possibility to create repository locally
- // - check existing, pending repository and datasources with same names
+ //TODO do we need bind datasource here?
- for (int i = 0; i < repositoryService.getConfig().getRepositoryConfigurations().size(); i++)
+ try
{
- RepositoryEntry conf = repositoryService.getConfig().getRepositoryConfigurations().get(i);
- if (conf.getName().equals(repositoryName))
- {
- throw new RepositoryCreationException("Repository " + repositoryName + " already exists.");
- }
-
+ repositoryService.createRepository(repositoryEntry);
}
-
- // try
- // {
- // ManageableRepository repo = repositoryService.getRepository(repositoryName);
- // if (repo != null)
- // {
- // throw new RepositoryCreationException("Repository " + repositoryName + " already exists.");
- // }
- // }
- // catch (RepositoryException e)
- // {
- // throw new RepositoryCreationException(e.getMessage(), e);
- // }
- // catch (RepositoryConfigurationException e)
- // {
- // throw new RepositoryCreationException(e.getMessage(), e);
- // }
-
- if (namesUnderNegotiation.contains(repositoryName) || pendingRepositories.contains(repositoryName))
+ catch (RepositoryConfigurationException e)
{
- throw new RepositoryCreationException("Repository name " + repositoryName + " already reserved.");
+ throw new RepositoryCreationException("Repository created but can not be started on this node: "
+ + e.getLocalizedMessage(), e);
}
+ catch (RepositoryException e)
+ {
+ throw new RepositoryCreationException("Repository created but can not be started on this node: "
+ + e.getLocalizedMessage(), e);
+ }
+ }
- // 2. reserve name and put additional information (ex. ip and port of current machine)
- namesUnderNegotiation.add(repositoryName);
+ /**
+ * TODO make another serialization scheme or move it to dedicated object
+ * Will be created the Object from JSON binary data.
+ *
+ * @param cl
+ * Class
+ * @param data
+ * binary data (JSON)
+ * @return Object
+ * @throws Exception
+ * will be generated Exception
+ */
+ private Object getObject(Class cl, byte[] data) throws Exception
+ {
+ JsonHandler jsonHandler = new JsonDefaultHandler();
+ JsonParser jsonParser = new JsonParserImpl();
+ InputStream inputStream = new ByteArrayInputStream(data);
+ jsonParser.parse(inputStream, jsonHandler);
+ JsonValue jsonValue = jsonHandler.getJsonObject();
- // TODO ask other nodes does thay have pending repositories
-
- pendingRepositories.add(repositoryName);
- namesUnderNegotiation.remove(repositoryName);
- // TODO register repositoryName on other nodes
-
- // 3. check possibility to create repository on others nodes
- // - sending to all cluster nodes information about new repository and waiting for answers
- // - all cluster nodes receive information and check possibility to create repository locally
- // - send response
- // 4. reserve name on all nodes of cluster
-
- return repositoryName;
+ return new BeanBuilder().createObject(cl, jsonValue);
}
-
}
15 years, 8 months
exo-jcr SVN: r3530 - jcr/trunk/exo.jcr.framework.command/src/main/resources/conf.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 04:56:16 -0500 (Wed, 24 Nov 2010)
New Revision: 3530
Removed:
jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/standalone/
jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands.xml
jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands2.xml
jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands3.xml
Log:
EXOJCR-1071: Move JCR framework commands list configuration to it right place
Deleted: jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands.xml
===================================================================
--- jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands.xml 2010-11-24 09:51:56 UTC (rev 3529)
+++ jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands.xml 2010-11-24 09:56:16 UTC (rev 3530)
@@ -1,32 +0,0 @@
-<!--
-
- 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.
-
--->
-<catalog>
-
- <!-- Single command "chains" from CatalogBaseTestCase -->
- <command name="Command1" className="org.exoplatform.services.command.TestCommand1" />
-
- <!-- Chains with nested commands -->
- <chain name="Execute2">
- <command id="1" className="org.exoplatform.services.command.TestCommand1" />
- <command id="2" className="org.exoplatform.services.command.TestCommand1" />
- </chain>
-
-</catalog>
Deleted: jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands2.xml
===================================================================
--- jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands2.xml 2010-11-24 09:51:56 UTC (rev 3529)
+++ jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands2.xml 2010-11-24 09:56:16 UTC (rev 3530)
@@ -1,28 +0,0 @@
-<!--
-
- 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.
-
--->
-<catalog>
-
- <!-- Single command "chains" from CatalogBaseTestCase -->
- <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
-
- <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
-
-</catalog>
Deleted: jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands3.xml
===================================================================
--- jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands3.xml 2010-11-24 09:51:56 UTC (rev 3529)
+++ jcr/trunk/exo.jcr.framework.command/src/main/resources/conf/test-commands3.xml 2010-11-24 09:56:16 UTC (rev 3530)
@@ -1,28 +0,0 @@
-<!--
-
- 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.
-
--->
-<catalog name="catalog1">
-
- <!-- Single command "chains" from CatalogBaseTestCase -->
- <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
-
- <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
-
-</catalog>
15 years, 8 months
exo-jcr SVN: r3529 - in kernel/trunk/exo.kernel.component.command/src: test/resources and 2 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 04:51:56 -0500 (Wed, 24 Nov 2010)
New Revision: 3529
Added:
kernel/trunk/exo.kernel.component.command/src/test/resources/conf/
kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/
kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/test-configuration.xml
kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/test-multi-configuration.xml
kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands.xml
kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands2.xml
kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands3.xml
Removed:
kernel/trunk/exo.kernel.component.command/src/main/resources/conf/standalone/
Log:
EXOJCR-1071: Move JCR framework commands list configuration to it right place
Added: kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/test-configuration.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/test-configuration.xml 2010-11-24 09:51:56 UTC (rev 3529)
@@ -0,0 +1,46 @@
+<?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>
+
+ <component>
+ <key>org.exoplatform.services.command.impl.CommandService</key>
+ <type>org.exoplatform.services.command.impl.CommandService</type>
+ <component-plugins>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+ <component>
+ <type>org.exoplatform.services.command.action.ActionService</type>
+ </component>
+
+</configuration>
Added: kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/test-multi-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/test-multi-configuration.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.command/src/test/resources/conf/standalone/test-multi-configuration.xml 2010-11-24 09:51:56 UTC (rev 3529)
@@ -0,0 +1,64 @@
+<?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>
+
+ <component>
+ <key>org.exoplatform.services.command.impl.CommandService</key>
+ <type>org.exoplatform.services.command.impl.CommandService</type>
+ <component-plugins>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands2.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands3.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+</configuration>
Added: kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands.xml
===================================================================
--- kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands.xml 2010-11-24 09:51:56 UTC (rev 3529)
@@ -0,0 +1,32 @@
+<!--
+
+ 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.
+
+-->
+<catalog>
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command1" className="org.exoplatform.services.command.TestCommand1" />
+
+ <!-- Chains with nested commands -->
+ <chain name="Execute2">
+ <command id="1" className="org.exoplatform.services.command.TestCommand1" />
+ <command id="2" className="org.exoplatform.services.command.TestCommand1" />
+ </chain>
+
+</catalog>
Added: kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands2.xml
===================================================================
--- kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands2.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands2.xml 2010-11-24 09:51:56 UTC (rev 3529)
@@ -0,0 +1,28 @@
+<!--
+
+ 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.
+
+-->
+<catalog>
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
+
+ <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
+
+</catalog>
Added: kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands3.xml
===================================================================
--- kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands3.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.command/src/test/resources/conf/test-commands3.xml 2010-11-24 09:51:56 UTC (rev 3529)
@@ -0,0 +1,28 @@
+<!--
+
+ 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.
+
+-->
+<catalog name="catalog1">
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
+
+ <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
+
+</catalog>
15 years, 8 months