[jbpm-commits] JBoss JBPM SVN: r2034 - jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Aug 28 00:34:55 EDT 2008
Author: alex.guizar at jboss.com
Date: 2008-08-28 00:34:55 -0400 (Thu, 28 Aug 2008)
New Revision: 2034
Modified:
jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceServiceFactory.java
Log:
[JBPM-1694] moved UserTransaction lookup to persistence service factory
Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
===================================================================
--- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2008-08-27 14:43:43 UTC (rev 2033)
+++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java 2008-08-28 04:34:55 UTC (rev 2034)
@@ -21,8 +21,6 @@
*/
package org.jbpm.persistence.jta;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
@@ -51,7 +49,7 @@
}
protected boolean isTransactionActive() {
- return isJtaTxCreated();
+ return isJtaTxCreated();
}
public void close() {
@@ -69,8 +67,8 @@
void beginJtaTransaction() {
try {
- log.debug("start user JTA transaction");
- userTransaction = getUserTransaction();
+ log.debug("start user JTA transaction");
+ userTransaction = ((JtaDbPersistenceServiceFactory) persistenceServiceFactory).getUserTransaction();
userTransaction.begin();
} catch (Exception e) {
throw new JbpmException("couldn't start JTA transaction", e);
@@ -95,27 +93,6 @@
}
}
- UserTransaction getUserTransaction() {
- String jndiName = persistenceServiceFactory.getConfiguration().getProperty("jta.UserTransaction");
- if (jndiName == null) {
- /*
- * EJB 2.1 section 20.9 The container must make the UserTransaction interface available to the
- * enterprise beans that are allowed to use this interface (only session and message-
- * driven beans with bean-managed transaction demarcation are allowed to use this
- * interface) in JNDI under the name java:comp/UserTransaction.
- * J2EE 1.4 section 4.2.1.1 The J2EE platform must provide an object implementing the
- * UserTransaction interface to all web components. The platform must publish the
- * UserTransaction object in JNDI under the name java:comp/UserTransaction.
- */
- jndiName = "java:comp/UserTransaction";
- }
- try {
- return (UserTransaction) new InitialContext().lookup(jndiName);
- } catch (NamingException e) {
- throw new JbpmException("couldn't lookup UserTransaction in JNDI with name "+jndiName, e);
- }
- }
-
int getJtaTransactionStatus() {
try {
return userTransaction.getStatus();
Modified: jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceServiceFactory.java
===================================================================
--- jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceServiceFactory.java 2008-08-27 14:43:43 UTC (rev 2033)
+++ jbpm3/trunk/modules/jpdl/core/src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceServiceFactory.java 2008-08-28 04:34:55 UTC (rev 2034)
@@ -21,6 +21,11 @@
*/
package org.jbpm.persistence.jta;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+
+import org.jbpm.JbpmException;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
import org.jbpm.svc.Service;
@@ -47,6 +52,8 @@
private static final long serialVersionUID = 1L;
+ private UserTransaction userTransaction;
+
public JtaDbPersistenceServiceFactory() {
setCurrentSessionEnabled(true);
setTransactionEnabled(false);
@@ -55,4 +62,28 @@
public Service openService() {
return new JtaDbPersistenceService(this);
}
+
+ public UserTransaction getUserTransaction() {
+ if (userTransaction == null) {
+ String jndiName = getConfiguration().getProperty("jta.UserTransaction");
+ if (jndiName == null) {
+ /*
+ * EJB 2.1 section 20.9 The container must make the UserTransaction interface available to the
+ * enterprise beans that are allowed to use this interface (only session and message-
+ * driven beans with bean-managed transaction demarcation are allowed to use this
+ * interface) in JNDI under the name java:comp/UserTransaction.
+ * J2EE 1.4 section 4.2.1.1 The J2EE platform must provide an object implementing the
+ * UserTransaction interface to all web components. The platform must publish the
+ * UserTransaction object in JNDI under the name java:comp/UserTransaction.
+ */
+ jndiName = "java:comp/UserTransaction";
+ }
+ try {
+ userTransaction = (UserTransaction) new InitialContext().lookup(jndiName);
+ } catch (NamingException e) {
+ throw new JbpmException("could not retrieve user transaction with name "+jndiName, e);
+ }
+ }
+ return userTransaction;
+ }
}
More information about the jbpm-commits
mailing list