openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r562530 - in /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa: ee/ kernel/
Date Fri, 03 Aug 2007 17:35:55 GMT
Author: mikedd
Date: Fri Aug  3 10:35:54 2007
New Revision: 562530

URL: http://svn.apache.org/viewvc?view=rev&rev=562530
Log:
OPENJPA-295

Added:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AbstractManagedRuntime.java
  (with props)
Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AutomaticManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/InvocationManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/JNDIManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/ManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/RegistryManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/SunOneManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WLSManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LocalManagedRuntime.java

Added: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AbstractManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AbstractManagedRuntime.java?view=auto&rev=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AbstractManagedRuntime.java
(added)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AbstractManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -0,0 +1,41 @@
+/*
+ * 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 javax.transaction.SystemException;
+
+/*
+ * AbstractManagedRuntime.java
+ *
+ * Created on August 2, 2007, 2:38 PM
+ *
+ */
+public abstract class AbstractManagedRuntime implements ManagedRuntime {
+    
+    /**
+     * Returns a transaction key that can be used to associate transactions
+     * and Brokers.
+     * The default implementation returns the Transaction associated 
+     * with the current thread's transaction.
+     * @return the transaction key
+     */
+    public Object getTransactionKey() throws Exception, SystemException {
+        return getTransactionManager().getTransaction();
+    }
+
+}

Propchange: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AbstractManagedRuntime.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AutomaticManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AutomaticManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AutomaticManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/AutomaticManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -20,6 +20,8 @@
 
 import java.util.LinkedList;
 import java.util.List;
+
+import javax.transaction.SystemException;
 import javax.transaction.TransactionManager;
 
 import org.apache.openjpa.lib.conf.Configurable;
@@ -47,7 +49,7 @@
  *
  * @author Marc Prud'hommeaux
  */
