activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r999451 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/
Date Tue, 21 Sep 2010 15:00:20 GMT
Author: tabish
Date: Tue Sep 21 15:00:19 2010
New Revision: 999451

URL: http://svn.apache.org/viewvc?rev=999451&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-316

Update CMSTemplate code to use only CMSException types and ensure that if a send operation
fails that the Message actually gets deleted to remove a memory leak found when testing with
timeout option on the failover transport.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.cpp?rev=999451&r1=999450&r2=999451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.cpp Tue
Sep 21 15:00:19 2010
@@ -16,13 +16,23 @@
  */
 
 #include "CmsAccessor.h"
-#include <activemq/exceptions/ExceptionDefines.h>
-#include <activemq/exceptions/ActiveMQException.h>
-#include <activemq/util/CMSExceptionSupport.h>
 
+#include <cms/IllegalStateException.h>
+
+using namespace cms;
 using namespace activemq::cmsutil;
-using namespace activemq::exceptions;
-using namespace decaf::lang::exceptions;
+
+/**
+ * A catch-all that throws an CMSException.
+ */
+#define CMSTEMPLATE_CATCHALL() \
+    catch( cms::CMSException& ex ){ \
+        throw ex; \
+    } catch( std::exception& ex ) { \
+        throw CMSException( ex.what(), NULL ); \
+    } catch( ... ){ \
+        throw CMSException( "caught unknown exception", NULL ); \
+    }
 
 ////////////////////////////////////////////////////////////////////////////////
 CmsAccessor::CmsAccessor() : resourceLifecycleManager(),
@@ -53,8 +63,7 @@ cms::Connection* CmsAccessor::createConn
 
         return c;
     }
-    AMQ_CATCH_RETHROW( IllegalStateException )
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -63,9 +72,7 @@ cms::Session* CmsAccessor::createSession
     try {
 
         if( con == NULL ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "connection object is invalid" );
+            throw CMSException( "connection object is invalid", NULL );
         }
 
         // Create the session.
@@ -76,15 +83,12 @@ cms::Session* CmsAccessor::createSession
 
         return s;
     }
