From 0482ca0c37643564cbb3d753bf866ba0b022ccff Mon Sep 17 00:00:00 2001 From: erik Date: Sat, 17 Jul 2010 21:56:00 +0000 Subject: [PATCH] --- .../SimpleTransactionManager.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleTransactionManager.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleTransactionManager.java index c81eb979..67d5f9e4 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleTransactionManager.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/SimpleTransactionManager.java @@ -21,10 +21,42 @@ import java.util.List; import javax.transaction.UserTransaction; import org.wamblee.general.ThreadSpecificProxyFactory; +import org.wamblee.test.persistence.JpaBuilder; /** + * + *

* Simple transaction manager provides a simple mechanism to manage transaction * in test code through the {@link UserTransaction} object. + * To construct the transaction manager use: + *

+ *
+ *      SimpleTransactionManager manager = 
+ *          new SimpleTransactionManager(new DefaultUserTransactionFactory());
+ * 
+ * + *

+ * Next, add resources to manage using {@link #addResource(TransactionResource)}: + *

+ *      manager.addResource(jpaTester.getJpaBuilder());
+ * 
+ *

+ * As you can see from the above, {@link JpaBuilder} is a resource that can be used + * so this mechanism can be used with JPA testing. + *

+ * + *

+ * The next step is to manage transactions using the standard UserTransaction + * APIs: + *

+ *
+ *      UserTransaction transaction = manager.getTransaction();
+ *      transaction.begin();
+ *     
+ *      ... do work...
+ *  
+ *      transaction.commit(); 
+ * 
* * @author Erik Brakkee * -- 2.31.1