[jboss-cvs] jboss-seam/src/main/org/jboss/seam/transaction ...
Gavin King
gavin.king at jboss.com
Sun Jun 24 19:35:01 EDT 2007
User: gavin
Date: 07/06/24 19:35:01
Modified: src/main/org/jboss/seam/transaction CMTTransaction.java
UTTransaction.java
Log:
Some EJBs can be BMTs
throw exception if PC is closed with an active tx
Revision Changes Path
1.2 +32 -13 jboss-seam/src/main/org/jboss/seam/transaction/CMTTransaction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CMTTransaction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/transaction/CMTTransaction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CMTTransaction.java 24 Jun 2007 06:34:34 -0000 1.1
+++ CMTTransaction.java 24 Jun 2007 23:35:01 -0000 1.2
@@ -8,14 +8,14 @@
import javax.transaction.Status;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
/**
* Wraps EJBContext transaction management in a
* UserTransaction interface. Note that container managed
- * transaction cannot be controlled by the application,
- * so begin(), commit() and rollback() all throw
- * UnsupportOperationException.
- *
+ * transactions cannot be controlled by the application,
+ * so begin(), commit() and rollback() are disallowed in
+ * a CMT.
*
* @author Mike Youngstrom
* @author Gavin King
@@ -39,13 +39,37 @@
public void begin() throws NotSupportedException, SystemException
{
- throw new UnsupportedOperationException("container managed transaction");
+ ejbContext.getUserTransaction().begin();
}
public void commit() throws RollbackException, HeuristicMixedException,
HeuristicRollbackException, SecurityException, IllegalStateException, SystemException
{
- throw new UnsupportedOperationException("container managed transaction");
+ UserTransaction userTransaction = ejbContext.getUserTransaction();
+ boolean success = false;
+ parent.beforeCommit();
+ try
+ {
+ userTransaction.commit();
+ success = true;
+ }
+ finally
+ {
+ parent.afterCommit(success);
+ }
+ }
+
+ public void rollback() throws IllegalStateException, SecurityException, SystemException
+ {
+ UserTransaction userTransaction = ejbContext.getUserTransaction();
+ try
+ {
+ userTransaction.rollback();
+ }
+ finally
+ {
+ parent.afterRollback();
+ }
}
public int getStatus() throws SystemException
@@ -63,15 +87,10 @@
}
catch (IllegalStateException ise)
{
- return Status.STATUS_NO_TRANSACTION;
+ return ejbContext.getUserTransaction().getStatus();
}
}
- public void rollback() throws IllegalStateException, SecurityException, SystemException
- {
- throw new UnsupportedOperationException("container managed transaction");
- }
-
public void setRollbackOnly() throws IllegalStateException, SystemException
{
ejbContext.setRollbackOnly();
@@ -79,7 +98,7 @@
public void setTransactionTimeout(int timeout) throws SystemException
{
- throw new UnsupportedOperationException("container managed transaction");
+ ejbContext.getUserTransaction().setTransactionTimeout(timeout);
}
@Override
1.5 +5 -5 jboss-seam/src/main/org/jboss/seam/transaction/UTTransaction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UTTransaction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/transaction/UTTransaction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- UTTransaction.java 24 Jun 2007 06:34:34 -0000 1.4
+++ UTTransaction.java 24 Jun 2007 23:35:01 -0000 1.5
@@ -52,11 +52,6 @@
}
}
- public int getStatus() throws SystemException
- {
- return delegate.getStatus();
- }
-
public void rollback() throws IllegalStateException, SecurityException, SystemException
{
try
@@ -69,6 +64,11 @@
}
}
+ public int getStatus() throws SystemException
+ {
+ return delegate.getStatus();
+ }
+
public void setRollbackOnly() throws IllegalStateException, SystemException
{
delegate.setRollbackOnly();
More information about the jboss-cvs-commits
mailing list