openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r825904 - in /openjpa/sandboxes/perf: openjpa-kernel/src/main/java/org/apache/openjpa/conf/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-persistence-jdbc/src/test/reso...
Date Fri, 16 Oct 2009 14:14:08 GMT
Author: curtisr7
Date: Fri Oct 16 14:14:08 2009
New Revision: 825904

URL: http://svn.apache.org/viewvc?rev=825904&view=rev
Log:
Updating preload with latests functional changes.

Modified:
    openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataRepositoryValue.java
    openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
    openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
    openjpa/sandboxes/perf/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
    openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java

Modified: openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataRepositoryValue.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataRepositoryValue.java?rev=825904&r1=825903&r2=825904&view=diff
==============================================================================
--- openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataRepositoryValue.java
(original)
+++ openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataRepositoryValue.java
Fri Oct 16 14:14:08 2009
@@ -34,9 +34,7 @@
     extends PluginValue {
 
     private static final String KEY = "MetaDataRepository";
-    private static final String PRELOAD_STR = "Preload=true";
-    private static final String NOLOCK_STR = "NoLock=true";
-      
+
     public MetaDataRepositoryValue() {
         super(KEY, false);
         String[] aliases = new String[] {
@@ -48,25 +46,6 @@
         setString(aliases[0]);
     }
 
-    public boolean getPreload() {
-        String p = getProperties();
-        if (p != null && p.indexOf(PRELOAD_STR) >= 0) {
-            return true;
-        } else if (getNoLock() == true) {
-            // No locking implies that we need to also preload.
-            // Return true regardless of the value of the
-            // preload flag.
-            return true;
-        }
-        return false;
-    }
-    public boolean getNoLock(){
-        String p = getProperties();
-        if (p != null && p.indexOf(NOLOCK_STR) >= 0) {
-            return true;
-        }
-        return false;
-    }
     public Object instantiate(Class type, Configuration c, boolean fatal) {
         MetaDataRepository repos = null;
         OpenJPAConfiguration conf = (OpenJPAConfiguration) c;

Modified: openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?rev=825904&r1=825903&r2=825904&view=diff
==============================================================================
--- openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
(original)
+++ openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Fri Oct 16 14:14:08 2009
@@ -150,19 +150,6 @@
         _brokers = newBrokerSet();
         getPcClassLoaders();
 
-        // This logic needs to happen here for a reason! The preloading of the MDR
-        // can not happen during the configuration of the MDR because when running
-        // in a container environment we need to be able to get an uninitialized
-        // MDR to pass to the PCClassFileTransformer. If we preload before registering
-        // the class transformer, we miss the class being defined by the JVM and in turn
-        // we fail to enhance our entities.
-        OpenJPAConfigurationImpl impl = (OpenJPAConfigurationImpl) config;
-        MetaDataRepositoryValue m = impl.metaRepositoryPlugin;
-        if (m.getPreload() == true) {
-            // Obtain a reference to the MetaDataRepository and trigger the preload
-            MetaDataRepository mdr = config.getMetaDataRepositoryInstance();
-            mdr.preload();
-        }
     }
 
     /**

Modified: openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?rev=825904&r1=825903&r2=825904&view=diff
==============================================================================
--- openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
(original)
+++ openjpa/sandboxes/perf/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
Fri Oct 16 14:14:08 2009
@@ -133,8 +133,8 @@
     private transient InterfaceImplGenerator _implGen = null;
     private transient MetaDataFactory _factory = null;
 
-    private int _resMode = MODE_META | MODE_MAPPING;
     private int _sourceMode = MODE_META | MODE_MAPPING | MODE_QUERY;
+    private int _resMode = MODE_META | MODE_MAPPING;
     private int _validate = VALIDATE_META | VALIDATE_UNENHANCED;
 
     // we buffer up any classes that register themselves to prevent
@@ -320,7 +320,7 @@
             _subs = new HashMap();
             _lock = null;
         }
-
+        
         MultiClassLoader multi =
             AccessController.doPrivileged(J2DoPrivHelper.newMultiClassLoaderAction());
         multi.addClassLoader(AccessController.doPrivileged(J2DoPrivHelper
@@ -343,7 +343,11 @@
                 Class<?> cls =
                     AccessController
                         .doPrivileged((J2DoPrivHelper.getForNameAction(c, true, multi)));
-                _factory.load(cls, MODE_ALL, multi);
+                // TODO -- need to test this
+//                resolveAll(multi);
+//                // Load query metadata
+//                _factory.load(cls, MODE_QUERY, multi);
+                _factory.load(cls, MODE_ALL, multi);                
             } catch (PrivilegedActionException pae) {
                 // Unexpected!
                 if (_log.isTraceEnabled() == true) {
@@ -352,6 +356,11 @@
                 }
             }
         }// end for
+        
+        // Hook this class in early so we can process registered classes and add them 
+        // to _aliases list.
+        PCRegistry.addRegisterClassListener(this);
+        processRegisteredClasses(multi);
     }
     
     protected void lock() {

Modified: openjpa/sandboxes/perf/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml?rev=825904&r1=825903&r2=825904&view=diff
==============================================================================
--- openjpa/sandboxes/perf/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
(original)
+++ openjpa/sandboxes/perf/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
Fri Oct 16 14:14:08 2009
@@ -94,6 +94,5 @@
         <mapping-file>org/apache/openjpa/persistence/jdbc/unique/orm.xml</mapping-file>
         <class>org.apache.openjpa.persistence.jdbc.unique.UniqueA</class>
         <class>org.apache.openjpa.persistence.jdbc.unique.UniqueB</class>
-    </persistence-unit>
-    
+    </persistence-unit>   
 </persistence>

Modified: openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java?rev=825904&r1=825903&r2=825904&view=diff
==============================================================================
--- openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
(original)
+++ openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
Fri Oct 16 14:14:08 2009
@@ -22,12 +22,14 @@
 import java.lang.instrument.IllegalClassFormatException;
 import java.security.ProtectionDomain;
 import java.util.Map;
+
 import javax.persistence.EntityManager;
 import javax.persistence.spi.ClassTransformer;
 import javax.persistence.spi.PersistenceProvider;
 import javax.persistence.spi.PersistenceUnitInfo;
 
 import org.apache.openjpa.conf.BrokerValue;
+import org.apache.openjpa.conf.MetaDataRepositoryValue;
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
 import org.apache.openjpa.enhance.PCClassFileTransformer;
@@ -38,6 +40,7 @@
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.meta.MetaDataModes;
 import org.apache.openjpa.meta.MetaDataRepository;
 import org.apache.openjpa.util.ClassResolver;
@@ -79,6 +82,18 @@
                 return null;
 
             BrokerFactory factory = getBrokerFactory(cp, poolValue, null);
+            
+            // We need to wait to preload until after we get back a fully configured/instantiated
+            // BrokerFactory. This is because it is possible that someone has extended OpenJPA
+            // functions and they need to be allowed time to configure themselves before
we go off and
+            // start instanting configurable objects (ie:openjpa.MetaDataRepository). Don't
catch
+            // any exceptions here because we want to fail-fast.
+            OpenJPAConfiguration conf = factory.getConfiguration();
+            Options o = Configurations.parseProperties(Configurations.getProperties(conf.getMetaDataRepository()));
+            if(o.getBooleanProperty("Preload")){
+                conf.getMetaDataRepositoryInstance().preload();
+            }
+            
             return JPAFacadeHelper.toEntityManagerFactory(factory);
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
@@ -153,6 +168,17 @@
                         _loc.get("transformer-registration-error", pui));
                 }
             }
+            // We need to wait to preload until after we get back a fully configured/instantiated
+            // BrokerFactory. This is because it is possible that someone has extended OpenJPA
+            // functions and they need to be allowed time to configure themselves before
we go off and
+            // start instanting configurable objects (ie:openjpa.MetaDataRepository). Don't
catch
+            // any exceptions here because we want to fail-fast.
+            OpenJPAConfiguration conf = factory.getConfiguration();
+            Options o = Configurations.parseProperties(Configurations.getProperties(conf.getMetaDataRepository()));
+            if(o.getBooleanProperty("Preload")){
+                conf.getMetaDataRepositoryInstance().preload();
+            }
+            
             return JPAFacadeHelper.toEntityManagerFactory(factory);
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);



Mime
View raw message