mirror of https://github.com/apache/openjpa.git
OPENJPA-2910 get rid of reflection
UOWAction stuff is now also freely available, so no need for dirty hacks anymore.
This commit is contained in:
parent
2ab2746f77
commit
f19ba018e2
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue