X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Ftest%2Ftransactions%2FSimpleTransactionManager.java;h=a3d57102a6f2fe4d3f324e6d00598d00a65e0e4e;hb=3fe2e2370bc97498af4ac5f010cd4c11454a8e35;hp=ee8eb77dc08fb3d8a25ad5efb9bb154a86372750;hpb=ff7251d55b8a57e6b0dd7374364a429120d880ef;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 ee8eb77d..a3d57102 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 @@ -20,9 +20,47 @@ import java.util.List; import javax.transaction.UserTransaction; +import org.wamblee.general.ThreadSpecificProxyFactory; +import org.wamblee.general.ThreadSpecificProxyFactory.CreationCallback; +import org.wamblee.test.persistence.JpaBuilder; + /** - * Simple transaction manager provides a simple mechanism to manage transaction - * in test code through the {@link UserTransaction} object. + * + *
+ * Simple transaction manager provides a simple mechanism to manage transactions + * 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 * @@ -30,9 +68,9 @@ import javax.transaction.UserTransaction; public class SimpleTransactionManager { private UserTransactionFactory factory; - private ThreadLocal