git://wamblee.org
/
utils
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Now using connections managed by JPA instead of using JNDI mocking.
[utils]
/
test
/
enterprise
/
src
/
main
/
java
/
org
/
wamblee
/
support
/
persistence
/
TransactionProxyFactory.java
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 4e72f4845d4a377b7075f62a11e0b8856b0e6783..e56d34fa78e7ea94b8c3020a810eb82205d004cb 100644
(file)
--- a/
test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java
+++ b/
test/enterprise/src/main/java/org/wamblee/support/persistence/TransactionProxyFactory.java
@@
-29,8
+29,8
@@
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.
*
* This utility makes sure that each invocation on a certain interface is
* carried out within a JPA unit of work.
*
- * Use {@link #getTransactionScopedEntityManager()} to get the transaction
scoped
- *
entity manager to pass to services.
+ * Use {@link #getTransactionScopedEntityManager()} to get the transaction
+ *
scoped entity manager to pass to services.
*
* @param T
* Type of interface to proxy.
*
* @param T
* Type of interface to proxy.
@@
-58,8
+58,15
@@
public class TransactionProxyFactory<T> {
ENTITY_MANAGER.set(aEm);
return aMethod.invoke(service, aArgs);
} catch (InvocationTargetException e) {
ENTITY_MANAGER.set(aEm);
return aMethod.invoke(service, aArgs);
} catch (InvocationTargetException e) {
- throw (Exception)e.getCause();
- } finally {
+ Throwable cause = e.getCause();
+ if (cause instanceof Exception) {
+ throw (Exception) cause;
+ } else if (cause instanceof Error) {
+ throw (Error) cause;
+ }
+ // last resort.
+ throw new RuntimeException(e);
+ } finally {
ENTITY_MANAGER.set(null);
}
}
ENTITY_MANAGER.set(null);
}
}
@@
-68,9
+75,9
@@
public class TransactionProxyFactory<T> {
}
}
- private static final ThreadSpecificProxyFactory<EntityManager> ENTITY_MANAGER =
-
new ThreadSpecificProxyFactory<EntityManager>(
EntityManager.class);
-
+ private static final ThreadSpecificProxyFactory<EntityManager> ENTITY_MANAGER =
new ThreadSpecificProxyFactory<EntityManager>(
+ EntityManager.class);
+
private JpaBuilder jpaBuilder;
private Class<T> clazz;
private JpaBuilder jpaBuilder;
private Class<T> clazz;
@@
-83,8
+90,8
@@
public class TransactionProxyFactory<T> {
jpaBuilder = aJpaBuilder;
clazz = aClass;
}
jpaBuilder = aJpaBuilder;
clazz = aClass;
}
-
- public EntityManager getTransactionScopedEntityManager() {
+
+ public EntityManager getTransactionScopedEntityManager() {
return ENTITY_MANAGER.getProxy();
}
return ENTITY_MANAGER.getProxy();
}
@@
-98,8
+105,9
@@
public class TransactionProxyFactory<T> {
new Class[] { InvocationHandler.class }).newInstance(
new Object[] { handler });
return proxy;
new Class[] { InvocationHandler.class }).newInstance(
new Object[] { handler });
return proxy;
- } catch (Exception e) {
- throw new RuntimeException("Could not create proxy for " + clazz.getName(), e);
+ } catch (Exception e) {
+ throw new RuntimeException("Could not create proxy for " +
+ clazz.getName(), e);
}
}
}
}
}
}