-    AMQ_CATCH_RETHROW( IllegalStateException )
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void CmsAccessor::checkConnectionFactory() {
     if( getConnectionFactory() == NULL ) {
-        throw IllegalStateException(
-            __FILE__, __LINE__,
-            "Property 'connectionFactory' is required" );
+        throw IllegalStateException( "Property 'connectionFactory' is required", NULL );
     }
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.h?rev=999451&r1=999450&r2=999451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsAccessor.h Tue Sep
21 15:00:19 2010
@@ -20,7 +20,6 @@
 #include <cms/ConnectionFactory.h>
 #include <activemq/cmsutil/ResourceLifecycleManager.h>
 #include <activemq/util/Config.h>
-#include <decaf/lang/exceptions/IllegalStateException.h>
 
 namespace activemq {
 namespace cmsutil {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp?rev=999451&r1=999450&r2=999451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp
Tue Sep 21 15:00:19 2010
@@ -17,8 +17,10 @@
 
 #include "CmsDestinationAccessor.h"
 
+#include <cms/IllegalStateException.h>
+
+using namespace cms;
 using namespace activemq::cmsutil;
-using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
 CmsDestinationAccessor::CmsDestinationAccessor() : CmsAccessor(),
@@ -69,8 +71,6 @@ cms::Destination* CmsDestinationAccessor
 void CmsDestinationAccessor::checkDestinationResolver() {
 
     if( getDestinationResolver() == NULL ) {
-        throw IllegalStateException(
-                __FILE__, __LINE__,
-                "Property 'destinationResolver' is required" );
+        throw IllegalStateException( "Property 'destinationResolver' is required", NULL );
     }
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp?rev=999451&r1=999450&r2=999451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.cpp Tue
Sep 21 15:00:19 2010
@@ -16,15 +16,15 @@
  */
 
 #include "CmsTemplate.h"
-#include <activemq/exceptions/ActiveMQException.h>
-#include <activemq/exceptions/ExceptionDefines.h>
 #include "ProducerCallback.h"
 #include "MessageCreator.h"
 #include <iostream>
 
+#include <cms/IllegalStateException.h>
+#include <cms/CMSException.h>
+
+using namespace cms;
 using namespace activemq::cmsutil;
-using namespace activemq::exceptions;
-using namespace decaf::lang::exceptions;
 using namespace std;
 
 /**
@@ -42,7 +42,7 @@ using namespace std;
         try { \
             t->destroy(); \
         } catch( ... ) {} \
-        throw ActiveMQException(ex).convertToCMSException(); \
+        throw CMSException( ex.what(), NULL ); \
     }
 
 /**
@@ -60,8 +60,11 @@ using namespace std;
         try { \
             t->destroy(); \
         } catch( ... ) {} \
-        throw ActiveMQException( __FILE__, __LINE__, \
-            "caught unknown exception" ).convertToCMSException(); \
+        throw CMSException( "caught unknown exception", NULL ); \
+    }
+
+#define CMSTEMPLATE_CATCHALL_NOTHROW( ) \
+    catch( ... ){ \
     }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -155,7 +158,6 @@ void CmsTemplate::init() {
             initialized = true;
         }
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCH( IllegalStateException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
@@ -180,7 +182,6 @@ void CmsTemplate::destroy() {
         // Call the base class.
         CmsDestinationAccessor::destroy();
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCH( IllegalStateException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
@@ -189,9 +190,8 @@ void CmsTemplate::destroy() {
 void CmsTemplate::checkDefaultDestination() {
     if( this->defaultDestination == NULL && this->defaultDestinationName.size()==0
) {
         throw IllegalStateException(
-            __FILE__, __LINE__,
             "No defaultDestination or defaultDestinationName specified."
-            "Check configuration of CmsTemplate." );
+            "Check configuration of CmsTemplate.", NULL );
     }
 }
 
@@ -216,7 +216,6 @@ cms::Destination* CmsTemplate::resolveDe
 
         return dest;
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCH( IllegalStateException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
@@ -243,19 +242,7 @@ cms::Connection* CmsTemplate::getConnect
         return connection;
     }
     CMSTEMPLATE_CATCH( IllegalStateException, this )
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
-    catch( cms::CMSException& ex ){
-        try {
-            this->destroy();
-        } catch( ... ) {}
-        throw ex;
-    } catch( ... ){
-        try {
-            this->destroy();
-        } catch( ... ) {}
-        throw ActiveMQException( __FILE__, __LINE__, \
-            "caught unknown exception" ).convertToCMSException();
-    }
+    CMSTEMPLATE_CATCHALL( this )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -270,7 +257,6 @@ PooledSession* CmsTemplate::takeSession(
         // Take a session from the pool.
         return sessionPools[getSessionAcknowledgeMode()]->takeSession();
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -287,7 +273,6 @@ void CmsTemplate::returnSession( PooledS
         session->close();
         session = NULL;
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -319,7 +304,6 @@ cms::MessageProducer* CmsTemplate::creat
 
         return producer;
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCH( IllegalStateException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
@@ -348,7 +332,6 @@ cms::MessageConsumer* CmsTemplate::creat
 
         return consumer;
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCH( IllegalStateException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
@@ -365,7 +348,7 @@ void CmsTemplate::destroyProducer( cms::
         // Close the producer, then destroy it.
         producer->close();
     }
-    AMQ_CATCH_NOTHROW( cms::CMSException )
+    CMSTEMPLATE_CATCHALL_NOTHROW()
 
     // Destroy if it's not a cached producer.
     CachedProducer* cachedProducer = dynamic_cast<CachedProducer*>( producer );
@@ -388,7 +371,7 @@ void CmsTemplate::destroyConsumer( cms::
         // Close the producer, then destroy it.
         consumer->close();
     }
-    AMQ_CATCH_NOTHROW( cms::CMSException )
+    CMSTEMPLATE_CATCHALL_NOTHROW()
 
     // Destroy if it's not a cached consumer.
     CachedConsumer* cachedConsumer = dynamic_cast<CachedConsumer*>( consumer );
@@ -435,7 +418,6 @@ void CmsTemplate::execute( SessionCallba
         returnSession( pooledSession );
     }
     CMSTEMPLATE_CATCH( IllegalStateException, this )
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -454,7 +436,6 @@ void CmsTemplate::execute( ProducerCallb
         execute( &cb );
     }
     CMSTEMPLATE_CATCH( IllegalStateException, this )
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -473,7 +454,6 @@ void CmsTemplate::execute( cms::Destinat
         execute( &cb );
     }
     CMSTEMPLATE_CATCH( IllegalStateException, this )
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -492,7 +472,6 @@ void CmsTemplate::execute( const std::st
         execute( &cb );
     }
     CMSTEMPLATE_CATCH( IllegalStateException, this )
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -517,7 +496,6 @@ void CmsTemplate::ProducerExecutor::doIn
         parent->destroyProducer( producer );
 
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, parent )
     CMSTEMPLATE_CATCHALL( parent )
 }
 
@@ -527,7 +505,6 @@ cms::Destination* CmsTemplate::ResolvePr
     try {
         return parent->resolveDestinationName( session, destinationName );
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, parent )
     CMSTEMPLATE_CATCH( IllegalStateException, parent )
     CMSTEMPLATE_CATCHALL( parent )
 }
@@ -539,7 +516,6 @@ void CmsTemplate::send( MessageCreator* 
         SendExecutor senderExecutor( messageCreator, this );
         execute( &senderExecutor );
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -550,7 +526,6 @@ void CmsTemplate::send( cms::Destination
         SendExecutor senderExecutor( messageCreator, this );
         execute( dest, &senderExecutor );
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -562,7 +537,6 @@ void CmsTemplate::send( const std::strin
         SendExecutor senderExecutor( messageCreator, this );
         execute( destinationName, &senderExecutor );
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -592,7 +566,7 @@ void CmsTemplate::doSend( cms::Session* 
         // Destroy the resources.
         destroyMessage( message );
 
-    } catch( ActiveMQException& e ) {
+    } catch( CMSException& e ) {
 
         e.setMark(__FILE__, __LINE__ );
 
@@ -609,7 +583,7 @@ cms::Message* CmsTemplate::doReceive( cm
     try {
 
         if( consumer == NULL ) {
-            throw new ActiveMQException( __FILE__, __LINE__, "consumer is NULL" );
+            throw CMSException( "consumer is NULL", NULL );
         }
 
         long long receiveTime = getReceiveTimeout();
@@ -627,7 +601,6 @@ cms::Message* CmsTemplate::doReceive( cm
         }
 
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -648,7 +621,7 @@ void CmsTemplate::ReceiveExecutor::doInC
         // Destroy the consumer resource.
         parent->destroyConsumer( consumer );
 
-    } catch( ActiveMQException& e ) {
+    } catch( CMSException& e ) {
 
         e.setMark( __FILE__, __LINE__ );
 
@@ -666,7 +639,6 @@ cms::Destination* CmsTemplate::ResolveRe
     try {
         return parent->resolveDestinationName( session, destinationName );
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, parent )
     CMSTEMPLATE_CATCH( IllegalStateException, parent )
     CMSTEMPLATE_CATCHALL( parent )
 }
@@ -681,7 +653,6 @@ cms::Message* CmsTemplate::receive() {
 
         return receiveExecutor.getMessage();
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -695,7 +666,6 @@ cms::Message* CmsTemplate::receive( cms:
 
         return receiveExecutor.getMessage();
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -710,7 +680,6 @@ cms::Message* CmsTemplate::receive( cons
 
         return receiveExecutor.getMessage();
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -725,7 +694,6 @@ cms::Message* CmsTemplate::receiveSelect
 
         return receiveExecutor.getMessage();
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -741,7 +709,6 @@ cms::Message* CmsTemplate::receiveSelect
 
         return receiveExecutor.getMessage();
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }
 
@@ -757,6 +724,5 @@ cms::Message* CmsTemplate::receiveSelect
 
         return receiveExecutor.getMessage();
     }
-    CMSTEMPLATE_CATCH( ActiveMQException, this )
     CMSTEMPLATE_CATCHALL( this )
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h?rev=999451&r1=999450&r2=999451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/CmsTemplate.h Tue Sep
21 15:00:19 2010
@@ -23,7 +23,6 @@
 #include <activemq/cmsutil/SessionCallback.h>
 #include <activemq/cmsutil/ProducerCallback.h>
 #include <activemq/cmsutil/SessionPool.h>
-#include <decaf/lang/exceptions/IllegalStateException.h>
 #include <cms/ConnectionFactory.h>
 #include <cms/DeliveryMode.h>
 #include <string>

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp?rev=999451&r1=999450&r2=999451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp
Tue Sep 21 15:00:19 2010
@@ -17,11 +17,11 @@
 
 #include "DynamicDestinationResolver.h"
 #include "ResourceLifecycleManager.h"
-#include <activemq/exceptions/ActiveMQException.h>
+#include <cms/CMSException.h>
 
 using namespace activemq::cmsutil;
-using namespace activemq::exceptions;
 using namespace decaf::util;
+using namespace cms;
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -96,9 +96,7 @@ cms::Destination* DynamicDestinationReso
         cms::Session* session, const std::string& destName, bool pubSubDomain ) {
 
     if( destName == "" ) {
-        throw ActiveMQException(
-            __FILE__, __LINE__,
-            "destination name is invalid" ).convertToCMSException();
+        throw CMSException( "destination name is invalid", NULL );
     }
 
     // Get the resolver for this session.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp?rev=999451&r1=999450&r2=999451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp Tue
Sep 21 15:00:19 2010
@@ -18,12 +18,20 @@
 #include "PooledSession.h"
 #include "SessionPool.h"
 #include "ResourceLifecycleManager.h"
-#include <activemq/exceptions/ActiveMQException.h>
-#include <activemq/exceptions/ExceptionDefines.h>
-#include <activemq/util/CMSExceptionSupport.h>
+#include <cms/CMSException.h>
 
+using namespace cms;
 using namespace activemq::cmsutil;
-using namespace activemq::exceptions;
+
+/**
+ * A catch-all that throws an CMSException.
+ */
+#define CMSTEMPLATE_CATCHALL() \
+    catch( cms::CMSException& ex ){ \
+        throw ex; \
+    } catch( ... ){ \
+        throw CMSException( "caught unknown exception", NULL ); \
+    }
 
 ////////////////////////////////////////////////////////////////////////////////
 PooledSession::PooledSession( SessionPool* pool, cms::Session* session )
@@ -72,7 +80,7 @@ cms::MessageProducer* PooledSession::cre
     try {
 
         if( destination == NULL ) {
-            throw ActiveMQException(__FILE__, __LINE__, "destination is NULL");
+            throw CMSException( "destination is NULL", NULL );
         }
 
         std::string key = getUniqueDestName(destination);
@@ -99,7 +107,7 @@ cms::MessageProducer* PooledSession::cre
 
         return cachedProducer;
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -110,7 +118,7 @@ cms::MessageConsumer* PooledSession::cre
     try {
 
         if( destination == NULL ) {
-            throw ActiveMQException( __FILE__, __LINE__, "destination is NULL" );
+            throw CMSException( "destination is NULL", NULL );
         }
 
         // Append the selector and noLocal flag onto the key.
@@ -142,7 +150,7 @@ cms::MessageConsumer* PooledSession::cre
 
         return cachedConsumer;
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp?rev=999451&r1=999450&r2=999451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp
Tue Sep 21 15:00:19 2010
@@ -17,12 +17,27 @@
 
 #include "ResourceLifecycleManager.h"
 
-#include <activemq/exceptions/ActiveMQException.h>
-#include <activemq/util/CMSExceptionSupport.h>
+#include <cms/CMSException.h>
 
+using namespace cms;
 using namespace activemq::cmsutil;
 
 ////////////////////////////////////////////////////////////////////////////////
+#define CMSTEMPLATE_CATCHALL() \
+    catch( cms::CMSException& ex ){ \
+        throw ex; \
+    } catch( std::exception& ex ) { \
+        throw CMSException( ex.what(), NULL ); \
+    } catch( ... ){ \
+        throw CMSException( "caught unknown exception", NULL ); \
+    }
+
+////////////////////////////////////////////////////////////////////////////////
+#define CMSTEMPLATE_CATCHALL_NOTHROW( ) \
+    catch( ... ){ \
+    }
+
+////////////////////////////////////////////////////////////////////////////////
 ResourceLifecycleManager::ResourceLifecycleManager() {
 }
 
@@ -34,7 +49,7 @@ ResourceLifecycleManager::~ResourceLifec
         // Destroy all the resources
         destroy();
     }
-    AMQ_CATCHALL_NOTHROW()
+    CMSTEMPLATE_CATCHALL_NOTHROW()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -119,7 +134,7 @@ void ResourceLifecycleManager::destroy()
         // Empty all the lists.
         releaseAll();
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -131,7 +146,7 @@ void ResourceLifecycleManager::addConnec
             connections.add( connection );
         }
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -143,10 +158,9 @@ void ResourceLifecycleManager::addSessio
             sessions.add( session );
         }
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
-
 ////////////////////////////////////////////////////////////////////////////////
 void ResourceLifecycleManager::addDestination( cms::Destination* dest ) {
 
@@ -156,7 +170,7 @@ void ResourceLifecycleManager::addDestin
             destinations.add( dest );
         }
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -168,7 +182,7 @@ void ResourceLifecycleManager::addMessag
             producers.add( producer );
         }
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -180,5 +194,5 @@ void ResourceLifecycleManager::addMessag
             consumers.add( consumer );
         }
     }
-    AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+    CMSTEMPLATE_CATCHALL()
 }



Mime
View raw message