[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Wed Sep 13 09:11:18 EDT 2006
User: msurtani
Date: 06/09/13 09:11:18
Modified: src/org/jboss/cache CacheSPI.java TreeCacheProxyImpl.java
Log:
added code + unit tests for manipulating interceptor chain via CacheSPI
Revision Changes Path
1.15 +19 -0 JBossCache/src/org/jboss/cache/CacheSPI.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheSPI.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheSPI.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- CacheSPI.java 11 Sep 2006 17:02:43 -0000 1.14
+++ CacheSPI.java 13 Sep 2006 13:11:18 -0000 1.15
@@ -36,6 +36,25 @@
List<Interceptor> getInterceptorChain();
/**
+ * Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain
+ * is at position 0 and the last one at getInterceptorChain().size() - 1.
+ *
+ * @param i
+ * @param position
+ */
+ void addInterceptor(Interceptor i, int position);
+
+
+ /**
+ * Removes the interceptor at a specified position, where the first interceptor in the chain
+ * is at position 0 and the last one at getInterceptorChain().size() - 1.
+ *
+ * @param position
+ */
+ void removeInterceptor(int position);
+
+
+ /**
* Retrieves the configured {@link CacheLoader}. If more than one {@link CacheLoader} is configured, this method
* returns an instance of {@link org.jboss.cache.loader.ChainingCacheLoader}.
*
1.31 +23 -1 JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheProxyImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- TreeCacheProxyImpl.java 12 Sep 2006 13:12:51 -0000 1.30
+++ TreeCacheProxyImpl.java 13 Sep 2006 13:11:18 -0000 1.31
@@ -10,6 +10,7 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.eviction.RegionManager;
+import org.jboss.cache.factories.InterceptorChainFactory;
import org.jboss.cache.interceptors.Interceptor;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
@@ -54,7 +55,28 @@
public List<Interceptor> getInterceptorChain()
{
- return treeCache.getInterceptors();
+ return Collections.unmodifiableList(treeCache.getInterceptors());
+ }
+
+ public synchronized void addInterceptor(Interceptor i, int position)
+ {
+ List<Interceptor> interceptors = treeCache.getInterceptors();
+
+ i.setCache(treeCache.getCacheSPI());
+
+ interceptors.add(position, i);
+
+ // now correct the chaining of interceptors...
+ Interceptor linkedChain = InterceptorChainFactory.correctInterceptorChaining(interceptors);
+
+ treeCache.setInterceptorChain(linkedChain);
+ }
+
+ public synchronized void removeInterceptor(int position)
+ {
+ List<Interceptor> i = treeCache.getInterceptors();
+ i.remove(position);
+ treeCache.setInterceptorChain(InterceptorChainFactory.correctInterceptorChaining(i));
}
public CacheLoader getCacheLoader()
More information about the jboss-cvs-commits
mailing list