[seam-commits] Seam SVN: r13681 - in modules/persistence/trunk: impl/src/main/java/org/jboss/seam/persistence and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Aug 31 22:47:04 EDT 2010
Author: swd847
Date: 2010-08-31 22:47:04 -0400 (Tue, 31 Aug 2010)
New Revision: 13681
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
modules/persistence/trunk/pom.xml
Log:
change the way the entity manager is closed
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-08-31 14:41:32 UTC (rev 13680)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-09-01 02:47:04 UTC (rev 13681)
@@ -42,5 +42,7 @@
public Class<?> getBeanType();
public SeamPersistenceProvider getProvider();
+
+ public void setClosed();
}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-08-31 14:41:32 UTC (rev 13680)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-09-01 02:47:04 UTC (rev 13681)
@@ -123,7 +123,7 @@
public void destroy(Bean<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
{
- em.close();
+ ((ManagedPersistenceContext)em).setClosed();
arg1.release();
try
{
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-08-31 14:41:32 UTC (rev 13680)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-09-01 02:47:04 UTC (rev 13681)
@@ -68,6 +68,8 @@
private final SeamPersistenceProvider provider;
private boolean persistenceContextsTouched = false;
+
+ private boolean closed = false;
static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
@@ -105,6 +107,10 @@
{
return provider;
}
+ if ("setClosed".equals(method.getName()) && method.getParameterTypes().length == 0)
+ {
+ return provider;
+ }
return super.invoke(proxy, method, args);
}
@@ -129,6 +135,25 @@
}
}
+ private void setClosed()
+ {
+ SeamTransaction transaction = userTransactionInstance.get();
+ try
+ {
+ if(transaction.isActive())
+ {
+ closed = true;
+ }
+ else
+ {
+ delegate.close();
+ }
+ } catch (SystemException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
private void changeFushMode(FlushModeType flushModeType)
{
provider.setFlushMode(delegate, flushModeType);
@@ -155,6 +180,10 @@
public void afterCompletion(int status)
{
synchronizationRegistered = false;
+ if(closed)
+ {
+ delegate.close();
+ }
}
public void beforeCompletion()
Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml 2010-08-31 14:41:32 UTC (rev 13680)
+++ modules/persistence/trunk/pom.xml 2010-09-01 02:47:04 UTC (rev 13681)
@@ -20,7 +20,7 @@
<description>
The Parent for Seam Persistence Modules
- </description>
+ </description>
<url>http://www.seamframework.org</url>
More information about the seam-commits
mailing list