openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r453066 - in /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa: datacache/DataCachePCDataGenerator.java datacache/DataCachePCDataImpl.java kernel/PCData.java
Date Wed, 04 Oct 2006 23:43:53 GMT
Author: awhite
Date: Wed Oct  4 16:43:51 2006
New Revision: 453066

URL: http://svn.apache.org/viewvc?view=rev&rev=453066
Log:
Enable caching of embedded instances by datacache.  Fix bugs in 
DataCachePCDataGenerator.


Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataGenerator.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCData.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataGenerator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataGenerator.java?view=diff&rev=453066&r1=453065&r2=453066
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataGenerator.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataGenerator.java
Wed Oct  4 16:43:51 2006
@@ -24,6 +24,8 @@
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.enhance.PCDataGenerator;
 import org.apache.openjpa.kernel.AbstractPCData;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.kernel.StoreContext;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.meta.JavaTypes;
@@ -72,14 +74,15 @@
     protected void decorate(BCClass bc, ClassMetaData meta) {
         enhanceToData(bc);
         enhanceToNestedData(bc);
-        replaceToEmbeddedData(bc);
+        replaceNewEmbeddedPCData(bc);
         addSynchronization(bc);
         addTimeout(bc);
     }
 
     private void enhanceToData(BCClass bc) {
         BCMethod meth = bc.declareMethod("toData", Object.class,
-            new Class []{ FieldMetaData.class, Object.class });
+            new Class []{ FieldMetaData.class, Object.class, 
+            StoreContext.class });
         Code code = meth.getCode(true);
         // if (fmd.isLRS ()))
         // 		return NULL;
@@ -89,12 +92,14 @@
         JumpInstruction ifins = code.ifeq();
         code.getstatic().setField(AbstractPCData.class, "NULL", Object.class);
         code.areturn();
-        // super.toData (fmd, val);
+        // super.toData (fmd, val, ctx);
         ifins.setTarget(code.aload().setThis());
         code.aload().setParam(0);
         code.aload().setParam(1);
+        code.aload().setParam(2);
         code.invokespecial().setMethod(AbstractPCData.class, "toData",
-            Object.class, new Class[]{ FieldMetaData.class, Object.class });
+            Object.class, new Class[]{ FieldMetaData.class, Object.class,
+            StoreContext.class });
         code.areturn();
         code.calculateMaxStack();
         code.calculateMaxLocals();
@@ -102,7 +107,8 @@
 
     private void enhanceToNestedData(BCClass bc) {
         BCMethod meth = bc.declareMethod("toNestedData", Object.class,
-            new Class []{ ValueMetaData.class, Object.class });
+            new Class []{ ValueMetaData.class, Object.class, 
+            StoreContext.class });
         Code code = meth.getCode(true);
 
         // if (val == null)
@@ -122,7 +128,7 @@
         // if (type != JavaTypes.COLLECTION &&
         // 	   type != JavaTypes.MAP &&
         // 	   type != JavaTypes.ARRAY)
-        // 	   return super.toNestedData (type, val, embedded);
+        // 	   return super.toNestedData(type, val, ctx);
         // 	else
         // 		return NULL;
         Collection jumps = new ArrayList(3);
@@ -138,8 +144,10 @@
         code.aload().setThis();
         code.aload().setParam(0);
         code.aload().setParam(1);
+        code.aload().setParam(2);
         code.invokespecial().setMethod(AbstractPCData.class, "toNestedData",
-            Object.class, new Class[]{ ValueMetaData.class, Object.class });
+            Object.class, new Class[]{ ValueMetaData.class, Object.class,
+            StoreContext.class });
         code.areturn();
         setTarget(code.getstatic().setField
             (AbstractPCData.class, "NULL", Object.class), jumps);
@@ -148,12 +156,24 @@
         code.calculateMaxLocals();
     }
 
-    private void replaceToEmbeddedData(BCClass bc) {
-        BCMethod meth = bc.declareMethod("toEmbeddedData", Object.class,
-            new Class[]{ Object.class });
+    private void replaceNewEmbeddedPCData(BCClass bc) {
+        BCMethod meth = bc.declareMethod("newEmbeddedPCData", 
+            AbstractPCData.class, new Class[]{ OpenJPAStateManager.class });
         Code code = meth.getCode(true);
-        code.getstatic().setField(AbstractPCData.class, "NULL", Object.class);
+
+        // return new DataCachePCDataImpl(sm.getObjectId(), sm.getMetaData());
+        code.anew().setType(DataCachePCDataImpl.class);
+        code.dup();
+        code.aload().setParam(0);
+        code.invokeinterface().setMethod(OpenJPAStateManager.class, "getId", 
+            Object.class, null);
+        code.aload().setParam(0);
+        code.invokeinterface().setMethod(OpenJPAStateManager.class, 
+            "getMetaData", ClassMetaData.class, null);
+        code.invokespecial().setMethod(DataCachePCDataImpl.class, "<init>",
+            void.class, new Class[] { Object.class, ClassMetaData.class });
         code.areturn();
+
         code.calculateMaxLocals();
         code.calculateMaxStack();
     }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java?view=diff&rev=453066&r1=453065&r2=453066
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java
Wed Oct  4 16:43:51 2006
@@ -18,6 +18,7 @@
 import java.util.BitSet;
 
 import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.kernel.AbstractPCData;
 import org.apache.openjpa.kernel.PCData;
 import org.apache.openjpa.kernel.PCDataImpl;
 import org.apache.openjpa.kernel.StoreContext;
@@ -138,8 +139,7 @@
         }
     }
 
-    protected Object toEmbeddedData(Object val) {
-        // don't try to cache embedded pcs until we do some testing
-        return NULL;
+    public AbstractPCData newEmbeddedPCData(OpenJPAStateManager sm) {
+        return new DataCachePCDataImpl(sm.getId(), sm.getMetaData());
     }
 }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCData.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCData.java?view=diff&rev=453066&r1=453065&r2=453066
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCData.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCData.java
Wed Oct  4 16:43:51 2006
@@ -100,5 +100,5 @@
     /**
      * Whether the given field index has stored data.
      */
-    public boolean isLoaded (int i);
+    public boolean isLoaded(int i);
 }



Mime
View raw message