tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r656504 - /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
Date Thu, 15 May 2008 04:29:19 GMT
Author: dblevins
Date: Wed May 14 21:29:18 2008
New Revision: 656504

URL: http://svn.apache.org/viewvc?rev=656504&view=rev
Log:
OPENEJB-801: Property hibernate.transaction.manager_lookup_class automatically set when using
Hibernate as the PersistenceProvider

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=656504&r1=656503&r2=656504&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
Wed May 14 21:29:18 2008
@@ -415,12 +415,33 @@
 
                 // Handle Properties
                 org.apache.openejb.jee.jpa.unit.Properties puiProperties = persistenceUnit.getProperties();
+
                 if (puiProperties != null) {
                     for (Property property : puiProperties.getProperty()) {
                         info.properties.put(property.getName(), property.getValue());
                     }
                 }
 
+                if (info.provider.equals("org.hibernate.ejb.HibernatePersistence")){
+
+                    // The result is that OpenEJB-specific configuration can be avoided when
+                    // using OpenEJB + Hibernate.  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 starts with
+                    // "org.hibernate.transaction" allows for a custom lookup strategy to
be
+                    // used and not overridden.
+
+                    String lookupProperty = "hibernate.transaction.manager_lookup_class";
+                    String openejbLookupClass = "org.apache.openejb.hibernate.TransactionManagerLookup";
+
+                    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);
+                    }
+                }
+
                 // Persistence Unit Root Url
                 appInfo.persistenceUnits.add(info);
             }



Mime
View raw message