[jboss-cvs] JBossCache/src/org/jboss/cache/factories ...
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/factories InterceptorChainFactory.java
Log:
added code + unit tests for manipulating interceptor chain via CacheSPI
Revision Changes Path
1.30 +33 -9 JBossCache/src/org/jboss/cache/factories/InterceptorChainFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InterceptorChainFactory.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/factories/InterceptorChainFactory.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- InterceptorChainFactory.java 6 Sep 2006 15:30:55 -0000 1.29
+++ InterceptorChainFactory.java 13 Sep 2006 13:11:18 -0000 1.30
@@ -29,21 +29,18 @@
{
if (cache.getConfiguration().isNodeLockingOptimistic())
{
- return setLastInterceptorPointer(createOptimisticInterceptorChain(cache));
+ return createOptimisticInterceptorChain(cache);
}
else
{
- return setLastInterceptorPointer(createPessimisticInterceptorChain(cache));
+ return createPessimisticInterceptorChain(cache);
}
}
- private Interceptor setLastInterceptorPointer(Interceptor first)
+ public static Interceptor setLastInterceptorPointer(Interceptor first, Interceptor last)
{
Interceptor i = first;
- while (i.getNext() != null) i = i.getNext();
- Interceptor last = i;
- i = first;
- while (i.getNext() != null)
+ while (i != null)
{
i.setLast(last);
i = i.getNext();
@@ -408,7 +405,7 @@
log.info("interceptor chain is:\n" + printInterceptorChain(first));
}
- return first;
+ return setLastInterceptorPointer(first, call_interceptor);
}
private Interceptor createOptimisticInterceptorChain(TreeCache treeCache) throws IllegalAccessException, InstantiationException, ClassNotFoundException
@@ -657,7 +654,7 @@
log.info("interceptor chain is:\n" + printInterceptorChain(first));
}
- return first;
+ return setLastInterceptorPointer(first, invokerInterceptor);
}
public static String printInterceptorChain(Interceptor i)
@@ -697,4 +694,31 @@
while (tmp != null);
return retval;
}
+
+ /**
+ * "Fixes" the next() and last() pointers for each interceptor, based on the order presented in the list passed in
+ *
+ * @param interceptors
+ * @return the first interceptor in the chain.
+ */
+ public static Interceptor correctInterceptorChaining(List<Interceptor> interceptors)
+ {
+ Interceptor first = null, last = null;
+
+ for (Interceptor next : interceptors)
+ {
+ if (first == null)
+ {
+ first = last = next;
+ continue;
+ }
+ last.setNext(next);
+ last = next;
+ }
+
+ if (last != null) last.setNext(null);
+
+ // now set the 'last' pointer.
+ return setLastInterceptorPointer(first, last);
+ }
}
More information about the jboss-cvs-commits
mailing list