You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2008/03/07 10:43:12 UTC
svn commit: r634593 - in /openejb/trunk/openejb3/container/openejb-core:
pom.xml src/main/java/org/apache/openejb/util/MakeTxLookup.java
src/main/resources/org/apache/openejb/hibernate/
Author: dblevins
Date: Fri Mar 7 01:43:08 2008
New Revision: 634593
URL: http://svn.apache.org/viewvc?rev=634593&view=rev
Log:
Different approach to generating a tx manager lookup class for hibernate users
Added:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/MakeTxLookup.java
Removed:
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/hibernate/
Modified:
openejb/trunk/openejb3/container/openejb-core/pom.xml
Modified: openejb/trunk/openejb3/container/openejb-core/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/pom.xml?rev=634593&r1=634592&r2=634593&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/pom.xml (original)
+++ openejb/trunk/openejb3/container/openejb-core/pom.xml Fri Mar 7 01:43:08 2008
@@ -123,6 +123,13 @@
</tstamp>
<replace file="target/classes/openejb-version.properties" token="@DATE-REPLACED-BY-MAVEN@" value="${DSTAMP}" />
<replace file="target/classes/openejb-version.properties" token="@TIME-REPLACED-BY-MAVEN@" value="${TSTAMP}" />
+ <property name="compile_classpath" refid="maven.compile.classpath"/>
+ <java classname="org.apache.openejb.util.MakeTxLookup">
+ <arg value="${project.build.directory}"/>
+ <classpath>
+ <pathelement path="${compile_classpath}"/>
+ </classpath>
+ </java>
</tasks>
</configuration>
</execution>
Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/MakeTxLookup.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/MakeTxLookup.java?rev=634593&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/MakeTxLookup.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/MakeTxLookup.java Fri Mar 7 01:43:08 2008
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.util;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+public class MakeTxLookup implements Opcodes {
+
+ public static void main(String[] args) throws Exception {
+ File file = new File(args[0]);
+
+ String[] path = {"classes", "org", "apache", "openejb", "hibernate", "TransactionManagerLookup.class"};
+ for (String s : path) file = new File(file, s);
+
+ file.getParentFile().mkdirs();
+
+ FileOutputStream out = new FileOutputStream(file);
+ out.write(dump());
+ out.close();
+ }
+
+ public static byte[] dump() throws Exception {
+
+ ClassWriter cw = new ClassWriter(false);
+ FieldVisitor fv;
+ MethodVisitor mv;
+ AnnotationVisitor av0;
+
+ cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "org/apache/openejb/hibernate/TransactionManagerLookup", null, "java/lang/Object", new String[]{"org/hibernate/transaction/TransactionManagerLookup"});
+
+ cw.visitSource("TransactionManagerLookup.java", null);
+
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "getTransactionManager", "(Ljava/util/Properties;)Ljavax/transaction/TransactionManager;", null, new String[]{"org/hibernate/HibernateException"});
+ mv.visitCode();
+ mv.visitMethodInsn(INVOKESTATIC, "org/apache/openejb/OpenEJB", "getTransactionManager", "()Ljavax/transaction/TransactionManager;");
+ mv.visitInsn(ARETURN);
+ mv.visitMaxs(1, 2);
+ mv.visitEnd();
+ }
+ {
+ mv = cw.visitMethod(ACC_PUBLIC, "getUserTransactionName", "()Ljava/lang/String;", null, null);
+ mv.visitCode();
+ mv.visitLdcInsn("java:comp/UserTransaction");
+ mv.visitInsn(ARETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+ cw.visitEnd();
+
+ return cw.toByteArray();
+ }
+}