(no commit message)
[utils] / test / enterprise / src / main / java / org / wamblee / test / transactions / SimpleTransactionManager.java
index 81a5bfad36f3479957d42a16a2c67aae6301fab8..3ba4e8147c760e19d76a410e25f4ec1d3f1f0224 100644 (file)
@@ -64,7 +64,7 @@ import org.wamblee.test.persistence.JpaBuilder;
 public class SimpleTransactionManager {
 
     private UserTransactionFactory factory;
-    private ThreadSpecificProxyFactory<UserTransaction> transaction; 
+    private ThreadLocal<UserTransaction> transaction; 
     private UserTransactionCallback callback;
     private List<TransactionResource> resources;
 
@@ -76,7 +76,7 @@ public class SimpleTransactionManager {
      */
     public SimpleTransactionManager(UserTransactionFactory aFactory) {
         factory = aFactory;
-        transaction = new ThreadSpecificProxyFactory<UserTransaction>(UserTransaction.class);
+        transaction = new ThreadLocal<UserTransaction>();
         callback = new UserTransactionCallback() {
 
             @Override
@@ -106,12 +106,16 @@ public class SimpleTransactionManager {
      * @return User transaction.
      */
     public UserTransaction getTransaction() {
+        return new AutoCreateUserTransaction(this);
+    }
+    
+    UserTransaction getOrCreateThreadSpecificTransaction() { 
         UserTransaction tx = transaction.get();
         if (tx == null) {
             tx = factory.create(callback, resources);
             transaction.set(tx);
         }
-        return transaction.getProxy();
+        return tx;
     }
     
     /**