cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r478021 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access: ObjectDiff.java ObjectStore.java
Date Wed, 22 Nov 2006 03:32:11 GMT
Author: aadamchik
Date: Tue Nov 21 19:32:11 2006
New Revision: 478021

URL: http://svn.apache.org/viewvc?view=rev&rev=478021
Log:
CAY-709: Leak-free ObjectContext
(redefining ObjectDiff, removing dependency on ObjectStore and eliminating object lookups)

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java?view=diff&rev=478021&r1=478020&r2=478021
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectDiff.java
Tue Nov 21 19:32:11 2006
@@ -50,7 +50,6 @@
  */
 class ObjectDiff extends NodeDiff {
 
-    private final ObjectStore objectStore;
     private final String entityName;
 
     private transient ClassDescriptor classDescriptor;
@@ -62,9 +61,9 @@
     private Map currentArcSnapshot;
     private Map flatIds;
 
-    Persistent object;
+    private Persistent object;
 
-    ObjectDiff(ObjectStore objectStore, final Persistent object) {
+    ObjectDiff(final Persistent object) {
 
         super(object.getObjectId());
 
@@ -72,10 +71,9 @@
         // objects and we can't allow it to deallocate dirty objects.
         this.object = object;
 
-        EntityResolver entityResolver = objectStore.getContext().getEntityResolver();
+        EntityResolver entityResolver = object.getObjectContext().getEntityResolver();
 
         this.entityName = object.getObjectId().getEntityName();
-        this.objectStore = objectStore;
         this.classDescriptor = entityResolver.getClassDescriptor(entityName);
 
         int state = object.getPersistenceState();
@@ -124,7 +122,7 @@
     ClassDescriptor getClassDescriptor() {
         // class descriptor is initiated in constructor, but is nullified on serialization
         if (classDescriptor == null) {
-            EntityResolver entityResolver = objectStore.getContext().getEntityResolver();
+            EntityResolver entityResolver = object.getObjectContext().getEntityResolver();
             this.classDescriptor = entityResolver.getClassDescriptor(entityName);
         }
 
@@ -139,9 +137,8 @@
         Object value = arcSnapshot != null ? arcSnapshot.get(propertyName) : null;
 
         if (value instanceof Fault) {
-            Persistent source = (Persistent) objectStore.getNode(nodeId);
             Persistent target = (Persistent) ((Fault) value).resolveFault(
-                    source,
+                    object,
                     propertyName);
 
             value = target != null ? target.getObjectId() : null;
@@ -195,8 +192,10 @@
             if (property instanceof CollectionProperty) {
 
                 // record flattened op changes
-                ObjEntity entity = objectStore.context.getEntityResolver().getObjEntity(
-                        entityName);
+                ObjEntity entity = object
+                        .getObjectContext()
+                        .getEntityResolver()
+                        .getObjEntity(entityName);
 
                 ObjRelationship relationship = (ObjRelationship) entity
                         .getRelationship(property.getName());
@@ -259,7 +258,6 @@
         }
 
         final boolean[] modFound = new boolean[1];
-        final Persistent object = (Persistent) objectStore.getNode(nodeId);
 
         int state = object.getPersistenceState();
         if (state == PersistenceState.NEW || state == PersistenceState.DELETED) {
@@ -328,7 +326,7 @@
     }
 
     private void applySimplePropertyChanges(final GraphChangeHandler handler) {
-        final Persistent object = (Persistent) objectStore.getNodeNoSync(nodeId);
+
         getClassDescriptor().visitProperties(new PropertyVisitor() {
 
             public boolean visitAttributeProperty(AttributeProperty property) {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java?view=diff&rev=478021&r1=478020&r2=478021
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
Tue Nov 21 19:32:11 2006
@@ -176,7 +176,7 @@
                 }
             }
 
-            objectDiff = new ObjectDiff(this, object);
+            objectDiff = new ObjectDiff(object);
             objectDiff.setDiffId(++currentDiffId);
             changes.put(nodeId, objectDiff);
         }



Mime
View raw message