[jbpm-commits] JBoss JBPM SVN: r5093 - in jbpm4/trunk/modules: enterprise/src/test/java/org/jbpm/test/deployer and 6 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Jun 23 09:27:09 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-06-23 09:27:08 -0400 (Tue, 23 Jun 2009)
New Revision: 5093
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaRetryInterceptor.java
Removed:
jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/jta/
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/RetryInterceptorDescriptor.java
Modified:
jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/test/deployer/DeployerTestServlet.java
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ServiceLocator.java
jbpm4/trunk/modules/integration/spi/src/main/java/org/jbpm/integration/spi/DeploymentAdaptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.jta.cfg.xml
Log:
JBPM-2339 JTA cleanup, creating jndi name constant for jboss global user transaction and adding retry interceptor properly to jta config
Modified: jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/test/deployer/DeployerTestServlet.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/test/deployer/DeployerTestServlet.java 2009-06-23 11:52:47 UTC (rev 5092)
+++ jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/test/deployer/DeployerTestServlet.java 2009-06-23 13:27:08 UTC (rev 5093)
@@ -52,6 +52,7 @@
try
{
+ // TODO remove explicit transaction demarcation JBPM-2353
InitialContext ctx = new InitialContext();
tx = (UserTransaction)ctx.lookup("UserTransaction");
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ServiceLocator.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ServiceLocator.java 2009-06-23 11:52:47 UTC (rev 5092)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ServiceLocator.java 2009-06-23 13:27:08 UTC (rev 5093)
@@ -55,6 +55,7 @@
try
{
Context ctx = createContext();
+ // TODO remove explicit transaction demarcation JBPM-2353
tx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
}
catch (Exception e)
Modified: jbpm4/trunk/modules/integration/spi/src/main/java/org/jbpm/integration/spi/DeploymentAdaptor.java
===================================================================
--- jbpm4/trunk/modules/integration/spi/src/main/java/org/jbpm/integration/spi/DeploymentAdaptor.java 2009-06-23 11:52:47 UTC (rev 5092)
+++ jbpm4/trunk/modules/integration/spi/src/main/java/org/jbpm/integration/spi/DeploymentAdaptor.java 2009-06-23 13:27:08 UTC (rev 5093)
@@ -50,6 +50,7 @@
try
{
InitialContext ctx = new InitialContext();
+ // TODO remove explicit transaction demarcation JBPM-2353
tx = (UserTransaction)ctx.lookup("UserTransaction");
tx.begin();
@@ -99,6 +100,7 @@
RepositoryService repositoryService = jbpmService.getProcessEngine().getRepositoryService();
InitialContext ctx = new InitialContext();
+ // TODO remove explicit transaction demarcation JBPM-2353
tx = (UserTransaction)ctx.lookup("UserTransaction");
tx.begin();
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaRetryInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaRetryInterceptor.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaRetryInterceptor.java 2009-06-23 13:27:08 UTC (rev 5093)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx.jta;
+
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.svc.RetryInterceptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JtaRetryInterceptor extends RetryInterceptor {
+
+ private static Log log = Log.getLog(JtaRetryInterceptor.class.getName());
+
+ public <T> T execute(Command<T> command) {
+ JtaTransaction jtaTransaction = Environment.getFromCurrent(JtaTransaction.class);
+ UserTransaction userTransaction = jtaTransaction.lookupJeeUserTransaction();
+ int status = JtaTransaction.getUserTransactionStatus(userTransaction);
+ if (status == Status.STATUS_NO_TRANSACTION) {
+ return executeWithRetry(command);
+ }
+ log.trace("transaction in progress. skipping retry interceptor");
+ return executeWithoutRetry(command);
+ }
+
+ public <T> T executeWithRetry(Command<T> command) {
+ return super.execute(command);
+ }
+
+ public <T> T executeWithoutRetry(Command<T> command) {
+ return next.execute(command);
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaRetryInterceptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java 2009-06-23 11:52:47 UTC (rev 5092)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java 2009-06-23 13:27:08 UTC (rev 5093)
@@ -30,16 +30,21 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.env.Transaction;
+import org.jbpm.internal.log.Log;
/**
* @author Tom Baeyens
*/
public class JtaTransaction implements Transaction {
+
+ private static Log log = Log.getLog(JtaTransaction.class.getName());
+
+ public static final String JNDINAME_USERTRANSACTION_JBOSS_GLOBAL = "UserTransaction";
+ public static final String JNDINAME_TRANSACTIONMANAGER_JBOSS_GLOBAL = "java:/TransactionManager";
- protected String jbossUserTransactionJndiName = "UserTransaction";
- protected String userTransactionJndiName = "java:comp/UserTransaction";
- protected String transactionManagerJndiName = "java:/TransactionManager";
+ protected String userTransactionJndiName = JNDINAME_USERTRANSACTION_JBOSS_GLOBAL;
+ protected String transactionManagerJndiName = JNDINAME_TRANSACTIONMANAGER_JBOSS_GLOBAL;
public boolean isRollbackOnly() {
try {
@@ -108,20 +113,7 @@
// lookups //////////////////////////////////////////////////////////////////
public UserTransaction lookupJeeUserTransaction() {
- Object tx;
-
- try
- {
- // non jee context, i.e. JBPMDeployer (jboss only)
- tx = lookupFromJndi(jbossUserTransactionJndiName);
- }
- catch (JbpmException e)
- {
- // jee components
- tx = lookupFromJndi(userTransactionJndiName);
- }
-
- return (UserTransaction) tx;
+ return (UserTransaction) lookupFromJndi(userTransactionJndiName);
}
public javax.transaction.Transaction lookupJeeTransaction() {
@@ -145,4 +137,15 @@
throw new JbpmException("couldn't lookup '"+jndiName+"' from jndi: "+e.getMessage()+": "+e.getMessage(), e);
}
}
+
+ public static int getUserTransactionStatus(UserTransaction userTransaction) {
+ int status = -1;
+ try {
+ status = userTransaction.getStatus();
+ } catch (SystemException e) {
+ throw new JbpmException("couldn't get transaction status: "+e.getMessage(), e);
+ }
+ log.trace("jta transaction status: "+JtaStatusHelper.toString(status));
+ return status;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java 2009-06-23 11:52:47 UTC (rev 5092)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java 2009-06-23 13:27:08 UTC (rev 5093)
@@ -45,13 +45,7 @@
UserTransaction userTransaction = jtaTransaction.lookupJeeUserTransaction();
- int status = -1;
- try {
- status = userTransaction.getStatus();
- } catch (SystemException e) {
- throw new JbpmException("couldn't get transaction status: "+e.getMessage(), e);
- }
- log.debug("jta transaction status: "+JtaStatusHelper.toString(status));
+ int status = JtaTransaction.getUserTransactionStatus(userTransaction);
if (status == Status.STATUS_ACTIVE) {
return executeInExistingTx(command);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java 2009-06-23 11:52:47 UTC (rev 5092)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java 2009-06-23 13:27:08 UTC (rev 5093)
@@ -22,7 +22,9 @@
package org.jbpm.pvm.internal.wire.binding;
import org.jbpm.pvm.internal.svc.RetryInterceptor;
-import org.jbpm.pvm.internal.wire.descriptor.RetryInterceptorDescriptor;
+import org.jbpm.pvm.internal.tx.jta.JtaRetryInterceptor;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -40,13 +42,21 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- RetryInterceptorDescriptor retryInterceptorDescriptor = new RetryInterceptorDescriptor();
+ RetryInterceptor retryInterceptor = null;
+ String type = XmlUtil.attribute(element, "type");
+ if ("jta".equals(type)) {
+ retryInterceptor = new JtaRetryInterceptor();
+ } else {
+ retryInterceptor = new RetryInterceptor();
+ }
+
+
if (element.hasAttribute("retries")) {
String retriesText = element.getAttribute("retries");
try {
int retries = Integer.parseInt(retriesText);
- retryInterceptorDescriptor.setRetries(retries);
+ retryInterceptor.setRetries(retries);
} catch (NumberFormatException e) {
parse.addProblem("couldn't parse retries "+retriesText, element);
}
@@ -56,7 +66,7 @@
String delayText = element.getAttribute("delay");
try {
long delay = Long.parseLong(delayText);
- retryInterceptorDescriptor.setDelay(delay);
+ retryInterceptor.setDelay(delay);
} catch (NumberFormatException e) {
parse.addProblem("couldn't parse delay "+delayText, element);
}
@@ -66,12 +76,12 @@
String delayFactorText = element.getAttribute("delay-factor");
try {
long delayFactor = Long.parseLong(delayFactorText);
- retryInterceptorDescriptor.setDelayFactor(delayFactor);
+ retryInterceptor.setDelayFactor(delayFactor);
} catch (NumberFormatException e) {
parse.addProblem("couldn't parse delay-factor "+delayFactorText, element);
}
}
- return retryInterceptorDescriptor;
+ return new ProvidedObjectDescriptor(retryInterceptor);
}
}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/RetryInterceptorDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/RetryInterceptorDescriptor.java 2009-06-23 11:52:47 UTC (rev 5092)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/RetryInterceptorDescriptor.java 2009-06-23 13:27:08 UTC (rev 5093)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.wire.descriptor;
-
-import org.jbpm.pvm.internal.svc.RetryInterceptor;
-import org.jbpm.pvm.internal.wire.WireContext;
-
-/**
- * @author Tom Baeyens
- */
-public class RetryInterceptorDescriptor extends AbstractDescriptor {
-
- private static final long serialVersionUID = 1L;
-
- RetryInterceptor retryInterceptor = new RetryInterceptor();
-
- public Object construct(WireContext wireContext) {
- return retryInterceptor;
- }
-
- public void setRetries(int retries) {
- retryInterceptor.setRetries(retries);
- }
- public void setDelay(long delay) {
- retryInterceptor.setDelay(delay);
- }
- public void setDelayFactor(long delayFactor) {
- retryInterceptor.setDelayFactor(delayFactor);
- }
-
-
-}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.jta.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.jta.cfg.xml 2009-06-23 11:52:47 UTC (rev 5092)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.jta.cfg.xml 2009-06-23 13:27:08 UTC (rev 5093)
@@ -5,6 +5,7 @@
<process-engine-context>
<command-service>
<environment-interceptor />
+ <retry-interceptor type="jta" />
<jta-transaction-interceptor />
</command-service>
</process-engine-context>
More information about the jbpm-commits
mailing list