[jboss-cvs] JBossCache/src/org/jboss/cache/pojo/impl ...
Jason Thomas Greene
jgreene at jboss.com
Fri Jun 22 19:01:08 EDT 2007
User: jgreene
Date: 07/06/22 19:01:08
Modified: src/org/jboss/cache/pojo/impl InternalHelper.java
ObjectGraphHandler.java PojoCacheDelegate.java
Log:
Fix JBCACHE-1111
Revision Changes Path
1.6 +29 -117 JBossCache/src/org/jboss/cache/pojo/impl/InternalHelper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InternalHelper.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/impl/InternalHelper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- InternalHelper.java 30 May 2007 06:08:01 -0000 1.5
+++ InternalHelper.java 22 Jun 2007 23:01:08 -0000 1.6
@@ -25,58 +25,26 @@
*/
public class InternalHelper
{
- private Log log = LogFactory.getLog(InternalHelper.class.getName());
- // This is an optimization flag to skip put lock when we are sure that it has been locked from
- // putObject. However, if later on there are transactional field updates, then we we will need
- // this off to protected the write lock.
- private boolean cacheOperationSkipLocking_ = true;
- private Option skipLockOption_;
- private Option gravitateOption_;
- private Option localModeOption_;
+ private static Log log = LogFactory.getLog(InternalHelper.class.getName());
- private CacheSPI cache_;
+ private CacheSPI cache;
InternalHelper(CacheSPI cache)
{
- cache_ = cache;
-
- skipLockOption_ = new Option();
- if (cacheOperationSkipLocking_)
- {
- skipLockOption_.setSuppressLocking(true);
- }
- else
- {
- skipLockOption_.setSuppressLocking(false);
+ this.cache = cache;
}
- localModeOption_ = new Option();
- localModeOption_.setCacheModeLocal(true);
-
- gravitateOption_ = new Option();
- gravitateOption_.setForceDataGravitation(true);
- }
-
- Option getLockOption()
+ PojoInstance getPojoInstance(Fqn fqn) throws CacheException
{
- return skipLockOption_;
- }
-
- PojoInstance getAopInstance(Fqn fqn) throws CacheException
- {
- // Not very efficient now since we are peeking every single time.
- // Should have cache it without going to local cache.
- return (PojoInstance) get(fqn, PojoInstance.KEY, false);
+ return (PojoInstance) get(fqn, PojoInstance.KEY, true);
}
PojoReference getPojoReference(Fqn fqn, String field) throws CacheException
{
- // Not very efficient now since we are peeking every single time.
- // Should have cache it without going to local cache.
if (field == null)
field = PojoReference.KEY;
- return (PojoReference) get(fqn, field, false);
+ return (PojoReference) get(fqn, field, true);
}
PojoReference getPojoReference(Fqn fqn) throws CacheException
@@ -84,19 +52,6 @@
return getPojoReference(fqn, null);
}
- PojoReference getPojoReferenceWithGravitation(Fqn fqn) throws CacheException
- {
- // Not very efficient now since we are peeking every single time.
- // Should have cache it without going to local cache.
- return (PojoReference) get(fqn, PojoReference.KEY, true);
- }
-
- private PojoInstance getAopInstanceWithGravitation(Fqn fqn) throws CacheException
- {
- // Not very efficient now since we are peeking every single time.
- // Should have cache it without going to local cache.
- return (PojoInstance) get(fqn, PojoInstance.KEY, true);
- }
static PojoInstance initializeAopInstance(Fqn sourceFqn)
{
@@ -111,7 +66,7 @@
*/
int incrementRefCount(Fqn originalFqn, Fqn referencingFqn) throws CacheException
{
- PojoInstance pojoInstance = getAopInstance(originalFqn);
+ PojoInstance pojoInstance = getPojoInstance(originalFqn);
if (pojoInstance == null)
throw new PojoCacheException("InternalDelegate.incrementRefCount(): null pojoReference for fqn: " + originalFqn);
@@ -133,53 +88,24 @@
private Object get(Fqn fqn, Object key, boolean gravitate) throws CacheException
{
// TODO let's find a better way to decouple this.
- if (gravitate && cache_.getBuddyManager() != null)
+ if (gravitate && cache.getBuddyManager() != null)
{
- cache_.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
- Object obj = cache_.get(fqn, key);
- cache_.getInvocationContext().getOptionOverrides().setForceDataGravitation(false);
+ cache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
+ Object obj = cache.get(fqn, key);
+ cache.getInvocationContext().getOptionOverrides().setForceDataGravitation(false);
return obj;
}
- else if (cache_.getCacheLoaderManager() != null)
- {
- // We have cache loader, we can't get it directly from the local get.
-// cache_.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- Object obj = cache_.get(fqn, key);
-// cache_.getInvocationContext().getOptionOverrides().setSuppressLocking(false);
- return obj;
- }
- else
- {
-// return cache_._get(fqn, key, false);
- return cache_.get(fqn, key);
- }
+ return cache.get(fqn, key);
}
private void put(Fqn fqn, Object key, Object value) throws CacheException
{
- // Use option to ski locking since we have parent lock already.
-// cache_.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- cache_.put(fqn, key, value);
-// cache_.getInvocationContext().getOptionOverrides().setSuppressLocking(false);
-// cache_.put(fqn, key, value);
+ cache.put(fqn, key, value);
}
void put(Fqn fqn, Map map) throws CacheException
{
- // Use option to ski locking since we have parent lock already.
-// cache_.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- cache_.put(fqn, map);
-// cache_.getInvocationContext().getOptionOverrides().setSuppressLocking(false);
-// cache_.put(fqn, key, value);
- }
-
- protected void localPut(Fqn fqn, Object key, Object value) throws CacheException
- {
- // Use option to ski locking since we have parent lock already.
- // TODO Need to make sure there is no tx here otherwise it won't work.
-// cache_.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- cache_.put(fqn, key, value);
-// cache_.getInvocationContext().getOptionOverrides().setSuppressLocking(false);
+ cache.put(fqn, map);
}
@@ -188,7 +114,7 @@
*/
int decrementRefCount(Fqn originalFqn, Fqn referencingFqn) throws CacheException
{
- PojoInstance pojoInstance = getAopInstance(originalFqn);
+ PojoInstance pojoInstance = getPojoInstance(originalFqn);
if (pojoInstance == null)
throw new PojoCacheException("InternalDelegate.decrementRefCount(): null pojoReference.");
@@ -210,12 +136,12 @@
int getRefCount(Fqn fqn) throws CacheException
{
- return getAopInstance(fqn).getRefCount();
+ return getPojoInstance(fqn).getRefCount();
}
String XgetRefFqn(Fqn fqn) throws CacheException
{
- PojoInstance pojoInstance = getAopInstance(fqn);
+ PojoInstance pojoInstance = getPojoInstance(fqn);
return getRefFqn(pojoInstance);
}
@@ -233,7 +159,7 @@
void setRefFqn(Fqn fqn, String internalFqn) throws CacheException
{
- PojoInstance pojoInstance = getAopInstance(fqn);
+ PojoInstance pojoInstance = getPojoInstance(fqn);
if (pojoInstance == null)
pojoInstance = new PojoInstance();
@@ -243,7 +169,7 @@
void removeRefFqn(Fqn fqn) throws CacheException
{
- PojoInstance pojoInstance = getAopInstance(fqn);
+ PojoInstance pojoInstance = getPojoInstance(fqn);
if (pojoInstance == null)
throw new PojoCacheException("InternalDelegate.getInternalFqn(): null pojoReference.");
@@ -270,21 +196,7 @@
realFqn = fqn;
}
- PojoInstance pojoInstance = getAopInstance(realFqn);
- if (pojoInstance == null)
- return null;
-
- return pojoInstance.get();
- }
-
- Object getPojoWithGravitation(Fqn fqn) throws CacheException
- {
- // This is for buddy replication
- PojoReference pojoReference = getPojoReferenceWithGravitation(fqn);
- // Find the real fqn where it is stored.
- Fqn internalFqn = pojoReference.getFqn();
-
- PojoInstance pojoInstance = getAopInstanceWithGravitation(internalFqn);
+ PojoInstance pojoInstance = getPojoInstance(realFqn);
if (pojoInstance == null)
return null;
@@ -293,7 +205,7 @@
void setPojo(Fqn fqn, Object pojo) throws CacheException
{
- PojoInstance pojoInstance = getAopInstance(fqn);
+ PojoInstance pojoInstance = getPojoInstance(fqn);
if (pojoInstance == null)
{
pojoInstance = new PojoInstance();
@@ -363,30 +275,30 @@
void removeInternalAttributes(Fqn fqn) throws CacheException
{
- cache_.remove(fqn, PojoInstance.KEY);
- cache_.remove(fqn, InternalConstant.CLASS_INTERNAL);
+ cache.remove(fqn, PojoInstance.KEY);
+ cache.remove(fqn, InternalConstant.CLASS_INTERNAL);
}
void cleanUp(Fqn fqn, String field) throws CacheException
{
if (field != null)
{
- cache_.remove(fqn, field);
+ cache.remove(fqn, field);
return;
}
// We can't do a brute force remove anymore?
- if (cache_.getRoot().getChild(fqn).getChildren().size() == 0)
+ if (cache.getRoot().getChild(fqn).getChildren().size() == 0)
{
// remove everything
- cache_.removeNode(fqn);
+ cache.removeNode(fqn);
// cache_.getRoot().getChild(fqn).clearData();
// removeNodeWithoutInterceptor(fqn);
}
else
{
// Assume everything here is all PojoCache data for optimization
- cache_.getRoot().getChild(fqn).clearData();
+ cache.getRoot().getChild(fqn).clearData();
if (log.isTraceEnabled())
{
log.trace("cleanup(): fqn: " + fqn + " is not empty. That means it has sub-pojos. Will not remove node");
@@ -421,7 +333,7 @@
void removeIndirectFqn(String oldFqn) throws CacheException
{
String indirectFqn = getIndirectFqn(oldFqn);
- cache_.remove(getInternalFqn(oldFqn), indirectFqn);
+ cache.remove(getInternalFqn(oldFqn), indirectFqn);
}
void setIndirectFqn(String oldFqn, String newFqn) throws CacheException
@@ -443,7 +355,7 @@
Fqn getNextFqnInLine(Fqn currentFqn) throws CacheException
{
- PojoInstance ai = getAopInstance(currentFqn);
+ PojoInstance ai = getPojoInstance(currentFqn);
return ai.getAndRemoveFirstFqnInList();
}
1.6 +2 -2 JBossCache/src/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/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 30 May 2007 06:08:01 -0000 1.5
+++ ObjectGraphHandler.java 22 Jun 2007 23:01:08 -0000 1.6
@@ -26,7 +26,7 @@
*
* @author Ben Wang
* Date: Aug 4, 2005
- * @version $Id: ObjectGraphHandler.java,v 1.5 2007/05/30 06:08:01 jgreene Exp $
+ * @version $Id: ObjectGraphHandler.java,v 1.6 2007/06/22 23:01:08 jgreene Exp $
*/
class ObjectGraphHandler
{
@@ -98,7 +98,7 @@
PojoInstance pojoInstance = null;
try
{
- pojoInstance = internal_.getAopInstance(internalFqn);
+ pojoInstance = internal_.getPojoInstance(internalFqn);
}
catch (CacheException e)
{
1.9 +1 -1 JBossCache/src/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/org/jboss/cache/pojo/impl/PojoCacheDelegate.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- PojoCacheDelegate.java 30 May 2007 06:08:01 -0000 1.8
+++ PojoCacheDelegate.java 22 Jun 2007 23:01:08 -0000 1.9
@@ -333,7 +333,7 @@
*/
Object obj;
- PojoInstance pojoInstance = internal_.getAopInstance(internalFqn);
+ PojoInstance pojoInstance = internal_.getPojoInstance(internalFqn);
if (pojoInstance == null)
return null;
More information about the jboss-cvs-commits
mailing list