Author: curtisr7
Date: Wed Nov 18 20:15:32 2009
New Revision: 881916

URL: http://svn.apache.org/viewvc?rev=881916&view=rev
Log: (empty)

Modified:
    
openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
    
openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java

Modified: 
openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
URL: 
http://svn.apache.org/viewvc/openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java?rev=881916&r1=881915&r2=881916&view=diff
==============================================================================
--- 
openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
 (original)
+++ 
openjpa/sandboxes/perf/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
 Wed Nov 18 20:15:32 2009
@@ -30,7 +30,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.MissingResourceException;
-
 import javax.persistence.spi.PersistenceUnitInfo;
 import javax.persistence.spi.PersistenceUnitTransactionType;
 
@@ -454,8 +453,6 @@
             _source = source;
         }
 
-        static final int MAX_PERF_LEVEL = 1;
-        
         @Override
         public void setInto(Configuration conf) {
             if (conf instanceof OpenJPAConfiguration) {
@@ -476,49 +473,6 @@
                         addProperty(key, Configurations.combinePlugins(orig, 
                             (String) override));
                 }
-                
-                // Setup Performance configuration properties. 
-                Map props = getProperties();
-                Object perfLevel = 
props.get(ProductDerivations.getConfigurationKey("Performance", 
getProperties()));
-                if (perfLevel instanceof String) {
-                    int level = 0;
-                    try {
-                        level = Integer.parseInt((String) perfLevel);
-                        if(level > MAX_PERF_LEVEL){
-                            level = MAX_PERF_LEVEL;
-                            Log log = 
oconf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
-                            // We missed translation. What to do about this?
-                            if(log.isInfoEnabled()){
-                                // LOG ME
-                            }
-                        }
-                    } catch (NumberFormatException nfe) {
-                        if (Boolean.parseBoolean((String) perfLevel) == true) {
-                            // If true, set to maximum perfLevel.
-                            level = MAX_PERF_LEVEL;
-                        } else {
-                            level = 0;
-                        }
-                    }// end catch
-                    
-                    // The reason that there is a switch here is that in the 
future when(if) there is another
-                    // performance level, the new level will include the 
older(lower) levels. ie: Level 2 would include
-                    // changes that were a part of Level 1.
-                    switch (level) {
-                        case 1:
-                            // TODO -- add a trace point if we found a user 
property conflicting with
-                            // the performance prop?
-                            String key = 
ProductDerivations.getConfigurationKey("MetaDataRepository", getProperties());
-                            if (props.containsKey(key) == false) {
-                                addProperty(key, 
"NoLock=true,EagerPersistentMetaData=true");
-                            }
-                            key = 
ProductDerivations.getConfigurationKey("BrokerImpl", getProperties());
-                            if (props.containsKey(key) == false) {
-                                addProperty(key, 
"SuppressBatchOleLogging=true");
-                            }
-                            break;
-                    }
-                }
             }
 
             super.setInto(conf, null);

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=881916&r1=881915&r2=881916&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
 Wed Nov 18 20:15:32 2009
@@ -85,22 +85,7 @@
                 return null;
 
             BrokerFactory factory = getBrokerFactory(cp, poolValue, null);
-            
-            // We need to wait to initializeEager 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 (MetaDataRepository.needsInitializeEager(o) == true) {
-                MetaDataRepository mdr = conf.getMetaDataRepositoryInstance(); 
-                mdr.setValidate(MetaDataRepository.VALIDATE_RUNTIME, true);
-                mdr.setResolve(MetaDataRepository.MODE_MAPPING_INIT, true);
-                ((AbstractBrokerFactory) 
factory).loadPersistentTypes((ClassLoader) AccessController.doPrivileged(
-                    J2DoPrivHelper.getContextClassLoaderAction()));
-                conf.getMetaDataRepositoryInstance().initializeEager();
-            }
+            preloadMetaDataRepository(factory);
             
             return JPAFacadeHelper.toEntityManagerFactory(factory);
         } catch (Exception e) {
@@ -176,22 +161,7 @@
                         _loc.get("transformer-registration-error", pui));
                 }
             }
-            // We need to wait to initializeEager 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 (MetaDataRepository.needsInitializeEager(o) == true) {
-                MetaDataRepository mdr = conf.getMetaDataRepositoryInstance(); 
-                mdr.setValidate(MetaDataRepository.VALIDATE_RUNTIME, true);
-                mdr.setResolve(MetaDataRepository.MODE_MAPPING_INIT, true);
-                ((AbstractBrokerFactory) 
factory).loadPersistentTypes((ClassLoader) AccessController
-                    
.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()));
-                conf.getMetaDataRepositoryInstance().initializeEager();
-            }
-            
+            preloadMetaDataRepository(factory);           
             return JPAFacadeHelper.toEntityManagerFactory(factory);
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
@@ -216,6 +186,30 @@
     protected OpenJPAConfiguration newConfigurationImpl() {
         return new OpenJPAConfigurationImpl();
     }
+
+    /**
+     * Private worker method that will call to the MetaDataRepository to 
preload if the provided
+     * BrokerFactory is configured to do so.
+     */
+    private void preloadMetaDataRepository(BrokerFactory factory){
+        // 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 (MetaDataRepository.needsPreload(o) == true) {
+            MetaDataRepository mdr = conf.getMetaDataRepositoryInstance(); 
+            mdr.setValidate(MetaDataRepository.VALIDATE_RUNTIME, true);
+            mdr.setResolve(MetaDataRepository.MODE_MAPPING_INIT, true);
+            
+            // Load persistent classes and hook in subclasser
+            ((AbstractBrokerFactory) 
factory).loadPersistentTypes((ClassLoader) AccessController
+                .doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()));
+            mdr.preload();
+        }
+    }
     
     /**
      * Java EE 5 class transformer.


Reply via email to