org.wamblee.test.transactions
Class TransactionProxyFactory<T>
java.lang.Object
org.wamblee.test.transactions.TransactionProxyFactory<T>
public class TransactionProxyFactory<T>
- extends java.lang.Object
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.
Use getTransactionScopedEntityManager() to get the transaction
scoped entity manager to pass to services.
For example:
JpaBuilder builder = ...
TransactionProxyFactory factory = new TransactionProxyFactory(
builder, Service.class);
Service service = new JpaService(factory.getTransactionScopedEntityManager());
Service proxy = factory.getProxy(service);
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.
- Author:
- Erik Brakkee
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TransactionProxyFactory
public TransactionProxyFactory(JpaBuilder aJpaBuilder,
java.lang.Class<T> aClass)
- Constructs the transaction proxy.
- Parameters:
aJpaBuilder -
getTransactionScopedEntityManager
public javax.persistence.EntityManager getTransactionScopedEntityManager()
getProxy
public T getProxy(T aService)
Copyright © 2010. All Rights Reserved.