db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata DescriptorRepository.java
Date Mon, 10 Nov 2003 19:41:04 GMT
brj         2003/11/10 11:41:04

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
               src/java/org/apache/ojb/broker/metadata
                        DescriptorRepository.java
  Log:
  simplified handling for getting all concrete subclass descriptors
  
  Revision  Changes    Path
  1.51      +10 -11    db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- PersistenceBrokerImpl.java	10 Nov 2003 13:09:27 -0000	1.50
  +++ PersistenceBrokerImpl.java	10 Nov 2003 19:41:04 -0000	1.51
  @@ -504,12 +504,11 @@
               String lastUsedTable = cld.getFullTableName();
               if (cld.isExtent())
               {
  -                Iterator extents = getDescriptorRepository().getAllConcreteSubclassesOf(cld).iterator();
  +                Iterator extents = getDescriptorRepository().getAllConcreteSubclassDescriptors(cld).iterator();
   
                   while (extents.hasNext())
                   {
  -                    Class ec = (Class) extents.next();
  -                    ClassDescriptor extCld = getClassDescriptor(ec);
  +                    ClassDescriptor extCld = (ClassDescriptor) extents.next();
   
                       // read same table only once
                       if (!extCld.getFullTableName().equals(lastUsedTable))
  @@ -1777,11 +1776,12 @@
           // we can lookup all tables of the extent classes:
           if (newObj == null && cld.isExtent())
           {
  -            Iterator extents = getDescriptorRepository().getAllConcreteSubclassesOf(cld).iterator();
  +            Iterator extents = getDescriptorRepository().getAllConcreteSubclassDescriptors(cld).iterator();
               
               while (extents.hasNext())
               {
  -                ClassDescriptor extCld = getClassDescriptor((Class)extents.next());
  +                ClassDescriptor extCld = (ClassDescriptor) extents.next();
  +                
                   newObj = dbAccess.materializeObject(extCld, oid);
                   if (newObj != null)
                   {
  @@ -2533,12 +2533,11 @@
               chainingIter.addIterator(factory.createRsIterator(query, cld, this));
           }
   
  -        Iterator extents = getDescriptorRepository().getAllConcreteSubclassesOf(cld).iterator();
  +        Iterator extents = getDescriptorRepository().getAllConcreteSubclassDescriptors(cld).iterator();
           while (extents.hasNext())
           {
  -            Class ec = (Class) extents.next();
  -            ClassDescriptor extCld = getClassDescriptor(ec);
  -
  +            ClassDescriptor extCld = (ClassDescriptor) extents.next();
  +            
               // read same table only once
               if (chainingIter.containsIteratorForTable(extCld.getFullTableName()))
               {
  @@ -2546,7 +2545,7 @@
               }
               else
               {    
  -                if(logger.isDebugEnabled()) logger.debug("Adding RsIterator of class ["+ec+"]
to ChainingIterator");
  +                if(logger.isDebugEnabled()) logger.debug("Adding RsIterator of class ["+extCld.getClassNameOfObject()+"]
to ChainingIterator");
   
                   // add the iterator to the chaining iterator.
                   chainingIter.addIterator(factory.createRsIterator(query, extCld, this));
  
  
  
  1.39      +31 -3     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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- DescriptorRepository.java	5 Nov 2003 20:33:11 -0000	1.38
  +++ DescriptorRepository.java	10 Nov 2003 19:41:04 -0000	1.39
  @@ -247,8 +247,7 @@
        *
        * Utility method to discover all concrete subclasses of a given super class. <br>
        * This method was introduced in order to get Extent Aware Iterators.
  -     * <b>TODO</b> : use a logger
  -     *
  +     * @deprecated use getAllConcreteSubclassDescriptors
        * @return a List of Class objects
        */
       public List getAllConcreteSubclassesOf(ClassDescriptor aCld)
  @@ -271,6 +270,35 @@
           }
           
           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: set to prevent duplicates
  +        Set concreteSubclassClds = new HashSet();
  +        Iterator iter = aCld.getExtentClasses().iterator();
  +
  +        while (iter.hasNext())
  +        {
  +            Class extentClass = (Class) iter.next();
  +            ClassDescriptor extCld = getDescriptorFor(extentClass);
  +            if (!extCld.isInterface())
  +            {
  +                concreteSubclassClds.add(extCld);
  +            }
  +
  +            // recurse
  +            concreteSubclassClds.addAll(getAllConcreteSubclassDescriptors(extCld));
  +        }
  +
  +        return concreteSubclassClds;
       }
       
       /**
  
  
  

---------------------------------------------------------------------
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