myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r511953 - in /myfaces/fusion/trunk: core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java core15/src/main/java/org/apache/myfaces/fusion/conversation/persistenceContexts/JpaPersistenceContextFactory.java
Date Mon, 26 Feb 2007 19:12:28 GMT
Author: imario
Date: Mon Feb 26 11:12:27 2007
New Revision: 511953

URL: http://svn.apache.org/viewvc?view=rev&rev=511953
Log:
fixed bug in ConversationUtils, Thanks to Werner Punz for pointing out,
added stack of bounded EM for ContextFactory

Modified:
    myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java
    myfaces/fusion/trunk/core15/src/main/java/org/apache/myfaces/fusion/conversation/persistenceContexts/JpaPersistenceContextFactory.java

Modified: myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java?view=diff&rev=511953&r1=511952&r2=511953
==============================================================================
--- myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java
(original)
+++ myfaces/fusion/trunk/core/src/main/java/org/apache/myfaces/fusion/conversation/ConversationUtils.java
Mon Feb 26 11:12:27 2007
@@ -1,4 +1,8 @@
 /*
+ * Copyright (c) 2007, Your Corporation. All Rights Reserved.
+ */
+
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -34,7 +38,7 @@
 	 * method returns a new instance of the "controller bean" for the given conversation</p>
 	 * <p>The "controller bean" is the one you configured in your spring config</p>
 	 */
-	public Object invalidateAndRestart(Conversation conversation)
+	public static Object invalidateAndRestart(Conversation conversation)
 	{
 		String name = conversation.getName();
 

Modified: myfaces/fusion/trunk/core15/src/main/java/org/apache/myfaces/fusion/conversation/persistenceContexts/JpaPersistenceContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/fusion/trunk/core15/src/main/java/org/apache/myfaces/fusion/conversation/persistenceContexts/JpaPersistenceContextFactory.java?view=diff&rev=511953&r1=511952&r2=511953
==============================================================================
--- myfaces/fusion/trunk/core15/src/main/java/org/apache/myfaces/fusion/conversation/persistenceContexts/JpaPersistenceContextFactory.java
(original)
+++ myfaces/fusion/trunk/core15/src/main/java/org/apache/myfaces/fusion/conversation/persistenceContexts/JpaPersistenceContextFactory.java
Mon Feb 26 11:12:27 2007
@@ -26,6 +26,7 @@
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.FlushModeType;
+import java.util.Stack;
 
 /**
  * myfaces fusion entity manager factory
@@ -41,18 +42,38 @@
 
 		return new PersistenceContext()
 		{
+			private final Stack bindings = new Stack();
 
 			public void bind()
 			{
-				TransactionSynchronizationManager.bindResource(entityManagerFactory,
-					new EntityManagerHolder(em));
-
+				synchronized(bindings)
+				{
+					EntityManagerHolder current = (EntityManagerHolder)
+						TransactionSynchronizationManager.getResource(entityManagerFactory);
+					if (current != null && current.getEntityManager() != em)
+					{
+						TransactionSynchronizationManager.unbindResource(entityManagerFactory);
+					}
+					bindings.push(current);
+
+					TransactionSynchronizationManager.bindResource(entityManagerFactory,
+						new EntityManagerHolder(em));
+				}
 			}
 
 			public void unbind()
 			{
-				TransactionSynchronizationManager.unbindResource(entityManagerFactory);
-
+				synchronized(bindings)
+				{
+					TransactionSynchronizationManager.unbindResource(entityManagerFactory);
+
+					Object holder = bindings.pop();
+					if (holder != null)
+					{
+						TransactionSynchronizationManager.bindResource(entityManagerFactory,
+							holder);
+					}
+				}
 			}
 
 			public void close()



Mime
View raw message