activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r508765 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands: ActiveMQTempDestination.cpp ActiveMQTempDestination.h
Date Sat, 17 Feb 2007 14:55:14 GMT
Author: tabish
Date: Sat Feb 17 06:55:13 2007
New Revision: 508765

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

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.cpp?view=diff&rev=508765&r1=508764&r2=508765
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.cpp
Sat Feb 17 06:55:13 2007
@@ -16,25 +16,36 @@
  */
 #include <activemq/connector/openwire/commands/ActiveMQTempDestination.h>
 
+#include <activemq/exceptions/ActiveMQException.h>
+
 using namespace std;
 using namespace activemq;
+using namespace activemq::exceptions;
 using namespace activemq::connector;
 using namespace activemq::connector::openwire;
 using namespace activemq::connector::openwire::commands;
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQTempDestination::ActiveMQTempDestination()
+ActiveMQTempDestination::ActiveMQTempDestination() :
+    ActiveMQDestination(),
+    connector( NULL )
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 ActiveMQTempDestination::ActiveMQTempDestination( const std::string& name ) :
-    ActiveMQDestination( name )
+    ActiveMQDestination( name ),
+    connector( NULL )
 {}
 
 ////////////////////////////////////////////////////////////////////////////////
 ActiveMQTempDestination::~ActiveMQTempDestination()
 {
+    try{
+        close();
+    }
+    AMQ_CATCH_NOTHROW( ActiveMQException )
+    AMQ_CATCHALL_NOTHROW( )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -43,3 +54,17 @@
     return ActiveMQTempDestination::ID_ACTIVEMQTEMPDESTINATION;
 }
 
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQTempDestination::close() throw ( cms::CMSException ) {
+
+    try {
+
+        // Give the Connector a chance to clean up this temp Destination
+        if( connector != NULL ) {
+            connector->destroyResource( this );
+        }
+
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.h?view=diff&rev=508765&r1=508764&r2=508765
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQTempDestination.h
Sat Feb 17 06:55:13 2007
@@ -24,6 +24,9 @@
 #endif
 
 #include <activemq/connector/openwire/commands/ActiveMQDestination.h>
+#include <activemq/connector/Connector.h>
+#include <activemq/connector/ConnectorResource.h>
+#include <cms/Closeable.h>
 #include <vector>
 #include <string>
 
@@ -32,10 +35,17 @@
 namespace openwire{
 namespace commands{
 
-    class ActiveMQTempDestination : public ActiveMQDestination
+    class ActiveMQTempDestination : public ActiveMQDestination,
+                                    public ConnectorResource,
+                                    public cms::Closeable
     {
     protected:
 
+        /**
+         * Connector that we call back on close to allow this resource to
+         * be cleaned up correctly at this end and at the Broker End.
+         */
+        connector::Connector* connector;
 
     public:
 
@@ -81,6 +91,33 @@
          */
         virtual bool equals( const DataStructure* value ) const {
             return ActiveMQDestination::equals( value );
+        }
+
+    public:   // Closeable
+
+        /**
+         * Closes this object and deallocates the appropriate resources.
+         * The object is generally no longer usable after calling close.
+         * @throws CMSException
+         */
+        virtual void close() throw( cms::CMSException );
+
+    public:    // ActiveMQTempDestination
+
+        /**
+         * Gets the Connector that this object will call when its closed
+         * @returns pointer to a Connector, or NULL if not set.
+         */
+        const connector::Connector* getConnector() const {
+            return this->connector;
+        }
+
+        /**
+         * Sets the Connector that this object will call when its closed
+         * @param connector - pointer to a Connector or NULL to clear.
+         */
+        virtual void setConnector( connector::Connector* connector ) {
+            this->connector = connector;
         }
 
     };



Mime
View raw message