X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Ftest%2Ftransactions%2FSimpleTransactionManager.java;h=a3d57102a6f2fe4d3f324e6d00598d00a65e0e4e;hb=ff76d53d3506968622ed1532255b638a26001ca1;hp=c81eb9798d9b08862d979dce4301943271748871;hpb=a6e781e3dc010072f0e6510d7a87157ce8bea04c;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..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 @@ -21,10 +21,46 @@ 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 * @@ -32,9 +68,9 @@ import org.wamblee.general.ThreadSpecificProxyFactory; public class SimpleTransactionManager { private UserTransactionFactory factory; - private ThreadSpecificProxyFactory