openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r650559 - in /openjpa/branches/1.1.x: openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/
Date Tue, 22 Apr 2008 15:47:01 GMT
Author: pcl
Date: Tue Apr 22 08:46:58 2008
New Revision: 650559

URL: http://svn.apache.org/viewvc?rev=650559&view=rev
Log:
OPENJPA-536. Committing on behalf of Amy Yang.

Added:
    openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
Modified:
    openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java
    openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
    openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java
    openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java

Modified: openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java?rev=650559&r1=650558&r2=650559&view=diff
==============================================================================
--- openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java
(original)
+++ openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceComparator.java
Tue Apr 22 08:46:58 2008
@@ -30,7 +30,7 @@
 public class InheritanceComparator
     implements Comparator, Serializable {
 
-    private Class _base = null;
+    private Class _base = Object.class;
 
     /**
      * Set the least-derived type possible; defaults to <code>null</code>.
@@ -92,8 +92,6 @@
     private int levels(Class to) {
         if (to.isInterface())
             return to.getInterfaces().length;
-        if (_base == null)
-            return 0;
         for (int i = 0; to != null; i++, to = to.getSuperclass())
             if (to == _base)
                 return i;

Added: openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java?rev=650559&view=auto
==============================================================================
--- openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
(added)
+++ openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InheritanceOrderedMetaDataList.java
Tue Apr 22 08:46:58 2008
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.meta;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.io.Serializable;
+
+public class InheritanceOrderedMetaDataList
+    implements Serializable {
+
+    private MetaDataInheritanceComparator _comp
+        = new MetaDataInheritanceComparator();
+    private LinkedList<ClassMetaData> buffer = new LinkedList<ClassMetaData>();
+
+    public boolean add(ClassMetaData meta) {
+        for (ListIterator<ClassMetaData> itr = buffer.listIterator();
+            itr.hasNext();) {
+            int ord = _comp.compare(meta, itr.next());
+            if (ord > 0)
+                continue;
+            if (ord == 0)
+                return false;
+            itr.previous();
+            itr.add(meta);
+            return true;
+        }
+        buffer.add(meta);
+        return true;
+    }
+
+    public boolean remove(ClassMetaData meta) {
+        return buffer.remove(meta);
+    }
+
+    public ClassMetaData peek() {
+        return buffer.peek();
+    }
+    
+    public int size() {
+        return buffer.size();
+    }
+    
+    public Iterator<ClassMetaData> iterator() {
+        return buffer.iterator();
+    }
+    
+    public boolean isEmpty() {
+        return buffer.isEmpty();
+    }
+    
+    public void clear() {
+        buffer.clear();
+    }
+}

Modified: openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?rev=650559&r1=650558&r2=650559&view=diff
==============================================================================
--- openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
(original)
+++ openjpa/branches/1.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
Tue Apr 22 08:46:58 2008
@@ -31,7 +31,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.SortedSet;
 import java.util.TreeSet;
 
 import org.apache.commons.lang.StringUtils;
@@ -137,10 +136,10 @@
     private final Collection _registered = new HashSet();
 
     // set of metadatas we're in the process of resolving
-    private final SortedSet _resolving = new TreeSet
-        (new MetaDataInheritanceComparator());
-    private final SortedSet _mapping = new TreeSet
-        (new MetaDataInheritanceComparator());
+    private final InheritanceOrderedMetaDataList _resolving =
+        new InheritanceOrderedMetaDataList();
+    private final InheritanceOrderedMetaDataList _mapping =
+        new InheritanceOrderedMetaDataList();
     private final List _errs = new LinkedList();
 
     // system listeners
@@ -574,12 +573,6 @@
      * if we're still in the process of resolving other metadatas.
      */
     private List resolveMeta(ClassMetaData meta) {
-
-        // pcl: 10 April 2008: disabling temporarily as this is causing
-        // integration problems. A more complete fix will be forthcoming.
-        // See OPENJPA-536. Also disabled code in TestGetMetaData.
-        // setBaseIfNecessary(meta);
-
         if (meta.getPCSuperclass() == null) {
             // set superclass
             Class sup = meta.getDescribedType().getSuperclass();
@@ -623,27 +616,6 @@
         return processBuffer(meta, _resolving, MODE_META);
     }
     
-    private void setBaseIfNecessary(ClassMetaData meta) {
-        if (_resolving == null)
-            return;
-
-        InheritanceComparator comp =
-            (InheritanceComparator) _resolving.comparator();
-        if (meta.getPCSuperclass() == null) {
-            Class sup = meta.getDescribedType().getSuperclass();
-            Class pBase = null;
-            while (sup != null && sup != Object.class) {
-                pBase = sup;
-                sup = sup.getSuperclass();
-            }
-            if (pBase != null && !pBase.equals(comp.getBase())) {
-                // setBase() can be called because getMetaData() is
-                // syncronized
-                comp.setBase(pBase);
-            }
-        }
-    }
-
     /**
      * Load mapping information for the given metadata.
      */
@@ -724,7 +696,8 @@
     /**
      * Process the given metadata and the associated buffer.
      */
-    private List processBuffer(ClassMetaData meta, SortedSet buffer, int mode) {
+    private List processBuffer(ClassMetaData meta,
+        InheritanceOrderedMetaDataList buffer, int mode) {
         // if we're already processing a metadata, just buffer this one; when
         // the initial metadata finishes processing, we traverse the buffer
         // and process all the others that were introduced during reentrant
@@ -739,7 +712,7 @@
         ClassMetaData buffered;
         List processed = new ArrayList(5);
         while (!buffer.isEmpty()) {
-            buffered = (ClassMetaData) buffer.first();
+            buffered = buffer.peek();
             try {
                 buffered.resolve(mode);
                 processed.add(buffered);

Modified: openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java?rev=650559&r1=650558&r2=650559&view=diff
==============================================================================
--- openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java
(original)
+++ openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestGetMetaData.java
Tue Apr 22 08:46:58 2008
@@ -29,10 +29,7 @@
     }
 
     public void testGetMetaData() {
-        // pcl: 10 April 2008: disabling temporarily as this is causing
-        // integration problems. A more complete fix will be forthcoming.
-        // See OPENJPA-536. Also disabled code in MetaDataRepository.
-        // assertNotNull(JPAFacadeHelper.getMetaData(emf, Item.class));
-        // assertNotNull(JPAFacadeHelper.getMetaData(emf, Person.class));
+        assertNotNull(JPAFacadeHelper.getMetaData(emf, Item.class));
+        assertNotNull(JPAFacadeHelper.getMetaData(emf, Person.class));
     }
 }

Modified: openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java?rev=650559&r1=650558&r2=650559&view=diff
==============================================================================
--- openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java
(original)
+++ openjpa/branches/1.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/meta/TestMetaDataInheritanceComparator.java
Tue Apr 22 08:46:58 2008
@@ -25,10 +25,6 @@
 
 public class TestMetaDataInheritanceComparator extends PersistenceTestCase {
 
-    public void testInheritanceComparatorWithoutBase() {
-        inheritanceComparatorHelper(false);
-    }
-
     public void testInheritanceComparatorWithBase() {
         inheritanceComparatorHelper(true);
     }
@@ -45,10 +41,6 @@
         assertEquals(-1, comp.compare(AbstractThing.class, A.class));
         assertEquals(-1, comp.compare(AbstractThing.class, B.class));
         assertTrue(comp.compare(AbstractThing.class, C.class) < 0);
-    }
-
-    public void testMetaDataInheritanceComparatorWithoutBase() {
-        metaDataInheritanceComparatorHelper(false);
     }
 
     public void testMetaDataInheritanceComparatorWithBase() {



Mime
View raw message