X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Ftest%2Ftransactions%2FTransactionProxyFactory.java;h=67f64bee95ba9fc65b683260687c4676a00226dc;hb=83898516d61bfcd1f4e3a3ea79bb56f3877f4900;hp=d6d47992983d13023d41f72627c3d96676879faf;hpb=a1ab1a2e44c95cc10ad4c4d15420b49e3744d93b;p=utils diff --git a/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionProxyFactory.java b/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionProxyFactory.java index d6d47992..67f64bee 100644 --- a/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionProxyFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/test/transactions/TransactionProxyFactory.java @@ -15,7 +15,6 @@ */ package org.wamblee.test.transactions; - import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -31,24 +30,27 @@ import org.wamblee.test.persistence.JpaBuilder.JpaUnitOfWork; /** * This utility makes sure that each invocation on a certain interface is - * carried out within a JPA unit of work. Note that this is equivalent - * to the sementics of a requiresNew transaction attribute. + * 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: + * For example: + * *
  *     JpaBuilder builder = ...
  *     TransactionProxyFactory factory = new TransactionProxyFactory(
  *           builder, Service.class);
  *     Service service = new JpaService(factory.getTransactionScopedEntityManager());
  *     Service proxy = factory.getProxy(service);
- *     proxy.executeMethod(...); 
+ *     proxy.executeMethod(...);
  * 
- * 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. + * + * 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. @@ -58,11 +60,12 @@ import org.wamblee.test.persistence.JpaBuilder.JpaUnitOfWork; public class TransactionProxyFactory { /** - * Executes the call on the service within a new transaction. + * Executes the call on the service within a new transaction. * * @author Erik Brakkee - * - * @param Type of the service interface. + * + * @param + * Type of the service interface. */ private class UnitOfWorkInvocationHandler implements InvocationHandler { @@ -75,11 +78,11 @@ public class TransactionProxyFactory { @Override public Object invoke(Object aProxy, final Method aMethod, final Object[] aArgs) throws Throwable { - return TransactionProxyFactory.this.jpaBuilder - .execute(new JpaUnitOfWork() { + return TransactionProxyFactory.this.jpaBuilder.execute( + new JpaUnitOfWork() { @Override public Object execute(EntityManager aEm) throws Exception { - EntityManager oldEm = ENTITY_MANAGER.get(); + EntityManager oldEm = ENTITY_MANAGER.get(); try { ENTITY_MANAGER.set(aEm); return aMethod.invoke(service, aArgs);