[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo ...

Ben Wang bwang at jboss.com
Wed Jul 12 09:28:25 EDT 2006


  User: bwang   
  Date: 06/07/12 09:28:25

  Modified:    src-50/org/jboss/cache/pojo       
                        CollectionClassHandler.java InternalDelegate.java
                        ObjectGraphHandler.java PojoCacheDelegate.java
                        SerializableObjectHandler.java
  Added:       src-50/org/jboss/cache/pojo        PojoReference.java
  Removed:     src-50/org/jboss/cache/pojo        AOPInstance.java
  Log:
  Renamed AOPInstance to PojoReference and also some refactoring.
  
  Revision  Changes    Path
  1.7       +6 -6      JBossCache/src-50/org/jboss/cache/pojo/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/CollectionClassHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- CollectionClassHandler.java	7 Jul 2006 10:26:07 -0000	1.6
  +++ CollectionClassHandler.java	12 Jul 2006 13:28:25 -0000	1.7
  @@ -28,7 +28,7 @@
    *
    * @author Ben Wang
    *         Date: Aug 4, 2005
  - * @version $Id: CollectionClassHandler.java,v 1.6 2006/07/07 10:26:07 bwang Exp $
  + * @version $Id: CollectionClassHandler.java,v 1.7 2006/07/12 13:28:25 bwang Exp $
    */
   class CollectionClassHandler
   {
  @@ -216,15 +216,15 @@
         if (isCollection)
         {
            // Always initialize the ref count so that we can mark this as an AopNode.
  -         AOPInstance aopInstance = InternalDelegate.initializeAopInstance();
  -         cache_.put(fqn, AOPInstance.KEY, aopInstance);
  +         PojoReference pojoReference = InternalDelegate.initializeAopInstance();
  +         cache_.put(fqn, PojoReference.KEY, pojoReference);
   
  -         // Attach aopInstance to that interceptor
  +         // Attach pojoReference to that interceptor
            BaseInterceptor baseInterceptor = (BaseInterceptor) CollectionInterceptorUtil.getInterceptor(
                    (ClassProxy) obj);
  -         baseInterceptor.setAopInstance(aopInstance);
  +         baseInterceptor.setAopInstance(pojoReference);
   
  -         InternalDelegate.setPojo(aopInstance, obj);
  +         InternalDelegate.setPojo(pojoReference, obj);
         }
         return isCollection;
      }
  
  
  
  1.4       +57 -57    JBossCache/src-50/org/jboss/cache/pojo/InternalDelegate.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: InternalDelegate.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/InternalDelegate.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- InternalDelegate.java	27 Jun 2006 06:19:17 -0000	1.3
  +++ InternalDelegate.java	12 Jul 2006 13:28:25 -0000	1.4
  @@ -63,26 +63,26 @@
         return skipLockOption_;
      }
   
  -   AOPInstance getAopInstance(Fqn fqn) throws CacheException
  +   PojoReference 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 (AOPInstance) get(fqn, AOPInstance.KEY, false);
  +      return (PojoReference) get(fqn, PojoReference.KEY, false);
      }
   
  -   private AOPInstance getAopInstanceWithGravitation(Fqn fqn) throws CacheException
  +   private PojoReference 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 (AOPInstance) get(fqn, AOPInstance.KEY, true);
  +      return (PojoReference) get(fqn, PojoReference.KEY, true);
      }
   
  -   static AOPInstance initializeAopInstance()
  +   static PojoReference initializeAopInstance()
      {
  -      AOPInstance aopInstance = new AOPInstance();
  +      PojoReference pojoReference = new PojoReference();
   
  -      aopInstance.incrementRefCount(null);
  -      return aopInstance;
  +      pojoReference.incrementRefCount(null);
  +      return pojoReference;
      }
   
      /**
  @@ -90,13 +90,13 @@
       */
      int incrementRefCount(Fqn originalFqn, Fqn referencingFqn) throws CacheException
      {
  -      AOPInstance aopInstance = getAopInstance(originalFqn);
  -      if (aopInstance == null)
  -         throw new RuntimeException("InternalDelegate.incrementRefCount(): null aopInstance for fqn: " + originalFqn);
  +      PojoReference pojoReference = getAopInstance(originalFqn);
  +      if (pojoReference == null)
  +         throw new RuntimeException("InternalDelegate.incrementRefCount(): null pojoReference for fqn: " + originalFqn);
   
  -      int count = aopInstance.incrementRefCount(referencingFqn);
  +      int count = pojoReference.incrementRefCount(referencingFqn);
         // need to update it.
  -      put(originalFqn, AOPInstance.KEY, aopInstance);
  +      put(originalFqn, PojoReference.KEY, pojoReference);
         return count;
      }
   
  @@ -152,24 +152,24 @@
       */
      int decrementRefCount(Fqn originalFqn, Fqn referencingFqn) throws CacheException
      {
  -      AOPInstance aopInstance = getAopInstance(originalFqn);
  -      if (aopInstance == null)
  -         throw new RuntimeException("InternalDelegate.decrementRefCount(): null aopInstance.");
  +      PojoReference pojoReference = getAopInstance(originalFqn);
  +      if (pojoReference == null)
  +         throw new RuntimeException("InternalDelegate.decrementRefCount(): null pojoReference.");
   
  -      int count = aopInstance.decrementRefCount(referencingFqn);
  +      int count = pojoReference.decrementRefCount(referencingFqn);
   
         if (count < -1)  // can't dip below -1
  -         throw new RuntimeException("InternalDelegate.decrementRefCount(): null aopInstance.");
  +         throw new RuntimeException("InternalDelegate.decrementRefCount(): null pojoReference.");
   
         // need to update it.
  -      put(originalFqn, AOPInstance.KEY, aopInstance);
  +      put(originalFqn, PojoReference.KEY, pojoReference);
         return count;
      }
   
  -   static boolean isReferenced(AOPInstance aopInstance)
  +   static boolean isReferenced(PojoReference pojoReference)
      {
         // If ref counter is greater than 0, we fqn is being referenced.
  -      return (aopInstance.getRefCount() > 0);
  +      return (pojoReference.getRefCount() > 0);
      }
   
      int getRefCount(Fqn fqn) throws CacheException
  @@ -179,16 +179,16 @@
   
      String getRefFqn(Fqn fqn) throws CacheException
      {
  -      AOPInstance aopInstance = getAopInstance(fqn);
  -      return getRefFqn(aopInstance);
  +      PojoReference pojoReference = getAopInstance(fqn);
  +      return getRefFqn(pojoReference);
      }
   
  -   String getRefFqn(AOPInstance aopInstance) throws CacheException
  +   String getRefFqn(PojoReference pojoReference) throws CacheException
      {
  -      if (aopInstance == null)
  +      if (pojoReference == null)
            return null;
   
  -      String aliasFqn = aopInstance.getRefFqn();
  +      String aliasFqn = pojoReference.getInternalFqn();
   
         if (aliasFqn == null || aliasFqn.length() == 0) return null;
   
  @@ -197,71 +197,71 @@
   
      void setRefFqn(Fqn fqn, String internalFqn) throws CacheException
      {
  -      AOPInstance aopInstance = getAopInstance(fqn);
  -      if (aopInstance == null)
  -         aopInstance = new AOPInstance();
  +      PojoReference pojoReference = getAopInstance(fqn);
  +      if (pojoReference == null)
  +         pojoReference = new PojoReference();
   
  -      aopInstance.setRefFqn(internalFqn);
  -      put(fqn, AOPInstance.KEY, aopInstance);
  +      pojoReference.setInternalFqn(internalFqn);
  +      put(fqn, PojoReference.KEY, pojoReference);
      }
   
      void removeRefFqn(Fqn fqn) throws CacheException
      {
  -      AOPInstance aopInstance = getAopInstance(fqn);
  -      if (aopInstance == null)
  -         throw new RuntimeException("InternalDelegate.getRefFqn(): null aopInstance.");
  +      PojoReference pojoReference = getAopInstance(fqn);
  +      if (pojoReference == null)
  +         throw new RuntimeException("InternalDelegate.getInternalFqn(): null pojoReference.");
   
  -      aopInstance.removeRefFqn();
  -      put(fqn, AOPInstance.KEY, aopInstance);
  +      pojoReference.removeInternalFqn();
  +      put(fqn, PojoReference.KEY, pojoReference);
      }
   
      Object getPojo(Fqn fqn) throws CacheException
      {
  -      AOPInstance aopInstance = getAopInstance(fqn);
  -      if (aopInstance == null)
  +      PojoReference pojoReference = getAopInstance(fqn);
  +      if (pojoReference == null)
            return null;
   
  -      return aopInstance.get();
  +      return pojoReference.get();
      }
   
      Object getPojoWithGravitation(Fqn fqn) throws CacheException
      {
         // This is for buddy replication
  -      AOPInstance aopInstance = getAopInstanceWithGravitation(fqn);
  -      if (aopInstance == null)
  +      PojoReference pojoReference = getAopInstanceWithGravitation(fqn);
  +      if (pojoReference == null)
            return null;
   
  -      return aopInstance.get();
  +      return pojoReference.get();
      }
   
      void setPojo(Fqn fqn, Object pojo) throws CacheException
      {
  -      AOPInstance aopInstance = getAopInstance(fqn);
  -      if (aopInstance == null)
  +      PojoReference pojoReference = getAopInstance(fqn);
  +      if (pojoReference == null)
         {
  -         aopInstance = new AOPInstance();
  -         put(fqn, AOPInstance.KEY, aopInstance);
  +         pojoReference = new PojoReference();
  +         put(fqn, PojoReference.KEY, pojoReference);
         }
   
  -      aopInstance.set(pojo);
  +      pojoReference.set(pojo);
         // No need to do a cache put since pojo is transient anyway.
      }
   
  -   static void setPojo(AOPInstance aopInstance, Object pojo)
  +   static void setPojo(PojoReference pojoReference, Object pojo)
      {
         // No need to do a cache put since pojo is transient anyway.
  -      aopInstance.set(pojo);
  +      pojoReference.set(pojo);
      }
   
  -   void setPojo(Fqn fqn, Object pojo, AOPInstance aopInstance) throws CacheException
  +   void setPojo(Fqn fqn, Object pojo, PojoReference pojoReference) throws CacheException
      {
  -      if (aopInstance == null)
  +      if (pojoReference == null)
         {
  -         aopInstance = new AOPInstance();
  -         put(fqn, AOPInstance.KEY, aopInstance);
  +         pojoReference = new PojoReference();
  +         put(fqn, PojoReference.KEY, pojoReference);
         }
   
  -      aopInstance.set(pojo);
  +      pojoReference.set(pojo);
         // No need to do a cache put since pojo is transient anyway.
      }
   
  @@ -293,7 +293,7 @@
         DataNode node = cache_.peek(fqn);
         if (node == null) return false;
   
  -      if (node.get(AOPInstance.KEY) != null)
  +      if (node.get(PojoReference.KEY) != null)
            return true;
         else
            return false;
  @@ -301,7 +301,7 @@
   
      void removeInternalAttributes(Fqn fqn) throws CacheException
      {
  -      cache_.remove(fqn, AOPInstance.KEY);
  +      cache_.remove(fqn, PojoReference.KEY);
         cache_.remove(fqn, CLASS_INTERNAL);
      }
   
  @@ -382,7 +382,7 @@
   
      Fqn getNextFqnInLine(Fqn currentFqn) throws CacheException
      {
  -      AOPInstance ai = getAopInstance(currentFqn);
  +      PojoReference ai = getAopInstance(currentFqn);
         return ai.getAndRemoveFirstFqnInList();
      }
   
  
  
  
  1.8       +6 -6      JBossCache/src-50/org/jboss/cache/pojo/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/ObjectGraphHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- ObjectGraphHandler.java	11 Jul 2006 09:07:40 -0000	1.7
  +++ ObjectGraphHandler.java	12 Jul 2006 13:28:25 -0000	1.8
  @@ -24,7 +24,7 @@
    *
    * @author Ben Wang
    *         Date: Aug 4, 2005
  - * @version $Id: ObjectGraphHandler.java,v 1.7 2006/07/11 09:07:40 bwang Exp $
  + * @version $Id: ObjectGraphHandler.java,v 1.8 2006/07/12 13:28:25 bwang Exp $
    */
   class ObjectGraphHandler
   {
  @@ -99,8 +99,8 @@
         boolean isTrue = false;
   
         // Note this is actually the aliasFqn, not the real fqn!
  -      AOPInstance aopInstance = internal_.getAopInstance(fqn);
  -      String refFqn = internal_.getRefFqn(aopInstance);
  +      PojoReference pojoReference = internal_.getAopInstance(fqn);
  +      String refFqn = internal_.getRefFqn(pojoReference);
         // check if this is a refernce
         if (refFqn != null)
         {
  @@ -114,7 +114,7 @@
            isTrue = true;
         } else
         {
  -         if (internal_.isReferenced(aopInstance))
  +         if (internal_.isReferenced(pojoReference))
            {
               // This node is currently referenced by others. We will relocate it to the next in line,
               // and update the indirectFqnMap
  @@ -177,7 +177,7 @@
         synchronized (refFqn)
         {  // we lock the internal fqn here so no one else has access.
            // Decrement ref counting on the internal node
  -         if (decrementRefCount(Fqn.fromString(refFqn), fqn) == AOPInstance.INITIAL_COUNTER_VALUE)
  +         if (decrementRefCount(Fqn.fromString(refFqn), fqn) == PojoReference.INITIAL_COUNTER_VALUE)
            {
               // 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.
  @@ -228,7 +228,7 @@
      private int decrementRefCount(Fqn originalFqn, Fqn referencingFqn) throws CacheException
      {
         int count = 0;
  -      if ((count = internal_.decrementRefCount(originalFqn, referencingFqn)) == (AOPInstance.INITIAL_COUNTER_VALUE + 1))
  +      if ((count = internal_.decrementRefCount(originalFqn, referencingFqn)) == (PojoReference.INITIAL_COUNTER_VALUE + 1))
         {
            internal_.removeIndirectFqn(originalFqn.toString());
         }
  
  
  
  1.2       +17 -17    JBossCache/src-50/org/jboss/cache/pojo/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/PojoCacheDelegate.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- PojoCacheDelegate.java	11 Jul 2006 09:07:40 -0000	1.1
  +++ PojoCacheDelegate.java	12 Jul 2006 13:28:25 -0000	1.2
  @@ -103,7 +103,7 @@
      {
         // the class attribute is implicitly stored as an immutable read-only attribute
         Class clazz = internal_.peekAopClazz(fqn);
  -      //  clazz and aopInstance can be not null if this node is the replicated brother node.
  +      //  clazz and pojoReference can be not null if this node is the replicated brother node.
         if (clazz == null)
            return null;
   
  @@ -117,10 +117,10 @@
         if ((obj = graphHandler_.objectGraphGet(fqn)) != null)
            return obj; // retrieved from internal ref node. We are done.
   
  -      AOPInstance aopInstance = internal_.getAopInstance(fqn);
  -      if (aopInstance == null)
  +      PojoReference pojoReference = internal_.getAopInstance(fqn);
  +      if (pojoReference == null)
         {
  -         throw new RuntimeException("PojoCacheDelegate._getObject(): null AOPInstance.");
  +         throw new RuntimeException("PojoCacheDelegate._getObject(): null PojoReference.");
         }
   
         if (Advised.class.isAssignableFrom(clazz))
  @@ -137,7 +137,7 @@
            // Insert interceptor at runtime
            InstanceAdvisor advisor = ((Advised) obj)._getInstanceAdvisor();
            CacheFieldInterceptor interceptor = new CacheFieldInterceptor(cache_, fqn, type);
  -         interceptor.setAopInstance(aopInstance);
  +         interceptor.setAopInstance(pojoReference);
            util_.attachInterceptor(obj, advisor, interceptor, observer_);
         } else
         { // Must be Collection classes. We will use aop.ClassProxy instance instead.
  @@ -157,7 +157,7 @@
            }
         }
   
  -      InternalDelegate.setPojo(aopInstance, obj);
  +      InternalDelegate.setPojo(pojoReference, obj);
         return obj;
      }
   
  @@ -315,10 +315,10 @@
            {
               return false;
            }
  -         AOPInstance aopInstance = interceptor.getAopInstance();
  +         PojoReference pojoReference = interceptor.getAopInstance();
            // Check if there is cross referenced.
  -         if (aopInstance.getRefCount() != 0) return true; // I have been referenced
  -         if (aopInstance.getRefFqn() != null) return true; // I am referencing others
  +         if (pojoReference.getRefCount() != 0) return true; // I have been referenced
  +         if (pojoReference.getInternalFqn() != null) return true; // I am referencing others
   
            boolean hasFieldAnnotation = hasAnnotation(obj.getClass(), ((Advised) obj)._getAdvisor(), type);
            // Check the fields
  @@ -376,11 +376,11 @@
   
            InstanceAdvisor advisor = ((ClassProxy) obj)._getInstanceAdvisor();
            BaseInterceptor interceptor = (BaseInterceptor) AopUtil.findCollectionInterceptor(advisor);
  -         AOPInstance aopInstance = interceptor.getAopInstance();
  -         if (aopInstance == null) return false; // safeguard
  +         PojoReference pojoReference = interceptor.getAopInstance();
  +         if (pojoReference == null) return false; // safeguard
            // Check if there is cross referenced.
  -         if (aopInstance.getRefCount() != 0) return true; // I have been referenced
  -         if (aopInstance.getRefFqn() != null) return true; // I am referencing others
  +         if (pojoReference.getRefCount() != 0) return true; // I have been referenced
  +         if (pojoReference.getInternalFqn() != null) return true; // I am referencing others
            // iterate thru the keys
            if (obj instanceof Map)
            {
  @@ -419,13 +419,13 @@
         // Let's do batch update via Map instead
         Map map = new HashMap();
         // Always initialize the ref count so we can mark this as an AopNode.
  -      AOPInstance aopInstance = InternalDelegate.initializeAopInstance();
  +      PojoReference pojoReference = InternalDelegate.initializeAopInstance();
         // Insert interceptor at runtime
         CacheFieldInterceptor interceptor = new CacheFieldInterceptor(cache_, fqn, type);
  -      interceptor.setAopInstance(aopInstance);
  +      interceptor.setAopInstance(pojoReference);
         util_.attachInterceptor(obj, advisor, interceptor, observer_);
   
  -      map.put(AOPInstance.KEY, aopInstance);
  +      map.put(PojoReference.KEY, pojoReference);
         // This is put into map first.
         InternalDelegate.putAopClazz(type.getType(), map);
         // we will do it recursively.
  @@ -476,7 +476,7 @@
         // Use option to skip locking since we have parent lock already.
         cache_.put(fqn, map, internal_.getLockOption());
         // This is in-memory operation only
  -      InternalDelegate.setPojo(aopInstance, obj);
  +      InternalDelegate.setPojo(pojoReference, obj);
   
         for (Object o : subPojoMap.keySet())
         {
  
  
  
  1.4       +4 -4      JBossCache/src-50/org/jboss/cache/pojo/SerializableObjectHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SerializableObjectHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src-50/org/jboss/cache/pojo/SerializableObjectHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- SerializableObjectHandler.java	27 Jun 2006 06:19:17 -0000	1.3
  +++ SerializableObjectHandler.java	12 Jul 2006 13:28:25 -0000	1.4
  @@ -20,7 +20,7 @@
    * Handle Serializable object cache management.
    *
    * @author Ben Wang
  - * @version $Id: SerializableObjectHandler.java,v 1.3 2006/06/27 06:19:17 bwang Exp $
  + * @version $Id: SerializableObjectHandler.java,v 1.4 2006/07/12 13:28:25 bwang Exp $
    */
   class SerializableObjectHandler
   {
  @@ -96,9 +96,9 @@
         internal_.putAopClazz(obj.getClass(), map);
   
         // Special optimization here.
  -      AOPInstance aopInstance = new AOPInstance();
  -      aopInstance.set(obj);
  -      map.put(AOPInstance.KEY, aopInstance);
  +      PojoReference pojoReference = new PojoReference();
  +      pojoReference.set(obj);
  +      map.put(PojoReference.KEY, pojoReference);
   
         /*
         if(cache_.isMarshallNonSerializable())
  
  
  
  1.1      date: 2006/07/12 13:28:25;  author: bwang;  state: Exp;JBossCache/src-50/org/jboss/cache/pojo/PojoReference.java
  
  Index: PojoReference.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.cache.pojo;
  
  import org.jboss.cache.Fqn;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.List;
  
  /** POJO class metadata information.
   * When an object is looked up or put in PojoCache, this object will be advised with a CacheFieldInterceptor.
   * The underlying cache stores a reference to this object (for example to update the instance variables, etc.).
   * Since this reference need to be transactional but never replicated (the reference is only valid
   * within the VM this reference is thus stored into an PojoReference (as a transient field).
   * In addition, this instance also serves as a metadata for PojoCache. E.g., it has a reference counting for
   * multiple references and reference FQN.
   *
   * @author Ben Wang
   */
  public class PojoReference implements Serializable // Externalizable is no more efficient
  {
  //    protected static Log log=LogFactory.getLog(PojoReference.class.getName());
     public static final Object KEY = "PojoReference";
     public static final int INITIAL_COUNTER_VALUE = -1;
  
     static final long serialVersionUID = 6492134565825613209L;
  
     // The instance is transient to avoid replication outside the VM
     private transient Object instance_;
  
     // If not null, it signifies that this is a reference that points to this fqn.
     // Note that this will get replicated.
     private String internalFqn_ = null;
  
     // Reference counting. THis will get replicated as well. This keep track of number of
     // other instances that referenced this fqn.
     private int refCount_ = INITIAL_COUNTER_VALUE;
  
     // List of fqns that reference this fqn. Assume list size is not big since it may not be efficient.
     private List referencedBy_ = null;
  
     public PojoReference()
     {
     }
  
     public PojoReference(Object instance)
     {
        set(instance);
     }
  
     Object get()
     {
        return instance_;
     }
  
     void set(Object instance)
     {
        instance_ = instance;
     }
  
     String getInternalFqn()
     {
        return internalFqn_;
     }
  
     void setInternalFqn(String refFqn)
     {
        internalFqn_ = refFqn;
     }
  
     void removeInternalFqn()
     {
        internalFqn_ = null;
     }
  
     synchronized int incrementRefCount(Fqn sourceFqn)
     {
        if(sourceFqn != null)
        {
           if (referencedBy_ == null)
           {
              referencedBy_ = new ArrayList();
           }
  
           if (referencedBy_.contains(sourceFqn))
              throw new IllegalStateException("PojoReference.incrementRefCount(): source fqn: " +
                      sourceFqn + " is already present.");
  
           referencedBy_.add(sourceFqn);
        }
        refCount_ += 1;
  //logger_.info("incrementRefCount(): current ref count " +refCount_);
        return refCount_;
     }
  
     synchronized int decrementRefCount(Fqn sourceFqn)
     {
        if(sourceFqn != null)
        {
           if (!referencedBy_.contains(sourceFqn))
              throw new IllegalStateException("PojoReference.decrementRefCount(): source fqn: " +
                      sourceFqn + " is not present.");
  
           referencedBy_.remove(sourceFqn);
        }
  
        refCount_ -= 1;
  //logger_.info("decrementRefCount(): current ref count " +refCount_);
        return refCount_;
     }
  
     synchronized int getRefCount()
     {
        return refCount_;
     }
  
     synchronized Fqn getAndRemoveFirstFqnInList()
     {
        return (Fqn) referencedBy_.remove(0);
     }
  
     synchronized void addXFqnIntoList(Fqn fqn)
     {
        referencedBy_.add(0, fqn);
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list