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/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java
Date Fri, 23 Jul 2004 11:40:03 GMT
arminw      2004/07/23 04:40:03

  Modified:    src/java/org/apache/ojb/broker/accesslayer RsIterator.java
               src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  patch by Charles Anthony:
  after fire a fireBrokerEvent() set 'target object' to null
  
  <snip>
  Anyway, OJB is holding on to far less of our objects - but it still is, a
  bit. All the PBLifeCycleEvents on PersistenceBrokerAbstractImpl (e.g.
  BEFORE_STORE_EVENT) have a target attribute, which is set when an event is
  fired, but never cleared. As Brokers are pooled, the targets are prevented
  from gc'd.
  
  I've modified RsIterator and PersistenceBrokerImpl to reset the target after
  firing the event. I'm sure there is a better solution [2], but the simple
  approach works.
  </snip>
  
  Revision  Changes    Path
  1.64      +2 -1      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
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- RsIterator.java	22 May 2004 09:51:26 -0000	1.63
  +++ RsIterator.java	23 Jul 2004 11:40:03 -0000	1.64
  @@ -269,6 +269,7 @@
                   // set target object
                   getAfterLookupEvent().setTarget(obj);
                   getBroker().fireBrokerEvent(getAfterLookupEvent());
  +                getAfterLookupEvent().setTarget(null);
                   return obj;
               }
               else
  
  
  
  1.87      +8 -2      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.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- PersistenceBrokerImpl.java	13 Jul 2004 11:37:57 -0000	1.86
  +++ PersistenceBrokerImpl.java	23 Jul 2004 11:40:03 -0000	1.87
  @@ -15,7 +15,6 @@
    * limitations under the License.
    */
   
  -import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Collections;
   import java.util.Enumeration;
  @@ -493,6 +492,7 @@
               // Invoke events on PersistenceBrokerAware instances and listeners
               BEFORE_DELETE_EVENT.setTarget(obj);
               fireBrokerEvent(BEFORE_DELETE_EVENT);
  +            BEFORE_DELETE_EVENT.setTarget(null);
   
               // 1. delete dependend collections
               if (cld.getCollectionDescriptors().size() > 0)
  @@ -516,6 +516,7 @@
               // Invoke events on PersistenceBrokerAware instances and listeners
               AFTER_DELETE_EVENT.setTarget(obj);
               fireBrokerEvent(AFTER_DELETE_EVENT);
  +            AFTER_DELETE_EVENT.setTarget(null);
   
               // let the connection manager to execute batch
               connectionManager.executeBatchIfNecessary();
  @@ -1381,6 +1382,7 @@
           // Invoke events on PersistenceBrokerAware instances and listeners
           AFTER_LOOKUP_EVENT.setTarget(obj);
           fireBrokerEvent(AFTER_LOOKUP_EVENT);
  +        AFTER_LOOKUP_EVENT.setTarget(null);
   
           //logger.info("RETRIEVING object " + obj);
           return obj;
  @@ -1539,11 +1541,13 @@
           {
               BEFORE_STORE_EVENT.setTarget(obj);
               fireBrokerEvent(BEFORE_STORE_EVENT);
  +            BEFORE_STORE_EVENT.setTarget(null);
           }
           else
           {
               BEFORE_UPDATE_EVENT.setTarget(obj);
               fireBrokerEvent(BEFORE_UPDATE_EVENT);
  +            BEFORE_UPDATE_EVENT.setTarget(null);
           }
   
           if (obj != null)
  @@ -1567,11 +1571,13 @@
           {
               AFTER_STORE_EVENT.setTarget(obj);
               fireBrokerEvent(AFTER_STORE_EVENT);
  +            AFTER_STORE_EVENT.setTarget(null);
           }
           else
           {
               AFTER_UPDATE_EVENT.setTarget(obj);
               fireBrokerEvent(AFTER_UPDATE_EVENT);
  +            AFTER_UPDATE_EVENT.setTarget(null);
           }
       }
   
  
  
  

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