Author: nmittler
Date: Sun Feb 10 13:08:24 2008
New Revision: 620328
URL: http://svn.apache.org/viewvc?rev=620328&view=rev
Log:
AMQCPP-152 - Adding destroy method to CmsTemplate
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.h
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.h
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp?rev=620328&r1=620327&r2=620328&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.cpp
Sun Feb 10 13:08:24 2008
@@ -47,6 +47,17 @@
// Give the resolver our lifecycle manager.
destinationResolver->setResourceLifecycleManager(getResourceLifecycleManager());
}
+
+////////////////////////////////////////////////////////////////////////////////
+void CmsDestinationAccessor::destroy()
+throw (cms::CMSException, IllegalStateException) {
+
+ // Invoke the base class.
+ CmsAccessor::destroy();
+
+ // Reinitialize the destination resolver with the lifecycle manager.
+
destinationResolver->setResourceLifecycleManager(getResourceLifecycleManager());
+}
////////////////////////////////////////////////////////////////////////////////
cms::Destination* CmsDestinationAccessor::resolveDestinationName(
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.h?rev=620328&r1=620327&r2=620328&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.h
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsDestinationAccessor.h
Sun Feb 10 13:08:24 2008
@@ -62,6 +62,9 @@
*/
virtual void init()
throw (cms::CMSException,
decaf::lang::exceptions::IllegalStateException);
+
+ virtual void destroy()
+ throw (cms::CMSException,
decaf::lang::exceptions::IllegalStateException);
virtual bool isPubSubDomain() const {
return this->pubSubDomain;
@@ -102,7 +105,7 @@
throw (cms::CMSException,
decaf::lang::exceptions::IllegalStateException);
/**
- * Verifies that the connection factory is valid.
+ * Verifies that the destination resolver is valid.
*/
virtual void checkDestinationResolver() throw
(decaf::lang::exceptions::IllegalStateException);
};
Modified: activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp?rev=620328&r1=620327&r2=620328&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.cpp Sun
Feb 10 13:08:24 2008
@@ -113,6 +113,28 @@
}
////////////////////////////////////////////////////////////////////////////////
+void CmsTemplate::destroy() throw (cms::CMSException, IllegalStateException) {
+
+ try {
+
+ // Destroy the session pools.
+ destroySessionPools();
+
+ // Clear the connection reference
+ connection = NULL;
+
+ // Clear the reference to the default destination.
+ defaultDestination = NULL;
+
+ // Call the base class.
+ CmsDestinationAccessor::destroy();
+ }
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCH_RETHROW( IllegalStateException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
void CmsTemplate::checkDefaultDestination() throw (IllegalStateException) {
if (this->defaultDestination == NULL &&
this->defaultDestinationName.size()==0) {
throw IllegalStateException(
@@ -696,5 +718,4 @@
AMQ_CATCH_RETHROW( ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
-
Modified: activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h?rev=620328&r1=620327&r2=620328&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/CmsTemplate.h Sun Feb
10 13:08:24 2008
@@ -281,6 +281,12 @@
throw (cms::CMSException,
decaf::lang::exceptions::IllegalStateException);
/**
+ * Clears all internal resources.
+ */
+ virtual void destroy()
+ throw (cms::CMSException,
decaf::lang::exceptions::IllegalStateException);
+
+ /**
* Sets the destination object to be used by default for send/receive
operations.
* If no default destination is provided, the
<code>defaultDestinationName</code>
* property is used to resolve this default destination for
send/receive
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp?rev=620328&r1=620327&r2=620328&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.cpp
Sun Feb 10 13:08:24 2008
@@ -73,11 +73,18 @@
////////////////////////////////////////////////////////////////////////////////
DynamicDestinationResolver::~DynamicDestinationResolver() {
+ clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DynamicDestinationResolver::clear() {
+
// Destroy the session resolvers.
vector<SessionResolver*> r = sessionResolverMap.getValues();
for( size_t ix=0; ix<r.size(); ++ix ) {
delete r[ix];
}
+ sessionResolverMap.clear();
}
////////////////////////////////////////////////////////////////////////////////
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.h?rev=620328&r1=620327&r2=620328&view=diff
==============================================================================
---
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.h
(original)
+++
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/DynamicDestinationResolver.h
Sun Feb 10 13:08:24 2008
@@ -72,6 +72,11 @@
public:
virtual ~DynamicDestinationResolver();
+
+ /**
+ * Clears the internal data structures.
+ */
+ void clear();
/**
* Sets the <code>ResourceLifecycleManager</code> to be used for
@@ -81,6 +86,11 @@
* the resource lifecycle manager.
*/
virtual void setResourceLifecycleManager( ResourceLifecycleManager*
mgr) {
+
+ // since we're changing the lifecycle manager, clear out references
+ // to old resources.
+ clear();
+
this->resourceLifecycleManager = mgr;
}