openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r446904 - in /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa: enhance/PCEnhancer.java meta/ClassMetaData.java meta/MetaDataRepository.java
Date Sat, 16 Sep 2006 17:39:57 GMT
Author: skim
Date: Sat Sep 16 10:39:57 2006
New Revision: 446904

URL: http://svn.apache.org/viewvc?view=rev&rev=446904
Log:
Remove warning from enhancing impl generated classes and optimize 
class / interface interaction

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?view=diff&rev=446904&r1=446903&r2=446904
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
Sat Sep 16 10:39:57 2006
@@ -1904,7 +1904,7 @@
                 method.makeProtected();
                 access = "protected";
             }
-            if (_log.isWarnEnabled())
+            if (!_meta.getDescribedType().isInterface() && _log.isWarnEnabled())
                 _log.warn(_loc.get("enhance-adddefaultconst", type, access));
         }
     }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java?view=diff&rev=446904&r1=446903&r2=446904
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Sat Sep 16 10:39:57 2006
@@ -142,6 +142,7 @@
     private Boolean _embedded = null;
     private Boolean _interface = null;
     private Class _impl = null;
+    private List _interfaces = null;
     private Map _ifaceMap = new HashMap();
     private int _identity = ID_UNKNOWN;
     private int _idStrategy = ValueStrategies.NONE;
@@ -698,6 +699,38 @@
     }
 
     /**
+     * Return all explicitly declared interfaces this class implements.
+     */
+    public Class[] getDeclaredInterfaces() {
+        if (_interfaces == null)
+            return _repos.EMPTY_CLASSES;
+
+        return (Class[]) _interfaces.toArray(new Class[_interfaces.size()]);
+    }
+
+    /**
+     * Explicitly declare the given interface among the ones this
+     * class implements.
+     */
+    public void addDeclaredInterface(Class iface) {
+        if (_interfaces == null)
+            _interfaces = new ArrayList();
+        if (!iface.isInterface())
+            throw new MetaDataException(_loc.get("declare-non-interface",
+                this, iface));
+        _interfaces.add(iface);
+    }
+
+    /**
+     * Remove the given interface from the declared list.
+     */
+    public boolean removeDeclaredInterface(Class iface) {
+        if (_interfaces == null)
+            return false;
+        return _interfaces.remove(iface);
+    }
+
+    /**
      * Alias properties from the given interface during  queries to
      * the local field.
      */
@@ -729,6 +762,18 @@
     }
     
     /**
+     * Return all aliases property named for the given interface.
+     */
+    public String[] getInterfaceAliasedProperties(Class iface) {
+        synchronized (_ifaceMap) {
+            Map fields = (Map) _ifaceMap.get(iface);
+            if (fields == null)
+                return new String[0];
+            return (String[]) fields.keySet().toArray(new String[0]);
+        }
+    }
+    
+    /**
      * Return the number of fields that use impl or intermediate data, in
      * order to create a compacted array for storage of said data.
      */
@@ -1609,6 +1654,13 @@
 
         // resolve lifecycle metadata now to prevent lazy threading problems
         _lifeMeta.resolve();
+
+        // record implements in the repository
+        if (_interfaces != null) {
+            for (Iterator it = _interfaces.iterator(); it.hasNext();) {
+                _repos.addDeclaredInterfaceImpl(this, (Class) it.next());
+            }
+        }
 
         // resolve fetch groups
         if (_fgMap != null)

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?view=diff&rev=446904&r1=446903&r2=446904
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
Sat Sep 16 10:39:57 2006
@@ -865,9 +865,23 @@
     /**
      * Add the given metadata as declared interface implementation.
      */
-    public void addDeclaredInterfaceImpl(ClassMetaData meta, Class iface) {
+    void addDeclaredInterfaceImpl(ClassMetaData meta, Class iface) {
         synchronized (_impls) {
-            addToCollection(_impls, iface, meta.getDescribedType(), false);
+            boolean supDec = false;
+            Collection vals = (Collection) _impls.get(iface);
+            
+            // check to see if the superclass already declares to avoid dups
+            if (vals != null) {
+                ClassMetaData sup = meta.getPCSuperclassMetaData();
+                while (vals != null && sup != null && !supDec) {
+                    supDec = vals.contains(sup.getDescribedType());
+                    sup = sup.getPCSuperclassMetaData();
+                }
+                if (supDec)
+                    return;
+            }
+
+            addToCollection(_impls, iface, meta.getDescribedType(), true);
         }
     }
 



Mime
View raw message