openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r532273 - in /incubator/openjpa/trunk/openjpa-kernel/src/main: java/org/apache/openjpa/enhance/PCEnhancer.java java/org/apache/openjpa/meta/MetaDataRepository.java resources/org/apache/openjpa/meta/localizer.properties
Date Wed, 25 Apr 2007 09:19:52 GMT
Author: pcl
Date: Wed Apr 25 02:19:51 2007
New Revision: 532273

URL: http://svn.apache.org/viewvc?view=rev&rev=532273
Log:
Usability improvements discovered while working on OPENJPA-228. When loading enumerated types
in the enhancer, pass them to serp as strings rather than as classes. This permits the use
case where a subclass and superclass are both compiled and enhanced, and then the superclass
is recompiled, and the subclass and superclass are both listed in persistence.xml, and the
enhancer is then invoked.

Similarly, treat NoSuchMethodErrors that contain the string '.pc' as warnings rather than
errors in MetaDataRepository.classForName().

Finally, changed MetaDataRepository errors to stringify internal data sets eagerly, to avoid
leaking incorrect information into error messages.

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/MetaDataRepository.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties

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=532273&r1=532272&r2=532273
==============================================================================
--- 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
Wed Apr 25 02:19:51 2007
@@ -3612,7 +3612,7 @@
         Collection classes;
         if (args.length == 0) {
             log.info(_loc.get("running-all-classes"));
-            classes = repos.loadPersistentTypes(true, loader);
+            classes = repos.getPersistentTypeNames(true, loader);
         } else {
             ClassArgParser cap = conf.getMetaDataRepositoryInstance().
                 getMetaDataFactory().newClassArgParser();
@@ -3628,11 +3628,14 @@
         int status;
         Class cls;
         for (Iterator itr = classes.iterator(); itr.hasNext();) {
-            cls = (Class) itr.next();
+            Object o = itr.next();
             if (log.isTraceEnabled())
-                log.trace(_loc.get("enhance-running", cls));
+                log.trace(_loc.get("enhance-running", o));
 
-            bc = project.loadClass(cls);
+            if (o instanceof String)
+                bc = project.loadClass((String) o);
+            else
+                bc = project.loadClass((Class) o);
             enhancer = new PCEnhancer(conf, bc, repos);
             if (writer != null)
                 enhancer.setBytecodeWriter(writer);

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=532273&r1=532272&r2=532273
==============================================================================
--- 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
Wed Apr 25 02:19:51 2007
@@ -312,7 +312,7 @@
 
         // multiple classes may have been defined with the same alias: we
         // will filter by checking against the current list of the
-        // persistent types and filted based on which classes are loadable
+        // persistent types and filter based on which classes are loadable
         // via the current environment's ClassLoader
         Set pcNames = getPersistentTypeNames(false, envLoader);
         Class cls = null;
@@ -346,7 +346,7 @@
         if (_aliases.containsKey(alias)) {
             if (mustExist)
                 throw new MetaDataException(_loc.get("no-alias-meta", alias,
-                    _aliases));
+                    _aliases.toString()));
             return null;
         }
 
@@ -923,7 +923,7 @@
         boolean mustExist) {
         if (oid == null && mustExist)
             throw new MetaDataException(_loc.get("no-oid-meta", oid, "?",
-                _oids));
+                _oids.toString()));
         if (oid == null)
             return null;
 
@@ -1235,6 +1235,20 @@
                 _log.info(_loc.get("bad-discover-class", name));
             if (_log.isTraceEnabled())
                 _log.trace(e);
+        } catch (NoSuchMethodError nsme) {
+            if (nsme.getMessage().indexOf(".pc") == -1)
+                throw nsme;
+
+            // if the error is about a method that uses the PersistenceCapable
+            // 'pc' method prefix, perform some logging and continue. This
+            // probably just means that the class is not yet enhanced.
+            if ((_validate & VALIDATE_RUNTIME) != 0) {
+                if (_log.isWarnEnabled())
+                    _log.warn(_loc.get("bad-discover-class", name));
+            } else if (_log.isInfoEnabled())
+                _log.info(_loc.get("bad-discover-class", name));
+            if (_log.isTraceEnabled())
+                _log.trace(nsme);
         }
         return null;
     }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties?view=diff&rev=532273&r1=532272&r2=532273
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
Wed Apr 25 02:19:51 2007
@@ -142,8 +142,9 @@
 	if you list your persistent classes, the class is included in your list.
 no-oid-meta: Could not locate metadata for the class using oid "{0}" of \
 	type "{1}".  Registered oid type mappings: "{2}"
-no-alias-meta: Could not locate metadata for the class using alias "{0}". \
-	Registered alias mappings: "{1}"
+no-alias-meta: Could not locate metadata for the class using alias "{0}". This \
+	could mean that the OpenJPA enhancer or load-time weaver was not run on \
+    the type whose alias is "{0}". Registered alias mappings: "{1}"
 error-registered: An error occurred while processing registered class "{0}".
 failed-registered: A potentially serious error occurred while processing \
 	registered class "{0}".  Deferring processing of this class until next \



Mime
View raw message