openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r454072 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-kernel/src/main/java/org/apache/openjpa/conf/ openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ openjpa-persistence-jdbc/src/main/j...
Date Sun, 08 Oct 2006 04:03:07 GMT
Author: awhite
Date: Sat Oct  7 21:03:06 2006
New Revision: 454072

URL: http://svn.apache.org/viewvc?view=rev&rev=454072
Log:
Get rid of warning for product derivations that use an unsupported class
version.  Minor API changes.


Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAProductDerivation.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
    incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java?view=diff&rev=454072&r1=454071&r2=454072
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCProductDerivation.java
Sat Oct  7 21:03:06 2006
@@ -15,21 +15,21 @@
  */
 package org.apache.openjpa.jdbc.conf;
 
+import java.util.Map;
+
 import org.apache.openjpa.conf.BrokerFactoryValue;
 import org.apache.openjpa.conf.OpenJPAProductDerivation;
 import org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory;
 import org.apache.openjpa.lib.conf.AbstractProductDerivation;
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 
-import java.util.Map;
-
 /**
  * Sets JDBC as default store.
  */
 public class JDBCProductDerivation extends AbstractProductDerivation
     implements OpenJPAProductDerivation {
 
-    public void initializeBrokerFactoryValueAliases(Map m) {
+    public void putBrokerFactoryAliases(Map m) {
         m.put("jdbc", JDBCBrokerFactory.class.getName());
     }
 

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java?view=diff&rev=454072&r1=454071&r2=454072
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/BrokerFactoryValue.java
Sat Oct  7 21:03:06 2006
@@ -42,9 +42,7 @@
 
     public static final String KEY = "BrokerFactory";
 
-    private static final List _aliases = new ArrayList();
-    private static final List _prefixes = new ArrayList(2);
-
+    private static final String[] _aliases;
     static {
         Map aliases = new HashMap();
         aliases.put("abstractstore", 
@@ -52,26 +50,16 @@
         ProductDerivation[] ds = ProductDerivations.getProductDerivations();
         for (int i = 0; i < ds.length; i++) {
             if (ds[i] instanceof OpenJPAProductDerivation)
-                ((OpenJPAProductDerivation) ds[i])
-                    .initializeBrokerFactoryValueAliases(aliases);
+                ((OpenJPAProductDerivation) ds[i]).putBrokerFactoryAliases
+                    (aliases);
         }
 
+        _aliases = new String[aliases.size() * 2];
+        int i = 0;
         for (Iterator iter = aliases.entrySet().iterator(); iter.hasNext(); ) {
             Map.Entry e = (Map.Entry) iter.next();
-            addDefaultAlias((String) e.getKey(), (String) e.getValue());
-        }
-    }
-
-    /**
-     * Add a mapping from <code>alias</code> to <code>cls</code>
to the list
-     * of default aliases for new values created after this invocation.
-     */
-    public static void addDefaultAlias(String alias, String cls) {
-        if (_aliases.contains(alias)) {
-            _aliases.set(_aliases.indexOf(alias) + 1, cls);
-        } else {
-            _aliases.add(alias);
-            _aliases.add(cls);
+            _aliases[i++] = (String) e.getKey();
+            _aliases[i++] = (String) e.getValue();
         }
     }
 
@@ -99,6 +87,6 @@
 
     public BrokerFactoryValue() {
         super(KEY, false);
-        setAliases((String[]) _aliases.toArray(new String[_aliases.size()]));
+        setAliases(_aliases);
     }
 }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAProductDerivation.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAProductDerivation.java?view=diff&rev=454072&r1=454071&r2=454072
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAProductDerivation.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAProductDerivation.java
Sat Oct  7 21:03:06 2006
@@ -32,9 +32,9 @@
     public static final int TYPE_PRODUCT_STORE = 400;
 
     /**
-     * Load default alias options into the BrokerFactoryValue's static data
-     * structures. In the case of multiple ProductDerivations, this will be
-     * invoked in the order defined by the type of the product derivation.
+     * Load default alias options into the given map.  Each entry maps an
+     * alias to a broker factory class name.  Replace anything perviously 
+     * under the desired keys.
      */
-    public void initializeBrokerFactoryValueAliases(Map aliases);
+    public void putBrokerFactoryAliases(Map aliases);
 }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java?view=diff&rev=454072&r1=454071&r2=454072
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
Sat Oct  7 21:03:06 2006
@@ -44,13 +44,10 @@
         String vers = pack == null ? null : pack.getImplementationVersion();
         if (vers == null || vers.length() == 0)
             vers = "0.0.0";
-
         VERSION_NUMBER = vers;
 
         StringTokenizer tok = new StringTokenizer(VERSION_NUMBER, ".-");
-
         int major, minor, patch;
-
         try {
             major = tok.hasMoreTokens() ? Integer.parseInt(tok.nextToken()) : 0;
         } catch (Exception e) {
@@ -71,8 +68,8 @@
 
         String revision = "";
         try {
-            InputStream in = OpenJPAVersion.class.
-                getResourceAsStream("/META-INF/org.apache.openjpa.revision.properties");
+            InputStream in = OpenJPAVersion.class.getResourceAsStream
+                ("/META-INF/org.apache.openjpa.revision.properties");
             if (in != null) {
                 try {
                     Properties props = new Properties();
@@ -102,12 +99,12 @@
         appendOpenJPABanner(buf);
         buf.append("\n");
 
-        getProperty("os.name", buf).append("\n");
-        getProperty("os.version", buf).append("\n");
-        getProperty("os.arch", buf).append("\n\n");
+        appendProperty("os.name", buf).append("\n");
+        appendProperty("os.version", buf).append("\n");
+        appendProperty("os.arch", buf).append("\n\n");
 
-        getProperty("java.version", buf).append("\n");
-        getProperty("java.vendor", buf).append("\n\n");
+        appendProperty("java.version", buf).append("\n");
+        appendProperty("java.vendor", buf).append("\n\n");
 
         buf.append("java.class.path:\n");
         StringTokenizer tok = new StringTokenizer
@@ -118,8 +115,7 @@
         }
         buf.append("\n");
 
-        getProperty("user.dir", buf);
-
+        appendProperty("user.dir", buf);
         return buf.toString();
     }
 
@@ -133,8 +129,7 @@
         buf.append("\n");
     }
 
-    private StringBuffer getProperty(String prop, StringBuffer buf) {
-        buf.append(prop).append(": ").append(System.getProperty(prop));
-        return buf;
+    private StringBuffer appendProperty(String prop, StringBuffer buf) {
+        return buf.append(prop).append(": ").append(System.getProperty(prop));
     }
 }

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=454072&r1=454071&r2=454072
==============================================================================
--- 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
Sat Oct  7 21:03:06 2006
@@ -33,6 +33,9 @@
  */
 public class ProductDerivations {
 
+    private static final Localizer _loc = Localizer.forPackage
+        (ProductDerivations.class);
+
     private static final ProductDerivation[] _derivations;
     private static final String[] _prefixes;
     static {
@@ -43,9 +46,11 @@
             try {
                 Class cls = Class.forName(pds[i], true, cl);
                 derivations.add(cls.newInstance());
+            } catch (UnsupportedClassVersionError ucve) {
+                // ignore so that < 1.5 users don't get errors about
+                // 1.5 products they aren't using
             } catch (Throwable t) {
-                Localizer loc = Localizer.forPackage(ProductDerivations.class);
-                System.err.println(loc.get("bad-product-derivation", pds[i], 
+                System.err.println(_loc.get("bad-product-derivation", pds[i], 
                     t));
             }
         }

Modified: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java?view=diff&rev=454072&r1=454071&r2=454072
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java
Sat Oct  7 21:03:06 2006
@@ -15,6 +15,8 @@
  */
 package org.apache.openjpa.persistence.jdbc;
 
+import java.util.Map;
+
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.conf.OpenJPAProductDerivation;
 import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
@@ -24,8 +26,6 @@
 import org.apache.openjpa.persistence.FetchPlan;
 import org.apache.openjpa.persistence.PersistenceProductDerivation;
 
-import java.util.Map;
-
 /**
  * Sets JDBC-specific JPA specification defaults.
  *
@@ -36,7 +36,7 @@
     extends AbstractProductDerivation 
     implements OpenJPAProductDerivation {
     
-    public void initializeBrokerFactoryValueAliases(Map m) {
+    public void putBrokerFactoryAliases(Map m) {
     }
 
     public int getType() {

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java?view=diff&rev=454072&r1=454071&r2=454072
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
Sat Oct  7 21:03:06 2006
@@ -70,7 +70,7 @@
     private static final Localizer _loc = Localizer.forPackage
         (PersistenceProductDerivation.class);
 
-    public void initializeBrokerFactoryValueAliases(Map m) {
+    public void putBrokerFactoryAliases(Map m) {
     }
 
     public int getType() {
@@ -326,10 +326,8 @@
             loader = Thread.currentThread().getContextClassLoader();
         try {
             if (PersistenceProviderImpl.class.isAssignableFrom
-                (Class.forName(provider, false, loader))) {
-                log(_loc.get("extended-provider", provider).getMessage());
+                (Class.forName(provider, false, loader)))
                 return true;
-            }
         } catch (Throwable t) {
             log(_loc.get("unloadable-provider", provider, t).getMessage());
             return false;

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties?view=diff&rev=454072&r1=454071&r2=454072
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties
Sat Oct  7 21:03:06 2006
@@ -86,7 +86,6 @@
 no-transaction: Cannot perform operation with no transaction.
 multiple-methods-on-callback: Class "{0}" declares method "{1}" as well \
 	as "{2}" for handling the same "{3}" callback. 
-extended-provider: NOTE: Found extended persistence provider "{0}".
 unloadable-provider: WARNING: Unable to load persistence provider "{0}" due \
     to "{1}"
 unrecognized-provider: WARNING: Found unrecognized persistence provider "{0}" \



Mime
View raw message