baliuka     02/04/20 03:30:18

  Modified:    simplestore/docs developers-guide.html
               simplestore/src/java/org/apache/commons/simplestore/persistence
                        Context.java PersistenceManager.java Storage.java
               simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        AbstractStorage.java ContextImpl.java
                        DBStorage.java JDBMStorage.java
                        PersistenceManagerImpl.java PersistentProxy.java
               simplestore/src/test/org/apache/commons/simplestore
                        TestSample.java
  Added:       simplestore/src/java/org/apache/commons/simplestore/persistence
                        EnumeratorCallback.java
  Log:
  
  
  Revision  Changes    Path
  1.5       +8 -2      jakarta-commons-sandbox/simplestore/docs/developers-guide.html
  
  Index: developers-guide.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/docs/developers-guide.html,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- developers-guide.html     14 Apr 2002 13:42:45 -0000      1.4
  +++ developers-guide.html     20 Apr 2002 10:30:18 -0000      1.5
  @@ -382,8 +382,14 @@
    contains all information for invalid property value.
   </p>
   <a name='interceptors'><h3>Interceptors</h3></a>
  -<p>
  - Custom interceptors for security and logging are planed.
  +<p>    
  +Interceptor calls Context  before invoking any public or protected method on 
persistent object.
  +<b>onInvoke</b> can be used for security checks or validation.
  +Any <b>Runtime</b> exeption  aborts method execution.
  +<code> 
  +   <b>public void</b> onInvoke(java.lang.Object object, java.lang.reflect.Method 
method, Object[] args);
  +</code>
  +
   </p>
   <hr style='color:navy'>
    <div align="center"><font color="#525D76" size="-1"><em>
  
  
  
  1.5       +13 -1     
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/Context.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Context.java      23 Mar 2002 14:54:52 -0000      1.4
  +++ Context.java      20 Apr 2002 10:30:18 -0000      1.5
  @@ -74,7 +74,7 @@
    * </pre>
    * @author Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - * @version $Id: Context.java,v 1.4 2002/03/23 14:54:52 baliuka Exp $
  + * @version $Id: Context.java,v 1.5 2002/04/20 10:30:18 baliuka Exp $
    */
   
   public interface Context {
  @@ -105,7 +105,19 @@
       */   
      public OIDGenerator getOIDGenerator();
      
  +   /** Returns instaled TypeConverter
  +    * @return converter
  +    */   
      public TypeConverter getTypeConverter();
  +   
  +   /** interceptor calls this method before invoking any public
  +    * or protected method on persistent object
  +    * @param object persistent
  +    * @param method intercepted method
  +    * @param args params
  +    */
   
  +   public void onInvoke(java.lang.Object object, java.lang.reflect.Method method, 
Object[] args);
  +   
   }
   
  
  
  
  1.5       +4 -1      
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/PersistenceManager.java
  
  Index: PersistenceManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/PersistenceManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PersistenceManager.java   14 Apr 2002 13:42:45 -0000      1.4
  +++ PersistenceManager.java   20 Apr 2002 10:30:18 -0000      1.5
  @@ -72,7 +72,7 @@
    *
    * @author Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - * @version $Id: PersistenceManager.java,v 1.4 2002/04/14 13:42:45 baliuka Exp $
  + * @version $Id: PersistenceManager.java,v 1.5 2002/04/20 10:30:18 baliuka Exp $
    */
   public interface PersistenceManager {
   
  @@ -128,6 +128,9 @@
        * @return Collection persistent objects
        */    
       public java.util.Set findAll(Class clasz) throws StorageException; 
  +    
  +    
  +    public void enumerate(Class clasz, EnumeratorCallback callback)throws 
StorageException; 
   
       /** Makes object removed, object becomes invalid after commit
        * @param pc Persistent
  
  
  
  1.8       +5 -2      
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/Storage.java
  
  Index: Storage.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/Storage.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Storage.java      14 Apr 2002 13:42:45 -0000      1.7
  +++ Storage.java      20 Apr 2002 10:30:18 -0000      1.8
  @@ -63,7 +63,7 @@
    *
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: Storage.java,v 1.7 2002/04/14 13:42:45 baliuka Exp $
  + *@version    $Id: Storage.java,v 1.8 2002/04/20 10:30:18 baliuka Exp $
    */
   
   public interface Storage extends Spi{
  @@ -79,7 +79,7 @@
        * @throws StorageException on storage error
        * @return  set of persistent objects
        */    
  -    public Set retrieveAll(Class clasz) throws StorageException;
  +    //public Set retrieveAll(Class clasz) throws StorageException;
       
       /**
        * retrieve object by OID
  @@ -98,6 +98,9 @@
        * @return set of persistent objects
        */    
       public java.util.Collection retrieve(Class clasz, int index, Object 
value)throws StorageException;
  +    
  +    
  +    public void enumerate(Class clasz, EnumeratorCallback callback)throws 
StorageException; 
       
   }
   
  
  
  
  1.1                  
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/EnumeratorCallback.java
  
  Index: EnumeratorCallback.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;
  
  import java.util.Set;
  import org.apache.commons.simplestore.cache.Cache;
  
  /** 
   * @author Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
   *      [EMAIL PROTECTED]</a>
   * @version $Id: EnumeratorCallback.java,v 1.1 2002/04/20 10:30:18 baliuka Exp $
   */
  public interface EnumeratorCallback {
      
      public boolean nextObject( Object object );
      
  }
  
  
  
  1.10      +5 -1      
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/AbstractStorage.java
  
  Index: AbstractStorage.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/AbstractStorage.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractStorage.java      14 Apr 2002 13:42:45 -0000      1.9
  +++ AbstractStorage.java      20 Apr 2002 10:30:18 -0000      1.10
  @@ -60,6 +60,7 @@
   import org.apache.commons.simplestore.persistence.StorageException;
   import org.apache.commons.simplestore.persistence.TransactionManager;
   import org.apache.commons.simplestore.persistence.SimplestoreException;
  +import org.apache.commons.simplestore.persistence.EnumeratorCallback;
   
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -69,7 +70,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: AbstractStorage.java,v 1.9 2002/04/14 13:42:45 baliuka Exp $
  + *@version    $Id: AbstractStorage.java,v 1.10 2002/04/20 10:30:18 baliuka Exp $
    */
   
   public abstract class AbstractStorage
  @@ -183,6 +184,9 @@
       public java.util.Collection getTransactionalObjects() {
           throw new java.lang.NoSuchMethodError();
       }
  +    
  +   abstract  public void enumerate(Class clasz, EnumeratorCallback callback) throws 
StorageException ;
  +    
       
   }
   
  
  
  
  1.5       +4 -1      
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/ContextImpl.java
  
  Index: ContextImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/ContextImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContextImpl.java  3 Apr 2002 18:17:08 -0000       1.4
  +++ ContextImpl.java  20 Apr 2002 10:30:18 -0000      1.5
  @@ -62,7 +62,7 @@
    *
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *     [EMAIL PROTECTED]</a>
  - *@version    $Id: ContextImpl.java,v 1.4 2002/04/03 18:17:08 baliuka Exp $
  + *@version    $Id: ContextImpl.java,v 1.5 2002/04/20 10:30:18 baliuka Exp $
    */
   public class ContextImpl implements Context {
       
  @@ -115,6 +115,9 @@
       
       public TypeConverter getTypeConverter() {
           return typeConverter;
  +    }
  +    
  +    public void onInvoke(java.lang.Object object, java.lang.reflect.Method method, 
Object[] args) {
       }
       
   }
  
  
  
  1.18      +45 -31    
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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DBStorage.java    14 Apr 2002 13:42:45 -0000      1.17
  +++ DBStorage.java    20 Apr 2002 10:30:18 -0000      1.18
  @@ -63,6 +63,7 @@
   import org.apache.commons.simplestore.persistence.StorageException;
   import org.apache.commons.simplestore.persistence.Context;
   import org.apache.commons.simplestore.persistence.IllegalTransactionStateException;
  +import org.apache.commons.simplestore.persistence.EnumeratorCallback;
   
   import java.lang.reflect.Method;
   import java.sql.Connection;
  @@ -84,7 +85,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: DBStorage.java,v 1.17 2002/04/14 13:42:45 baliuka Exp $
  + *@version    $Id: DBStorage.java,v 1.18 2002/04/20 10:30:18 baliuka Exp $
    */
   public class DBStorage extends AbstractStorage implements 
