openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r454064 - 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 02:05:50 GMT
Author: pcl
Date: Sat Oct  7 19:05:49 2006
New Revision: 454064

URL: http://svn.apache.org/viewvc?view=rev&rev=454064
Log:
Changed OpenJPAProductDerivation to have a proper lifecycle callback for BrokerFactoryValue
initialization; added supporting infrastructure as needed.

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-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.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

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=454064&r1=454063&r2=454064
==============================================================================
--- 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 19:05:49 2006
@@ -21,15 +21,16 @@
 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 {
 
-    static {
-        BrokerFactoryValue.addDefaultAlias("jdbc",
-            JDBCBrokerFactory.class.getName());
+    public void initializeBrokerFactoryValueAliases(Map m) {
+        m.put("jdbc", JDBCBrokerFactory.class.getName());
     }
 
     public int getType() {
@@ -39,7 +40,7 @@
     public boolean beforeConfigurationConstruct(ConfigurationProvider cp) {
         // default to JDBC when no broker factory set
         if (BrokerFactoryValue.get(cp) == null) {
-            BrokerFactoryValue.set(cp, JDBCBrokerFactory.class.getName());
+            BrokerFactoryValue.set(cp, "jdbc");
             return true;
         }
         return false;

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=454064&r1=454063&r2=454064
==============================================================================
--- 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 19:05:49 2006
@@ -17,13 +17,17 @@
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Iterator;
 
 import org.apache.openjpa.abstractstore.AbstractStoreBrokerFactory;
 import org.apache.openjpa.kernel.BrokerFactory;
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.PluginValue;
 import org.apache.openjpa.lib.conf.ProductDerivations;
+import org.apache.openjpa.lib.conf.ProductDerivation;
 
 /**
  * Value type used to represent the {@link BrokerFactory}. This type is
@@ -40,9 +44,22 @@
 
     private static final List _aliases = new ArrayList();
     private static final List _prefixes = new ArrayList(2);
+
     static {
-        addDefaultAlias("abstractstore",
+        Map aliases = new HashMap();
+        aliases.put("abstractstore", 
             AbstractStoreBrokerFactory.class.getName());
+        ProductDerivation[] ds = ProductDerivations.getProductDerivations();
+        for (int i = 0; i < ds.length; i++) {
+            if (ds[i] instanceof OpenJPAProductDerivation)
+                ((OpenJPAProductDerivation) ds[i])
+                    .initializeBrokerFactoryValueAliases(aliases);
+        }
+
+        for (Iterator iter = aliases.entrySet().iterator(); iter.hasNext(); ) {
+            Map.Entry e = (Map.Entry) iter.next();
+            addDefaultAlias((String) e.getKey(), (String) e.getValue());
+        }
     }
 
     /**

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=454064&r1=454063&r2=454064
==============================================================================
--- 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 19:05:49 2006
@@ -16,6 +16,7 @@
 package org.apache.openjpa.conf;
 
 import org.apache.openjpa.lib.conf.ProductDerivation;
+import java.util.Map;
 
 /**
  * Adds datastore based extension to ProductDerivation.  
@@ -29,4 +30,11 @@
     public static final int TYPE_STORE = 200;
     public static final int TYPE_SPEC_STORE = 300;
     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.
+     */
+    public void initializeBrokerFactoryValueAliases(Map aliases);
 }

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java?view=diff&rev=454064&r1=454063&r2=454064
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java
(original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java
Sat Oct  7 19:05:49 2006
@@ -47,14 +47,14 @@
 
     /**
      * Load globals into the returned ConfigurationProvider, or return null if 
-     * no globals is found.
+     * no globals are found.
      */
     public ConfigurationProvider loadGlobals(ClassLoader loader) 
         throws Exception;
 
     /**
      * Load defaults into the returned ConfigurationProvider, or return null if 
-     * no defaults is found.
+     * no defaults are found.
      */
     public ConfigurationProvider loadDefaults(ClassLoader loader) 
         throws Exception;

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=454064&r1=454063&r2=454064
==============================================================================
--- 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 19:05:49 2006
@@ -76,6 +76,13 @@
     }
 
     /**
+     * Return all the product derivations registered in the current classloader
+     */
+    public static ProductDerivation[] getProductDerivations() {
+        return _derivations;
+    }
+
+    /**
      * Return the recognized prefixes for configuration properties.
      */
     public static String[] getConfigurationPrefixes() {

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=454064&r1=454063&r2=454064
==============================================================================
--- 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 19:05:49 2006
@@ -24,6 +24,8 @@
 import org.apache.openjpa.persistence.FetchPlan;
 import org.apache.openjpa.persistence.PersistenceProductDerivation;
 
+import java.util.Map;
+
 /**
  * Sets JDBC-specific JPA specification defaults.
  *
@@ -34,6 +36,9 @@
     extends AbstractProductDerivation 
     implements OpenJPAProductDerivation {
     
+    public void initializeBrokerFactoryValueAliases(Map m) {
+    }
+
     public int getType() {
         return TYPE_SPEC_STORE;
     }

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=454064&r1=454063&r2=454064
==============================================================================
--- 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 19:05:49 2006
@@ -70,6 +70,9 @@
     private static final Localizer _loc = Localizer.forPackage
         (PersistenceProductDerivation.class);
 
+    public void initializeBrokerFactoryValueAliases(Map m) {
+    }
+
     public int getType() {
         return TYPE_SPEC;
     }



Mime
View raw message