baliuka     02/03/16 10:55:45

  Modified:    simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        DBStorage.java MetaClassImpl.java
                        PersistentProxy.java TransactionImpl.java
               simplestore/src/java/org/apache/commons/simplestore/tools
                        Enhancer.java
               simplestore/src/test/org/apache/commons/simplestore
                        TestAll.java TestEnhancer.java TestSample.java
  Added:       simplestore/src/java/org/apache/commons/simplestore/persistence
                        IllegalTransactionStateException.java
               simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        ConnectionFactory.java
  Removed:     simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        AutoCommitTransactionManager.java
  Log:
  bug fixes
  
  Revision  Changes    Path
  1.1                  
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/IllegalTransactionStateException.java
  
  Index: IllegalTransactionStateException.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache Cocoon" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.commons.simplestore.persistence;
  
  
  /**
   *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
   *      [EMAIL PROTECTED]</a>
   *@version    $Id: IllegalTransactionStateException.java,v 1.1 2002/03/16 18:55:45 
baliuka Exp $
   */
  public class IllegalTransactionStateException extends 
java.lang.IllegalStateException {
      
      /**
       * Creates a new instance of <code>IllegalTransactionStateException</code> 
without detail message.
       */
      public IllegalTransactionStateException() {
      }
      
      
      /**
       * Constructs an instance of <code>IllegalTransactionStateException</code> with 
the specified detail message.
       * @param msg the detail message.
       */
      public IllegalTransactionStateException(String msg) {
          super(msg);
      }
  }
  
  
  
  1.12      +13 -7     
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/DBStorage.java
  
  Index: DBStorage.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/DBStorage.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DBStorage.java    14 Mar 2002 19:42:22 -0000      1.11
  +++ DBStorage.java    16 Mar 2002 18:55:45 -0000      1.12
  @@ -62,6 +62,7 @@
   import org.apache.commons.simplestore.persistence.Persistent;
   import org.apache.commons.simplestore.persistence.StorageException;
   import org.apache.commons.simplestore.persistence.Context;
  +import org.apache.commons.simplestore.persistence.IllegalTransactionStateException;
   
   import java.lang.reflect.Method;
   import java.lang.reflect.Proxy;
  @@ -85,7 +86,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: DBStorage.java,v 1.11 2002/03/14 19:42:22 baliuka Exp $
  + *@version    $Id: DBStorage.java,v 1.12 2002/03/16 18:55:45 baliuka Exp $
    */
   public class DBStorage extends AbstractStorage implements 
