From: Erik Brakkee Date: Sat, 17 Jul 2010 21:56:00 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.7~261 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=87bfe9fe1ac87890640d475765a6e42bc4293162;p=utils --- 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 *