mkalen      2005/02/24 16:09:26

  Modified:    src/java/org/apache/ojb/broker/core/proxy Tag:
                        OJB_1_0_RELEASE CollectionProxyDefaultImpl.java
               src/java/org/apache/ojb/broker/metadata Tag: OJB_1_0_RELEASE
                        MetadataManager.java
               .        Tag: OJB_1_0_RELEASE release-notes.txt
  Log:
  Optimize fix for collection-proxy instantiation in per-thread metadata 
changes environment: make currentProfileKey thread local in MetadataManager. to 
allow loading of profile only if not set in CollectionProxy. Fix relase notes 
to correct offset/version!
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.7.2.4   +13 -8     
db-ojb/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java
  
  Index: CollectionProxyDefaultImpl.java
  ===================================================================
  RCS file: 
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/proxy/CollectionProxyDefaultImpl.java,v
  retrieving revision 1.7.2.3
  retrieving revision 1.7.2.4
  diff -u -r1.7.2.3 -r1.7.2.4
  --- CollectionProxyDefaultImpl.java   23 Feb 2005 21:52:08 -0000      1.7.2.3
  +++ CollectionProxyDefaultImpl.java   25 Feb 2005 00:09:25 -0000      1.7.2.4
  @@ -105,11 +105,16 @@
           setQuery(query);
       }
   
  -    protected void loadProfile() {
  +    protected void loadProfileIfNeeded()
  +    {
           Object key = getProfileKey();
  -        if (key != null) {
  +        if (key != null)
  +        {
               MetadataManager mm = MetadataManager.getInstance();
  -            mm.loadProfile(key);
  +            if (!key.equals(mm.getCurrentProfileKey()))
  +            {
  +                mm.loadProfile(key);
  +            }
           }
       }
   
  @@ -135,7 +140,7 @@
           try
           {
               if (_perThreadDescriptorsEnabled) {
  -                loadProfile();
  +                loadProfileIfNeeded();
               }
               return broker.getCount(getQuery());
           }
  @@ -179,7 +184,7 @@
               else if (_size != 0)
               {
                   if (_perThreadDescriptorsEnabled) {
  -                    loadProfile();
  +                    loadProfileIfNeeded();
                   }
                   // TODO: returned ManageableCollection should extend 
Collection to avoid
                   // this cast
  @@ -211,7 +216,7 @@
               CollectionProxyListener listener;
   
               if (_perThreadDescriptorsEnabled) {
  -                loadProfile();
  +                loadProfileIfNeeded();
               }
               for (int idx = _listeners.size() - 1; idx >= 0; idx--)
               {
  @@ -231,7 +236,7 @@
               CollectionProxyListener listener;
   
               if (_perThreadDescriptorsEnabled) {
  -                loadProfile();
  +                loadProfileIfNeeded();
               }
               for (int idx = _listeners.size() - 1; idx >= 0; idx--)
               {
  
  
  
  No                   revision
  No                   revision
  1.19.2.2  +6 -7      
db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java
  
  Index: MetadataManager.java
  ===================================================================
  RCS file: 
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java,v
  retrieving revision 1.19.2.1
  retrieving revision 1.19.2.2
  diff -u -r1.19.2.1 -r1.19.2.2
  --- MetadataManager.java      23 Feb 2005 21:52:09 -0000      1.19.2.1
  +++ MetadataManager.java      25 Feb 2005 00:09:25 -0000      1.19.2.2
  @@ -124,6 +124,7 @@
   
       private static final String MSG_STR = "* Can't find DescriptorRepository 
for current thread, use default one *";
       private static ThreadLocal threadedRepository = new ThreadLocal();
  +    private static ThreadLocal currentProfileKey = new ThreadLocal();
       private static MetadataManager singleton;
   
       private Hashtable metadataProfiles;
  @@ -131,7 +132,6 @@
       private ConnectionRepository connectionRepository;
       private boolean enablePerThreadChanges;
       private PBKey defaultPBKey;
  -    private Object currentProfileKey;
   
       // singleton
       private MetadataManager()
  @@ -142,7 +142,6 @@
       private void init()
       {
           metadataProfiles = new Hashtable();
  -        currentProfileKey = null;
           String repository = ((PersistenceBrokerConfiguration) 
OjbConfigurator.getInstance()
                   .getConfigurationFor(null)).getRepositoryFilename();
           try
  @@ -491,7 +490,7 @@
           {
               throw new MetadataException("Can not find profile for key '" + 
key + "'");
           }
  -        currentProfileKey = key;
  +        currentProfileKey.set(key);
           setDescriptor(rep);
       }
   
  @@ -507,7 +506,7 @@
           {
               throw new MetadataException("Call to this method is undefined, 
since per-thread mode is disabled.");
           }
  -        return currentProfileKey;
  +        return currentProfileKey.get();
       }
   
       /**
  @@ -524,7 +523,7 @@
       public void clearProfiles()
       {
           metadataProfiles.clear();
  -        currentProfileKey = null;
  +        currentProfileKey.set(null);
       }
   
       /**
  @@ -536,7 +535,7 @@
       public void removeAllProfiles()
       {
           metadataProfiles.clear();
  -        currentProfileKey = null;
  +        currentProfileKey.set(null);
       }
   
       /**
  
  
  
  No                   revision
  No                   revision
  1.54.2.27 +13 -14    db-ojb/release-notes.txt
  
  Index: release-notes.txt
  ===================================================================
  RCS file: /home/cvs/db-ojb/release-notes.txt,v
  retrieving revision 1.54.2.26
  retrieving revision 1.54.2.27
  diff -u -r1.54.2.26 -r1.54.2.27
  --- release-notes.txt 23 Feb 2005 21:52:09 -0000      1.54.2.26
  +++ release-notes.txt 25 Feb 2005 00:09:26 -0000      1.54.2.27
  @@ -35,6 +35,10 @@
     please see comments in OJB.properties file.
   
   CHANGES:
  +- CollectionProxy classes will now throw an exception in constructor, if 
trying
  +  to use dynamic proxies with MetadataManager in 'per thread changes' mode 
but
  +  without any metadata profile key loaded in the current thread. See note 
about
  +  fix in CollectionProxy under "BUG FIXES" below.
   - Minor changes in the repository.dtd. Add element object-cache to metadata 
interface and abstract class
     declaration in class-descriptor. So replacement of old repository.dtd is 
needed.
   - Remove object-cache declaration from OJB.properties file. Use the 
'object-cache' element in
  @@ -66,6 +70,14 @@
   under http://issues.apache.org/scarab/servlet/scarab/issues/id/OJBxxx
   to see details for a bug with id OJBxxx.
   
  +- Fix bug in MetadataManager, when 'per thread changes' is enabled and 
CollectionProxy
  +  proxies are used. Using proxies in this mode used to be undefined, since 
the lazy
  +  loading might or might not succeed depending on in which thread the data 
was loaded.
  +  OJB will now reload the metadata profile used when creating the proxy,
  +  before attempting to reference any persistence capable classes.
  +  (Fixes occasional ClassNotPersistenceCapable exceptions seen in 
multithreaded
  +   applications when using 'per thread changes'.)
  +  See http://mail-archives.apache.org/eyebrowse/[EMAIL PROTECTED]&msgNo=9143
   - Managed Environment: Fix problem of abandoned connections and statements 
(e.g. detected
     by JBoss) when query (iterator) result sets only partially materialized.
   - Fix bug in ObjectCacheDefaultImpl resolve cache object conflicts, see
  @@ -386,11 +398,6 @@
   are now deprecated but will NOT be removed in near future (so don't panic!).
   
   CHANGES:
  -- CollectionProxy classes will now throw an exception in constructor, if 
trying
  -to use dynamic proxies with MetadataManager in 'per thread changes' mode but
  -without any metadata profile key loaded in the current thread. See note about
  -fix in CollectionProxy under "BUG FIXES" below.
  -
   - fix bug in internal table OJB_HL_SEQ, column type of MAX_ID was INTEGER but
   needs BIGINT to support Long on java side
   
  @@ -422,14 +429,6 @@
   under http://issues.apache.org/scarab/servlet/scarab/issues/id/OJBxxx
   to see details for a bug with id OJBxxx.
   
  -- fix bug in MetadataManager, when 'per thread changes' is enabled and 
CollectionProxy
  -proxies are used. Using proxies in this mode used to be undefined, since the 
lazy
  -loading might or might not succeed depending on in which thread the data was 
loaded.
  -OJB will now reload the metadata profile used when creating the proxy,
  -before attempting to reference any persistence capable classes.
  -(Fixes occasional ClassNotPersistenceCapable exceptions seen in multithreaded
  -applications when using 'per thread changes'.)
  -
   - fix bug in MetadataManager, when 'per thread changes' is enabled and many 
different
   DescriptorRepository instances were used, gc can't collect unused instances 
because
   StatementManager doesn't release references to used DescriptorRepository 
instances.
  
  
  

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

Reply via email to