db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata DescriptorRepository.java
Date Wed, 04 Aug 2004 00:16:22 GMT
arminw      2004/08/03 17:16:22

  Modified:    src/java/org/apache/ojb/broker/metadata
                        DescriptorRepository.java
  Log:
  remove deprecated method
  cache concrete subclasses now
  
  Revision  Changes    Path
  1.52      +37 -60    db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
  
  Index: DescriptorRepository.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- DescriptorRepository.java	30 Jul 2004 14:58:43 -0000	1.51
  +++ DescriptorRepository.java	4 Aug 2004 00:16:22 -0000	1.52
  @@ -72,6 +72,7 @@
       private transient Map m_multiMappedTableMap;
       private transient Map m_topLevelClassTable;
       private transient Map m_firstConcreteClassMap;
  +    private transient Map m_allConcreteSubClass;
   
       /**
        * Constructor declaration
  @@ -321,80 +322,55 @@
       /**
        *
        * Utility method to discover all concrete subclasses of a given super class. <br>
  -     * This method was introduced in order to get Extent Aware Iterators. <br>
  -     * Attention: The order of the returned collection is not predictable !
  -     * @deprecated use getAllConcreteSubclassDescriptors
  -     * @return a List of Class objects
  -     */
  -    public List getAllConcreteSubclassesOf(ClassDescriptor aCld)
  -    {
  -        // BRJ: set to prevent duplicates
  -        Set concreteSubclasses = new HashSet();
  -        Iterator iter = aCld.getExtentClasses().iterator();
  -
  -        while (iter.hasNext())
  -        {
  -            Class extentClass = (Class) iter.next();
  -            ClassDescriptor extCld = getDescriptorFor(extentClass);
  -            if (aCld.equals(extCld))
  -            {
  -                // prevent infinite recursion caused by cyclic references
  -                continue;
  -            }
  -            if (!extCld.isInterface())
  -            {
  -                concreteSubclasses.add(extentClass);
  -            }
  -
  -            // recurse
  -            concreteSubclasses.addAll(getAllConcreteSubclassesOf(extCld));
  -        }
  -
  -        return new ArrayList(concreteSubclasses);
  -    }
  -
  -    /**
  -     *
  -     * Utility method to discover all concrete subclasses of a given super class. <br>
        * This method was introduced in order to get Extent Aware Iterators.
        *
        * @return a Collection of ClassDescriptor objects
        */
       public Collection getAllConcreteSubclassDescriptors(ClassDescriptor aCld)
       {
  -        // BRJ: As long as we do not have an ordered Set
  -        // duplicates have to be prevented manually.
  -        // a HashSet should not be used because the order is unpredictable
  -        Collection concreteSubclassClds = new ArrayList();
  -        Iterator iter = aCld.getExtentClasses().iterator();
  +        if(m_allConcreteSubClass == null)
  +        {
  +            m_allConcreteSubClass = new HashMap();
  +        }
  +        Collection concreteSubclassClds = (Collection) m_allConcreteSubClass.get(aCld.getClassOfObject());
   
  -        while (iter.hasNext())
  +        if (concreteSubclassClds == null)
           {
  -            Class extentClass = (Class) iter.next();
  -            ClassDescriptor extCld = getDescriptorFor(extentClass);
  -            if (aCld.equals(extCld))
  -            {
  -                // prevent infinite recursion caused by cyclic references
  -                continue;
  -            }
  -            if (!extCld.isInterface())
  +            // BRJ: As long as we do not have an ordered Set
  +            // duplicates have to be prevented manually.
  +            // a HashSet should not be used because the order is unpredictable
  +            concreteSubclassClds = new ArrayList();
  +            Iterator iter = aCld.getExtentClasses().iterator();
  +
  +            while (iter.hasNext())
               {
  -                if (!concreteSubclassClds.contains(extCld))
  +                Class extentClass = (Class) iter.next();
  +                ClassDescriptor extCld = getDescriptorFor(extentClass);
  +                if (aCld.equals(extCld))
                   {
  -                    concreteSubclassClds.add(extCld);
  +                    // prevent infinite recursion caused by cyclic references
  +                    continue;
  +                }
  +                if (!extCld.isInterface() && !extCld.isAbstract())
  +                {
  +                    if (!concreteSubclassClds.contains(extCld))
  +                    {
  +                        concreteSubclassClds.add(extCld);
  +                    }
                   }
  -            }
   
  -            // recurse
  -            Iterator subIter = getAllConcreteSubclassDescriptors(extCld).iterator();
  -            while (subIter.hasNext())
  -            {
  -                ClassDescriptor subCld = (ClassDescriptor)subIter.next();
  -                if (!concreteSubclassClds.contains(subCld))
  +                // recurse
  +                Iterator subIter = getAllConcreteSubclassDescriptors(extCld).iterator();
  +                while (subIter.hasNext())
                   {
  -                    concreteSubclassClds.add(subCld);
  +                    ClassDescriptor subCld = (ClassDescriptor)subIter.next();
  +                    if (!concreteSubclassClds.contains(subCld))
  +                    {
  +                        concreteSubclassClds.add(subCld);
  +                    }
                   }
               }
  +            m_allConcreteSubClass.put(aCld.getClassOfObject(), concreteSubclassClds);
           }
   
           return concreteSubclassClds;
  @@ -504,6 +480,7 @@
           m_multiMappedTableMap = null;
           m_topLevelClassTable = null;
           m_firstConcreteClassMap = null;
  +        m_allConcreteSubClass = null;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message