[jboss-svn-commits] JBL Code SVN: r15412 - in labs/jbossesb/trunk/product: samples/quickstarts/business_service and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Sep 27 15:43:52 EDT 2007


Author: kurt.stam at jboss.com
Date: 2007-09-27 15:43:51 -0400 (Thu, 27 Sep 2007)
New Revision: 15412

Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
   labs/jbossesb/trunk/product/samples/quickstarts/business_service/
Log:
JBESB-1051, suspending tx when calling JAXR, then resuming after the call.

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2007-09-27 19:30:39 UTC (rev 15411)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2007-09-27 19:43:51 UTC (rev 15412)
@@ -33,6 +33,10 @@
 import java.util.Properties;
 import java.util.Set;
 
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
 import javax.xml.registry.BulkResponse;
 import javax.xml.registry.BusinessLifeCycleManager;
 import javax.xml.registry.BusinessQueryManager;
@@ -65,6 +69,7 @@
 import org.jboss.soa.esb.services.registry.Registry;
 import org.jboss.soa.esb.services.registry.RegistryException;
 import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
+import org.jboss.tm.TransactionManagerLocator;
 /**
  * Utility class for the Registry.
  * If need be we can extract the interface from here, add a factory and have JAXR as a plugin, allowing
@@ -129,6 +134,7 @@
 	 */
 	protected Service registerService(String category, String serviceName, String serviceDescription) throws JAXRException 
 	{
+        
 		Service service =null;
 		Organization organization = getJBossESBOrganization();
 		Connection connection = JAXRRegistryImpl.getConnection();
@@ -158,10 +164,13 @@
 	 */
 	@SuppressWarnings("unchecked")
     public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException{
-//    first find the ServiceBindings for this service
+        TransactionManager txManager = TransactionManagerLocator.getInstance().locate();
+        Transaction currentTx = null;
+        //first find the ServiceBindings for this service
         Connection connection = JAXRRegistryImpl.getConnection();
         Service service = null;
         try {
+            currentTx = txManager.suspend();
             service = findService(category, serviceName);
             if (service==null) {
                 throw new ServiceNotFoundException("No such EPR found for service with name = " 
@@ -175,8 +184,11 @@
             blm.deleteServices(serviceKeys);
         } catch (JAXRException je) {
             throw new RegistryException(je.getLocalizedMessage(), je);
+        } catch (SystemException se) {
+            throw new RegistryException(se.getLocalizedMessage(), se);
         } finally {
             closeConnection(connection);
+            resumeTransaction(txManager, currentTx);
         }
 	}
 	/** 
@@ -185,8 +197,11 @@
 	public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription) 
 		throws RegistryException
 	{
+        TransactionManager txManager = TransactionManagerLocator.getInstance().locate();
+        Transaction currentTx = null;
 		Connection connection = JAXRRegistryImpl.getConnection();
 		try {
+            currentTx = txManager.suspend();
 			//Find the service
 			Service service = findService(category,serviceName);
 			if (service==null) {
@@ -220,18 +235,24 @@
             throw new RegistryException(uee.getLocalizedMessage(), uee);
         } catch (MarshalException me) {
             throw new RegistryException(me.getLocalizedMessage(), me);
+        } catch (SystemException se) {
+            throw new RegistryException(se.getLocalizedMessage(), se);
 		} finally {
 			closeConnection(connection);
+            resumeTransaction(txManager, currentTx);
 		}
 	}
 	/** 
 	 * Remove an EPR from the Registry
 	 */
 	public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException, ServiceNotFoundException{
+        TransactionManager txManager = TransactionManagerLocator.getInstance().locate();
+        Transaction currentTx = null;
 		//first find the ServiceBindings for this service
         Connection connection = JAXRRegistryImpl.getConnection();
         Service service = null;
 		try {
+            currentTx = txManager.suspend();
             service = findService(category, serviceName);
             if (service==null) {
                 throw new ServiceNotFoundException("No such Service found for service with category= "
@@ -260,8 +281,11 @@
             throw new RegistryException(uee.getLocalizedMessage(), uee);
         } catch (MarshalException me) {
             throw new RegistryException(me.getLocalizedMessage(), me);
+        } catch (SystemException se) {
+            throw new RegistryException(se.getLocalizedMessage(), se);
 		} finally {
 		    closeConnection(connection);
+            resumeTransaction(txManager, currentTx);
         }
 	}
 	
@@ -271,16 +295,24 @@
 	 */
 	public List<String> findAllServices() throws RegistryException
 	{
+        TransactionManager txManager = TransactionManagerLocator.getInstance().locate();
+        Transaction currentTx = null;
 		List<String> serviceNames = new ArrayList<String>();
 		try {
+            if (txManager!=null) currentTx =  txManager.suspend();
 			Collection services = getJBossESBOrganization().getServices();
 			for (Iterator i=services.iterator();i.hasNext();) {
 				String serviceName = ((Service)i.next()).getName().getValue();
 				serviceNames.add(serviceName);
 			}
+            
 		} catch (JAXRException je) {
 			throw new RegistryException(je.getLocalizedMessage(), je);
-		}
+		} catch (SystemException se) {
+            throw new RegistryException(se.getLocalizedMessage(), se);
+        } finally {
+            resumeTransaction(txManager, currentTx);
+        }
 		return serviceNames;
 	}
 	/**
@@ -291,8 +323,11 @@
 	 */
 	public List<String> findServices(String category) throws RegistryException
 	{
+        TransactionManager txManager = TransactionManagerLocator.getInstance().locate();
+        Transaction currentTx = null;
 		List<String>serviceNames = new ArrayList<String>();
 		try {
+            currentTx = txManager.suspend();
 			Collection<Service>services = findServicesForCategory(category);
 			for (Iterator<Service> i=services.iterator();i.hasNext();) {
 				String serviceName = i.next().getName().getValue();
@@ -300,7 +335,11 @@
 			}
 		} catch (JAXRException je) {
 			throw new RegistryException(je.getLocalizedMessage(), je);
-		}
+        } catch (SystemException se) {
+            throw new RegistryException(se.getLocalizedMessage(), se);
+		} finally {
+            resumeTransaction(txManager, currentTx);
+        }
 		return serviceNames;
 	}
 	/**
@@ -310,9 +349,12 @@
 	 */
 	public List<EPR> findEPRs(String category, String serviceName) throws RegistryException, ServiceNotFoundException
 	{
+        TransactionManager txManager = TransactionManagerLocator.getInstance().locate();
+        Transaction currentTx = null;
 		List<EPR> eprs = new ArrayList<EPR>();
 		Connection connection = JAXRRegistryImpl.getConnection();
 		try {
+            currentTx = txManager.suspend();
 			Service service = findService(category, serviceName);
 			if (service==null){
 				throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
@@ -333,8 +375,11 @@
             throw new RegistryException(uee.getLocalizedMessage(), uee);
         } catch (UnmarshalException me) {
             throw new RegistryException(me.getLocalizedMessage(), me);
+        } catch (SystemException se) {
+            throw new RegistryException(se.getLocalizedMessage(), se);
 		} finally {
 			closeConnection(connection);
+            resumeTransaction(txManager, currentTx);
 		}
 		return eprs;
 	}
@@ -345,9 +390,12 @@
 	 */
 	public EPR findEPR(String category, String serviceName) throws RegistryException, ServiceNotFoundException
 	{
+        TransactionManager txManager = TransactionManagerLocator.getInstance().locate();
+        Transaction currentTx = null;
 		EPR epr = null;
 		Connection connection = JAXRRegistryImpl.getConnection();
 		try {
+            currentTx = txManager.suspend();
 			Service service = findService(category, serviceName);
 			if (service==null){
 				throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
@@ -365,8 +413,11 @@
             throw new RegistryException(uee.getLocalizedMessage(), uee);
         } catch (UnmarshalException me) {
             throw new RegistryException(me.getLocalizedMessage(), me);
+        } catch (SystemException se) {
+            throw new RegistryException(se.getLocalizedMessage(), se);
 		} finally {
 			closeConnection(connection);
+            resumeTransaction(txManager, currentTx);
 		}
 		return epr;
 	}
@@ -695,6 +746,18 @@
 			closeConnection(connection);
 		}
 	}
+    
+    private void resumeTransaction(TransactionManager txManager, Transaction currentTx) {
+        try {
+            if (txManager!=null && currentTx!=null) {
+                txManager.resume(currentTx);
+            }
+        } catch (InvalidTransactionException it) {
+            logger.error(it.getLocalizedMessage(),it);
+        } catch (SystemException se) {
+            logger.error(se.getLocalizedMessage(),se);
+        }
+    }
 	
 }
 


Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/business_service
___________________________________________________________________
Name: svn:ignore
   + build





More information about the jboss-svn-commits mailing list