tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1557859 - in /tomee/tomee/trunk/container: openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java openejb-jpa-integration/src/main/java/org/apache/openejb/jpa/integration/MakeTxLookup.java
Date Mon, 13 Jan 2014 21:30:16 GMT
Author: rmannibucau
Date: Mon Jan 13 21:30:15 2014
New Revision: 1557859

URL: http://svn.apache.org/r1557859
Log:
TOMEE-1107 supporting new hibernate provider, need new jtaplatform since hibernate loves to
change packages...

Modified:
    tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
    tomee/tomee/trunk/container/openejb-jpa-integration/src/main/java/org/apache/openejb/jpa/integration/MakeTxLookup.java

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java?rev=1557859&r1=1557858&r2=1557859&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
(original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
Mon Jan 13 21:30:15 2014
@@ -757,14 +757,19 @@ class AppInfoBuilder {
                 }
 
                 if (className == null || className.startsWith("org.hibernate.transaction")
|| className.startsWith("org.hibernate.service.jta.platform")){
-                    // hibernate 4
+                    // hibernate 4.3
                     String key = HIBERNATE_JTA_PLATFORM;
-                    String value = MakeTxLookup.HIBERNATE_NEW_FACTORY;
+                    String value = MakeTxLookup.HIBERNATE_NEW_FACTORY2;
 
-                    if (classLoader.getResource(ClassLoaderUtil.resourceName("org.hibernate.service.jta.platform.spi.JtaPlatform"))
== null) {
-                        // hibernate 3. In the worse case it is set with a hibernate 4 and
hibernate will convert it.
-                        key = HIBERNATE_TRANSACTION_MANAGER_LOOKUP_CLASS;
-                        value = MakeTxLookup.HIBERNATE_FACTORY;
+                    if (classLoader.getResource(ClassLoaderUtil.resourceName("org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform"))
== null) {
+                        // previous hibernate 4
+                        value = MakeTxLookup.HIBERNATE_NEW_FACTORY;
+
+                        if (classLoader.getResource(ClassLoaderUtil.resourceName("org.hibernate.service.jta.platform.spi.JtaPlatform"))
== null) {
+                            // hibernate 3. In the worse case it is set with a hibernate
4 and hibernate will convert it.
+                            key = HIBERNATE_TRANSACTION_MANAGER_LOOKUP_CLASS;
+                            value = MakeTxLookup.HIBERNATE_FACTORY;
+                        }
                     }
 
                     if (classLoader.getResource(ClassLoaderUtil.resourceName(value)) != null)
{

Modified: tomee/tomee/trunk/container/openejb-jpa-integration/src/main/java/org/apache/openejb/jpa/integration/MakeTxLookup.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-jpa-integration/src/main/java/org/apache/openejb/jpa/integration/MakeTxLookup.java?rev=1557859&r1=1557858&r2=1557859&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-jpa-integration/src/main/java/org/apache/openejb/jpa/integration/MakeTxLookup.java
(original)
+++ tomee/tomee/trunk/container/openejb-jpa-integration/src/main/java/org/apache/openejb/jpa/integration/MakeTxLookup.java
Mon Jan 13 21:30:15 2014
@@ -30,6 +30,7 @@ public class MakeTxLookup implements Opc
 
     public static final String HIBERNATE_FACTORY = "org.apache.openejb.hibernate.TransactionManagerLookup";
     public static final String HIBERNATE_NEW_FACTORY = "org.apache.openejb.hibernate.OpenEJBJtaPlatform";
+    public static final String HIBERNATE_NEW_FACTORY2 = "org.apache.openejb.hibernate.OpenEJBJtaPlatform2";
     public static final String TOPLINK_FACTORY = "org.apache.openejb.toplink.JTATransactionController";
     public static final String ECLIPSELINK_FACTORY = "org.apache.openejb.eclipselink.JTATransactionController";
 
@@ -37,23 +38,25 @@ public class MakeTxLookup implements Opc
 
         File file = new File(args[0]);
 
-        createHibernteStrategy(file);
-        createNewHibernateStrategy(file);
         createTopLinkStrategy(file);
         createEclipseLinkStrategy(file);
+        createHibernteStrategy(file);
+        // hibernate repackaged its SPI...keeping all the same excepted packages
+        createNewHibernateStrategy(file, HIBERNATE_NEW_FACTORY, "org/hibernate/service/jta/platform/internal");
+        createNewHibernateStrategy(file, HIBERNATE_NEW_FACTORY2, "org/hibernate/engine/transaction/jta/platform/internal");
     }
 
-    private static void createNewHibernateStrategy(File basedir) throws Exception {
+    private static void createNewHibernateStrategy(final File basedir, final String target,
final String abstractJtaPlatformPackage) throws Exception {
         ClassWriter cw = new ClassWriter(0);
         MethodVisitor mv;
 
-        cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, "org/apache/openejb/hibernate/OpenEJBJtaPlatform",
null, "org/hibernate/service/jta/platform/internal/AbstractJtaPlatform", null);
+        cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, target.replace('.', '/'), null, abstractJtaPlatformPackage
+ "/AbstractJtaPlatform", null);
 
         {
             mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
             mv.visitCode();
             mv.visitVarInsn(ALOAD, 0);
-            mv.visitMethodInsn(INVOKESPECIAL, "org/hibernate/service/jta/platform/internal/AbstractJtaPlatform",
"<init>", "()V");
+            mv.visitMethodInsn(INVOKESPECIAL, abstractJtaPlatformPackage + "/AbstractJtaPlatform",
"<init>", "()V");
             mv.visitInsn(RETURN);
             mv.visitMaxs(1, 1);
             mv.visitEnd();
@@ -94,9 +97,7 @@ public class MakeTxLookup implements Opc
         }
         cw.visitEnd();
 
-        String factory = HIBERNATE_NEW_FACTORY;
-        String classFilePath = factory.replace('.', '/');
-        write(basedir, cw, classFilePath);
+        write(basedir, cw, target.replace('.', '/'));
     }
 
     private static void createHibernteStrategy(File baseDir) throws Exception {



Mime
View raw message