openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r1159318 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-kernel/src/main/java/org/apache/openjpa/conf/
Date Thu, 18 Aug 2011 17:20:04 GMT
Author: mikedd
Date: Thu Aug 18 17:20:04 2011
New Revision: 1159318

URL: http://svn.apache.org/viewvc?rev=1159318&view=rev
Log:
OPENJPA-2040: Default to non-strict MetaData and Mapping Factories when a user provided factory
class is set.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MetaDataPlusMappingFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java?rev=1159318&r1=1159317&r2=1159318&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingFactoryValue.java
Thu Aug 18 17:20:04 2011
@@ -19,6 +19,7 @@
 package org.apache.openjpa.jdbc.conf;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.jdbc.meta.MetaDataPlusMappingFactory;
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.conf.Configurations;
@@ -155,8 +156,20 @@ public class MappingFactoryValue
 
         // if no mapping setting, return meta factory alone, assuming it handles
         // both metadata and mapping
-        MetaDataFactory ret = (map == null) ? meta
-            : new MetaDataPlusMappingFactory(meta, map);
-        return ret;
+        MetaDataFactory ret = null;
+        if(map == null ) { 
+            ret = meta;
+        }
+        else {
+            if( conf instanceof OpenJPAConfiguration) {
+                ret = new MetaDataPlusMappingFactory(meta, map, (OpenJPAConfiguration) conf);
+            }
+            else {
+                ret = new MetaDataPlusMappingFactory(meta, map);
+            }
+        }
+        
+        return ret; 
+        
     }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MetaDataPlusMappingFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MetaDataPlusMappingFactory.java?rev=1159318&r1=1159317&r2=1159318&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MetaDataPlusMappingFactory.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MetaDataPlusMappingFactory.java
Thu Aug 18 17:20:04 2011
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.DelegatingMetaDataFactory;
 import org.apache.openjpa.meta.MetaDataFactory;
@@ -42,16 +43,30 @@ public class MetaDataPlusMappingFactory
 
     private final MetaDataFactory _map;
 
+    
     /**
      * Constructor; supply delegates.
      */
-    public MetaDataPlusMappingFactory(MetaDataFactory meta,
-        MetaDataFactory map) {
+    public MetaDataPlusMappingFactory(MetaDataFactory meta, MetaDataFactory map) {
+        this(meta, map, null);
+
+    }
+    
+    /**
+     * Constructor, supply delegates and Configuration. 
+     * 
+     * @param meta MetaFactory delegate, should not be null.
+     * @param map  MappingFactory delegate, should not be null.
+     * @param conf Configuration in use. Used to determine whether delegates should use strict
mode. 
+     */
+    public MetaDataPlusMappingFactory(MetaDataFactory meta, MetaDataFactory map, OpenJPAConfiguration
conf) {
         super(meta);
         _map = map;
 
-        meta.setStrict(true);
-        map.setStrict(true);
+        if(conf.getCompatibilityInstance().getMetaFactoriesAreStrict()) {
+            meta.setStrict(true);
+            map.setStrict(true);
+        }
     }
 
     /**

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java?rev=1159318&r1=1159317&r2=1159318&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
Thu Aug 18 17:20:04 2011
@@ -72,6 +72,7 @@ public class Compatibility {
     private boolean _convertPositionalParametersToNamed = false;
     
     private boolean _useListAttributeForArrays = false; 
+    private boolean _metaFactoriesAreStrict = false; 
     
     /**
      * Whether to require exact identity value types when creating object
@@ -640,4 +641,29 @@ public class Compatibility {
     public void setUseListAttributeForArrays(boolean useListAttribute ) { 
         _useListAttributeForArrays = useListAttribute;
     }
+
+    /**
+     * Whether the MetaDataFactory and MappingFactory should be set to strict mode. If strict
mode is used a
+     * MetaDataFactory will only resolve MetaData (no JDBC mappings), and a MappingFactory
will only resolve Mapping
+     * information.
+     * 
+     * @since 2.2.0
+     * @return Whether strict mode should be used.
+     */
+    public boolean getMetaFactoriesAreStrict() { 
+        return _metaFactoriesAreStrict;
+    }
+    
+    /**
+     * Set whether MetaDataFactories and MappingFactories will be strictly separate.
+     * 
+     * @since 2.2.0
+     * 
+     * @param metaFactoriesAreStrict
+     *            True if the MetaDataFactory should only process metadata, and the MappingFactory
should only process
+     *            mappings.
+     */
+    public void setMetaFactoriesAreStrict(boolean metaFactoriesAreStrict) {
+        _metaFactoriesAreStrict = metaFactoriesAreStrict;
+    }
 }



Mime
View raw message