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 Sat, 03 Jan 2004 12:54:41 GMT
arminw      2004/01/03 04:54:40

  Modified:    src/java/org/apache/ojb/broker/metadata
                        DescriptorRepository.java
  Log:
  fix bug in findFirstConcreteClass method
  
  Revision  Changes    Path
  1.43      +28 -15    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.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- DescriptorRepository.java	19 Dec 2003 16:34:32 -0000	1.42
  +++ DescriptorRepository.java	3 Jan 2004 12:54:40 -0000	1.43
  @@ -109,6 +109,7 @@
   
       private transient Map m_multiMappedTableMap;
       private transient Map m_topLevelClassTable;
  +    private transient Map m_firstConcreteClassMap;
   
       /**
        * Constructor declaration
  @@ -163,6 +164,9 @@
                   // remove extent from super class descriptor
                   cld.removeExtentClass(classname);
                   m_topLevelClassTable.remove(extClass);
  +                // clear map with first concrete classes, because the removed
  +                // extent could be such a first found concrete class
  +                m_firstConcreteClassMap = null;
               }
           }
       }
  @@ -306,29 +310,37 @@
        */
       public ClassDescriptor findFirstConcreteClass(ClassDescriptor cld)
       {
  -        ClassDescriptor result = null;
  -        if(cld.isInterface() || cld.isAbstract())
  +        if(m_firstConcreteClassMap == null)
           {
  -            if(cld.isExtent())
  +            m_firstConcreteClassMap = new HashMap();
  +        }
  +        ClassDescriptor result = (ClassDescriptor) m_firstConcreteClassMap.get(cld.getClassNameOfObject());
  +        if (result == null)
  +        {
  +            if(cld.isInterface() || cld.isAbstract())
               {
  -                List extents = cld.getExtentClasses();
  -                for (int i = 0; i < extents.size(); i++)
  +                if(cld.isExtent())
                   {
  -                    ClassDescriptor extCld = (ClassDescriptor) extents.get(i);
  -                    result = findFirstConcreteClass(extCld);
  -                    if(result != null) break;
  +                    List extents = cld.getExtentClasses();
  +                    for (int i = 0; i < extents.size(); i++)
  +                    {
  +                        Class ext = (Class) extents.get(i);
  +                        result = findFirstConcreteClass(getDescriptorFor(ext));
  +                        if(result != null) break;
  +                    }
                   }
  +                else
  +                {
  +                    LoggerFactory.getDefaultLogger().error("["+this.getClass().getName()+"]
Found interface/abstract class" +
  +                            " in metadata declarations without concrete class: "+cld.getClassNameOfObject());
  +                }
  +                m_firstConcreteClassMap.put(cld.getClassNameOfObject(), result);
               }
               else
               {
  -                LoggerFactory.getDefaultLogger().warn("["+this.getClass().getName()+"]
Found interface/abstract class" +
  -                        " in metadata declarations without concrete class: "+cld.getClassNameOfObject());
  +                result = cld;
               }
           }
  -        else
  -        {
  -            result = cld;
  -        }
           return result;
       }
   
  @@ -492,6 +504,7 @@
       {
           m_multiMappedTableMap = null;
           m_topLevelClassTable = null;
  +        m_firstConcreteClassMap = 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