org.apache.commons.simplestore.tools.Constants {
       
  @@ -93,7 +94,7 @@
        private final static String INTERNAL_OID = "INTERNAL_OID";
       //TODO : must be in MetaClass
       private static Properties procedures = new Properties();
  -    private DataSource ds;
  +    private ConnectionFactory ds;
       private Context context;
       //private MetaClass rootMetaClass = new MetaClassImpl(this);
       /**
  @@ -101,7 +102,7 @@
        *
        *@param  ds
        */
  -    public DBStorage(DataSource ds) {
  +    public DBStorage(ConnectionFactory ds) {
           this.ds = ds;
       }
       
  @@ -260,6 +261,14 @@
           final MetaClass mClass =  context.getMetaClass(clasz);
           final String sql = "SELECT "+ mClass.getOIDName() + " AS " + INTERNAL_OID + 
", * FROM " + mClass.getName();
           final Set objects = new HashSet();
  +      java.util.Collection tObjects = 
context.getTransactionManager().getTransaction().getTransactionalObjects();
  +        for( java.util.Iterator i = tObjects.iterator(); i.hasNext(); ){
  +          MetaObject mo = (MetaObject)i.next();
  +          if( mo.getPersistentClass().equals(clasz) ){
  +              objects.add( mo.getObject() );
  +          }
  +        }
  +    
           
           excecute( sql, null, new QueryHandler(objects, clasz));
           
  @@ -415,10 +424,7 @@
           Connection connection = (Connection) 
context.getTransactionManager().getTransaction().getAttribute(CONNECTION);
           
           if (connection == null) {
  -           // for auto comit, not wery good idea :( 
  -           context.getTransactionManager().getTransaction().begin(); 
  -           connection = (Connection) 
context.getTransactionManager().getTransaction().getAttribute(CONNECTION);
  -           // throw new IllegalStateException("Transaction not Started");
  +              throw new IllegalTransactionStateException("Transaction not Started");
           }
           
           return connection;
  
  
  
  1.12      +8 -7      
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MetaClassImpl.java        14 Mar 2002 19:42:22 -0000      1.11
  +++ MetaClassImpl.java        16 Mar 2002 18:55:45 -0000      1.12
  @@ -65,7 +65,7 @@
    *
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *     [EMAIL PROTECTED]</a>
  - *@version    $Id: MetaClassImpl.java,v 1.11 2002/03/14 19:42:22 baliuka Exp $
  + *@version    $Id: MetaClassImpl.java,v 1.12 2002/03/16 18:55:45 baliuka Exp $
    */
   public class MetaClassImpl implements MetaClass, 
org.apache.commons.simplestore.tools.Constants  {
       
  @@ -253,11 +253,16 @@
           return newInstance( nextOID(), true );
           
       }
  -    
  + 
  +      public Persistent newInstance(Object oid, boolean create, 
java.lang.ClassLoader cl) {
  +        //TODO :
  +        return PersistentProxy.getPersitent(clasz, oid , create , context,cl );
  +    }
  + 
       
       protected Persistent newInstance(Object oid, boolean create) {
           
  -        return PersistentProxy.getPersitent(clasz, oid , create , context );
  +        return  newInstance( oid , create , loader );
       }
       
       /**
  @@ -297,10 +302,6 @@
           
       }
       
  -    public Persistent newInstance(Object oid, boolean create, java.lang.ClassLoader 
cl) {
  -        //TODO :
  -        return PersistentProxy.getPersitent(clasz, oid , create , context );
  -    }
       
       
       
  
  
  
  1.18      +10 -10    
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java
  
  Index: PersistentProxy.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistentProxy.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- PersistentProxy.java      14 Mar 2002 16:45:02 -0000      1.17
  +++ PersistentProxy.java      16 Mar 2002 18:55:45 -0000      1.18
  @@ -78,7 +78,7 @@
    *      [EMAIL PROTECTED]</a>
    *@author     Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: PersistentProxy.java,v 1.17 2002/03/14 16:45:02 baliuka Exp $
  + *@version    $Id: PersistentProxy.java,v 1.18 2002/03/16 18:55:45 baliuka Exp $
    */
   public class PersistentProxy
   implements MetaObject,  org.apache.commons.simplestore.tools.Constants ,
  @@ -130,7 +130,7 @@
       public static Persistent getPersitent( Class persistent,
       Object oid,
       boolean newCreated,
  -    Context context ) {
  +    Context context,ClassLoader loader ) {
       try{    
           
           PersistentProxy handler = new PersistentProxy( persistent, oid,
  @@ -143,7 +143,7 @@
              interfaces = new Class[]{ Persistent.class} ;
           }
           Persistent p = (Persistent)
  -        Enhancer.enhance( 
persistent,null,interfaces,handler,Persistent.class.getClassLoader());
  +        Enhancer.enhance( persistent,null,interfaces,handler,loader);
           
           handler.m_object = p;
           if ( newCreated ) {
  @@ -266,9 +266,9 @@
            if(DEBUG){
              System.out.println("Invoke super:" + method);
            }
  -         if( method.equals(HASH_CODE)  ||
  -             method.equals(TO_STRING)  ||
  -             method.equals(EQUALS)    ){
  +         if( Enhancer.equals(method, HASH_CODE)  ||
  +             Enhancer.equals(method,TO_STRING)  ||
  +             Enhancer.equals(method,EQUALS)    ){
                return false;
            }else  return true;
       }
  @@ -277,14 +277,14 @@
       }
       public Object invoke(Object obj, Method method, Object[] obj2) throws Throwable 
{
           synchronized (this) {
  -            if (GET_META_OBJECT.equals(method)) {
  +            if ( Enhancer.equals(method,GET_META_OBJECT) ) {
                   return this;
  -            } else if (TO_STRING.equals(method)) {
  +            } else if (Enhancer.equals(method,TO_STRING)) {
                   return toString();
  -            } else if (GET_OID.equals(method)) {
  +            } else if (Enhancer.equals(method,GET_OID)) {
                   return m_oid;
                   
  -            } else if (HASH_CODE.equals(method)) {
  +            } else if ( Enhancer.equals(method,HASH_CODE)) {
                   if (m_oid == null) {
                       
                       return new Integer(0);
  
  
  
  1.6       +6 -12     
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/TransactionImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TransactionImpl.java      14 Mar 2002 19:42:22 -0000      1.5
  +++ TransactionImpl.java      16 Mar 2002 18:55:45 -0000      1.6
  @@ -58,6 +58,7 @@
   import org.apache.commons.simplestore.cache.impl.SoftRefMemoryCache;
   import org.apache.commons.simplestore.persistence.InternalTransaction;
   import org.apache.commons.simplestore.persistence.MetaObject;
  +import org.apache.commons.simplestore.persistence.IllegalTransactionStateException;
   
   import java.util.HashMap;
   import java.util.HashSet;
  @@ -68,7 +69,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: TransactionImpl.java,v 1.5 2002/03/14 19:42:22 baliuka Exp $
  + *@version    $Id: TransactionImpl.java,v 1.6 2002/03/16 18:55:45 baliuka Exp $
    */
   
   public class TransactionImpl 
  @@ -194,27 +195,20 @@
       void checkState(boolean b) {
           if (!b) {
               new Exception().printStackTrace();
  -            throw new IllegalStateException("Illegal Transaction state" + 
transaction.getClass().getName());
  +            throw new IllegalTransactionStateException("Illegal Transaction state" 
+ transaction.getClass().getName());
           }
       }
   
       void checkState() {
           int id = getCurrentThreadId();
           if (threadId != id) {
  -            throw new IllegalStateException("Accessed Transaction " + threadId + " 
in " + id);
  +            throw new IllegalTransactionStateException("Accessed Transaction " + 
threadId + " in " + id);
           }
       }
       
       public java.util.Collection getTransactionalObjects() {
           return java.util.Collections.unmodifiableCollection(objects);
       }
  -    protected void finalize()throws Throwable{
  -        try{
  -          checkState(complete);
  -        }catch(Throwable t){
  -           t.printStackTrace();//FATAL
  -           doRollback();
  -        }
  -    }
  -}
  +    
  + }
   
  
  
  
  1.1                  
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/ConnectionFactory.java
  
  Index: ConnectionFactory.java
  ===================================================================
  /*
   * ConnectionFactory.java
   *
   * Created on �e�tadienis, 2002, Kovo 16, 00.43
   */
  
  package org.apache.commons.simplestore.persistence.impl;
  
  /**
   *
   * @author  user
   */
  public interface ConnectionFactory {
      
   public java.sql.Connection getConnection()throws java.sql.SQLException;
   
  }
  
  
  
  1.14      +20 -8     
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Enhancer.java
  
  Index: Enhancer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/tools/Enhancer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Enhancer.java     10 Mar 2002 12:32:30 -0000      1.13
  +++ Enhancer.java     16 Mar 2002 18:55:45 -0000      1.14
  @@ -98,7 +98,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: Enhancer.java,v 1.13 2002/03/10 12:32:30 baliuka Exp $
  + *@version    $Id: Enhancer.java,v 1.14 2002/03/16 18:55:45 baliuka Exp $
    */
   public class Enhancer implements org.apache.bcel.Constants , Constants{
       
  @@ -844,19 +844,22 @@
               this.method = method;
           }
           public boolean equals(Object obj) {
  -            if (obj == null || !(obj instanceof java.lang.reflect.Method)) {
  +            if (obj == null || !(obj instanceof MethodWrapper)) {
                   return false;
               }
  -            return equalsForEnhancer(method, (java.lang.reflect.Method) obj);
  +            return Enhancer.equals(method, ((MethodWrapper) obj).method );
           }
           public int hashCode() {
  -            return method.hashCode();
  +            return method.getName().hashCode();
           }
       }
  -    static boolean equalsForEnhancer(
  -        java.lang.reflect.Method m1,
  +    
  +   public static boolean equals(
  +            java.lang.reflect.Method m1,
           java.lang.reflect.Method m2) {
  +            
           if (m1 == m2) {
  +            
               return true;
           }
           if (m1.getName().equals(m2.getName())) {
  @@ -864,13 +867,22 @@
               Class[] params2 = m2.getParameterTypes();
               if (params1.length == params2.length) {
                   for (int i = 0; i < params1.length; i++) {
  -                    if (params1[i] != params2[i]) {
  -                        return false;
  +                    if (!params1[i].getName().equals( params2[i].getName() ) ) {
  +                              return false;
                       }
                   }
  +             /*  Some veryfier ? 
  +              if(!m1.getReturnType().getName().
  +                   equals(m2.getReturnType().getName()) ){
  +                 throw new java.lang.IllegalStateException(
  +                  "Can't implement:\n" + m1.getDeclaringClass().getName() +
  +                   "\n      and\n" + m2.getDeclaringClass().getName() + "\n"+
  +                     m1.toString() + "\n" + m2.toString());
  +              }*/           
                   return true;
               }
           }
  +     
           return false;
       }
   }
  
  
  
  1.11      +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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestAll.java      14 Mar 2002 15:44:03 -0000      1.10
  +++ TestAll.java      16 Mar 2002 18:55:45 -0000      1.11
  @@ -59,7 +59,7 @@
   /**
    *@author     Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: TestAll.java,v 1.10 2002/03/14 15:44:03 baliuka Exp $
  + *@version    $Id: TestAll.java,v 1.11 2002/03/16 18:55:45 baliuka Exp $
    */
   public class TestAll extends TestCase {
       public TestAll(String testName) {
  @@ -69,7 +69,7 @@
       public static Test suite() {
           TestSuite suite = new TestSuite();
           suite.addTest(TestSample.suite());
  -       //suite.addTest(TestEnhancer.suite());
  +        suite.addTest(TestEnhancer.suite());
           return suite;
       }
   
  
  
  
  1.9       +7 -20     
jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestEnhancer.java
  
  Index: TestEnhancer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestEnhancer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestEnhancer.java 11 Mar 2002 10:37:22 -0000      1.8
  +++ TestEnhancer.java 16 Mar 2002 18:55:45 -0000      1.9
  @@ -64,7 +64,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: TestEnhancer.java,v 1.8 2002/03/11 10:37:22 baliuka Exp $
  + *@version    $Id: TestEnhancer.java,v 1.9 2002/03/16 18:55:45 baliuka Exp $
    */
   public class TestEnhancer  extends TestCase {
       
  @@ -94,6 +94,7 @@
           System.err.println();
       }
       public void testEnhance()throws Throwable{
  +         System.setOut(new java.io.PrintStream(new 
java.io.FileOutputStream("c:\\error")));
           //test enchance vector:
           Object obj = Enhancer.enhance( null, "TESTEnhancer",new 
Class[]{TestPersistent.class},null,
           Thread.currentThread().getContextClassLoader()
  @@ -101,7 +102,7 @@
       
           java.util.Vector vector = (java.util.Vector)Enhancer.enhance(
           java.util.Vector.class,
  -        null,
  +        new Class[]{java.util.List.class},
           
           new MethodInterceptor(){
               
  @@ -109,8 +110,6 @@
               public Object beforeInvoke( Object obj,java.lang.reflect.Method method,
               Object args[] )
               throws java.lang.Throwable{
  -      //          System.err.print("beforeInvoke:" + method);
  -       //         printArgs(args);
                   return null;
               }
               
  @@ -118,29 +117,18 @@
               Object args[], Object retValFromBefore )
               throws java.lang.Throwable{
                   
  -           //     System.err.print("invokeSuper:" + method);
  -             //   printArgs(args);
  -                if( "remove".equals(method.getName()) ) return false;//owerride size
  -                return true;//let super to call this
  +           
  +                return true;
               }
               
               public void afterConstruction(Object obj,Object args[] ){
  -            //    System.err.print("costructed: " + obj);
  -              //  printArgs(args);
                 }
               
           public Object afterReturn(  Object obj,     java.lang.reflect.Method method,
           Object args[],  Object retValFromBefore,
           boolean invokedSuper, Object retValFromSuper,
           java.lang.Throwable e )throws java.lang.Throwable{
  -            if( e != null ){
  -          //      System.err.println("Cauth Exeption from super " + 
obj.getClass().getSuperclass().getName());
  -            //    e.printStackTrace();
  -            //    System.err.println();
  -            }
  -          //  System.err.print("afterReturn:" + method + " returned:" + 
retValFromSuper);
  -          //  printArgs(args);
  -            if( !invokedSuper )return new Boolean(false); //it was "remove"
  +           
               return retValFromSuper;//return the same as supper
           }
           
  @@ -151,12 +139,11 @@
       vector.add(null);
       vector.elements();
       vector.size();
  -    vector.add(this);
       vector.add(value);
       vector.remove(value);
       vector.remove(value);
       vector.contains(value);
  -    vector.get(vector.indexOf("NOTHING"));//must catch exeption in afterReturn
  +    vector.get(0);
       
       
   }
  
  
  
  1.14      +11 -4     
jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestSample.java
  
  Index: TestSample.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/test/org/apache/commons/simplestore/TestSample.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestSample.java   11 Mar 2002 15:40:53 -0000      1.13
  +++ TestSample.java   16 Mar 2002 18:55:45 -0000      1.14
  @@ -60,6 +60,7 @@
   import org.apache.commons.simplestore.persistence.impl.PersistenceManager;
   import org.apache.commons.simplestore.persistence.impl.ContextImpl;
   import org.apache.commons.simplestore.persistence.impl.MetaClassImpl;
  +import org.apache.commons.simplestore.persistence.impl.ConnectionFactory;
   import org.apache.commons.simplestore.persistence.ValidationException;
   import org.apache.commons.simplestore.cache.impl.SoftRefMemoryCache;
   
  @@ -73,7 +74,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: TestSample.java,v 1.13 2002/03/11 15:40:53 baliuka Exp $
  + *@version    $Id: TestSample.java,v 1.14 2002/03/16 18:55:45 baliuka Exp $
    */
   public class TestSample extends TestCase implements 
org.apache.commons.simplestore.tools.Constants{
       
  @@ -227,7 +228,7 @@
           
           MetaClassImpl.parse("org/apache/commons/simplestore/storage.xml");
           
  -        DriverDataSource ds = new DriverDataSource();
  +       final DriverDataSource ds = new DriverDataSource();
           ds.setDriver("org.hsqldb.jdbcDriver");
           ds.setMaxConnections(1);
           ds.setUrl("jdbc:hsqldb:sample");
  @@ -251,8 +252,14 @@
               con.close();
           }
          
  -        MetaClassImpl mclass = new MetaClassImpl();
  -        DBStorage storage = new DBStorage(ds);
  +        MetaClassImpl mclass = new MetaClassImpl( 
MetaClassImpl.class.getClassLoader());
  +        DBStorage storage = new DBStorage( new ConnectionFactory(){
  +           public java.sql.Connection getConnection()throws java.sql.SQLException{
  +             return ds.getConnection();
  +           }   
  +       } 
  +         
  +        );
           ContextImpl context = new ContextImpl(mclass,storage,
                 SoftRefMemoryCache.getInstance(new java.util.HashMap(),0xFF),
                           storage );
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to