org.apache.commons.simplestore.tools.Constants {
       
  @@ -149,7 +150,9 @@
                           for (int i = 1; i <= cnt; i++) {
                               String name = rsmd.getColumnName(i);
                               Object val = rs.getObject(i);
  -                            eh.nextResult(i, name, val, rsmd.getColumnType(i));
  +                            if(! eh.nextResult(i, name, val, 
rsmd.getColumnType(i))){
  +                                break;
  +                            }
                           }
                       }
                       
  @@ -194,17 +197,17 @@
           ResultSetHandler rsh =
           new ResultSetHandler() {
               
  -            public void nextResult(int index, String name, Object value, int type) 
throws StorageException {
  +            public boolean nextResult(int index, String name, Object value, int 
type) throws StorageException {
                   
                   try {
                       if ( name.equalsIgnoreCase(mClass.getOIDName())) {
                           //OID is known
  -                        return;
  +                        return true;
                       }
                       
                       int propIndex =  mClass.getPropertyIndex( name );
                       props[ propIndex ] = value;
  -                    
  +                    return true;
                   } catch (Throwable t) {
                       t.printStackTrace();
                       throw new StorageException(t.getMessage(), 
t.fillInStackTrace());
  @@ -222,7 +225,7 @@
           return result;
       }
       
  -    public Set retrieveAll(final Class clasz) throws StorageException {
  +    public void enumerate(final Class clasz, final EnumeratorCallback callback) 
throws StorageException {
           
           final MetaClass mClass =  context.getMetaClass(clasz);
           final String sql = "SELECT "+ mClass.getOIDName() + " AS " + INTERNAL_OID + 
", * FROM " + mClass.getName();
  @@ -233,26 +236,19 @@
           for( java.util.Iterator i = tObjects.iterator(); i.hasNext(); ){
               MetaObject mo = (MetaObject)i.next();
               if( mo.getPersistentClass().equals(clasz) ){
  -                objects.add( mo.getObject() );
  +                objects.add(mo.getObject());
  +                if(! callback.nextObject(mo.getObject()))
  +                    return;
               }
           }
           
           
  -        excecute( sql, null, new QueryHandler(objects, clasz));
  +        excecute( sql, null, new QueryHandler(objects,clasz,callback));
  +        
           
  -        return objects;
       }
       
       
  -    public Set query(final Class clasz, String proc, Object[] args) throws 
StorageException {
  -        
  -        final Set objects = new HashSet();
  -        proc = procedures.getProperty(proc);
  -        
  -        excecute( proc, args, new QueryHandler(objects, clasz));
  -        
  -        return objects;
  -    }
       
       
       public void storeObject(MetaObject properties) throws StorageException {
  @@ -333,9 +329,9 @@
           
       }
       
  -   /**
  -    * this method doe's not removes object from cache  
  -    */
  +    /**
  +     * this method doe's not removes object from cache
  +     */
       
       protected void removeObject(MetaObject obj) throws StorageException {
           
  @@ -423,26 +419,38 @@
           }
           
           
  -        excecute( sql, new Object[]{value}, new QueryHandler(objects, clasz));
  +        excecute( sql, new Object[]{value}, new QueryHandler(objects, clasz,
  +        new EnumeratorCallback(){
  +            
  +            public boolean nextObject(Object object){
  +                return true;
  +            }
  +            
  +        }
  +        )
  +        );
           
           return objects;
           
           
       }
       
  +    
       class QueryHandler implements ResultSetHandler {
           Object props[];
           Set objects;
           MetaClass mClass ;
           java.beans.PropertyDescriptor[] descriptors;
  +        EnumeratorCallback callback;
           
  -        QueryHandler(Set objects, Class clasz) {
  +        QueryHandler(Set objects, Class clasz,EnumeratorCallback callback) {
               this.objects = objects;
               this.mClass =  context.getMetaClass(clasz);
               this.descriptors = mClass.getProperties();
  +            this.callback = callback;
           }
           
  -        public void nextResult(int index, String name, Object value, int type) 
throws StorageException {
  +        public boolean nextResult(int index, String name, Object value, int type) 
throws StorageException {
               try {
                   name = name.toUpperCase();
                   if (index == 1) {
  @@ -450,22 +458,28 @@
                       Persistent p = (Persistent) context.getCache().get(value);
                       if ( p != null ) {
                           props = null;
  -                        objects.add(p);
  -                        return;
  +                        if( objects.add(p)){
  +                            return callback.nextObject(p);
  +                        }
                       }
                       p = mClass.newInstance( value );
                       MetaObject pc = p.getMetaObject();
                       props = pc.getProperties();
  -                    objects.add(p);
  -                    context.getCache().put(value,p);
  -                    return;
  +                    if( objects.add(p)){
  +                        context.getCache().put(value,p);
  +                        return callback.nextObject(p);
  +                    }
  +                    
  +                    
                   }
                   
                   if ( name.equals( mClass.getOIDName() ) || props == null) {
  -                    return;
  +                    return true;
                   }
                   
                   props[  mClass.getPropertyIndex( name ) ] = value ;
  +              
  +                return true;
                   
               } catch (Throwable t) {
                   t.printStackTrace();
  @@ -476,7 +490,7 @@
       
       
       interface ResultSetHandler {
  -        public void nextResult(int index, String name, Object value, int type) 
throws StorageException;
  +        public boolean nextResult(int index, String name, Object value, int type) 
throws StorageException;
       }
       
   }
  
  
  
  1.2       +14 -5     
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/JDBMStorage.java
  
  Index: JDBMStorage.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/JDBMStorage.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JDBMStorage.java  24 Mar 2002 09:12:33 -0000      1.1
  +++ JDBMStorage.java  20 Apr 2002 10:30:18 -0000      1.2
  @@ -63,6 +63,7 @@
   import org.apache.commons.simplestore.persistence.StorageException;
   import org.apache.commons.simplestore.persistence.Context;
   import org.apache.commons.simplestore.persistence.IllegalTransactionStateException;
  +import org.apache.commons.simplestore.persistence.EnumeratorCallback;
   
   import jdbm.JDBMEnumeration;
   import jdbm.JDBMHashtable;
  @@ -93,7 +94,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: JDBMStorage.java,v 1.1 2002/03/24 09:12:33 baliuka Exp $
  + *@version    $Id: JDBMStorage.java,v 1.2 2002/04/20 10:30:18 baliuka Exp $
    */
   
   public class JDBMStorage extends AbstractStorage implements 
org.apache.commons.simplestore.tools.Constants {
  @@ -236,7 +237,7 @@
           
       }
       
  -    public Set retrieveAll(Class clasz) throws StorageException {
  +     public void enumerate(final Class clasz, final EnumeratorCallback callback) 
throws StorageException {
           try{
               BTree tree = getTree(
               clasz.getName()
  @@ -247,7 +248,11 @@
               for( java.util.Iterator i = tObjects.iterator(); i.hasNext(); ){
                   MetaObject mo = (MetaObject)i.next();
                   if( mo.getPersistentClass().equals(clasz) ){
  -                    objects.add( mo.getObject() );
  +                    if(objects.add( mo.getObject() )){
  +                     if(!callback.nextObject( mo.getObject() ) ){
  +                        return;
  +                     }
  +                    }
                   }
               }
               
  @@ -256,9 +261,12 @@
               while ( browser.getNext( tuple ) ) {
                   Object id = tuple.getKey();
                   Persistent pc = (Persistent)retrieveObject(clasz,id);
  -                objects.add( pc );
  +                if( objects.add( pc ) ){
  +                     if(!callback.nextObject( pc ) ){
  +                        return;
  +                     }
  +             }
               }
  -            return objects;
           }catch(java.io.IOException ioe){
               throw new StorageException(ioe.getMessage(),ioe);
           }
  @@ -296,5 +304,6 @@
       public void storeObject(MetaObject properties) throws StorageException {
           createObject(properties);
       }
  +    
       
   }
  
  
  
  1.3       +20 -2     
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistenceManagerImpl.java
  
  Index: PersistenceManagerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/persistence/impl/PersistenceManagerImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PersistenceManagerImpl.java       23 Mar 2002 14:54:53 -0000      1.2
  +++ PersistenceManagerImpl.java       20 Apr 2002 10:30:18 -0000      1.3
  @@ -64,6 +64,7 @@
   import org.apache.commons.simplestore.persistence.TransactionManager;
   import org.apache.commons.simplestore.persistence.Context;
   import org.apache.commons.simplestore.persistence.PersistenceManager;
  +import org.apache.commons.simplestore.persistence.EnumeratorCallback;
   
   import java.math.BigInteger;
   import java.util.HashMap;
  @@ -72,7 +73,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: PersistenceManagerImpl.java,v 1.2 2002/03/23 14:54:53 baliuka 
Exp $
  + *@version    $Id: PersistenceManagerImpl.java,v 1.3 2002/04/20 10:30:18 baliuka 
Exp $
    */
   
   public class PersistenceManagerImpl implements PersistenceManager{
  @@ -118,7 +119,18 @@
       }
   
       public Set findAll(Class clasz) throws StorageException {
  -        return context.getStorage().retrieveAll(clasz);
  +      final java.util.Set set = new java.util.HashSet();
  +       context.getStorage().enumerate(clasz, 
  +        
  +        new EnumeratorCallback(){
  +           public boolean nextObject( Object object ){
  +            set.add(object);
  +            return true;
  +          }
  +       }
  +        
  +       );
  +        return set; 
       }
   
       public void removeInstance(Object pc) {
  @@ -138,6 +150,12 @@
           
           return ((Persistent)pc).getMetaObject().isDeleted();
       }
  +    
  +    public void enumerate(Class clasz, EnumeratorCallback callback) throws 
StorageException {
  +         
  +        context.getStorage().enumerate(clasz, callback);
  +         
  +   }
       
   }
   
  
  
  
  1.27      +2 -1      
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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- PersistentProxy.java      13 Apr 2002 13:28:09 -0000      1.26
  +++ PersistentProxy.java      20 Apr 2002 10:30:18 -0000      1.27
  @@ -77,7 +77,7 @@
    *      [EMAIL PROTECTED]</a>
    *@author     Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: PersistentProxy.java,v 1.26 2002/04/13 13:28:09 baliuka Exp $
  + *@version    $Id: PersistentProxy.java,v 1.27 2002/04/20 10:30:18 baliuka Exp $
    */
   public class PersistentProxy
   implements MetaObject,  org.apache.commons.simplestore.tools.Constants ,
  @@ -271,6 +271,7 @@
            }else  return true;
       }
       public Object beforeInvoke(Object obj,Method method,Object[] args) throws 
Throwable{
  +        m_context.onInvoke(obj,method,args);
          return null;
       }
       public Object invoke(Object obj, Method method, Object[] obj2) throws Throwable 
{
  
  
  
  1.22      +3 -3      
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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- TestSample.java   13 Apr 2002 13:28:09 -0000      1.21
  +++ TestSample.java   20 Apr 2002 10:30:18 -0000      1.22
  @@ -72,7 +72,7 @@
   /**
    *@author     Juozas Baliuka <a href="mailto:[EMAIL PROTECTED]";>
    *      [EMAIL PROTECTED]</a>
  - *@version    $Id: TestSample.java,v 1.21 2002/04/13 13:28:09 baliuka Exp $
  + *@version    $Id: TestSample.java,v 1.22 2002/04/20 10:30:18 baliuka Exp $
    */
   public class TestSample extends TestCase implements 
org.apache.commons.simplestore.tools.Constants{
       
  @@ -222,7 +222,7 @@
       
       protected void setUp() throws java.lang.Exception {
           super.setUp();
  -        long time = System.currentTimeMillis();
  +    
           if(true){
               DBPersistenceManagerFactory factory = new DBPersistenceManagerFactory();
               factory.setDriver("org.hsqldb.jdbcDriver");
  @@ -238,7 +238,7 @@
               factory.setMetaResource("org/apache/commons/simplestore/storage.xml");
               pm = factory.getPersistenceManager();
           }
  -        System.out.println("Setup: " + ( System.currentTimeMillis()/1000f - 
time/1000f )  );
  +    
       }
       
   }
  
  
  

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

Reply via email to