openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r448625 - in /incubator/openjpa/trunk: openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
Date Thu, 21 Sep 2006 18:28:07 GMT
Author: awhite
Date: Thu Sep 21 11:28:06 2006
New Revision: 448625

URL: http://svn.apache.org/viewvc?view=rev&rev=448625
Log:
Die in ProductDerivations.load() if given resource/file can't be parsed by any
ProductDerivations in the system.


Modified:
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java?view=diff&rev=448625&r1=448624&r2=448625
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
Thu Sep 21 11:28:06 2006
@@ -751,7 +751,7 @@
      */
     public void setProperties(String resourceName) throws IOException {
         ProductDerivations.load(resourceName, null, 
-                getClass().getClassLoader()).setInto(this);
+            getClass().getClassLoader()).setInto(this);
         _auto = resourceName;
     }
 
@@ -761,8 +761,8 @@
      * <code>propertiesFile</code> value with the name of a file.
      */
     public void setPropertiesFile(File file) throws IOException {
-        ProductDerivations.load(file, null, 
-                getClass().getClassLoader()).setInto(this);
+        ProductDerivations.load(file, null, getClass().getClassLoader()).
+            setInto(this);
         _auto = file.toString();
     }
 

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java?view=diff&rev=448625&r1=448624&r2=448625
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
Thu Sep 21 11:28:06 2006
@@ -133,7 +133,8 @@
             }
         }
         reportErrors(errs, resource);
-        return null;
+        throw new MissingResourceException(resource, 
+            ProductDerivations.class.getName(), resource);
     }
 
     /**
@@ -162,7 +163,8 @@
             }
         }
         reportErrors(errs, file.getAbsolutePath());
-        return null;
+        throw new MissingResourceException(file.getAbsolutePath(), 
+            ProductDerivations.class.getName(), file.getAbsolutePath());
     }
    
     /**

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java?view=diff&rev=448625&r1=448624&r2=448625
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java
Thu Sep 21 11:28:06 2006
@@ -48,6 +48,8 @@
 public class PersistenceUnitInfoImpl
     implements PersistenceUnitInfo, SourceTracker {
 
+    public static final String KEY_PROVIDER = "javax.persistence.provider";
+
     private static final Localizer s_loc = Localizer.forPackage
         (PersistenceUnitInfoImpl.class);
 
@@ -181,8 +183,8 @@
     }
 
     public List<URL> getJarFileUrls() {
-        return (_jarFiles == null)
-            ? (List<URL>) Collections.EMPTY_LIST : _jarFiles;
+        return (_jarFiles == null) ? (List<URL>) Collections.EMPTY_LIST 
+            : _jarFiles;
     }
 
     public void addJarFile(URL jar) {
@@ -215,8 +217,8 @@
                 }
             }
         }
-        throw new IllegalArgumentException(s_loc.get("bad-jar-name", name)
-            .getMessage());
+        throw new IllegalArgumentException(s_loc.get("bad-jar-name", name).
+            getMessage());
     }
 
     public List<String> getManagedClassNames() {
@@ -269,13 +271,13 @@
         for (Object o : map.entrySet()) {
             key = ((Map.Entry) o).getKey();
             val = ((Map.Entry) o).getValue();
-            if ("javax.persistence.provider".equals(key))
+            if (KEY_PROVIDER.equals(key))
                 setPersistenceProviderClassName((String) val);
             else if ("javax.persistence.transactionType".equals(key)) {
                 PersistenceUnitTransactionType ttype;
                 if (val instanceof String)
-                    ttype = Enum.valueOf
-                        (PersistenceUnitTransactionType.class, (String) val);
+                    ttype = Enum.valueOf(PersistenceUnitTransactionType.class, 
+                        (String) val);
                 else
                     ttype = (PersistenceUnitTransactionType) val;
                 setTransactionType(ttype);
@@ -320,11 +322,9 @@
             map.put("openjpa.ConnectionFactoryMode", "managed");
             hasJta = true;
         } else if (info instanceof PersistenceUnitInfoImpl
-            && ((PersistenceUnitInfoImpl) info).getJtaDataSourceName() != null)
-        {
-            map.put("openjpa.ConnectionFactoryName",
-                ((PersistenceUnitInfoImpl)
-                    info).getJtaDataSourceName());
+            && ((PersistenceUnitInfoImpl) info).getJtaDataSourceName() != null){
+            map.put("openjpa.ConnectionFactoryName", ((PersistenceUnitInfoImpl)
+                info).getJtaDataSourceName());
             map.put("openjpa.ConnectionFactoryMode", "managed");
             hasJta = true;
         }
@@ -343,8 +343,7 @@
             if (!hasJta)
                 map.put("openjpa.ConnectionFactoryName", nonJtaName);
             else
-                map.put("openjpa.ConnectionFactory2Name",
-                    nonJtaName);
+                map.put("openjpa.ConnectionFactory2Name", nonJtaName);
         }
 
         if (info.getClassLoader() != null)
@@ -354,13 +353,13 @@
         Properties props = info.getProperties();
         if (props != null) {
             map.putAll(props);
-            // this isn't a real config property; remove it.
+            // this isn't a real config property; remove it
             map.remove(PersistenceProviderImpl.CLASS_TRANSFORMER_OPTIONS);
         }
 
         Properties metaFactoryProps = new Properties();
-        if (info.getManagedClassNames() != null &&
-            !info.getManagedClassNames().isEmpty()) {
+        if (info.getManagedClassNames() != null 
+            && !info.getManagedClassNames().isEmpty()) {
             StringBuffer types = new StringBuffer();
             for (String type : info.getManagedClassNames()) {
                 if (types.length() > 0)
@@ -404,8 +403,7 @@
         }
         if (!metaFactoryProps.isEmpty()) {
             // set persistent class locations as properties of metadata factory
-            String factory =
-                (String) map.get("openjpa.MetaDataFactory");
+            String factory = (String) map.get("openjpa.MetaDataFactory");
             if (factory == null)
                 factory = Configurations.serializeProperties(metaFactoryProps);
             else {
@@ -417,6 +415,9 @@
             }
             map.put("openjpa.MetaDataFactory", factory);
         }
+
+        // always record provider name for product derivations to access
+        map.put(KEY_PROVIDER, info.getPersistenceProviderClassName());
         return map;
     }
 



Mime
View raw message