activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r500793 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands: ActiveMQDestination.cpp ActiveMQDestination.h BaseDataStructure.h
Date Sun, 28 Jan 2007 13:47:23 GMT
Author: tabish
Date: Sun Jan 28 05:47:22 2007
New Revision: 500793

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

Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.cpp?view=diff&rev=500793&r1=500792&r2=500793
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.cpp
Sun Jan 28 05:47:22 2007
@@ -16,9 +16,11 @@
  */
 #include <activemq/connector/openwire/commands/ActiveMQDestination.h>
 #include <activemq/exceptions/NullPointerException.h>
+#include <activemq/util/URISupport.h>
 
 using namespace std;
 using namespace activemq;
+using namespace activemq::util;
 using namespace activemq::exceptions;
 using namespace activemq::connector;
 using namespace activemq::connector::openwire;
@@ -36,17 +38,43 @@
 const std::string ActiveMQDestination::TEMP_PREFIX = "{TD{";
 const std::string ActiveMQDestination::TEMP_POSTFIX = "}TD}";
 const std::string ActiveMQDestination::COMPOSITE_SEPARATOR = ",";
+const std::string ActiveMQDestination::DestinationFilter::ANY_CHILD = ">";
+const std::string ActiveMQDestination::DestinationFilter::ANY_DESCENDENT = "*";
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQDestination::ActiveMQDestination()
-{
+ActiveMQDestination::ActiveMQDestination() {
+    
     this->physicalName = "";
     this->orderedTarget = DEFAULT_ORDERED_TARGET;
+    this->exclusive = false;
+    this->ordered = false;
+    this->advisory = false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQDestination::~ActiveMQDestination()
-{
+ActiveMQDestination::ActiveMQDestination( const std::string& physicalName ) {
+
+    this->setPhysicalName( physicalName );
+    this->orderedTarget = DEFAULT_ORDERED_TARGET;
+    this->exclusive = false;
+    this->ordered = false;
+    this->advisory = false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQDestination::setPhysicalName( const std::string& physicalName ) {
+    
+    this->physicalName = physicalName;
+
+    size_t pos = physicalName.find_first_of('?');
+    if( pos != string::npos ) {
+
+        std::string optstring = physicalName.substr( pos + 1 );
+        this->physicalName = physicalName.substr( 0, pos );
+        URISupport::parseQuery( optstring, &options );
+    }
+
+    this->advisory = physicalName.find_first_of( ADVISORY_PREFIX ) == 0;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -66,10 +94,33 @@
     }
     
     this->setPhysicalName( srcPtr->getPhysicalName() );
+    this->setAdvisory( srcPtr->isAdvisory() );
+    this->setOrdered( srcPtr->isOrdered() );
+    this->setExclusive( srcPtr->isExclusive() );
+    this->setOrderedTarget( srcPtr->getOrderedTarget() );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 unsigned char ActiveMQDestination::getDataStructureType() const
 {
     return ActiveMQDestination::ID_ACTIVEMQDESTINATION; 
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string ActiveMQDestination::getClientId( 
+    const ActiveMQDestination* destination )
+{
+    std::string answer = "";
+    if( destination != NULL && destination->isTemporary() ) {
+        std::string name = destination->getPhysicalName();
+        size_t start = name.find_first_of( TEMP_PREFIX );
+        if( start != std::string::npos ) {
+            start += TEMP_PREFIX.length();
+            size_t stop = name.find_last_of( TEMP_POSTFIX );
+            if( stop > start && stop < name.length() ) {
+                answer = name.substr( start, stop );
+            }
+        }
+    }
+    return answer;
 }

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.h?view=diff&rev=500793&r1=500792&r2=500793
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.h
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQDestination.h
Sun Jan 28 05:47:22 2007
@@ -24,6 +24,8 @@
 #endif
 
 #include <activemq/connector/openwire/commands/BaseDataStructure.h>
+#include <activemq/util/SimpleProperties.h>
+#include <cms/Destination.h>
 
 #include <vector>
 #include <string>
@@ -44,6 +46,11 @@
             ACTIVEMQ_QUEUE = 3,
             ACTIVEMQ_TEMPORARY_QUEUE = 4
         };
+
+        struct DestinationFilter{
+            static const std::string ANY_CHILD;
+            static const std::string ANY_DESCENDENT;
+        };
         
         /**
          * prefix for Advisory message destinations
@@ -81,7 +88,7 @@
         std::string orderedTarget;
         
         std::string physicalName;
-        std::map<std::string, std::string> options;
+        util::SimpleProperties options;
 
     public:
 
@@ -90,7 +97,8 @@
     public:
 
         ActiveMQDestination();
-        virtual ~ActiveMQDestination();
+        ActiveMQDestination( const std::string& physicalName );
+        virtual ~ActiveMQDestination() {}
 
         /**
          * Copy the contents of the passed object into this objects
@@ -116,28 +124,26 @@
          * Set this destination's physical name
          * @returns const string containing the name
          */
-        virtual void setPhysicalName( const std::string& physicalName ){
-            this->physicalName = physicalName;
-        }
+        virtual void setPhysicalName( const std::string& physicalName );
 
         /**
          * @return Returns the advisory.
          */
-        virtual bool isAdvisory() {
+        virtual bool isAdvisory() const {
             return advisory;
         }
         
         /**
          * @param advisory The advisory to set.
          */
-        void setAdvisory( bool advisory ){
+        virtual void setAdvisory( bool advisory ){
             this->advisory = advisory;
         }
         
         /**
          * @return true if this is a destination for Consumer advisories
          */
-        bool isConsumerAdvisory() {
+        virtual bool isConsumerAdvisory() const {
             return isAdvisory() && 
                    physicalName.find(CONSUMER_ADVISORY_PREFIX) == 0;
         }
@@ -145,7 +151,7 @@
         /**
          * @return true if this is a destination for Producer advisories
          */
-        bool isProducerAdvisory() {
+        virtual bool isProducerAdvisory() const {
             return isAdvisory() && 
                    physicalName.find(PRODUCER_ADVISORY_PREFIX) == 0;
         }
@@ -153,7 +159,7 @@
         /**
          * @return true if this is a destination for Connection advisories
          */
-        bool isConnectionAdvisory() {
+        virtual bool isConnectionAdvisory() const {
             return isAdvisory() && 
                    physicalName.find(CONNECTION_ADVISORY_PREFIX) == 0;
         }
@@ -161,43 +167,120 @@
         /**
          * @return Returns the exclusive.
          */
-        bool isExclusive() {
+        virtual bool isExclusive() const {
             return exclusive;
         }
         
         /**
          * @param exclusive The exclusive to set.
          */
-        void setExclusive( bool exclusive ) {
+        virtual void setExclusive( bool exclusive ) {
             this->exclusive = exclusive;
         }
         
         /**
          * @return Returns the ordered.
          */
-        bool isOrdered() {
+        virtual bool isOrdered() const {
             return ordered;
         }
 
         /**
          * @param ordered The ordered to set.
          */
-        void setOrdered( bool ordered ) {
+        virtual void setOrdered( bool ordered ) {
             this->ordered = ordered;
         }
 
         /**
          * @return Returns the orderedTarget.
          */
-        std::string getOrderedTarget() {
+        virtual std::string getOrderedTarget() const {
             return orderedTarget;
         }
 
         /**
          * @param orderedTarget The orderedTarget to set.
          */
-        void setOrderedTarget( const std::string& orderedTarget) {
+        virtual void setOrderedTarget( const std::string& orderedTarget) {
             this->orderedTarget = orderedTarget;
+        }
+
+    public:
+    
+        /**
+         * Returns the Type of Destination that this object represents
+         * @returns int type qualifier.
+         */
+        virtual cms::Destination::DestinationType getDestinationType() const = 0;
+    
+        /**
+         * Create a temporary name from the clientId
+         *
+         * @param clientId
+         * @return
+         */
+        static std::string CreateTemporaryName( 
+            const std::string& clientId ) {
+
+            return TEMP_PREFIX + clientId + TEMP_POSTFIX;
+        }
+        
+        /**
+         * From a temporary destination find the clientId of the Connection that created
it
+         *
+         * @param destination
+         * @return the clientId or null if not a temporary destination
+         */
+        static std::string getClientId( const ActiveMQDestination* destination );
+
+        /**
+         * Returns true if a temporary Destination
+         * @return true/false
+         */        
+        virtual bool isTemporary() const {
+            return getDestinationType() == cms::Destination::TEMPORARY_TOPIC ||
+                   getDestinationType() == cms::Destination::TEMPORARY_QUEUE;
+        }
+        
+        /**
+         * Returns true if a Topic Destination
+         * @return true/false
+         */        
+        virtual bool isTopic() const {
+            return getDestinationType() == cms::Destination::TOPIC || 
+                   getDestinationType() == cms::Destination::TEMPORARY_TOPIC;
+        }
+        
+        /**
+         * Returns true if a Queue Destination
+         * @return true/false
+         */
+        virtual bool isQueue() const {
+            return !isTopic();
+        }
+        
+        /**
+         * Returns true if this destination represents a collection of
+         * destinations; allowing a set of destinations to be published to or 
+         * subscribed from in one CMS operation.
+         * <p/>
+         * If this destination is a composite then you can call 
+         * {@link #getChildDestinations()}
+         * to return the list of child destinations.
+         * @return true if this destination represents a collection of child 
+         *         destinations.
+         */
+        virtual bool isComposite() const {
+            return physicalName.find_first_of( COMPOSITE_SEPARATOR ) > 0;
+        }
+
+        /**
+         * @return true if the destination matches multiple possible destinations
+         */
+        virtual bool isWildcard() const {
+            return physicalName.find_first_of( DestinationFilter::ANY_CHILD ) != std::string::npos
||
+                   physicalName.find_first_of( DestinationFilter::ANY_DESCENDENT ) != std::string::npos;
         }
 
     };

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h?view=diff&rev=500793&r1=500792&r2=500793
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/BaseDataStructure.h
Sun Jan 28 05:47:22 2007
@@ -88,6 +88,15 @@
             return std::vector<unsigned char>(); 
         }
 
+        /**
+         * Copy the contents of the passed object into this objects
+         * members, overwriting any existing data.
+         * @return src - Source Object
+         */
+        virtual void copyDataStructure( const DataStructure* src ) {
+            // Nothing to do here
+        }
+
     };
 
 }}}}



Mime
View raw message