diff --git a/openjpa-kernel/pom.xml b/openjpa-kernel/pom.xml
index 71b7fe094..b1eb29b08 100644
--- a/openjpa-kernel/pom.xml
+++ b/openjpa-kernel/pom.xml
@@ -71,6 +71,20 @@
xbean-asm9-shaded
${xbean.version}
+
+
+
+ io.openliberty.api
+ io.openliberty.transaction
+ 1.1.74
+ provided
+ true
+
@@ -97,7 +111,7 @@
org.apache.maven.plugins
maven-antrun-plugin
-
+
generate-standard-sco-proxies
process-classes
diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java b/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
index 553217374..28259513f 100644
--- a/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
+++ b/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
@@ -18,12 +18,10 @@
*/
package org.apache.openjpa.ee;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-
import javax.naming.Context;
import javax.naming.InitialContext;
+
+import com.ibm.websphere.jtaextensions.ExtendedJTATransaction;
import jakarta.transaction.HeuristicMixedException;
import jakarta.transaction.HeuristicRollbackException;
import jakarta.transaction.InvalidTransactionException;
@@ -36,7 +34,6 @@ import jakarta.transaction.Transaction;
import javax.transaction.xa.XAResource;
import org.apache.openjpa.conf.OpenJPAConfiguration;
-import org.apache.openjpa.enhance.AsmAdaptor;
import org.apache.openjpa.lib.conf.Configurable;
import org.apache.openjpa.lib.conf.Configuration;
import org.apache.openjpa.lib.log.Log;
@@ -44,8 +41,6 @@ import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.util.InvalidStateException;
import org.apache.openjpa.util.NoTransactionException;
-import serp.bytecode.BCClass;
-import serp.bytecode.Project;
/**
* {@link ManagedRuntime} implementation that allows synchronization with a
@@ -68,9 +63,7 @@ public class WASManagedRuntime extends AbstractManagedRuntime
private static final Localizer _loc =
Localizer.forPackage(WASManagedRuntime.class);
- private Object _extendedTransaction = null;
- private Method _getGlobalId = null;
- private Method _registerSync = null;
+ private com.ibm.websphere.jtaextensions.ExtendedJTATransaction _extendedTransaction = null;
private OpenJPAConfiguration _conf = null;
private Log _log = null;
@@ -137,8 +130,7 @@ public class WASManagedRuntime extends AbstractManagedRuntime
throws IllegalStateException, RollbackException, SystemException {
if (_extendedTransaction != null) {
try {
- _registerSync.invoke(_extendedTransaction,
- new Object[] { new WASSynchronization(arg0) });
+ _extendedTransaction.registerSynchronizationCallback(new WASSynchronization(arg0));
} catch (Exception e) {
throw new InvalidStateException(_loc
.get("was-reflection-exception")).setCause(e);
@@ -157,7 +149,7 @@ public class WASManagedRuntime extends AbstractManagedRuntime
*/
private byte[] getGlobalId() {
try {
- return (byte[]) _getGlobalId.invoke(_extendedTransaction, null);
+ return _extendedTransaction.getGlobalId();
} catch (Exception e) {
throw new InvalidStateException(_loc
.get("was-reflection-exception")).setCause(e);
@@ -284,9 +276,8 @@ public class WASManagedRuntime extends AbstractManagedRuntime
* is instantiated, therefore this class should only be used when running in
* WebSphere.
*
- * @see org.apache.openjpa.util.WASTransformer
*/
- static class WASSynchronization {
+ static class WASSynchronization implements com.ibm.websphere.jtaextensions.SynchronizationCallback {
Synchronization _sync = null;
@@ -338,22 +329,10 @@ public class WASManagedRuntime extends AbstractManagedRuntime
try {
Context ctx = new InitialContext();
try {
- _extendedTransaction =
- ctx.lookup("java:comp/websphere/ExtendedJTATransaction");
+ _extendedTransaction = (ExtendedJTATransaction) ctx.lookup("java:comp/websphere/ExtendedJTATransaction");
} finally {
ctx.close();
}
-
- Class extendedJTATransaction = Class.forName(
- "com.ibm.websphere.jtaextensions.ExtendedJTATransaction");
- Class synchronizationCallback = Class.forName(
- "com.ibm.websphere.jtaextensions.SynchronizationCallback");
-
- _registerSync = extendedJTATransaction.getMethod(
- "registerSynchronizationCallbackForCurrentTran",
- new Class[] { synchronizationCallback });
- _getGlobalId = extendedJTATransaction.
- getMethod("getGlobalId", null);
} catch (Exception e) {
throw new InvalidStateException(_loc
.get("was-reflection-exception"), e).setFatal(true);
@@ -380,27 +359,6 @@ public class WASManagedRuntime extends AbstractManagedRuntime
static final String INTERFACE =
"com.ibm.websphere.jtaextensions.SynchronizationCallback";
- public static void main(String[] args)
- throws IOException {
- Project project = new Project();
-
- InputStream in = WASManagedRuntime.class.getClassLoader()
- .getResourceAsStream(CLASS.replace('.', '/') + ".class");
- BCClass bcClass = project.loadClass(in);
-
- String [] interfaces = bcClass.getInterfaceNames();
-
- if(interfaces != null) {
- for (String anInterface : interfaces) {
- if (anInterface.equals(INTERFACE)) {
- return;
- }
- }
- }
- bcClass.declareInterface(INTERFACE);
- AsmAdaptor.write(bcClass);
- }
-
@Override
public void setRollbackOnly(Throwable cause)
throws Exception {
diff --git a/openjpa-kernel/src/test/java/org/apache/openjpa/ee/TestWASManagedRuntime.java b/openjpa-kernel/src/test/java/org/apache/openjpa/ee/TestWASManagedRuntime.java
deleted file mode 100644
index f1f37e325..000000000
--- a/openjpa-kernel/src/test/java/org/apache/openjpa/ee/TestWASManagedRuntime.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.openjpa.ee;
-
-import org.apache.openjpa.lib.util.ClassUtil;
-import org.junit.Test;
-
-
-import static org.junit.Assert.*;
-
-/**
- * Test class for build transformation performed by WASManagedRuntime.
- *
- */
-public class TestWASManagedRuntime {
-
- /**
- * This test will verify that the WASManagedRuntime$WASSynchronization
- * class was properly modified by the maven build process (reference
- * the top level pom.xml). This testcase will not execute properly
- * within Eclipse since the Eclipse target directory (probably) hasn't
- * been modified via the maven build.
- *
- * @throws ClassNotFoundException
- */
- @Test
- public void testInterfaceAdded() throws ClassNotFoundException {
-
- String msg = null;
-
- try {
- Class.forName(WASManagedRuntime.CLASS);
- fail("expected an exception to be thrown");
- } catch (NoClassDefFoundError e) {
- msg = e.getMessage();
- }
- String interfaceName = ClassUtil.getClassName(WASManagedRuntime.INTERFACE);
- assertTrue("message should have contained "
- + interfaceName + ", but was '" + msg + "'",
- msg.indexOf(interfaceName) != -1);
- }
-}