[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo ...
Ben Wang
bwang at jboss.com
Thu Jul 13 11:56:15 EDT 2006
User: bwang
Date: 06/07/13 11:56:15
Modified: src-50/org/jboss/cache/pojo PojoReference.java
PojoTreeCache.java
Removed: src-50/org/jboss/cache/pojo
CollectionClassHandler.java InternalDelegate.java
ObjectGraphHandler.java PojoCacheDelegate.java
SerializableObjectHandler.java
Log:
Refctoring and moved some classes to impl dir.
Revision Changes Path
1.2 +10 -10 JBossCache/src-50/org/jboss/cache/pojo/PojoReference.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoReference.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/PojoReference.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PojoReference.java 12 Jul 2006 13:28:25 -0000 1.1
+++ PojoReference.java 13 Jul 2006 15:56:15 -0000 1.2
@@ -53,32 +53,32 @@
set(instance);
}
- Object get()
+ public Object get()
{
return instance_;
}
- void set(Object instance)
+ public void set(Object instance)
{
instance_ = instance;
}
- String getInternalFqn()
+ public String getInternalFqn()
{
return internalFqn_;
}
- void setInternalFqn(String refFqn)
+ public void setInternalFqn(String refFqn)
{
internalFqn_ = refFqn;
}
- void removeInternalFqn()
+ public void removeInternalFqn()
{
internalFqn_ = null;
}
- synchronized int incrementRefCount(Fqn sourceFqn)
+ synchronized public int incrementRefCount(Fqn sourceFqn)
{
if(sourceFqn != null)
{
@@ -98,7 +98,7 @@
return refCount_;
}
- synchronized int decrementRefCount(Fqn sourceFqn)
+ synchronized public int decrementRefCount(Fqn sourceFqn)
{
if(sourceFqn != null)
{
@@ -114,17 +114,17 @@
return refCount_;
}
- synchronized int getRefCount()
+ synchronized public int getRefCount()
{
return refCount_;
}
- synchronized Fqn getAndRemoveFirstFqnInList()
+ synchronized public Fqn getAndRemoveFirstFqnInList()
{
return (Fqn) referencedBy_.remove(0);
}
- synchronized void addXFqnIntoList(Fqn fqn)
+ synchronized public void addXFqnIntoList(Fqn fqn)
{
referencedBy_.add(0, fqn);
}
1.8 +23 -158 JBossCache/src-50/org/jboss/cache/pojo/PojoTreeCache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoTreeCache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/PojoTreeCache.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- PojoTreeCache.java 11 Jul 2006 09:07:40 -0000 1.7
+++ PojoTreeCache.java 13 Jul 2006 15:56:15 -0000 1.8
@@ -11,13 +11,11 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.RegionNotEmptyException;
import org.jboss.cache.TreeCache;
-import org.jboss.cache.marshall.ObjectSerializationFactory;
import org.jboss.cache.marshall.Region;
import org.jboss.cache.marshall.RegionNameConflictException;
import org.jboss.cache.pojo.eviction.AopEvictionPolicy;
import org.jboss.cache.pojo.util.ObjectUtil;
-import org.jboss.cache.pojo.observable.Observer;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.pojo.impl.InternalConstant;
import org.jgroups.JChannel;
import org.w3c.dom.Element;
@@ -28,15 +26,8 @@
public class PojoTreeCache extends TreeCache
{
- // Class -> CachedType
- // use WeakHashMap to allow class reloading
- private Map cachedTypes = new WeakHashMap();
- private PojoCacheDelegate delegate_;
private Element config_ = null;
// boolean detachPojoWhenEvicted_ = false;
- private boolean marshallNonSerializable_ = false;
- // Observer for field event notification
- private Observer observer_;
public PojoTreeCache(String cluster_name,
String props,
@@ -44,29 +35,15 @@
throws Exception
{
super(cluster_name, props, state_fetch_timeout);
- init();
}
public PojoTreeCache() throws Exception
{
- init();
- }
-
- public PojoTreeCache(Observer observer) throws Exception
- {
- observer_ = observer;
- init();
}
public PojoTreeCache(JChannel channel) throws Exception
{
super(channel);
- init();
- }
-
- private void init()
- {
- delegate_ = new PojoCacheDelegate(this, observer_);
}
@Override
@@ -89,9 +66,6 @@
log.info("parseConfig(): PojoCacheConfig is empty");
return;
}
- marshallNonSerializable_ = XmlHelper.readBooleanContents(config_, "marshallNonSerializable");
- log.info("marshallNonSerializable flag is set: " + marshallNonSerializable_);
-
// detachPojoWhenEvicted_ = XmlHelper.readBooleanContents(config_, "DetachPojoWhenEvicted");
}
@@ -141,7 +115,7 @@
{
// We will remove all children nodes as well since we assume all children nodes are part
// of this "object" node.
- if (delegate_.isAopNode(fqn))
+ if (isAopNode(fqn))
{
if (log.isDebugEnabled())
{
@@ -174,6 +148,18 @@
super.evict(fqn);
}
+ private boolean isAopNode(Fqn fqn)
+ {
+ // Use this API so it doesn't go thru the interceptor.
+ DataNode node = peek(fqn);
+ if (node == null) return false;
+
+ if (node.get(PojoReference.KEY) != null)
+ return true;
+ else
+ return false;
+ }
+
@Override
protected void createEvictionPolicy()
{
@@ -189,7 +175,7 @@
// We will remove all children nodes as well since we assume all children nodes are part
// of this "object" node.
- if (delegate_.isAopNode(subtree))
+ if (isAopNode(subtree))
{
if (log.isDebugEnabled())
{
@@ -223,18 +209,18 @@
} else
{
// If the internal region is not activated yet, activate it first
- Region region = regionManager_.getRegion(InternalDelegate.JBOSS_INTERNAL);
+ Region region = regionManager_.getRegion(InternalConstant.JBOSS_INTERNAL);
if ((region == null && inactiveOnStartup)
|| (region != null && region.isInactive()))
{
- super.activateRegion(InternalDelegate.JBOSS_INTERNAL.toString());
+ super.activateRegion(InternalConstant.JBOSS_INTERNAL.toString());
}
// If we don't have an internal map node yet, create one.
// Doing this ensures the code that integrates map references for
// the region will have a node to integrate into
- if (get(InternalDelegate.JBOSS_INTERNAL_MAP) == null)
- createSubtreeRootNode(InternalDelegate.JBOSS_INTERNAL_MAP);
+ if (get(InternalConstant.JBOSS_INTERNAL_MAP) == null)
+ createSubtreeRootNode(InternalConstant.JBOSS_INTERNAL_MAP);
// Now activate the requested region
super.activateRegion(subtreeFqn);
@@ -256,9 +242,9 @@
super.acquireLocksForStateTransfer(root, lockOwner, timeout, true, force);
Fqn fqn = root.getFqn();
if (fqn.size() > 0 &&
- !fqn.isChildOf(InternalDelegate.JBOSS_INTERNAL))
+ !fqn.isChildOf(InternalConstant.JBOSS_INTERNAL))
{
- DataNode refMapNode = get(InternalDelegate.JBOSS_INTERNAL_MAP);
+ DataNode refMapNode = get(InternalConstant.JBOSS_INTERNAL_MAP);
if (refMapNode != null)
{
@@ -305,7 +291,7 @@
super.releaseStateTransferLocks(root, lockOwner, true);
Fqn fqn = root.getFqn();
releaseInternal = (fqn.size() > 0 &&
- !fqn.isChildOf(InternalDelegate.JBOSS_INTERNAL));
+ !fqn.isChildOf(InternalConstant.JBOSS_INTERNAL));
}
finally
{
@@ -313,7 +299,7 @@
{
try
{
- DataNode refMapNode = get(InternalDelegate.JBOSS_INTERNAL_MAP);
+ DataNode refMapNode = get(InternalConstant.JBOSS_INTERNAL_MAP);
if (refMapNode != null)
{
// Rather than going to the effort of identifying which
@@ -329,92 +315,6 @@
}
}
- /**
- * Obtain a cache aop type for user to traverse the defined "primitive" types in aop.
- * Note that this is not a synchronized call now for speed optimization.
- *
- * @param clazz The original pojo class
- * @return CachedType
- */
- public synchronized CachedType getCachedType(Class clazz)
- {
- CachedType type = (CachedType) cachedTypes.get(clazz);
- if (type == null)
- {
- type = new CachedType(clazz);
- cachedTypes.put(clazz, type);
- return type;
- } else
- {
- return type;
- }
- }
-
- public Object getObject(String fqn) throws CacheException
- {
- return getObject(Fqn.fromString(fqn));
- }
-
- public Object getObject(Fqn fqn) throws CacheException
- {
- return delegate_._getObject(fqn);
- }
-
- public Object putObject(String fqn, Object obj) throws CacheException
- {
- return putObject(Fqn.fromString(fqn), obj);
- }
-
- public Object putObject(Fqn fqn, Object obj) throws CacheException
- {
- if (log.isDebugEnabled())
- {
- log.debug("putObject(): Fqn:" + fqn);
- }
-
- return delegate_._putObject(fqn, obj);
- }
-
- public Object removeObject(String fqn) throws CacheException
- {
- return removeObject(Fqn.fromString(fqn));
- }
-
- public Object removeObject(Fqn fqn) throws CacheException
- {
- if (log.isDebugEnabled())
- {
- log.debug("removeObject(): Fqn:" + fqn);
- }
-
- return _removeObject(fqn, true);
- }
-
- /**
- */
- public Map findObjects(String fqn) throws CacheException
- {
- return delegate_._findObjects(Fqn.fromString(fqn));
- }
-
- public void setMarshallNonSerializable(boolean marshall)
- {
- if (marshall)
- {
- if (!ObjectSerializationFactory.useJBossSerialization())
- {
- throw new IllegalStateException("PojoCache.setMarshallNonSerializable(). " +
- "Can't set MarshallNonSerializable to true since useJBossSerialization is false");
- }
- }
- marshallNonSerializable_ = marshall;
- }
-
- public boolean isMarshallNonSerializable()
- {
- return marshallNonSerializable_;
- }
-
public Object getLockOwner()
{
return getOwnerForLock();
@@ -441,39 +341,4 @@
return getLocalTransaction();
}
- /**
- * Used by internal implementation. Not for general public.
- */
- public Object _removeObject(Fqn fqn) throws CacheException
- {
- boolean removeCacheInterceptor = true;
- return _removeObject(fqn, removeCacheInterceptor);
- }
-
- /**
- * Used by internal implementation. Not for general public.
- */
- public Object _removeObject(Fqn fqn, boolean removeCacheInterceptor) throws CacheException
- {
- boolean evict = false;
- // Don't trigger bulk remove now since there is still some problem with Collection class
- // when it is detached.
- delegate_.setBulkRemove(true);
- return delegate_._removeObject(fqn, removeCacheInterceptor, evict);
- }
-
- /**
- * Used by internal implementation. Not for general public.
- */
- public Object _evictObject(Fqn fqn) throws CacheException
- {
- boolean evict = true;
- boolean removeCacheInterceptor = false;
-
- // Configurable option to see if we want to remove the cache interceptor when the pojo is
- // evicted.
-// if(detachPojoWhenEvicted_) removeCacheInterceptor = true;
- delegate_.setBulkRemove(false);
- return delegate_._removeObject(fqn, removeCacheInterceptor, evict);
- }
}
More information about the jboss-cvs-commits
mailing list