[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo/collection ...
Ben Wang
bwang at jboss.com
Wed Aug 2 11:40:25 EDT 2006
User: bwang
Date: 06/08/02 11:40:25
Modified: src-50/org/jboss/cache/pojo/collection
CachedListAbstract.java CachedListImpl.java
CachedMapImpl.java CachedSetImpl.java
CollectionInterceptorUtil.java
Log:
Added interceptor to check for recursive Collection toString
Revision Changes Path
1.4 +3 -1 JBossCache/src-50/org/jboss/cache/pojo/collection/CachedListAbstract.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CachedListAbstract.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedListAbstract.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- CachedListAbstract.java 27 Jun 2006 05:25:42 -0000 1.3
+++ CachedListAbstract.java 2 Aug 2006 15:40:24 -0000 1.4
@@ -6,6 +6,8 @@
*/
package org.jboss.cache.pojo.collection;
+import org.jboss.cache.pojo.annotation.Reentrant;
+
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -16,7 +18,7 @@
* @author Scott Marlow
*/
- at SuppressWarnings({"CanBeFinal"})
+ at Reentrant
abstract class CachedListAbstract implements List
{
public void clear()
1.8 +0 -2 JBossCache/src-50/org/jboss/cache/pojo/collection/CachedListImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CachedListImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedListImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- CachedListImpl.java 27 Jul 2006 14:25:26 -0000 1.7
+++ CachedListImpl.java 2 Aug 2006 15:40:24 -0000 1.8
@@ -27,8 +27,6 @@
* @author Ben Wang
* @author Scott Marlow
*/
-
- at SuppressWarnings({"CanBeFinal"})
public class CachedListImpl extends CachedListAbstract implements List
{
1.11 +2 -1 JBossCache/src-50/org/jboss/cache/pojo/collection/CachedMapImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CachedMapImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedMapImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- CachedMapImpl.java 2 Aug 2006 04:20:30 -0000 1.10
+++ CachedMapImpl.java 2 Aug 2006 15:40:24 -0000 1.11
@@ -11,6 +11,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.pojo.util.Null;
import org.jboss.cache.pojo.PojoTreeCache;
+import org.jboss.cache.pojo.annotation.Reentrant;
import org.jboss.cache.pojo.impl.PojoCacheImpl;
import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
import org.jboss.aop.Advised;
@@ -32,7 +33,7 @@
* @author Ben Wang
* @author Scott Marlow
*/
- at SuppressWarnings({"CanBeFinal"})
+ at Reentrant
public class CachedMapImpl implements Map
{
1.7 +2 -1 JBossCache/src-50/org/jboss/cache/pojo/collection/CachedSetImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CachedSetImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CachedSetImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- CachedSetImpl.java 27 Jul 2006 14:25:26 -0000 1.6
+++ CachedSetImpl.java 2 Aug 2006 15:40:24 -0000 1.7
@@ -12,6 +12,7 @@
import org.jboss.cache.pojo.util.AopUtil;
import org.jboss.cache.pojo.util.Null;
import org.jboss.cache.pojo.PojoTreeCache;
+import org.jboss.cache.pojo.annotation.Reentrant;
import org.jboss.cache.pojo.impl.PojoCacheImpl;
import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
@@ -29,7 +30,7 @@
* @author Scott Marlow
* @author Jussi Pyörre
*/
- at SuppressWarnings({"CanBeFinal"})
+ at Reentrant
public class CachedSetImpl extends AbstractSet
{
// protected static final Log log_=LogFactory.getLog(CachedSetImpl.class);
1.6 +41 -1 JBossCache/src-50/org/jboss/cache/pojo/collection/CollectionInterceptorUtil.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CollectionInterceptorUtil.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/collection/CollectionInterceptorUtil.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- CollectionInterceptorUtil.java 13 Jul 2006 15:56:12 -0000 1.5
+++ CollectionInterceptorUtil.java 2 Aug 2006 15:40:24 -0000 1.6
@@ -9,18 +9,22 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.aop.InstanceAdvisor;
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.pointcut.ast.ParseException;
+import org.jboss.aop.advice.AdviceBinding;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.aop.proxy.ClassProxy;
import org.jboss.aop.proxy.ClassProxyFactory;
import org.jboss.aop.util.MethodHashing;
import org.jboss.cache.Fqn;
-import org.jboss.cache.pojo.PojoTreeCache;
+import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.pojo.impl.PojoCacheImpl;
import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
import org.jboss.cache.pojo.interceptors.dynamic.CachedListInterceptor;
import org.jboss.cache.pojo.interceptors.dynamic.CachedMapInterceptor;
import org.jboss.cache.pojo.interceptors.dynamic.CachedSetInterceptor;
+import org.jboss.cache.pojo.interceptors.dynamic.ReentrancyStopperInterceptor;
import org.jboss.cache.pojo.util.AopUtil;
import java.lang.reflect.InvocationTargetException;
@@ -47,6 +51,42 @@
ClassProxy result = ClassProxyFactory.newInstance(clazz);
InstanceAdvisor advisor = result._getInstanceAdvisor();
advisor.appendInterceptor(interceptor);
+
+ // Also take care of just toString()
+ try
+ {
+ String bindName = clazz.getName() +".toString";
+ HashMap<String, AdviceBinding> bindings = AspectManager.instance().getBindings();
+ if(bindings.get(bindName) == null)
+ {
+ String bind = null;
+ if(interceptor instanceof CachedListInterceptor)
+ {
+ bind = "execution(public String " + CachedListAbstract.class.getName() + "->toString())";
+ } else if (interceptor instanceof CachedSetInterceptor)
+ {
+ bind = "execution(public String " + CachedSetImpl.class.getName() + "->toString())";
+ } else if (interceptor instanceof CachedMapInterceptor)
+ {
+ bind = "execution(public String " + CachedMapImpl.class.getName() + "->toString())";
+ } else
+ {
+ throw new IllegalStateException("CollectionInterceptorUtil.createProxy(). Non Collection interceptor"
+ + interceptor);
+ }
+
+ AdviceBinding bindingm = new AdviceBinding(bindName,
+ bind, null);
+ bindingm.addInterceptor(ReentrancyStopperInterceptor.class);
+ AspectManager.instance().addBinding(bindingm);
+ // result._getInstanceAdvisor().addBinding(bindingm);
+ }
+ } catch (ParseException e)
+ {
+ throw new PojoCacheException("PojoUtil._attachInterceptor(): can't parse the field binding: "
+ +e);
+ }
+
return result;
}
More information about the jboss-cvs-commits
mailing list