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/xmldb/org/apache/commons/simplestore/xmldb XmlDbStorage.java
Date Tue, 06 Aug 2002 18:45:13 GMT
baliuka     2002/08/06 11:45:13

  Modified:    simplestore/src/java/org/apache/commons/simplestore/cache/impl
                        SynchronizedCache.java
               simplestore/src/java/org/apache/commons/simplestore/persistence/impl
                        AbstractStorage.java MetaClassImpl.java
                        PersistenceManagerImpl.java PersistentProxy.java
               simplestore/src/jdbc/org/apache/commons/simplestore/jdbc
                        DBStorage.java
               simplestore/src/xmldb/org/apache/commons/simplestore/xmldb
                        XmlDbStorage.java
  Log:
  started refactoring
  
  Revision  Changes    Path
  1.2       +3 -1      jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/cache/impl/SynchronizedCache.java
  
  Index: SynchronizedCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/cache/impl/SynchronizedCache.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SynchronizedCache.java	11 Feb 2002 20:23:15 -0000	1.1
  +++ SynchronizedCache.java	6 Aug 2002 18:45:13 -0000	1.2
  @@ -102,5 +102,7 @@
               mCache.put(key, value);
           }
       }
  +    
  +    
   }
   
  
  
  
  1.17      +6 -3      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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AbstractStorage.java	9 Jun 2002 08:01:31 -0000	1.16
  +++ AbstractStorage.java	6 Aug 2002 18:45:13 -0000	1.17
  @@ -243,10 +243,13 @@
       }
       
       public final Object retrieveObject(Class clasz,Object id){
  -       Object result =  context.getCache().get(id);
  +        
  +       Object key =  new KeyPair( context.getMetaClass(clasz) ,id);
  +       
  +       Object result =  context.getCache().get( key );
          if(result == null){
           result =  retrieveObjectInternal(clasz,id);
  -        context.getCache().put(id,result);
  +        context.getCache().put( key , result );
          }
          return result;
       }
  
  
  
  1.18      +3 -3      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MetaClassImpl.java	5 Aug 2002 20:02:02 -0000	1.17
  +++ MetaClassImpl.java	6 Aug 2002 18:45:13 -0000	1.18
  @@ -552,10 +552,10 @@
                       (PropertyChangeListener[])listeners.toArray( LITENETS_TYPE );
           
           String propertyName = descriptors[index].getName();
  -        Object source = context.getCache().get( sourceOid );
  +        Object source = context.getCache().get( new KeyPair(this, sourceOid) );
           
           if( source == null ){
  -            source = sourceOid;
  +            throw   new IllegalStateException( sourceOid + "  not found in cache" );
           }
           PropertyChangeEvent pche = new PropertyChangeEvent( source, propertyName,
                                                                oldValue, newValue);
  
  
  
  1.12      +5 -5      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- PersistenceManagerImpl.java	5 Aug 2002 20:08:55 -0000	1.11
  +++ PersistenceManagerImpl.java	6 Aug 2002 18:45:13 -0000	1.12
  @@ -104,9 +104,9 @@
   
       public Object createInstance( Class aclass ) {
       
  -        
  -      Persistent p = context.getMetaClass(aclass).newInstance();
  -      context.getCache().put( p.getOID(), p );
  +      MetaClass mclass = context.getMetaClass(aclass);
  +      Persistent p = mclass.newInstance();
  +      context.getCache().put( new KeyPair( mclass , p.getOID()), p );
         
         Object key = new KeyPair(aclass,ALL);  
         java.util.Set cachedSet = (java.util.Set)context.getCache().get(key);
  @@ -124,7 +124,7 @@
   
       public Set findAll(Class clasz) throws StorageException {
           
  -      Object key = new KeyPair(clasz,ALL);  
  +      Object key = new KeyPair( clasz, ALL );  
         java.util.Set cachedSet = (java.util.Set)context.getCache().get(key);
         if(cachedSet != null)
             return cachedSet;
  
  
  
  1.42      +6 -6      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.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- PersistentProxy.java	5 Aug 2002 20:02:02 -0000	1.41
  +++ PersistentProxy.java	6 Aug 2002 18:45:13 -0000	1.42
  @@ -97,7 +97,7 @@
       private Object m_props[] ;
       private Object m_oid         = null;
       private int state = 0;
  -    private Thread lock;
  + 
       
       private Persistent m_object;
       private Class m_clazz;
  @@ -338,11 +338,11 @@
               return ;
           }
           
  -        //Dirty :
  -        lock = Thread.currentThread();
           
           Object newValue = param;
           
  +        setState(true,DIRTY);
  +        
           if( m_metaClass.isReference(method) ){
               if( param != null ){
                   newValue = ((Persistent)param).getOID();
  @@ -350,7 +350,7 @@
               setProperty(index, newValue );
           }else{
               setProperty(index, param);
  -            
  +           return; 
           }
           
           
  @@ -372,7 +372,7 @@
               set.add(m_object);
           }
           
  -        setState(true,DIRTY);
  +        
           
       }
       
  
  
  
  1.6       +4 -4      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DBStorage.java	5 Aug 2002 20:02:02 -0000	1.5
  +++ DBStorage.java	6 Aug 2002 18:45:13 -0000	1.6
  @@ -432,8 +432,8 @@
                   
                   if (index == 0 ) {
                       //try to find in cache first
  -                    
  -                    Persistent p = (Persistent) context.getCache().get(value);
  +                    Object key = new KeyPair( mClass, value ); 
  +                    Persistent p = (Persistent) context.getCache().get(key);
                       if ( p != null ) {
                           
                           if( objects.add(p) && callback != null ){
  @@ -447,7 +447,7 @@
                       
                       final MetaObject pc = p.getMetaObject();
                       props = pc.getProperties();
  -                    context.getCache().put(value,p);
  +                    context.getCache().put(key,p);
                       
                       if( objects.add(p) && callback != null ){
                           return callback.nextObject(p);
  
  
  
  1.6       +6 -15     jakarta-commons-sandbox/simplestore/src/xmldb/org/apache/commons/simplestore/xmldb/XmlDbStorage.java
  
  Index: XmlDbStorage.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/simplestore/src/xmldb/org/apache/commons/simplestore/xmldb/XmlDbStorage.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XmlDbStorage.java	25 May 2002 13:48:59 -0000	1.5
  +++ XmlDbStorage.java	6 Aug 2002 18:45:13 -0000	1.6
  @@ -55,17 +55,8 @@
   package org.apache.commons.simplestore.xmldb;
   
   import org.apache.commons.simplestore.cache.Cache;
  -import org.apache.commons.simplestore.persistence.InternalTransaction;
  -import org.apache.commons.simplestore.persistence.Storage;
  -import org.apache.commons.simplestore.persistence.MetaObject;
  -import org.apache.commons.simplestore.persistence.MetaClass;
  -import org.apache.commons.simplestore.persistence.ObjectNotFound;
  -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 org.apache.commons.simplestore.persistence.EnumeratorCallback;
  -import org.apache.commons.simplestore.persistence.impl.AbstractStorage;
  +import org.apache.commons.simplestore.persistence.*;
  +import org.apache.commons.simplestore.persistence.impl.*;
   
   import org.xmldb.api.base.*;
   import org.xmldb.api.modules.*;
  @@ -503,8 +494,8 @@
               if ( name.equals(mClasz.getName()) ) {
                       
                     Object  value = parse( mClasz.getOIDType(),attributes.getValue(mClasz.getOIDName()
));
  -                    
  -                    Persistent p = (Persistent) cntxt.getCache().get(value);
  +                   Object key = new KeyPair( mClasz, value ); 
  +                    Persistent p = (Persistent) cntxt.getCache().get(key);
                       if ( p != null ) {
                          props = null;
                           if( objects.add(p)){
  @@ -518,7 +509,7 @@
                       props = pc.getProperties();
                     
                       if( objects.add(p)){
  -                        cntxt.getCache().put(value,p);
  +                        cntxt.getCache().put(key,p);
                           if( callback != null)
                               callback.nextObject(p);
                        
  
  
  

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