[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo/impl ...
Ben Wang
bwang at jboss.com
Thu Jul 27 10:25:26 EDT 2006
User: bwang
Date: 06/07/27 10:25:26
Modified: src-50/org/jboss/cache/pojo/impl AdvisedPojoHandler.java
ObjectGraphHandler.java PojoCacheDelegate.java
PojoCacheImpl.java
Log:
Moved the interceptor annotation and also now lock parent node for Collection.
Revision Changes Path
1.8 +3 -3 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.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- AdvisedPojoHandler.java 26 Jul 2006 17:02:13 -0000 1.7
+++ AdvisedPojoHandler.java 27 Jul 2006 14:25:26 -0000 1.8
@@ -40,7 +40,7 @@
*
* @author Ben Wang
* Date: Aug 4, 2005
- * @version $Id: AdvisedPojoHandler.java,v 1.7 2006/07/26 17:02:13 bwang Exp $
+ * @version $Id: AdvisedPojoHandler.java,v 1.8 2006/07/27 14:25:26 bwang Exp $
*/
class AdvisedPojoHandler
{
@@ -161,7 +161,7 @@
Object value = subPojoMap.get(field);
if(value == null) continue; // really no need to map the POJO.
Fqn tmpFqn = new Fqn(fqn, field.getName());
- pCache_.putObject(tmpFqn, value);
+ pCache_.attach(tmpFqn, value);
// If it is Collection classes, we replace it with dynamic proxy.
// But we will have to ignore it if value is null
if (value instanceof Map || value instanceof List || value instanceof Set)
@@ -190,7 +190,7 @@
Object value = null;
if (!fieldType.isImmediate())
{
- value = pCache_.removeObject(new Fqn(fqn, field.getName()));
+ value = pCache_.detach(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))
1.6 +2 -2 JBossCache/src-50/org/jboss/cache/pojo/impl/ObjectGraphHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ObjectGraphHandler.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/impl/ObjectGraphHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ObjectGraphHandler.java 17 Jul 2006 09:07:08 -0000 1.5
+++ ObjectGraphHandler.java 27 Jul 2006 14:25:26 -0000 1.6
@@ -30,7 +30,7 @@
*
* @author Ben Wang
* Date: Aug 4, 2005
- * @version $Id: ObjectGraphHandler.java,v 1.5 2006/07/17 09:07:08 bwang Exp $
+ * @version $Id: ObjectGraphHandler.java,v 1.6 2006/07/27 14:25:26 bwang Exp $
*/
class ObjectGraphHandler
{
@@ -136,7 +136,7 @@
{
// No one is referring it so it is safe to remove
// TODO we should make sure the parent nodes are also removed they are empty as well.
- pCache_.removeObject(referencingFqn);
+ pCache_.detach(referencingFqn);
}
}
}
1.10 +1 -1 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.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- PojoCacheDelegate.java 27 Jul 2006 02:24:29 -0000 1.9
+++ PojoCacheDelegate.java 27 Jul 2006 14:25:26 -0000 1.10
@@ -130,7 +130,7 @@
// remove old value before overwriting it. This is necessary to detach any interceptor.
// TODO Or can we simply walk thru that somewhere? Well, there is also implication of Collection though
- pCache_.removeObject(fqn);
+ pCache_.detach(fqn);
if (obj == null)
{
1.14 +34 -10 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.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- PojoCacheImpl.java 20 Jul 2006 18:43:11 -0000 1.13
+++ PojoCacheImpl.java 27 Jul 2006 14:25:26 -0000 1.14
@@ -13,6 +13,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
+//import org.jboss.cache.PropertyConfigurator;
import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.pojo.CachedType;
import org.jboss.cache.pojo.PojoCache;
@@ -37,7 +38,7 @@
* Implementation class for PojoCache interface
*
* @author Ben Wang
- * @version $Id: PojoCacheImpl.java,v 1.13 2006/07/20 18:43:11 msurtani Exp $
+ * @version $Id: PojoCacheImpl.java,v 1.14 2006/07/27 14:25:26 bwang Exp $
*/
public class PojoCacheImpl implements PojoCache, Observer
{
@@ -64,6 +65,9 @@
try
{
cache_ = new PojoTreeCache();
+// PropertyConfigurator config = new PropertyConfigurator();
+// config.configure(cache_, configStr);
+
cache_.setConfiguration(new XmlConfigurationParser().parseFile(configStr));
} catch (Exception e)
{
@@ -80,12 +84,17 @@
public PojoTreeCache getUnderlyingCache() { return cache_; }
- @Attach
public Object attach(String id, Object pojo) throws PojoCacheException
{
+ return attach(Fqn.fromString(id), pojo);
+ }
+
+ @Attach
+ public Object attach(Fqn id, Object pojo) throws PojoCacheException
+ {
try
{
- Object obj = putObject(Fqn.fromString(id), pojo);
+ Object obj = putObject(id, pojo);
return obj;
} catch (CacheException e)
{
@@ -106,16 +115,21 @@
return obj;
}
- @Detach
public Object detach(String id) throws PojoCacheException
{
+ return detach(Fqn.fromString(id));
+ }
+
+ @Detach
+ public Object detach(Fqn id) throws PojoCacheException
+ {
try
{
Object pojo = find(id); // TODO need optimization here since it will be redundant here
if(pojo == null) return pojo;
notifyDetach(pojo, true);
- Object obj = removeObject(Fqn.fromString(id));
+ Object obj = removeObject(id);
notifyDetach(pojo, false);
return obj;
} catch (CacheException e)
@@ -136,12 +150,17 @@
throw new RuntimeException("getPojoID not yet implemented");
}
- @Find
public Object find(String id) throws PojoCacheException
{
+ return find(Fqn.fromString(id));
+ }
+
+ @Find
+ public Object find(Fqn id) throws PojoCacheException
+ {
try
{
- return getObject(Fqn.fromString(id));
+ return getObject(id);
} catch (CacheException e)
{
e.printStackTrace(); // TODO
@@ -155,12 +174,17 @@
return delegate_.getObject(id);
}
- @Find
public Map findAll(String id) throws PojoCacheException
{
+ return findAll(Fqn.fromString(id));
+ }
+
+ @Find
+ public Map findAll(Fqn id) throws PojoCacheException
+ {
try
{
- return delegate_.findObjects(Fqn.fromString(id));
+ return delegate_.findObjects(id);
} catch (CacheException e)
{
e.printStackTrace(); // TODO
More information about the jboss-cvs-commits
mailing list