[infinispan-commits] Infinispan SVN: r107 - trunk/core/src/main/java/org/infinispan.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Apr 13 08:23:10 EDT 2009
Author: mircea.markus
Date: 2009-04-13 08:23:10 -0400 (Mon, 13 Apr 2009)
New Revision: 107
Added:
trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java
trunk/core/src/main/java/org/infinispan/AbstractDelegatingCache.java
Log:
[ISPN-33] - Add an abstract delegating Cache implementation
Added: trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java (rev 0)
+++ trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java 2009-04-13 12:23:10 UTC (rev 107)
@@ -0,0 +1,126 @@
+package org.infinispan;
+
+import org.infinispan.batch.BatchContainer;
+import org.infinispan.container.DataContainer;
+import org.infinispan.eviction.EvictionManager;
+import org.infinispan.factories.ComponentRegistry;
+import org.infinispan.interceptors.base.CommandInterceptor;
+import org.infinispan.invocation.Flag;
+import org.infinispan.invocation.InvocationContextContainer;
+import org.infinispan.remoting.RpcManager;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Similar to {@link org.infinispan.AbstractDelegatingCache}, but for {@link AdvancedCache}.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @see org.infinispan.AbstractDelegatingCache
+ */
+public class AbstractDelegatingAdvancedCache<K, V> extends AbstractDelegatingCache<K, V> implements AdvancedCache<K, V> {
+
+ private AdvancedCache<K, V> cache;
+
+ public AbstractDelegatingAdvancedCache(AdvancedCache<K, V> cache) {
+ super(cache);
+ this.cache = cache;
+ }
+
+ public void addInterceptor(CommandInterceptor i, int position) {
+ cache.addInterceptor(i, position);
+ }
+
+ public void addInterceptorAfter(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor) {
+ cache.addInterceptorAfter(i, afterInterceptor);
+ }
+
+ public void addInterceptorBefore(CommandInterceptor i, Class<? extends CommandInterceptor> beforeInterceptor) {
+ cache.addInterceptorBefore(i, beforeInterceptor);
+ }
+
+ public void removeInterceptor(int position) {
+ cache.removeInterceptor(position);
+ }
+
+ public void removeInterceptor(Class<? extends CommandInterceptor> interceptorType) {
+ cache.removeInterceptor(interceptorType);
+ }
+
+ public List<CommandInterceptor> getInterceptorChain() {
+ return cache.getInterceptorChain();
+ }
+
+ public EvictionManager getEvictionManager() {
+ return cache.getEvictionManager();
+ }
+
+ public ComponentRegistry getComponentRegistry() {
+ return cache.getComponentRegistry();
+ }
+
+ public RpcManager getRpcManager() {
+ return cache.getRpcManager();
+ }
+
+ public BatchContainer getBatchContainer() {
+ return cache.getBatchContainer();
+ }
+
+ public InvocationContextContainer getInvocationContextContainer() {
+ return cache.getInvocationContextContainer();
+ }
+
+ public DataContainer getDataContainer() {
+ return cache.getDataContainer();
+ }
+
+ public void putForExternalRead(K key, V value, Flag... flags) {
+ cache.putForExternalRead(key, value, flags);
+ }
+
+ public V put(K key, V value, Flag... flags) {
+ return cache.put(key, value, flags);
+ }
+
+ public V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ return cache.put(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit, flags);
+ }
+
+ public V putIfAbsent(K key, V value, Flag... flags) {
+ return cache.putIfAbsent(key, value, flags);
+ }
+
+ public V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ return cache.putIfAbsent(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit, flags);
+ }
+
+ public void putAll(Map<? extends K, ? extends V> map, Flag... flags) {
+ cache.putAll(map, flags);
+ }
+
+ public void putAll(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ cache.putAll(map, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit, flags);
+ }
+
+ public V remove(Object key, Flag... flags) {
+ return cache.remove(key, flags);
+ }
+
+ public boolean remove(Object key, Object oldValue, Flag... flags) {
+ return cache.remove(key, oldValue, flags);
+ }
+
+ public void clear(Flag... flags) {
+ cache.clear(flags);
+ }
+
+ public boolean containsKey(Object key, Flag... flags) {
+ return cache.containsKey(key, flags);
+ }
+
+ public V get(Object key, Flag... flags) {
+ return cache.get(key, flags);
+ }
+}
Property changes on: trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/core/src/main/java/org/infinispan/AbstractDelegatingCache.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/AbstractDelegatingCache.java (rev 0)
+++ trunk/core/src/main/java/org/infinispan/AbstractDelegatingCache.java 2009-04-13 12:23:10 UTC (rev 107)
@@ -0,0 +1,196 @@
+package org.infinispan;
+
+import org.infinispan.config.Configuration;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.manager.CacheManager;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * This is a convenient base class for implementing a cache delegate. The only constructor takes a {@link Cache} argument, to
+ * which each method call is delegated. One can extend this class and override the method sub-set it is interested in.
+ * There is also an similar implmentation for {@link org.infinispan.AdvancedCache}:
+ * {@link org.infinispan.AbstractDelegatingAdvancedCache}.
+ *
+ * @see org.infinispan.AbstractDelegatingAdvancedCache
+ * @author Mircea.Markus at jboss.com
+ */
+public abstract class AbstractDelegatingCache<K, V> implements Cache<K, V> {
+
+ private Cache<K, V> cache;
+
+ public AbstractDelegatingCache(Cache<K, V> cache) {
+ this.cache = cache;
+ }
+
+ public void putForExternalRead(K key, V value) {
+ cache.putForExternalRead(key, value);
+ }
+
+ public void evict(K key) {
+ cache.evict(key);
+ }
+
+ public Configuration getConfiguration() {
+ return cache.getConfiguration();
+ }
+
+ public boolean startBatch() {
+ return cache.startBatch();
+ }
+
+ public void endBatch(boolean successful) {
+ cache.endBatch(successful);
+ }
+
+ public String getName() {
+ return cache.getName();
+ }
+
+ public String getVersion() {
+ return cache.getVersion();
+ }
+
+ public CacheManager getCacheManager() {
+ return cache.getCacheManager();
+ }
+
+ public V put(K key, V value, long lifespan, TimeUnit unit) {
+ return cache.put(key, value, lifespan, unit);
+ }
+
+ public V putIfAbsent(K key, V value, long lifespan, TimeUnit unit) {
+ return cache.putIfAbsent(key, value, lifespan, unit);
+ }
+
+ public void putAll(Map<? extends K, ? extends V> map, long lifespan, TimeUnit unit) {
+ cache.putAll(map, lifespan, unit);
+ }
+
+ public V replace(K key, V value, long lifespan, TimeUnit unit) {
+ return cache.replace(key, value, lifespan, unit);
+ }
+
+ public boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit unit) {
+ return cache.replace(key, oldValue, value, lifespan, unit);
+ }
+
+ public V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) {
+ return cache.put(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+ }
+
+ public V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) {
+ return cache.putIfAbsent(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+ }
+
+ public void putAll(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) {
+ cache.putAll(map, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+ }
+
+ public V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) {
+ return cache.replace(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+ }
+
+ public boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) {
+ return cache.replace(key, oldValue, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit);
+ }
+
+ public AdvancedCache<K, V> getAdvancedCache() {
+ return cache.getAdvancedCache();
+ }
+
+ public void compact() {
+ cache.compact();
+ }
+
+ public ComponentStatus getStatus() {
+ return cache.getStatus();
+ }
+
+ public V putIfAbsent(K key, V value) {
+ return cache.putIfAbsent(key, value);
+ }
+
+ public boolean remove(Object key, Object value) {
+ return cache.remove(key, value);
+ }
+
+ public boolean replace(K key, V oldValue, V newValue) {
+ return cache.replace(key, oldValue, newValue);
+ }
+
+ public V replace(K key, V value) {
+ return cache.replace(key, value);
+ }
+
+ public int size() {
+ return cache.size();
+ }
+
+ public boolean isEmpty() {
+ return cache.isEmpty();
+ }
+
+ public boolean containsKey(Object key) {
+ return cache.containsKey(key);
+ }
+
+ public boolean containsValue(Object value) {
+ return cache.containsValue(value);
+ }
+
+ public V get(Object key) {
+ return cache.get(key);
+ }
+
+ public V put(K key, V value) {
+ return cache.put(key, value);
+ }
+
+ public V remove(Object key) {
+ return cache.remove(key);
+ }
+
+ public void putAll(Map<? extends K, ? extends V> t) {
+ cache.putAll(t);
+ }
+
+ public void clear() {
+ cache.clear();
+ }
+
+ public Set<K> keySet() {
+ return cache.keySet();
+ }
+
+ public Set<Entry<K, V>> entrySet() {
+ return cache.entrySet();
+ }
+
+ public Collection<V> values() {
+ return cache.values();
+ }
+
+ public void start() {
+ cache.start();
+ }
+
+ public void stop() {
+ cache.stop();
+ }
+
+ public void addListener(Object listener) {
+ cache.addListener(listener);
+ }
+
+ public void removeListener(Object listener) {
+ cache.removeListener(listener);
+ }
+
+ public Set<Object> getListeners() {
+ return cache.getListeners();
+ }
+}
Property changes on: trunk/core/src/main/java/org/infinispan/AbstractDelegatingCache.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the infinispan-commits
mailing list