openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mprud...@apache.org
Subject svn commit: r549517 - /openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
Date Thu, 21 Jun 2007 15:44:07 GMT
Author: mprudhom
Date: Thu Jun 21 08:44:06 2007
New Revision: 549517

URL: http://svn.apache.org/viewvc?view=rev&rev=549517
Log:
Changed checking for javax.xml.bind.annotation.XmlType to use reflection instead of a hard-wired
class name so we more gracefully handle cases where JAXB is not available.

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java?view=diff&rev=549517&r1=549516&r2=549517
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java
Thu Jun 21 08:44:06 2007
@@ -51,7 +51,6 @@
 import javax.persistence.TableGenerator;
 import javax.persistence.Temporal;
 import javax.persistence.UniqueConstraint;
-import javax.xml.bind.annotation.XmlType;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
@@ -1023,6 +1022,14 @@
             throw new MetaDataException(_loc.get("num-cols-mismatch", fm,
                 String.valueOf(cols.size()), String.valueOf(pcols.length)));
 
+        // cache the JAXB XmlType class if it is present so we do not
+        // have a hard-wired dependency on JAXB here
+        Class xmlTypeClass = null;
+        try {
+            xmlTypeClass = Class.forName("javax.xml.bind.annotation.XmlType");
+        } catch (Exception e) {
+        }
+
         int unique = 0;
         String secondary = null;
         for (int i = 0; i < pcols.length; i++) {
@@ -1034,8 +1041,9 @@
                 cols.add(newColumn(pcols[i]));
             }
             
-            if (StringUtils.isEmpty(pcols[i].columnDefinition())
-                && fm.getDeclaredType().isAnnotationPresent(XmlType.class)) {
+            if (xmlTypeClass != null
+                && StringUtils.isEmpty(pcols[i].columnDefinition())
+                && fm.getDeclaredType().isAnnotationPresent(xmlTypeClass)) {
                 DBDictionary dict = ((MappingRepository) getRepository())
                     .getDBDictionary();
                 if (dict.supportsXMLColumn)



Mime
View raw message