You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by st...@apache.org on 2023/05/15 07:59:22 UTC

[openjpa] branch master updated: OPENJPA-2910 get rid of reflection

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git


The following commit(s) were added to refs/heads/master by this push:
     new f19ba018e OPENJPA-2910 get rid of reflection
f19ba018e is described below

commit f19ba018e23ddbf8cdc1eef6d505340b705b257b
Author: Mark Struberg <st...@apache.org>
AuthorDate: Mon May 15 09:58:34 2023 +0200

    OPENJPA-2910 get rid of reflection
    
    UOWAction stuff is now also freely available, so no
    need for dirty hacks anymore.
---
 .../src/main/java/com/ibm/wsspi/uow/UOWAction.java | 30 ----------------------
 .../openjpa/ee/WASRegistryManagedRuntime.java      | 29 +++++----------------
 2 files changed, 7 insertions(+), 52 deletions(-)

diff --git a/openjpa-kernel/src/main/java/com/ibm/wsspi/uow/UOWAction.java b/openjpa-kernel/src/main/java/com/ibm/wsspi/uow/UOWAction.java
deleted file mode 100644
index d2c1951eb..000000000
--- a/openjpa-kernel/src/main/java/com/ibm/wsspi/uow/UOWAction.java
+++ /dev/null
@@ -1,30 +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 com.ibm.wsspi.uow;
-
-/**
- * This is a clean room re-implementation of the IBM UOWAction API from the existing bytecode API.
- * This will not be shipped in any distribution but excluded from the packaged JAR file.
- * It purely exists for compiling against it.
- *
- * @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
- */
-public interface UOWAction {
-    void run() throws Exception;
-}
diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASRegistryManagedRuntime.java b/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASRegistryManagedRuntime.java
index 57cc1a193..527d12b2a 100644
--- a/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASRegistryManagedRuntime.java
+++ b/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASRegistryManagedRuntime.java
@@ -19,33 +19,21 @@
 package org.apache.openjpa.ee;
 
 import com.ibm.wsspi.uow.UOWAction;
-
-import java.lang.reflect.Method;
+import com.ibm.wsspi.uow.UOWManager;
+import com.ibm.wsspi.uow.UOWManagerFactory;
 
 /**
  * WASRegistryManagedRuntime provides WebSphere specific extensions to
- * {@link RegistryManagedRuntime}. Currently these extensions consist of using
- * the WebSphere UOWManager interface to submit non transactional work.
+ * {@link RegistryManagedRuntime}. Currently, these extensions consist of using
+ * the WebSphere UOWManager interface to submit non-transactional work.
  */
 public class WASRegistryManagedRuntime extends RegistryManagedRuntime {
 
     // value taken from com.ibm.websphere.uow.UOWSynchronizationRegistry
     private static final int WEBSPHERE_UOW_TYPE_LOCAL_TRANSACTION = 0;
 
-    private final Method getUOWManager;
-    private final Method runUnderUOW;
 
     public WASRegistryManagedRuntime() {
-        try {
-            Class classUOWManagerFactory = Class.forName("com.ibm.wsspi.uow.UOWManagerFactory");
-            getUOWManager = classUOWManagerFactory.getMethod("getUOWManager");
-
-            Class classUOWManager = Class.forName("com.ibm.wsspi.uow.UOWManager");
-            runUnderUOW = classUOWManager.getMethod("runUnderUOW", new Class[]{int.class, boolean.class, UOWAction.class});
-        }
-        catch (Exception e) {
-            throw new RuntimeException("Problem while creating WASManagedRuntime", e);
-        }
     }
 
     /**
@@ -55,13 +43,10 @@ public class WASRegistryManagedRuntime extends RegistryManagedRuntime {
      * </P>
      */
     @Override
-    public void doNonTransactionalWork(Runnable runnable)
-            throws RuntimeException, UnsupportedOperationException {
+    public void doNonTransactionalWork(Runnable runnable) throws RuntimeException {
         try {
-            Object uowManager = getUOWManager.invoke(null);
-
-            runUnderUOW.invoke(uowManager, WEBSPHERE_UOW_TYPE_LOCAL_TRANSACTION, false, new DelegatingUOWAction(runnable));
-
+            UOWManager uowManager = UOWManagerFactory.getUOWManager();
+            uowManager.runUnderUOW(WEBSPHERE_UOW_TYPE_LOCAL_TRANSACTION, false, new DelegatingUOWAction(runnable));
         }
         catch(Exception e ) {
             RuntimeException re = new RuntimeException(e.getMessage(), e);