commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bali...@apache.org
Subject cvs commit: jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore TestAll.java
Date Fri, 07 Jun 2002 18:53:12 GMT
baliuka     2002/06/07 11:53:12

  Modified:    simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        MetaClassImpl.java
               simplestore/src/jdbc/org/apache/commons/simplestore/jdbc
                        DBStorage.java
               simplestore/src/test/org/apache/commons/simplestore
                        TestAll.java
  Log:
  Optimizations
  
  Revision  Changes    Path
  1.16      +2 -1      jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/MetaClassImpl.java
  
  Index: MetaClassImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/MetaClassImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- MetaClassImpl.java	13 Apr 2002 21:51:44 -0000	1.15
  +++ MetaClassImpl.java	7 Jun 2002 18:53:12 -0000	1.16
  @@ -65,7 +65,7 @@
    *
    *@author     Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
    *     baliuka@mwm.lt</a>
  - *@version    $Id: MetaClassImpl.java,v 1.15 2002/04/13 21:51:44 baliuka Exp $
  + *@version    $Id: MetaClassImpl.java,v 1.16 2002/06/07 18:53:12 baliuka Exp $
    */
   public class MetaClassImpl implements MetaClass, org.apache.commons.simplestore.tools.Constants
 {
       
  @@ -322,6 +322,7 @@
                
               for( int i = 0; i < descriptors.length; i++ ){
                
  +                
                    if ( descriptors[i].getReadMethod() != null &&
                     java.lang.reflect.Modifier.isAbstract( descriptors[i].getReadMethod().getModifiers()
)){
                       abstractProps.add(descriptors[i]);
  
  
  
  1.3       +30 -27    jakarta-commons-sandbox/simplestore/src/jdbc/org/apache/commons/simplestore/jdbc/DBStorage.java
  
  Index: DBStorage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/jdbc/org/apache/commons/simplestore/jdbc/DBStorage.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DBStorage.java	6 Jun 2002 17:42:32 -0000	1.2
  +++ DBStorage.java	7 Jun 2002 18:53:12 -0000	1.3
  @@ -77,7 +77,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:baliuka@mwm.lt">
    *      baliuka@mwm.lt</a>
  - *@version    $Id: DBStorage.java,v 1.2 2002/06/06 17:42:32 baliuka Exp $
  + *@version    $Id: DBStorage.java,v 1.3 2002/06/07 18:53:12 baliuka Exp $
    */
   public class DBStorage extends AbstractStorage implements org.apache.commons.simplestore.tools.Constants
{
      
  @@ -180,7 +180,7 @@
                           return true;
                       }
                     
  -                    props[ index ] = value;
  +                    props[ index - 1 ] = value;
                       return true;
                   } catch (Throwable t) {
                       t.printStackTrace();
  @@ -209,16 +209,21 @@
       private String propertyList(MetaClass mclass){
       
           final java.beans.PropertyDescriptor[] beanProps = mclass.getProperties();
  -        
  +               
           StringBuffer names = new StringBuffer();
  -        names.append(mclass.getName());
  +        names.append(mclass.getOIDName());
           for (int i = 0; i < beanProps.length; i++) {
               java.beans.PropertyDescriptor descriptor = beanProps[i];
  -            if (descriptor.getWriteMethod() != null) {
  -                names.append("," + mclass.getPropertyName(i) );
  +            names.append(",");
  +              if(!  descriptor.getPropertyType().
  +                  isAssignableFrom(java.util.Collection.class)){
  +                names.append( mclass.getPropertyName(i) );
  +              }else {
  +                names.append( mclass.getOIDName() );
  +              }
                   
               }
  -        }
  +        
       
           return names.toString() + " ";
       }
  @@ -371,19 +376,12 @@
           
           
           final MetaClass mClass =  context.getMetaClass(clasz);
  -        final String sql = "SELECT "+   propertyList(mClass) +  " FROM " + mClass.getName()
+
  -        " WHERE " + mClass.getPropertyName(index) + "=?";
  +        final String sql = "SELECT "+   propertyList(mClass) +  " FROM " + 
  +            mClass.getName() +
  +           " WHERE " + mClass.getPropertyName(index) + "=?";
           
  -        excecute( sql, new Object[]{value}, new QueryHandler(objects, clasz,
  -        new EnumeratorCallback(){
  -            
  -            public boolean nextObject(Object object){
  -                return true;
  -            }
  -            
  -        }
  -        )
  -        );
  +        excecute( sql, new Object[]{value},
  +                    new QueryHandler(objects, clasz, null ) );
           
       }
       
  @@ -396,10 +394,12 @@
           EnumeratorCallback callback;
           
           QueryHandler(Set objects, Class clasz,EnumeratorCallback callback) {
  +            
               this.objects = objects;
               this.mClass =  context.getMetaClass(clasz);
               this.descriptors = mClass.getProperties();
               this.callback = callback;
  +            
           }
           
           public boolean nextResult(int index,  Object value ) throws StorageException {
  @@ -409,25 +409,28 @@
                       //try to find in cache first
                       Persistent p = (Persistent) context.getCache().get(value);
                       if ( p != null ) {
  -                        props = null;
  -                        if( objects.add(p)){
  -                            return callback.nextObject(p);
  +                        
  +                        if( objects.add(p) && callback != null ){
  +                            callback.nextObject(p);
  +                            return false;
                           }
                       }
  +                    
                       p = mClass.newInstance( value );
                       MetaObject pc = p.getMetaObject();
                       props = pc.getProperties();
  -                    if( objects.add(p)){
  -                        context.getCache().put(value,p);
  -                        return callback.nextObject(p);
  +                    context.getCache().put(value,p);
  +                    
  +                    if( objects.add(p) && callback != null ){
  +                          return callback.nextObject(p);
                       }
                       
                       return true;
                   }
                   
  +               
                   
  -                
  -                props[  index  ] = value ;
  +                props[  index - 1  ] = value ;
                   
                   return true;
                   
  
  
  
  1.15      +2 -2      jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestAll.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TestAll.java	2 Jun 2002 11:53:35 -0000	1.14
  +++ TestAll.java	7 Jun 2002 18:53:12 -0000	1.15
  @@ -59,7 +59,7 @@
   /**
    *@author     Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
    *      g-froehlich@gmx.de</a>
  - *@version    $Id: TestAll.java,v 1.14 2002/06/02 11:53:35 baliuka Exp $
  + *@version    $Id: TestAll.java,v 1.15 2002/06/07 18:53:12 baliuka Exp $
    */
   public class TestAll extends TestCase {
       public TestAll(String testName) {
  @@ -68,7 +68,7 @@
   
       public static Test suite() {
           TestSuite suite = new TestSuite();
  -     //   suite.addTest(TestSample.suite());
  +        suite.addTest(TestSample.suite());
           suite.addTest(TestEnhancer.suite());
          // suite.addTest(TestXmlDbStorage.suite());
           return suite;
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message