activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1202925 - /activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp
Date Wed, 16 Nov 2011 23:08:59 GMT
Author: tabish
Date: Wed Nov 16 23:08:58 2011
New Revision: 1202925

URL: http://svn.apache.org/viewvc?rev=1202925&view=rev
Log:
Simplify the cleanup methods in the example to avoid confusion.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp?rev=1202925&r1=1202924&r2=1202925&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/main.cpp Wed Nov 16 23:08:58 2011
@@ -140,33 +140,18 @@ public:
 
 private:
 
-    void cleanup(){
+    void cleanup() {
+        if (connection != NULL) {
+            connection->close();
+        }
 
-        // Destroy resources.
-        try{
-            if( destination != NULL ) delete destination;
-        }catch ( CMSException& e ) { e.printStackTrace(); }
+        delete destination;
         destination = NULL;
-
-        try{
-            if( producer != NULL ) delete producer;
-        }catch ( CMSException& e ) { e.printStackTrace(); }
+        delete producer;
         producer = NULL;
-
-        // Close open resources.
-        try{
-            if( session != NULL ) session->close();
-            if( connection != NULL ) connection->close();
-        }catch ( CMSException& e ) { e.printStackTrace(); }
-
-        try{
-            if( session != NULL ) delete session;
-        }catch ( CMSException& e ) { e.printStackTrace(); }
+        delete session;
         session = NULL;
-
-        try{
-            if( connection != NULL ) delete connection;
-        }catch ( CMSException& e ) { e.printStackTrace(); }
+        delete connection;
         connection = NULL;
     }
 };
@@ -317,39 +302,17 @@ public:
 
 private:
 
-    void cleanup(){
-
-        //*************************************************
-        // Always close destination, consumers and producers before
-        // you destroy their sessions and connection.
-        //*************************************************
-
-        // Destroy resources.
-        try{
-            if( destination != NULL ) delete destination;
-        }catch (CMSException& e) { e.printStackTrace(); }
+    void cleanup() {
+        if (connection != NULL) {
+            connection->close();
+        }
+        delete destination;
         destination = NULL;
-
-        try{
-            if( consumer != NULL ) delete consumer;
-        }catch (CMSException& e) { e.printStackTrace(); }
+        delete consumer;
         consumer = NULL;
-
-        // Close open resources.
-        try{
-            if( session != NULL ) session->close();
-            if( connection != NULL ) connection->close();
-        }catch (CMSException& e) { e.printStackTrace(); }
-
-        // Now Destroy them
-        try{
-            if( session != NULL ) delete session;
-        }catch (CMSException& e) { e.printStackTrace(); }
+        delete session;
         session = NULL;
-
-        try{
-            if( connection != NULL ) delete connection;
-        }catch (CMSException& e) { e.printStackTrace(); }
+        delete connection;
         connection = NULL;
     }
 };



Mime
View raw message