tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r764240 - /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
Date Sat, 11 Apr 2009 19:49:47 GMT
Author: dblevins
Date: Sat Apr 11 19:49:47 2009
New Revision: 764240

URL: http://svn.apache.org/viewvc?rev=764240&view=rev
Log:
Move the persistence provider specific property augmentation into an innerclass so that it's
easier to find (keep expecting this to be in its own class).

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java?rev=764240&r1=764239&r2=764240&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
Sat Apr 11 19:49:47 2009
@@ -547,51 +547,8 @@
                     info.properties.put(property, value);
                 }
 
-                // The result is that OpenEJB-specific configuration can be avoided when
-                // using OpenEJB + Hibernate or another vendor.  A second benefit is that
-                // if another vendor is used in production, the value will automatically
-                // be reset for using OpenEJB in the test environment.  Ensuring the strategy
-                // doesn't start with "org.hibernate.transaction" allows for a custom lookup
-                // strategy to be used and not overridden.
-
-                // DMB: This whole block could be a map, but I left it this way just
-                // in case we decided we wanted to do other custom handing for the
-                // providers listed.
-                if ("org.hibernate.ejb.HibernatePersistence".equals(info.provider)){
-
-                    String lookupProperty = "hibernate.transaction.manager_lookup_class";
-                    String openejbLookupClass = MakeTxLookup.HIBERNATE_FACTORY;
-
-                    String className = info.properties.getProperty(lookupProperty);
-
-                    if (className == null || className.startsWith("org.hibernate.transaction")){
-                        info.properties.setProperty(lookupProperty, openejbLookupClass);
-                        logger.debug("Adjusting PersistenceUnit(name="+info.name+") property
to "+lookupProperty+"="+openejbLookupClass);
-                    }
-                } else if ("oracle.toplink.essentials.PersistenceProvider".equals(info.provider)
||
-                        "oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider".equals(info.provider)
){
-
-                    String lookupProperty = "toplink.target-server";
-                    String openejbLookupClass = MakeTxLookup.TOPLINK_FACTORY;
-
-                    String className = info.properties.getProperty(lookupProperty);
-
-                    if (className == null || className.startsWith("oracle.toplink.transaction")){
-                        info.properties.setProperty(lookupProperty, openejbLookupClass);
-                        logger.debug("Adjusting PersistenceUnit(name="+info.name+") property
to "+lookupProperty+"="+openejbLookupClass);
-                    }
-                    } else if ("org.eclipse.persistence.jpa.PersistenceProvider".equals(info.provider)
|| "org.eclipse.persistence.jpa.osgi.PersistenceProvider".equals(info.provider)){
-
-                    String lookupProperty = "eclipselink.target-server";
-                    String openejbLookupClass = MakeTxLookup.ECLIPSELINK_FACTORY;
-
-                    String className = info.properties.getProperty(lookupProperty);
-
-                    if (className == null || className.startsWith("org.eclipse.persistence.transaction")){
-                        info.properties.setProperty(lookupProperty, openejbLookupClass);
-                        logger.debug("Adjusting PersistenceUnit(name="+info.name+") property
to "+lookupProperty+"="+openejbLookupClass);
-                    }
-                }
+                PersistenceProviderProperties.apply(info);
+
 
                 // Persistence Unit Root Url
                 appInfo.persistenceUnits.add(info);
@@ -599,6 +556,57 @@
         }
     }
 
+
+    public static class PersistenceProviderProperties {
+        private static void apply(PersistenceUnitInfo info) {
+            // The result is that OpenEJB-specific configuration can be avoided when
+            // using OpenEJB + Hibernate or another vendor.  A second benefit is that
+            // if another vendor is used in production, the value will automatically
+            // be reset for using OpenEJB in the test environment.  Ensuring the strategy
+            // doesn't start with "org.hibernate.transaction" allows for a custom lookup
+            // strategy to be used and not overridden.
+
+            // DMB: This whole block could be a map, but I left it this way just
+            // in case we decided we wanted to do other custom handing for the
+            // providers listed.
+            if ("org.hibernate.ejb.HibernatePersistence".equals(info.provider)){
+
+                String lookupProperty = "hibernate.transaction.manager_lookup_class";
+                String openejbLookupClass = MakeTxLookup.HIBERNATE_FACTORY;
+
+                String className = info.properties.getProperty(lookupProperty);
+
+                if (className == null || className.startsWith("org.hibernate.transaction")){
+                    info.properties.setProperty(lookupProperty, openejbLookupClass);
+                    logger.debug("Adjusting PersistenceUnit(name="+info.name+") property
to "+lookupProperty+"="+openejbLookupClass);
+                }
+            } else if ("oracle.toplink.essentials.PersistenceProvider".equals(info.provider)
||
+                    "oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider".equals(info.provider)
){
+
+                String lookupProperty = "toplink.target-server";
+                String openejbLookupClass = MakeTxLookup.TOPLINK_FACTORY;
+
+                String className = info.properties.getProperty(lookupProperty);
+
+                if (className == null || className.startsWith("oracle.toplink.transaction")){
+                    info.properties.setProperty(lookupProperty, openejbLookupClass);
+                    logger.debug("Adjusting PersistenceUnit(name="+info.name+") property
to "+lookupProperty+"="+openejbLookupClass);
+                }
+                } else if ("org.eclipse.persistence.jpa.PersistenceProvider".equals(info.provider)
|| "org.eclipse.persistence.jpa.osgi.PersistenceProvider".equals(info.provider)){
+
+                String lookupProperty = "eclipselink.target-server";
+                String openejbLookupClass = MakeTxLookup.ECLIPSELINK_FACTORY;
+
+                String className = info.properties.getProperty(lookupProperty);
+
+                if (className == null || className.startsWith("org.eclipse.persistence.transaction")){
+                    info.properties.setProperty(lookupProperty, openejbLookupClass);
+                    logger.debug("Adjusting PersistenceUnit(name="+info.name+") property
to "+lookupProperty+"="+openejbLookupClass);
+                }
+            }
+        }
+    }
+
     private static String getClientModuleId(ClientModule clientModule) {
         String jarLocation = clientModule.getJarLocation();
         File file = new File(jarLocation);



Mime
View raw message