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/test/org/apache/ojb/broker/metadata MetadataMultithreadedTest.java
Date Tue, 15 Feb 2005 19:17:49 GMT
arminw      2005/02/15 11:17:49

  Modified:    src/java/org/apache/ojb/broker/accesslayer Tag:
                        OJB_1_0_RELEASE RelationshipPrefetcherFactory.java
                        RsIterator.java
               src/java/org/apache/ojb/broker/core Tag: OJB_1_0_RELEASE
                        PersistenceBrokerImpl.java
                        QueryReferenceBroker.java
               src/test/org/apache/ojb/broker/metadata Tag: OJB_1_0_RELEASE
                        MetadataMultithreadedTest.java
  Log:
  fix concurrency problem caused by RelationshipPrefetcherFactory
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.6.2.1   +16 -9     db-ojb/src/java/org/apache/ojb/broker/accesslayer/RelationshipPrefetcherFactory.java
  
  Index: RelationshipPrefetcherFactory.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RelationshipPrefetcherFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- RelationshipPrefetcherFactory.java	12 May 2004 19:25:54 -0000	1.6
  +++ RelationshipPrefetcherFactory.java	15 Feb 2005 19:17:48 -0000	1.6.2.1
  @@ -29,33 +29,40 @@
    */
   public class RelationshipPrefetcherFactory
   {
  +    private PersistenceBrokerImpl broker;
  +
  +    public RelationshipPrefetcherFactory(final PersistenceBrokerImpl broker)
  +    {
  +        this.broker = broker;
  +    }
  +
       /**
        * create either a CollectionPrefetcher or a ReferencePrefetcher
        */ 
  -    public static RelationshipPrefetcher createRelationshipPrefetcher(PersistenceBrokerImpl
aBroker, ObjectReferenceDescriptor ord)
  +    public RelationshipPrefetcher createRelationshipPrefetcher(ObjectReferenceDescriptor
ord)
       {
           if (ord instanceof CollectionDescriptor)
           {
               CollectionDescriptor cds = (CollectionDescriptor)ord;
               if (cds.isMtoNRelation())
               {
  -                return new MtoNCollectionPrefetcher(aBroker, cds);                    
           
  +                return new MtoNCollectionPrefetcher(broker, cds);
               }
               else
               {
  -                return new CollectionPrefetcher(aBroker, cds);                
  +                return new CollectionPrefetcher(broker, cds);
               }
           }
           else
           {    
  -            return new ReferencePrefetcher(aBroker, ord);
  +            return new ReferencePrefetcher(broker, ord);
           }
       }   
       
       /**
        * create either a CollectionPrefetcher or a ReferencePrefetcher
        */ 
  -    public static RelationshipPrefetcher createRelationshipPrefetcher(PersistenceBrokerImpl
aBroker, ClassDescriptor anOwnerCld, String aRelationshipName)
  +    public RelationshipPrefetcher createRelationshipPrefetcher(ClassDescriptor anOwnerCld,
String aRelationshipName)
       {
           ObjectReferenceDescriptor ord;
           
  @@ -65,10 +72,10 @@
               ord = anOwnerCld.getObjectReferenceDescriptorByName(aRelationshipName);
               if (ord == null)
               {
  -                throw new PersistenceBrokerException("Relationship not found: " + aRelationshipName);
  +                throw new PersistenceBrokerException("Relationship named '" + aRelationshipName
  +                        + "' not found in owner class " + (anOwnerCld != null ? anOwnerCld.getClassNameOfObject()
: null));
               }
           }
  -        
  -        return createRelationshipPrefetcher(aBroker, ord);
  +        return createRelationshipPrefetcher(ord);
       }   
   }
  
  
  
  1.63.2.8  +3 -3      db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
  
  Index: RsIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java,v
  retrieving revision 1.63.2.7
  retrieving revision 1.63.2.8
  diff -u -r1.63.2.7 -r1.63.2.8
  --- RsIterator.java	23 Jan 2005 03:07:31 -0000	1.63.2.7
  +++ RsIterator.java	15 Feb 2005 19:17:48 -0000	1.63.2.8
  @@ -354,8 +354,8 @@
           for (int i = 0; i < prefetchedRel.size(); i++)
           {
               relName = (String) prefetchedRel.get(i);
  -            prefetchers[i] =
  -                    RelationshipPrefetcherFactory.createRelationshipPrefetcher(getBroker(),
getQueryObject().getClassDescriptor(), relName);
  +            prefetchers[i] = getBroker().getRelationshipPrefetcherFactory()
  +                    .createRelationshipPrefetcher(getQueryObject().getClassDescriptor(),
relName);
               prefetchers[i].prepareRelationshipSettings();
           }
   
  
  
  
  No                   revision
  No                   revision
  1.83.2.12 +10 -3     db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.83.2.11
  retrieving revision 1.83.2.12
  diff -u -r1.83.2.11 -r1.83.2.12
  --- PersistenceBrokerImpl.java	23 Jan 2005 03:07:32 -0000	1.83.2.11
  +++ PersistenceBrokerImpl.java	15 Feb 2005 19:17:49 -0000	1.83.2.12
  @@ -28,7 +28,6 @@
   import org.apache.ojb.broker.IdentityFactory;
   import org.apache.ojb.broker.ManageableCollection;
   import org.apache.ojb.broker.MtoNImplementor;
  -import org.apache.ojb.broker.OJBRuntimeException;
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PBState;
   import org.apache.ojb.broker.PersistenceBrokerException;
  @@ -46,6 +45,7 @@
   import org.apache.ojb.broker.accesslayer.PkEnumeration;
   import org.apache.ojb.broker.accesslayer.StatementManagerFactory;
   import org.apache.ojb.broker.accesslayer.StatementManagerIF;
  +import org.apache.ojb.broker.accesslayer.RelationshipPrefetcherFactory;
   import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
   import org.apache.ojb.broker.accesslayer.sql.SqlGeneratorFactory;
   import org.apache.ojb.broker.cache.MaterializationCache;
  @@ -119,6 +119,7 @@
       private StatementManagerIF statementManager = null;
       private SqlGenerator sqlGenerator;
       private IdentityFactory identityFactory;
  +    private RelationshipPrefetcherFactory relationshipPrefetcherFactory;
       private PBKey pbKey;
   
       /**
  @@ -191,6 +192,7 @@
           mtoNBroker = new MtoNBroker(this);
           referencesBroker = new QueryReferenceBroker(this);
           identityFactory = new IdentityFactoryImpl(this);
  +        relationshipPrefetcherFactory = new RelationshipPrefetcherFactory(this);
       }
   
       public MaterializationCache getInternalCache()
  @@ -243,6 +245,11 @@
           return this.referencesBroker;
       }
   
  +    public RelationshipPrefetcherFactory getRelationshipPrefetcherFactory()
  +    {
  +        return relationshipPrefetcherFactory;
  +    }
  +
       public boolean isClosed()
       {
           return this.isClosed;
  @@ -346,12 +353,12 @@
                   */
                   connectionManager.setBatchMode(false);
               }
  -            removeAllListeners();
           }
           finally
           {
               // free current used DescriptorRepository reference
               descriptorRepository = null;
  +            removeAllListeners();
               this.setClosed(true);
           }
           return true;
  
  
  
  1.17.2.3  +6 -7      db-ojb/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java
  
  Index: QueryReferenceBroker.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java,v
  retrieving revision 1.17.2.2
  retrieving revision 1.17.2.3
  diff -u -r1.17.2.2 -r1.17.2.3
  --- QueryReferenceBroker.java	23 Jan 2005 03:07:32 -0000	1.17.2.2
  +++ QueryReferenceBroker.java	15 Feb 2005 19:17:49 -0000	1.17.2.3
  @@ -30,7 +30,6 @@
   import org.apache.ojb.broker.accesslayer.PagingIterator;
   import org.apache.ojb.broker.accesslayer.PlainPrefetcher;
   import org.apache.ojb.broker.accesslayer.RelationshipPrefetcher;
  -import org.apache.ojb.broker.accesslayer.RelationshipPrefetcherFactory;
   import org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl;
   import org.apache.ojb.broker.core.proxy.CollectionProxyListener;
   import org.apache.ojb.broker.core.proxy.IndirectionHandler;
  @@ -338,7 +337,7 @@
                       continue;
                   }
   
  -                prefetcher = RelationshipPrefetcherFactory.createRelationshipPrefetcher(pb,
ord);
  +                prefetcher = pb.getRelationshipPrefetcherFactory().createRelationshipPrefetcher(ord);
                   prefetcher.prefetchRelationship(owners);
                   it.remove();
               }
  @@ -385,7 +384,7 @@
                   }
                   else
                   {
  -                    refObj = getReferencedObject(id, rds, cld);
  +                    refObj = getReferencedObject(id, rds);
                   }
   
                   if (isRefObjDefined)
  @@ -529,7 +528,7 @@
        * <br>
        * If no Proxy-class is defined, a getObjectByIdentity(...) lookup is performed.
        */
  -    private Object getReferencedObject(Identity id, ObjectReferenceDescriptor rds, ClassDescriptor
cld)
  +    private Object getReferencedObject(Identity id, ObjectReferenceDescriptor rds)
       {
           Class referencedProxy;
   
  @@ -865,7 +864,7 @@
           {
               if (_key instanceof ObjectReferenceDescriptor)
               {
  -                return RelationshipPrefetcherFactory.createRelationshipPrefetcher(pb, (ObjectReferenceDescriptor)
_key);
  +                return pb.getRelationshipPrefetcherFactory().createRelationshipPrefetcher((ObjectReferenceDescriptor)
_key);
               }
               else // PersistentBrokerImpl.this
               {
  @@ -996,7 +995,7 @@
   
           protected RelationshipPrefetcher getPrefetcher(Object listenedObject)
           {
  -            return RelationshipPrefetcherFactory.createRelationshipPrefetcher(pb, (CollectionDescriptor)_key);
  +            return pb.getRelationshipPrefetcherFactory().createRelationshipPrefetcher((CollectionDescriptor)_key);
           }
   
           public void beforeLoading(CollectionProxyDefaultImpl col)
  
  
  
  No                   revision
  No                   revision
  1.7.2.1   +6 -7      db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataMultithreadedTest.java
  
  Index: MetadataMultithreadedTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataMultithreadedTest.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- MetadataMultithreadedTest.java	5 Apr 2004 17:13:27 -0000	1.7
  +++ MetadataMultithreadedTest.java	15 Feb 2005 19:17:49 -0000	1.7.2.1
  @@ -26,6 +26,11 @@
       // we change table name in test for target class
       private String newTestObjectString = "SM_TAB_MAX_AA";
       private Class targetTestClass = Repository.SMMaxA.class;
  +    int loops = 7;
  +    int threads = 4;
  +    // need min 80% free memory after test campared with
  +    // beginning, else test fails
  +    int minimalFreeMemAfterTest = 80;
   
       private String oldTestObjectString;
       DescriptorRepository defaultRepository;
  @@ -67,12 +72,6 @@
   
       public void testRuntimeMetadataChanges() throws Exception
       {
  -        int loops = 7;
  -        int threads = 8;
  -        // need min 80% free memory after test campared with
  -        // beginning, else test fails
  -        int minimalFreeMemAfterTest = 80;
  -
           PersistenceBroker broker = null;
           try
           {
  
  
  

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