openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r941515 - in /openjpa/trunk: openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-slice/src/main/java/org/apache/openjpa/slice/ openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/ openjpa-slice/src/test/java/org/apache/open...
Date Wed, 05 May 2010 22:11:52 GMT
Author: ppoddar
Date: Wed May  5 22:11:51 2010
New Revision: 941515

URL: http://svn.apache.org/viewvc?rev=941515&view=rev
Log:
OPENJPA-1649: Share metadata/mapping repository across slices. 

Modified:
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/ProductDerivation.java
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
    openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java?rev=941515&r1=941514&r2=941515&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
Wed May  5 22:11:51 2010
@@ -143,13 +143,9 @@ public abstract class DelegatingDataSour
             // that does not support getConnection(user, password)
             // see http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html
             // hence this workaround
-            try {
-                if (setBeanProperty(_ds, "setUsername", user)
-                 && setBeanProperty(_ds, "setPassword", pass))
-                    return _ds.getConnection();
-            } catch (Exception e) {
-                throw ex;
-            }
+            if (setBeanProperty(_ds, "setUsername", user)
+             && setBeanProperty(_ds, "setPassword", pass))
+                return _ds.getConnection();
         }
         return null;
     }
@@ -173,7 +169,7 @@ public abstract class DelegatingDataSour
     
     private boolean setBeanProperty(Object target, String method, Object val) {
         try {
-            Method setter = target.getClass().getMethod(method, new Class[]{});
+            Method setter = target.getClass().getMethod(method, new Class[]{String.class});
             setter.invoke(target, val);
             return true;
         } catch (Throwable t) {

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/ProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/ProductDerivation.java?rev=941515&r1=941514&r2=941515&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/ProductDerivation.java
(original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/ProductDerivation.java
Wed May  5 22:11:51 2010
@@ -24,13 +24,7 @@ import java.util.Set;
 
 import org.apache.openjpa.conf.OpenJPAProductDerivation;
 import org.apache.openjpa.lib.conf.AbstractProductDerivation;
-import org.apache.openjpa.lib.conf.Configuration;
-import org.apache.openjpa.lib.conf.PluginValue;
-import org.apache.openjpa.lib.conf.Value;
-import org.apache.openjpa.lib.log.Log;
-import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.slice.jdbc.DistributedJDBCBrokerFactory;
-import org.apache.openjpa.slice.jdbc.DistributedJDBCConfigurationImpl;
 
 /**
  * Derives configuration for Slice.
@@ -43,8 +37,6 @@ import org.apache.openjpa.slice.jdbc.Dis
  */
 public class ProductDerivation extends AbstractProductDerivation implements
 		OpenJPAProductDerivation {
-	private static final Localizer _loc = 
-		Localizer.forPackage(ProductDerivation.class);
     /**
      * Prefix for all Slice-specific configuration properties. 
      */
@@ -71,35 +63,6 @@ public class ProductDerivation extends A
 		return TYPE_STORE;
 	}
 	
-	/**
-	 * Sets the {@link DistributionPolicy} and {@link ReplicationPolicy} to
-	 * their respective defaults if not set by the user.
-	 */
-    @Override
-    public boolean afterSpecificationSet(Configuration c) {
-        if (!(c instanceof DistributedJDBCConfigurationImpl))
-            return false;
-        DistributedJDBCConfigurationImpl conf = 
-        	(DistributedJDBCConfigurationImpl)c;
-        boolean modified = false;
-        Log log = conf.getConfigurationLog();
-        if (conf.getDistributionPolicyInstance() == null) {
-        	forceSet(conf.distributionPolicyPlugin,"random", log);
-        	modified = true;
-        }
-        if (conf.getReplicationPolicyInstance() == null) {
-        	forceSet(conf.replicationPolicyPlugin, "all", log);
-        	modified = true;
-        }
-        return modified;
-    }
-    
-    void forceSet(Value v, String forced, Log log) {
-    	v.setString(forced);
-    	if (log.isWarnEnabled())
-            log.warn(_loc.get("forced-set-config", v.getProperty(), forced));
-    }
-    
     public Set<String> getSupportedQueryHints() {
         return Collections.singleton(HINT_TARGET);
     }

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java?rev=941515&r1=941514&r2=941515&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
(original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
Wed May  5 22:11:51 2010
@@ -90,11 +90,13 @@ public class DistributedJDBCConfiguratio
         distributionPolicyPlugin = addPlugin(PREFIX_SLICE + "DistributionPolicy", true);
         distributionPolicyPlugin.setAlias("random", DistributionPolicy.Default.class.getName());
         distributionPolicyPlugin.setDefault("random");
+        distributionPolicyPlugin.setString("random");
         distributionPolicyPlugin.setDynamic(true);
         
         replicationPolicyPlugin = addPlugin(PREFIX_SLICE + "ReplicationPolicy", true);
         replicationPolicyPlugin.setAlias("all", ReplicationPolicy.Default.class.getName());
         replicationPolicyPlugin.setDefault("all");
+        replicationPolicyPlugin.setString("all");
         replicationPolicyPlugin.setDynamic(true);
         
         lenientPlugin = addBoolean(PREFIX_SLICE + "Lenient");
@@ -382,11 +384,14 @@ public class DistributedJDBCConfiguratio
      * @param original a set of properties.
      * @return a newly configured slice
      */
-    protected Slice newSlice(String key, Map original) {
+    private Slice newSlice(String key, Map original) {
         JDBCConfiguration child = new JDBCConfigurationImpl();
         child.fromProperties(createSliceProperties(original, key));
         child.setId(getId()+DOT+key);
         setDiagnosticContext(child);
+        child.setMappingDefaults(this.getMappingDefaultsInstance());
+        child.setDataCacheManager(this.getDataCacheManagerInstance());
+        child.setMetaDataRepository(this.getMetaDataRepositoryInstance());
         Slice slice = new Slice(key, child);
         Log log = getConfigurationLog();
         if (log.isTraceEnabled())

Modified: openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java?rev=941515&r1=941514&r2=941515&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java
(original)
+++ openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java
Wed May  5 22:11:51 2010
@@ -310,7 +310,7 @@ public class TestQueryMultiThreaded exte
      * OPENJPA-1044</A>
      * for details.
      */
-    public void xtestQueryParameterEntity() {
+    public void testQueryParameterEntity() {
         final EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
         final Query addressQ =



Mime
View raw message