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=b1d0fe855fcf6fd4ddf6e47701eb8b3d0f8ffc9f;hp=c81eb9798d9b08862d979dce4301943271748871;hpb=cd7c2439f09ef8d7f675f8bbfaa683fdac8f2733;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