[jbpm-commits] JBoss JBPM SVN: r6690 - jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Sep 28 08:16:41 EDT 2010


Author: bradsdavis
Date: 2010-09-28 08:16:40 -0400 (Tue, 28 Sep 2010)
New Revision: 6690

Added:
   jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsUtil.java
Modified:
   jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsConnectorService.java
Log:
Added JmsUtil for cleaning up connections, sessions, and message producers.

Modified: jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsConnectorService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsConnectorService.java	2010-09-28 12:02:37 UTC (rev 6689)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsConnectorService.java	2010-09-28 12:16:40 UTC (rev 6690)
@@ -83,22 +83,8 @@
       throw new JbpmException("could not send jms message", e);
     }
     finally {
-      if(messageProducer!=null) {
-    		try {
-    			messageProducer.close();
-  			}
-    		catch (JMSException e) {
-    	    	  log.warn("could not close message producer", e);
-    	    }
-	  }
-      if(session!=null) {
-	      try {
-	            session.close();
-	      }
-	      catch (JMSException e) {
-	    	  log.warn("could not close jms session", e);
-	      }
-      }
+    	JmsUtil.closeSilently(messageProducer);
+    	JmsUtil.closeSilently(session);
     }
   }
 
@@ -134,14 +120,6 @@
   }
 
   public void close() {
-	try {
-      if(connection!=null)
-      {
-		connection.close();
-      }
-    }
-    catch (JMSException e) {
-      log.warn("could not close jms connection", e);
-    }
+	JmsUtil.closeSilently(connection);
   }
 }

Added: jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsUtil.java	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsUtil.java	2010-09-28 12:16:40 UTC (rev 6690)
@@ -0,0 +1,51 @@
+package org.jbpm.jms;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class JmsUtil {
+
+	private static final Log log = LogFactory.getLog(JmsUtil.class);
+	private JmsUtil(){
+		//seal
+	}
+	
+	public static void closeSilently(MessageProducer producer)
+	{
+		if(producer!=null) {
+			try {
+				producer.close();
+			} catch (JMSException e) {
+				log.warn("issue closing message producer.",e);
+			}
+		}
+	}
+	
+	public static void closeSilently(Session session)
+	{
+		if(session!=null) {
+			try {
+				session.close();
+			} catch(JMSException e) {
+				log.warn("issue closing session.",e);
+			}
+		}
+	}
+	
+	public static void closeSilently(Connection connection)
+	{
+		if(connection!=null) {
+			try {
+				connection.close();
+			} catch (JMSException e) {
+				log.warn("issue closing connection.",e);
+			}
+		}
+			
+	}
+}


Property changes on: jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/src/main/java/org/jbpm/jms/JmsUtil.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the jbpm-commits mailing list