X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsupport%2Fpersistence%2FTransactionProxyFactory.java;h=548a3cdaebc1a8279ebaef779854807387925a99;hb=eb05ee41d982e68776ff798b4216a7e95ac9c08b;hp=e56d34fa78e7ea94b8c3020a810eb82205d004cb;hpb=1092f4c2e75cabd49c41a087f9dc67cd966d11fa;p=utils diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java index e56d34fa..548a3cda 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java @@ -15,6 +15,7 @@ */ package org.wamblee.support.persistence; + import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -27,11 +28,25 @@ import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork; /** * This utility makes sure that each invocation on a certain interface is - * carried out within a JPA unit of work. + * carried out within a JPA unit of work. Note that this is equivalent + * to the sementics of a requiresNew transaction attribute. * * Use {@link #getTransactionScopedEntityManager()} to get the transaction * scoped entity manager to pass to services. * + * + * For example: + *
+ * JpaBuilder builder = ... + * TransactionProxyFactory+ * The above example executes the executeMethod() call on the service object within an active transaction. + * In the constructor of the service a transaction scoped entity manager is passed. + * * @param T * Type of interface to proxy. * @@ -39,6 +54,13 @@ import org.wamblee.support.persistence.JpaBuilder.JpaUnitOfWork; */ public class TransactionProxyFactoryfactory = new TransactionProxyFactory ( + * builder, Service.class); + * Service service = new JpaService(factory.getTransactionScopedEntityManager()); + * Service proxy = factory.getProxy(service); + * proxy.executeMethod(...); + *