svn commit: r693469 - /webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java

[email protected]
Newsgroups gmane.comp.apache.webservices.fx.devel
Message-ID <[email protected]>
Author: mckierna
Date: Tue Sep  9 07:28:20 2008
New Revision: 693469

URL: http://svn.apache.org/viewvc?rev=693469&view=rev
Log:
Do not enlist beans when transaction is not active (see SANDESHA2-177)

Modified:
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java?rev=693469&r1=693468&r2=693469&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java Tue Sep  9 07:28:20 2008
@@ -26,6 +26,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
 import org.apache.sandesha2.storage.SandeshaStorageException;
 import org.apache.sandesha2.storage.Transaction;
 import org.apache.sandesha2.storage.beans.RMBean;
@@ -92,7 +94,8 @@
 	
 	public void enlist(RMBean bean) {
 		if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Entry: InMemoryTransaction::enlist, " + bean);
-		if (bean != null) {
+		if(isActive()){
+		  if (bean != null) {
 			DummyTransaction tran = null;
 			synchronized (bean) {
 				tran = (DummyTransaction) bean.getTransaction();
@@ -122,7 +125,12 @@
 
 			}
 		}
-		
+	} else {
+		String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noTransaction);
+		IllegalStateException e = new IllegalStateException(message);
+		if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("An attempt to enlist new work to an InMemoryTransaction that has previously been committed or rolled back.", e);
+		throw e;
+	}
 		if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Exit: InMemoryTransaction::enlist");
 	}
 	
@@ -170,3 +178,4 @@
 
 
 
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.