[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo/impl ...
Ben Wang
bwang at jboss.com
Fri Jul 14 13:56:51 EDT 2006
User: bwang
Date: 06/07/14 13:56:51
Modified: src-50/org/jboss/cache/pojo/impl AdvisedPojoHandler.java
CollectionClassHandler.java PojoCacheDelegate.java
PojoCacheImpl.java
Log:
JBCACHE-697 PojoCache sub-field Collection reference.
Revision Changes Path
1.3 +39 -36 JBossCache/src-50/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AdvisedPojoHandler.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- AdvisedPojoHandler.java 14 Jul 2006 16:35:48 -0000 1.2
+++ AdvisedPojoHandler.java 14 Jul 2006 17:56:51 -0000 1.3
@@ -17,7 +17,6 @@
import org.jboss.cache.pojo.memory.FieldPersistentReference;
import org.jboss.cache.pojo.util.AopUtil;
import org.jboss.cache.pojo.interceptors.dynamic.AbstractCollectionInterceptor;
-import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor;
import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor;
import org.jboss.cache.pojo.collection.CollectionInterceptorUtil;
import org.jboss.cache.Fqn;
@@ -33,7 +32,6 @@
import java.util.List;
import java.util.Set;
import java.util.Iterator;
-import java.util.Collection;
import java.util.HashMap;
import java.lang.reflect.Field;
@@ -42,7 +40,7 @@
*
* @author Ben Wang
* Date: Aug 4, 2005
- * @version $Id: AdvisedPojoHandler.java,v 1.2 2006/07/14 16:35:48 bwang Exp $
+ * @version $Id: AdvisedPojoHandler.java,v 1.3 2006/07/14 17:56:51 bwang Exp $
*/
class AdvisedPojoHandler
{
@@ -107,11 +105,47 @@
_regularPutObject(fqn, obj, advisor, type);
}
- void remove(Fqn fqn) throws CacheException
+ Object remove(Fqn fqn, Object result, Class clazz
+ ) throws CacheException
+ {
+ CachedType type = pCache_.getCachedType(clazz);
+ InstanceAdvisor advisor = ((Advised) result)._getInstanceAdvisor();
+ for (Iterator i = type.getFields().iterator(); i.hasNext();)
+ {
+ Field field = (Field) (((FieldPersistentReference) i.next())).get();
+ CachedType fieldType = pCache_.getCachedType(field.getType());
+ Object value = null;
+ if (!fieldType.isImmediate())
+ {
+ value = pCache_.removeObject(new Fqn(fqn, field.getName()));
+
+ // Check for Collection. If it is, we need to reset the original reference.
+ if ((value instanceof Map || value instanceof List || value instanceof Set) &&
+ (value instanceof ClassProxy))
{
+ Interceptor interceptor = CollectionInterceptorUtil.getInterceptor((ClassProxy) value);
+ Object origValue = ((AbstractCollectionInterceptor)interceptor).getCurrecntCopy();
+ util_.collectionReplaceWithProxy(value, field, origValue);
+ }
+
+ }
}
+ // batch remove
+ cache_.removeData(fqn);
+ // Determine if we want to keep the interceptor for later use.
+ CacheFieldInterceptor interceptor = (CacheFieldInterceptor) AopUtil.findCacheInterceptor(advisor);
+ // Remember to remove the interceptor from in-memory object but make sure it belongs to me first.
+ if (interceptor != null)
+ {
+ if (log.isDebugEnabled()) {
+ log.debug("regularRemoveObject(): removed cache interceptor fqn: " + fqn + " interceptor: "+interceptor);
+ }
+ util_.detachInterceptor(advisor, interceptor, observer_);
+ }
+ return null; // Not really null though.
+ }
/*****************************************************************************************
* private methods
@@ -216,35 +250,4 @@
return CachedType.hasAnnotation(clazz, advisor, type);
}
-
- public void remove(Fqn fqn, Object result, Class clazz
- ) throws CacheException
- {
- CachedType type = pCache_.getCachedType(clazz);
- for (Iterator i = type.getFields().iterator(); i.hasNext();)
- {
- Field field = (Field) (((FieldPersistentReference) i.next())).get();
- CachedType fieldType = pCache_.getCachedType(field.getType());
- Object value = null;
- if (!fieldType.isImmediate())
- {
- value = pCache_.removeObject(new Fqn(fqn, field.getName()));
-
- // Check for Collection. If it is, we need to reset the original reference.
-/*
- if ((value instanceof Map || value instanceof List || value instanceof Set) &&
- (value instanceof ClassProxy))
- {
- Interceptor interceptor = CollectionInterceptorUtil.getInterceptor((ClassProxy) value);
- Object origValue = ((AbstractCollectionInterceptor)interceptor).getCurrecntCopy();
- util_.collectionReplaceWithProxy(value, field, origValue);
- }
-*/
- }
- }
-
- // batch remove
- cache_.removeData(fqn);
- }
-
}
1.4 +3 -3 JBossCache/src-50/org/jboss/cache/pojo/impl/CollectionClassHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CollectionClassHandler.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/impl/CollectionClassHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- CollectionClassHandler.java 14 Jul 2006 16:35:48 -0000 1.3
+++ CollectionClassHandler.java 14 Jul 2006 17:56:51 -0000 1.4
@@ -20,7 +20,6 @@
import org.jboss.cache.pojo.CachedType;
import org.jboss.cache.pojo.PojoReference;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -31,7 +30,7 @@
*
* @author Ben Wang
* Date: Aug 4, 2005
- * @version $Id: CollectionClassHandler.java,v 1.3 2006/07/14 16:35:48 bwang Exp $
+ * @version $Id: CollectionClassHandler.java,v 1.4 2006/07/14 17:56:51 bwang Exp $
*/
class CollectionClassHandler
{
@@ -234,7 +233,7 @@
}
}
- void remove(Fqn fqn, Object obj) throws CacheException
+ Object remove(Fqn fqn, Object obj) throws CacheException
{
if (!(obj instanceof ClassProxy))
{
@@ -245,5 +244,6 @@
boolean removeFromCache = true;
// detach the interceptor. This will trigger a copy and remove.
((AbstractCollectionInterceptor) interceptor).detach(removeFromCache);
+ return ((AbstractCollectionInterceptor) interceptor).getCurrecntCopy();
}
}
1.4 +2 -4 JBossCache/src-50/org/jboss/cache/pojo/impl/PojoCacheDelegate.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoCacheDelegate.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/impl/PojoCacheDelegate.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- PojoCacheDelegate.java 14 Jul 2006 16:35:48 -0000 1.3
+++ PojoCacheDelegate.java 14 Jul 2006 17:56:51 -0000 1.4
@@ -10,7 +10,6 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.aop.Advised;
import org.jboss.aop.Advisor;
-import org.jboss.aop.ClassInstanceAdvisor;
import org.jboss.aop.InstanceAdvisor;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.proxy.ClassProxy;
@@ -20,13 +19,11 @@
import org.jboss.cache.pojo.memory.FieldPersistentReference;
import org.jboss.cache.pojo.util.AopUtil;
import org.jboss.cache.pojo.interceptors.dynamic.BaseInterceptor;
-import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor;
import org.jboss.cache.pojo.observable.Observer;
import org.jboss.cache.pojo.PojoTreeCache;
import org.jboss.cache.pojo.PojoUtil;
import org.jboss.cache.pojo.CachedType;
import org.jboss.cache.pojo.PojoReference;
-import org.jboss.cache.pojo.collection.CollectionInterceptorUtil;
import java.lang.reflect.Field;
import java.util.Collection;
@@ -455,7 +452,8 @@
advisedHandler_.remove(fqn, result, clazz);
} else if (isCollectionGet(clazz))
{
- collectionHandler_.remove(fqn, result);
+ // We need to return the original reference
+ result = collectionHandler_.remove(fqn, result);
} else
{ // Just Serializable objects. Do a brute force remove is ok.
serializableHandler_.remove();
1.10 +2 -2 JBossCache/src-50/org/jboss/cache/pojo/impl/PojoCacheImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoCacheImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/impl/PojoCacheImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- PojoCacheImpl.java 14 Jul 2006 16:35:48 -0000 1.9
+++ PojoCacheImpl.java 14 Jul 2006 17:56:51 -0000 1.10
@@ -38,7 +38,7 @@
* Implementation class for PojoCache interface
*
* @author Ben Wang
- * @version $Id: PojoCacheImpl.java,v 1.9 2006/07/14 16:35:48 bwang Exp $
+ * @version $Id: PojoCacheImpl.java,v 1.10 2006/07/14 17:56:51 bwang Exp $
*/
public class PojoCacheImpl implements PojoCache, Observer
{
@@ -247,7 +247,7 @@
{
// Don't trigger bulk remove now since there is still some problem with Collection class
// when it is detached.
- delegate_.setBulkRemove(true);
+ delegate_.setBulkRemove(false);
return delegate_._removeObject(fqn);
}
More information about the jboss-cvs-commits
mailing list