deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject git commit: DELTASPIKE-458 lookup UserTransaction via @Resource
Date Thu, 05 Dec 2013 10:34:40 GMT
Updated Branches:
  refs/heads/master 4a57c90ad -> b1cdf8765


DELTASPIKE-458 lookup UserTransaction via @Resource

Fallback to JNDI only if the injected UserTransaction
is not available (null)


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/b1cdf876
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/b1cdf876
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/b1cdf876

Branch: refs/heads/master
Commit: b1cdf8765d0d958217fe65568631c4be776eaaba
Parents: 4a57c90
Author: Mark Struberg <struberg@apache.org>
Authored: Thu Dec 5 11:23:56 2013 +0100
Committer: Mark Struberg <struberg@apache.org>
Committed: Thu Dec 5 11:25:56 2013 +0100

----------------------------------------------------------------------
 .../transaction/BeanManagedUserTransactionStrategy.java     | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/b1cdf876/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/BeanManagedUserTransactionStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/BeanManagedUserTransactionStrategy.java
b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/BeanManagedUserTransactionStrategy.java
index f08087a..556b6d8 100644
--- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/BeanManagedUserTransactionStrategy.java
+++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/BeanManagedUserTransactionStrategy.java
@@ -24,6 +24,7 @@ import org.apache.deltaspike.core.util.ExceptionUtils;
 import org.apache.deltaspike.jpa.api.transaction.TransactionConfig;
 import org.apache.deltaspike.jpa.impl.transaction.context.EntityManagerEntry;
 
+import javax.annotation.Resource;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Alternative;
 import javax.persistence.EntityManager;
@@ -55,6 +56,9 @@ public class BeanManagedUserTransactionStrategy extends ResourceLocalTransaction
 
     private transient TransactionConfig transactionConfig;
 
+    @Resource
+    private UserTransaction userTransaction;
+
     @Override
     protected EntityManagerEntry createEntityManagerEntry(
         EntityManager entityManager, Class<? extends Annotation> qualifier)
@@ -158,6 +162,11 @@ public class BeanManagedUserTransactionStrategy extends ResourceLocalTransaction
 
     protected UserTransaction resolveUserTransaction()
     {
+        if (userTransaction != null)
+        {
+            return userTransaction;
+        }
+
         return JndiUtils.lookup(USER_TRANSACTION_JNDI_NAME, UserTransaction.class);
     }
 


Mime
View raw message