-public class AutomaticManagedRuntime
+public class AutomaticManagedRuntime extends AbstractManagedRuntime
     implements ManagedRuntime, Configurable {
 
     private static final String [] JNDI_LOCS = new String []{
@@ -242,6 +244,16 @@
         if (_runtime != null)
             return _runtime.getRollbackCause();
 
+        return null;
+    }
+    
+    public Object getTransactionKey() throws Exception, SystemException {
+        if(_runtime == null) 
+            getTransactionManager();
+        
+        if(_runtime != null )
+            return _runtime.getTransactionKey();
+        
         return null;
     }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/InvocationManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/InvocationManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/InvocationManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/InvocationManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -34,7 +34,7 @@
  *
  * @author Marc Prud'hommeaux
  */
-public class InvocationManagedRuntime
+public class InvocationManagedRuntime extends AbstractManagedRuntime
     implements ManagedRuntime, Configurable {
 
     private String _methodName = null;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/JNDIManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/JNDIManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/JNDIManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/JNDIManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -28,7 +28,7 @@
  *
  * @author Abe White
  */
-public class JNDIManagedRuntime
+public class JNDIManagedRuntime extends AbstractManagedRuntime
     implements ManagedRuntime {
 
     private String _tmLoc = "java:/TransactionManager";

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/ManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/ManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/ManagedRuntime.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/ManagedRuntime.java Fri
Aug  3 10:35:54 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.ee;
 
+import javax.transaction.SystemException;
 import javax.transaction.TransactionManager;
 
 /**
@@ -56,4 +57,13 @@
      */
     public Throwable getRollbackCause()
         throws Exception;
+
+    /**
+     * Returns a transaction key that can be used to associate transactions
+     * and Brokers.
+     * @return the transaction key
+     */
+    public Object getTransactionKey()
+        throws Exception, SystemException;
+    
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/RegistryManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/RegistryManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/RegistryManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/RegistryManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -45,7 +45,7 @@
 
     private String _registryName =
         "java:comp/TransactionSynchronizationRegistry";
-    private TransactionManager _tm = null;
+    private TransactionManagerRegistryFacade _tm = null;
 
     /**
      * Return the cached TransactionManager instance.
@@ -84,6 +84,10 @@
         return _registryName;
     }
 
+    public Object getTransactionKey() throws Exception, SystemException {
+        return _tm.getTransactionKey();
+    }
+
     /** 
      *  A {@link TransactionManager} and {@link Transaction} facade
      *  that delegates the appropriate methods to the internally-held
@@ -124,6 +128,10 @@
         public int getStatus()
             throws SystemException {
             return _registry.getTransactionStatus();
+        }
+
+        public Object getTransactionKey() {
+            return _registry.getTransactionKey();
         }
 
         //////////////////////////////

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/SunOneManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/SunOneManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/SunOneManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/SunOneManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -26,7 +26,7 @@
  *
  * @author Marc Prud'hommeaux
  */
-public class SunOneManagedRuntime
+public class SunOneManagedRuntime extends AbstractManagedRuntime
     implements ManagedRuntime {
 
     private Method _switchMeth;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -59,9 +59,10 @@
  * WASManagedRuntime provides the wrapper classes needed to interact with the
  * WAS proprietary interface and the OpenJPA kernel.
  *
- * @author Michael Dick, Kevin Sutter
+ * @author Kevin Sutter
  */
-public class WASManagedRuntime implements ManagedRuntime, Configurable {
+public class WASManagedRuntime extends AbstractManagedRuntime
+        implements ManagedRuntime, Configurable {
 
     private static final Localizer _loc =
         Localizer.forPackage(WASManagedRuntime.class);

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WLSManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WLSManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WLSManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WLSManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -28,7 +28,7 @@
  *
  * @author Arunabh Hazarika, Patrick Linskey
  */
-public class WLSManagedRuntime
+public class WLSManagedRuntime extends AbstractManagedRuntime
     implements ManagedRuntime {
 
     private final Method _txHelperMeth;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Fri Aug  3 10:35:54 2007
@@ -38,6 +38,7 @@
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.conf.OpenJPAVersion;
 import org.apache.openjpa.datacache.DataCacheStoreManager;
+import org.apache.openjpa.ee.ManagedRuntime;
 import org.apache.openjpa.enhance.PCRegistry;
 import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.event.RemoteCommitEventManager;
@@ -526,9 +527,12 @@
      */
     protected BrokerImpl findTransactionalBroker(String user, String pass) {
         Transaction trans;
+        ManagedRuntime mr = _conf.getManagedRuntimeInstance();
+        Object txKey;
         try {
-            trans = _conf.getManagedRuntimeInstance().getTransactionManager().
+            trans = mr.getTransactionManager().
                 getTransaction();
+            txKey = mr.getTransactionKey();
 
             if (trans == null
                 || trans.getStatus() == Status.STATUS_NO_TRANSACTION
@@ -540,7 +544,7 @@
             throw new GeneralException(e);
         }
 
-        Collection brokers = (Collection) _transactional.get(trans);
+        Collection brokers = (Collection) _transactional.get(txKey);
         if (brokers != null) {
             // we don't need to synchronize on brokers since one JTA transaction
             // can never be active on multiple concurrent threads.
@@ -703,8 +707,8 @@
     boolean syncWithManagedTransaction(BrokerImpl broker, boolean begin) {
         Transaction trans;
         try {
-            TransactionManager tm = broker.getManagedRuntime().
-                getTransactionManager();
+            ManagedRuntime mr = broker.getManagedRuntime();
+            TransactionManager tm = mr.getTransactionManager();
             trans = tm.getTransaction();
             if (trans != null
                 && (trans.getStatus() == Status.STATUS_NO_TRANSACTION
@@ -723,11 +727,13 @@
             // we don't need to synchronize on brokers or guard against multiple
             // threads using the same trans since one JTA transaction can never
             // be active on multiple concurrent threads.
-            Collection brokers = (Collection) _transactional.get(trans);
+            Object txKey = mr.getTransactionKey();
+            Collection brokers = (Collection) _transactional.get(txKey);
+            
             if (brokers == null) {
                 brokers = new ArrayList(2);
-                _transactional.put(trans, brokers);
-                trans.registerSynchronization(new RemoveTransactionSync(trans));
+                _transactional.put(txKey, brokers);
+                trans.registerSynchronization(new RemoveTransactionSync(txKey));
             }
             brokers.add(broker);
             
@@ -754,9 +760,9 @@
     private class RemoveTransactionSync
         implements Synchronization {
 
-        private final Transaction _trans;
+        private final Object _trans;
 
-        public RemoveTransactionSync(Transaction trans) {
+        public RemoveTransactionSync(Object trans) {
             _trans = trans;
         }
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LocalManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LocalManagedRuntime.java?view=diff&rev=562530&r1=562529&r2=562530
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LocalManagedRuntime.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LocalManagedRuntime.java
Fri Aug  3 10:35:54 2007
@@ -26,6 +26,7 @@
 import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAResource;
 
+import org.apache.openjpa.ee.AbstractManagedRuntime;
 import org.apache.openjpa.ee.ManagedRuntime;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.InternalException;
@@ -40,7 +41,7 @@
  *
  * @author Abe White
  */
-class LocalManagedRuntime
+class LocalManagedRuntime extends AbstractManagedRuntime
     implements ManagedRuntime, TransactionManager, Transaction {
 
     private static final Localizer _loc = Localizer.forPackage



Mime
View raw message