activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r479862 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/activemq/connector/stomp/commands/ main/activemq/util/ main/cms/ test/ test/activemq/connector/stomp/commands/ test/activemq/util/
Date Tue, 28 Nov 2006 02:53:53 GMT
Author: nmittler
Date: Mon Nov 27 18:53:52 2006
New Revision: 479862

URL: http://svn.apache.org/viewvc?view=rev&rev=479862
Log:
[AMQCPP-16] Changed CMS::Message to match the JMS Message property methods

Added:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.h
Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Properties.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/SimpleProperties.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Message.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/CommandConstantsTest.h
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Mon Nov 27 18:53:52 2006
@@ -67,7 +67,8 @@
     activemq/util/StringTokenizer.cpp \
     activemq/util/Guid.cpp \
     activemq/util/Date.cpp \
-    activemq/util/Math.cpp
+    activemq/util/Math.cpp \
+    activemq/util/PrimitiveMap.cpp
 
 h_sources = \
     activemq/core/ActiveMQSessionResource.h \
@@ -224,7 +225,9 @@
     activemq/util/StringTokenizer.h \
     activemq/util/Queue.h \
     activemq/util/Date.h \
+    activemq/util/Map.h \
     activemq/util/Math.h \
+    activemq/util/PrimitiveMap.h \
     cms/DeliveryMode.h \
     cms/TemporaryQueue.h \
     cms/MapMessage.h \
@@ -247,8 +250,8 @@
     cms/Message.h \
     cms/MessageConsumer.h
 
-include activemq/connector/openwire/commands/srcmakefile.mk
-include activemq/connector/openwire/marshal/v2/srcmakefile.mk
+# include activemq/connector/openwire/commands/srcmakefile.mk
+# include activemq/connector/openwire/marshal/v2/srcmakefile.mk
 
 ##
 ## Compiler / Linker Info

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h Mon Nov 27 18:53:52 2006
@@ -118,7 +118,14 @@
             }
                     
             return iter->second;
-        }             
+        }
+        
+        static bool isCommandId( const std::string& str ){
+            std::map<std::string, CommandId>::iterator iter = 
+                StaticInitializer::commandMap.find(str);
+
+            return iter != StaticInitializer::commandMap.end();
+        }         
         
         static std::string toString( const StompHeader header ){
             return StaticInitializer::stompHeaders[header];
@@ -134,7 +141,14 @@
             }
                     
             return iter->second;            
-        }        
+        }
+        
+        static bool isStompHeader( const std::string& str ){
+            std::map<std::string, StompHeader>::iterator iter = 
+                StaticInitializer::stompHeaderMap.find(str);
+
+            return iter != StaticInitializer::stompHeaderMap.end();
+        }     
         
         static std::string toString( const AckMode mode ){
             return StaticInitializer::ackModes[mode];

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h Mon Nov 27 18:53:52 2006
@@ -23,12 +23,16 @@
 #include <activemq/connector/stomp/commands/AbstractCommand.h>
 #include <activemq/transport/Command.h>
 #include <activemq/connector/stomp/StompTopic.h>
+#include <activemq/exceptions/IllegalArgumentException.h>
+#include <activemq/exceptions/NoSuchElementException.h>
+#include <activemq/exceptions/RuntimeException.h>
 
 #include <activemq/util/Long.h>
 #include <activemq/util/Integer.h>
 #include <activemq/util/Boolean.h>
 
 #include <string>
+#include <sstream>
 
 namespace activemq{
 namespace connector{
@@ -60,7 +64,7 @@
         
     public:
 
-        StompMessage(void) :
+        StompMessage() :
             AbstractCommand< transport::Command >(),
             ackHandler( NULL ) { dest = NULL; }
         StompMessage( StompFrame* frame ) : 
@@ -73,24 +77,163 @@
                         CommandConstants::HEADER_DESTINATION ), "" ) );
         }
 
-    	virtual ~StompMessage(void) { delete dest; }
+    	virtual ~StompMessage() { delete dest; }
 
         /**
-         * Gets the properties map for this command.
-         * @return Reference to a Properties object
+         * Clears out the body of the message.  This does not clear the
+         * headers or properties.
          */
-        virtual util::Properties& getProperties(void){
-            return getFrame().getProperties();
-        }   
-        virtual const util::Properties& getProperties(void) const{
-            return getFrame().getProperties();
-        }   
+        virtual void clearBody(){
+            getFrame().setBody( NULL, 0 );
+        }
+        
+        /**
+         * Clears the message properties.  Does not clear the body or
+         * header values.
+         */
+        virtual void clearProperties(){
+            
+            util::Properties& props = getFrame().getProperties();
+            std::vector< std::pair< std::string, std::string > > propArray = props.toArray();
+            for( int ix=0; ix<propArray.size(); ++ix ){
+                
+                const std::string& name = propArray[ix].first;
+                
+                // Only clear properties that aren't Stomp headers.
+                if( !CommandConstants::isStompHeader(name) ){
+                    props.remove( name );
+                }
+            }
+        }
+        
+        /**
+         * Retrieves the propery names.
+         * @return The complete set of property names currently in this
+         * message.
+         */
+        virtual std::vector<std::string> getPropertyNames() const{
+            std::vector<std::string> names;
+            
+            const util::Properties& props = getFrame().getProperties();
+            std::vector< std::pair< std::string, std::string > > propArray = props.toArray();
+            for( int ix=0; ix<propArray.size(); ++ix ){
+                
+                const std::string& name = propArray[ix].first;
+                
+                // Only clear properties that aren't Stomp headers.
+                if( !CommandConstants::isStompHeader(name) ){
+                    names.push_back( name );
+                }
+            }
+            
+            return names;
+        }
+        
+        /**
+         * Indicates whether or not a given property exists.
+         * @param name The name of the property to look up.
+         * @return True if the property exists in this message.
+         */
+        virtual bool propertyExists( const std::string& name ) const{
+            if( CommandConstants::isStompHeader( name ) ){
+                return false;
+            }
+            
+            return getFrame().getProperties().hasProperty( name );
+        }                
+        
+        virtual bool getBooleanProperty( const std::string& name ) const 
+            throw( cms::CMSException ){
+            testProperty(name);
+            std::string value = getPropertyValue( name );
+            return value == "true";
+        }
+        
+        virtual unsigned char getByteProperty( const std::string& name ) const 
+            throw( cms::CMSException ){
+            return getStrictPropertyValue<unsigned char>(name);
+        }
+        
+        virtual double getDoubleProperty( const std::string& name ) const 
+            throw( cms::CMSException ){
+            return getStrictPropertyValue<double>(name);
+        }
+        
+        virtual float getFloatProperty( const std::string& name ) const 
+            throw( cms::CMSException ){
+            return getStrictPropertyValue<float>(name);
+        }
+        
+        virtual int getIntProperty( const std::string& name ) const 
+            throw( cms::CMSException ){
+            return getStrictPropertyValue<int>(name);
+        }
+        
+        virtual long long getLongProperty( const std::string& name ) const 
+            throw( cms::CMSException ){
+            return getStrictPropertyValue<long long>(name);
+        }
+        
+        virtual short getShortProperty( const std::string& name ) const 
+            throw( cms::CMSException ){
+            return getStrictPropertyValue<short>(name);
+        }
+        
+        virtual std::string getStringProperty( const std::string& name ) const 
+            throw( cms::CMSException ){
+            testProperty( name );
+            return getPropertyValue( name );
+        }
+        
+        virtual void setBooleanProperty( const std::string& name,
+            bool value ) throw( cms::CMSException ){
+            testProperty( name );
+            
+            std::string strvalue = value? "true" : "false";
+            setPropertyValue( name, strvalue );
+        }
+        
+        virtual void setByteProperty( const std::string& name,
+            unsigned char value ) throw( cms::CMSException ){
+            setStrictPropertyValue<unsigned char>( name, value );
+        }
+        
+        virtual void setDoubleProperty( const std::string& name,
+            double value ) throw( cms::CMSException ){
+            setStrictPropertyValue<double>( name, value );
+        }
+        
+        virtual void setFloatProperty( const std::string& name,
+            float value ) throw( cms::CMSException ){
+            setStrictPropertyValue<float>( name, value );
+        }
+        
+        virtual void setIntProperty( const std::string& name,
+            int value ) throw( cms::CMSException ){
+            setStrictPropertyValue<int>( name, value );
+        }
+        
+        virtual void setLongProperty( const std::string& name,
+            long long value ) throw( cms::CMSException ){
+            setStrictPropertyValue<long long>( name, value );
+        }
+        
+        virtual void setShortProperty( const std::string& name,
+            short value ) throw( cms::CMSException ){
+            setStrictPropertyValue<short>( name, value );
+        }
+        
+        virtual void setStringProperty( const std::string& name,
+            const std::string& value ) throw( cms::CMSException ){
+            testProperty( name );            
+            setPropertyValue( name, value );
+        }
 
         /**
          * Get the Correlation Id for this message
          * @return string representation of the correlation Id
          */
-        virtual std::string getCMSCorrelationId(void) const {
+        virtual std::string getCMSCorrelationId() const {
             return getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_CORRELATIONID ), "" );
@@ -112,7 +255,7 @@
          * of this consumed message.
          * @throws CMSException
          */
-        virtual void acknowledge(void) const throw( cms::CMSException ) {
+        virtual void acknowledge() const throw( cms::CMSException ) {
             if(ackHandler != NULL) ackHandler->acknowledgeMessage( this );
         }
 
@@ -120,7 +263,7 @@
          * Sets the DeliveryMode for this message
          * @return DeliveryMode enumerated value.
          */
-        virtual int getCMSDeliveryMode(void) const {
+        virtual int getCMSDeliveryMode() const {
             if(!getFrame().getProperties().hasProperty( 
                    CommandConstants::toString( 
                        CommandConstants::HEADER_PERSISTANT ) ) ) {
@@ -147,7 +290,7 @@
          * Gets the Destination for this Message
          * @return Destination object can be NULL
          */
-        virtual const cms::Destination* getCMSDestination(void) const{
+        virtual const cms::Destination* getCMSDestination() const{
             return dest;
         }
               
@@ -170,7 +313,7 @@
          * Gets the Expiration Time for this Message
          * @return time value
          */
-        virtual long long getCMSExpiration(void) const {
+        virtual long long getCMSExpiration() const {
             return util::Long::parseLong( getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_EXPIRES ), "0" ) );
@@ -191,7 +334,7 @@
          * Gets the CMS Message Id for this Message
          * @return time value
          */
-        virtual std::string getCMSMessageId(void) const {
+        virtual std::string getCMSMessageId() const {
             return getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_MESSAGEID ), "" );
@@ -212,7 +355,7 @@
          * Gets the Priority Value for this Message
          * @return priority value
          */
-        virtual int getCMSPriority(void) const {
+        virtual int getCMSPriority() const {
             return util::Integer::parseInt( getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_JMSPRIORITY ), "0" ) );
@@ -233,7 +376,7 @@
          * Gets the Redelivered Flag for this Message
          * @return redelivered value
          */
-        virtual bool getCMSRedelivered(void) const {
+        virtual bool getCMSRedelivered() const {
             return util::Boolean::parseBoolean( getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_REDELIVERED ), 
@@ -255,7 +398,7 @@
          * Gets the CMS Reply To Address for this Message
          * @return Reply To Value
          */
-        virtual std::string getCMSReplyTo(void) const {
+        virtual std::string getCMSReplyTo() const {
             return getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_REPLYTO ), "" );
@@ -276,7 +419,7 @@
          * Gets the Time Stamp for this Message
          * @return time stamp value
          */
-        virtual long long getCMSTimeStamp(void) const {
+        virtual long long getCMSTimeStamp() const {
             return util::Long::parseLong( getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_TIMESTAMP ), "0" ) );
@@ -297,7 +440,7 @@
          * Gets the CMS Message Type for this Message
          * @return type value
          */
-        virtual std::string getCMSMessageType(void) const {
+        virtual std::string getCMSMessageType() const {
             return getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_TYPE ), "" );
@@ -329,7 +472,7 @@
          * Gets the number of times this message has been redelivered.
          * @return redelivery count
          */
-        virtual int getRedeliveryCount(void) const {
+        virtual int getRedeliveryCount() const {
             return util::Integer::parseInt( getPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_REDELIVERYCOUNT ),
@@ -348,8 +491,64 @@
                 util::Integer::toString( count ) );
         }
 
-    protected:
-    
+    protected:   
+        
+        /**
+         * Checks to see if the given property has the name of a
+         * pre-defined header.  If so, throws an exception.
+         */
+        virtual void testProperty( const std::string& name ) const
+            throw( cms::CMSException ){
+            if( CommandConstants::isStompHeader( name ) ){
+                throw exceptions::IllegalArgumentException( __FILE__, __LINE__, 
+                    "searching for property with name of pre-defined header" );
+            }
+        }
+        
+        /**
+         * Attempts to get a property from the frame's property
+         * map.
+         */
+        template <typename TYPE>
+        TYPE getStrictPropertyValue( const std::string& name ) const
+            throw( cms::CMSException ){
+                
+            testProperty( name );
+            
+            const char* strProp = getPropertyValue(name);
+            if( strProp == NULL ){
+                throw exceptions::NoSuchElementException( __FILE__, __LINE__, 
+                    "property not available in message" );
+            }
+            
+            std::istringstream stream( strProp );
+            TYPE value;
+            stream >> value;
+            
+            if( stream.fail() ){
+                throw exceptions::RuntimeException( __FILE__, __LINE__, 
+                    "Error extracting property from string" );
+            }
+            
+            return value;
+        }
+        
+        /**
+         * Attempts to set the property in the frame.  If an error occurs or
+         * the property name is that of a pre-defined header, an exception
+         * is thrown.
+         */
+        template <typename TYPE>
+        void setStrictPropertyValue( const std::string& name, TYPE value ) 
+            throw( cms::CMSException ){
+            testProperty( name );
+            
+            std::ostringstream stream;
+            stream << value;
+            
+            setPropertyValue( name, stream.str() );
+        }
+        
         /**
          * Inheritors are required to override this method to init the
          * frame with data appropriate for the command type.

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h?view=auto&rev=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Map.h Mon Nov 27 18:53:52 2006
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACTIVEMQ_UTIL_MAP_H_
+#define ACTIVEMQ_UTIL_MAP_H_
+
+#include <map>
+#include <vector>
+#include <activemq/exceptions/NoSuchElementException.h>
+
+namespace activemq{
+namespace util{
+
+    /**
+     * Map template that wraps around a std::map to provide
+     * a more user-friendly interface and to provide common
+     * functions that do not exist in std::map.
+     */
+    template <typename K, typename V> class Map
+    {
+    private:
+    
+        std::map<K,V> valueMap;
+        
+    public:
+    
+    	Map(){};
+    	virtual ~Map(){};
+        
+        /**
+         * Removes all keys and values from this map.
+         */
+        virtual void clear();
+        
+        /**
+         * Indicates whether or this map contains a value for the
+         * given key.
+         * @param key The key to look up.
+         * @return true if this map contains the value, otherwise false.
+         */
+        virtual bool contains( const K& key ) const;
+        
+        /**
+         * @return The number of elements (key/value pairs) in this map.
+         */
+        virtual int count() const;
+        
+        /**
+         * Gets the value for the specified key.
+         * @param key The search key.
+         * @return The value for the given key.
+         * @throws activemq::exceptions::NoSuchElementException
+         */
+        virtual V getValue( const K& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+            
+        /**
+         * Sets the value for the specified key.
+         * @param key The target key.
+         * @param value The value to be set.
+         */
+        virtual void setValue( const K& key, V value );
+
+        /**
+         * Removes the value (key/value pair) for the specified key from 
+         * the map.
+         * @param key The search key.
+         */        
+        virtual void remove( const K& key );
+        
+        /**
+         * @return the entire set of keys in this map as a std::vector.
+         */
+        virtual std::vector<K> getKeys() const;
+        
+        /**
+         * @return the entire set of values in this map as a std::vector.
+         */
+        virtual std::vector<V> getValues() const;
+    };
+    
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>
+    void Map<K,V>::clear(){
+        valueMap.clear();
+    }
+    
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>
+    bool Map<K,V>::contains(const K& key) const{
+        typename std::map<K,V>::const_iterator iter;
+        iter = valueMap.find(key);
+        return iter != valueMap.end();
+    }
+    
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>
+    int Map<K,V>::count() const{
+        return valueMap.size();
+    }
+    
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>
+    V Map<K,V>::getValue( const K& key ) const 
+        throw(activemq::exceptions::NoSuchElementException){
+            
+        typename std::map<K,V>::const_iterator iter;
+        iter = valueMap.find(key);
+        if( iter == valueMap.end() ){
+            throw activemq::exceptions::NoSuchElementException( __FILE__, 
+                __LINE__, 
+                "Key does not exist in map" );
+        }
+        
+        return iter->second;
+    }
+        
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>
+    void Map<K,V>::setValue( const K& key, V value ){
+        valueMap[key] = value;
+    }
+    
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>
+    void Map<K,V>::remove( const K& key ){
+        valueMap.erase(key);
+    }
+    
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>
+    std::vector<K> Map<K,V>::getKeys() const{
+        std::vector<K> values(valueMap.size());
+        
+        typename std::map<K,V>::const_iterator iter;
+        iter=valueMap.begin();
+        for( int ix=0; iter != valueMap.end(); ++iter, ++ix ){
+            values[ix] = iter->first;
+        }
+    }
+    
+    ////////////////////////////////////////////////////////////////////////////
+    template <typename K, typename V>
+    std::vector<V> Map<K,V>::getValues() const{
+        std::vector<V> values(valueMap.size());
+        
+        typename std::map<K,V>::const_iterator iter;
+        iter=valueMap.begin();
+        for( int ix=0; iter != valueMap.end(); ++iter, ++ix ){
+            values[ix] = iter->second;
+        }
+    }
+
+}}
+
+#endif /*ACTIVEMQ_UTIL_MAP_H_*/

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp?view=auto&rev=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.cpp Mon Nov 27 18:53:52 2006
@@ -0,0 +1,214 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "PrimitiveMap.h"
+
+using namespace activemq::connector::openwire;
+using namespace activemq::exceptions;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveMap::PrimitiveMap()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveMap::~PrimitiveMap()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::clear()
+{
+    valueNodeMap.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool PrimitiveMap::contains( const string& key ) const{
+    
+    return valueNodeMap.contains( key );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int PrimitiveMap::count() const{
+    
+    return valueNodeMap.count();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool PrimitiveMap::getBool( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getBool();
+}
+    
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setBool( const string& key, bool value ){
+    
+    ValueNode node;
+    node.setBool( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char PrimitiveMap::getByte( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getByte();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setByte( const string& key, unsigned char value ){
+    ValueNode node;
+    node.setByte( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+char PrimitiveMap::getChar( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getChar();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setChar( const string& key, char value ){
+    ValueNode node;
+    node.setChar( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+short PrimitiveMap::getShort( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getShort();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setShort( const string& key, short value ){
+    ValueNode node;
+    node.setShort( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int PrimitiveMap::getInt( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getInt();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setInt( const string& key, int value ){
+    ValueNode node;
+    node.setInt( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long PrimitiveMap::getLong( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getLong();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setLong( const string& key, long long value ){
+    ValueNode node;
+    node.setLong( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double PrimitiveMap::getDouble( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getDouble();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setDouble( const string& key, double value ){
+    ValueNode node;
+    node.setDouble( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float PrimitiveMap::getFloat( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getFloat();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setFloat( const string& key, float value ){
+    ValueNode node;
+    node.setFloat( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+string PrimitiveMap::getString( const string& key ) const 
+    throw(NoSuchElementException){
+        
+    ValueNode node = valueNodeMap.getValue( key );
+    return node.getString();        
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::setString( const string& key, string& value ){
+    ValueNode node;
+    node.setString( value );
+    
+    valueNodeMap.setValue( key, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveMap::remove( const string& key ){
+    valueNodeMap.remove( key );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+vector<string> PrimitiveMap::getKeys() const{
+    
+    return valueNodeMap.getKeys();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+vector<PrimitiveMap::ValueNode> PrimitiveMap::getValues() const{
+    
+    return valueNodeMap.getValues();
+}
+
+

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h?view=auto&rev=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/PrimitiveMap.h Mon Nov 27 18:53:52 2006
@@ -0,0 +1,349 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACTIVEMQ_CONNECTOR_OPENWIRE_PRIMITIVEMAP_H_
+#define ACTIVEMQ_CONNECTOR_OPENWIRE_PRIMITIVEMAP_H_
+
+#include <string>
+#include <activemq/util/Map.h>
+
+namespace activemq{
+namespace connector{
+namespace openwire{
+        
+    /**
+     * Map of named primitives.
+     */
+    class PrimitiveMap
+    {        
+    public:
+    
+        /**
+         * Enumeration for the various primitive types.
+         */
+        enum ValueTypeEnum{
+            NULL_TYPE               = 0,
+            BOOLEAN_TYPE            = 1,
+            BYTE_TYPE               = 2,
+            CHAR_TYPE               = 3,
+            SHORT_TYPE              = 4,
+            INTEGER_TYPE            = 5,
+            LONG_TYPE               = 6,
+            DOUBLE_TYPE             = 7,
+            FLOAT_TYPE              = 8,
+            STRING_TYPE             = 9
+            //BYTE_ARRAY_TYPE         = 10,
+            //MAP_TYPE                = 11,
+            //LIST_TYPE               = 12,
+            //BIG_STRING_TYPE         = 13
+        };
+        
+        /**
+         * Define a union type comprised of the various types.
+         */
+        union Value {
+            
+            bool boolValue;
+            unsigned char byteValue;
+            char charValue;
+            short shortValue;
+            int intValue;
+            long long longValue;
+            double doubleValue;
+            float floatValue;
+            std::string* stringValue;
+        };
+    
+        /**
+         * Class that wraps around a single value of one of the
+         * many types.  Manages memory for complex types, such
+         * as strings.  Note: the destructor was left non-virtual
+         * so no virtual table will be created.  This probaly isn't
+         * necessary, but will avoid needless memory allocation. Since 
+         * we'll never extend this class, not having a virtual
+         * destructor isn't a concern.
+         */
+        class ValueNode{
+        private:
+        
+            ValueTypeEnum valueType;            
+            Value value;
+            
+        public:
+        
+            ValueNode(){
+                valueType = NULL_TYPE;  
+                memset( &value, 0, sizeof(value) );              
+            }
+            
+            ValueNode( const ValueNode& node ){
+                valueType = NULL_TYPE; 
+                memset( &value, 0, sizeof(value) );                
+                (*this) = node;            
+            }
+            
+            ~ValueNode(){
+                clear();
+            }
+            
+            ValueNode& operator =( const ValueNode& node ){
+                clear();
+                valueType = node.valueType;
+                
+                if( valueType == STRING_TYPE && node.value.stringValue != NULL ){
+                    value.stringValue = new std::string( *node.value.stringValue );
+                } else{
+                    value = node.value;
+                }
+            }
+            
+            ValueTypeEnum getValueType() const { return valueType; }
+            
+            void clear(){
+                if( valueType == STRING_TYPE && value.stringValue != NULL ){
+                    delete value.stringValue;
+                }
+                valueType = NULL_TYPE;  
+                memset( &value, 0, sizeof(value) );
+            }
+            
+            void setBool( bool lvalue ){
+                clear();
+                valueType = BOOLEAN_TYPE;
+                value.boolValue = lvalue;
+            }
+            
+            bool getBool() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != BOOLEAN_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not BOOLEAN_TYPE" );
+                }
+                
+                return value.boolValue;
+            }
+            
+            void setByte( unsigned char lvalue ){
+                clear();
+                valueType = BYTE_TYPE;
+                value.byteValue = lvalue;
+            }
+            
+            unsigned char getByte() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != BYTE_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not BYTE_TYPE" );
+                }
+                
+                return value.byteValue;
+            }
+            
+            void setChar( char lvalue ){
+                clear();
+                valueType = CHAR_TYPE;
+                value.charValue = lvalue;
+            }
+            
+            char getChar() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != CHAR_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not CHAR_TYPE" );
+                }
+                
+                return value.charValue;
+            }
+            
+            void setShort( short lvalue ){
+                clear();
+                valueType = SHORT_TYPE;
+                value.shortValue = lvalue;
+            }
+            
+            short getShort() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != SHORT_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not SHORT_TYPE" );
+                }
+                
+                return value.shortValue;
+            }
+            
+            void setInt( int lvalue ){
+                clear();
+                valueType = INTEGER_TYPE;
+                value.intValue = lvalue;
+            }
+            
+            int getInt() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != INTEGER_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not INTEGER_TYPE" );
+                }
+                
+                return value.intValue;
+            }
+            
+            void setLong( long long lvalue ){
+                clear();
+                valueType = LONG_TYPE;
+                value.longValue = lvalue;
+            }
+            
+            long long getLong() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != LONG_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not LONG_TYPE" );
+                }
+                
+                return value.longValue;
+            }
+            
+            void setDouble( double lvalue ){
+                clear();
+                valueType = DOUBLE_TYPE;
+                value.doubleValue = lvalue;
+            }
+            
+            double getDouble() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != DOUBLE_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not DOUBLE_TYPE" );
+                }
+                
+                return value.doubleValue;
+            }
+            
+            void setFloat( float lvalue ){
+                clear();
+                valueType = FLOAT_TYPE;
+                value.floatValue = lvalue;
+            }
+            
+            float getFloat() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != FLOAT_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not FLOAT_TYPE" );
+                }
+                
+                return value.floatValue;
+            }
+            
+            void setString( std::string& lvalue ){
+                clear();
+                valueType = STRING_TYPE;
+                value.stringValue = new std::string( lvalue );
+            }
+            
+            std::string getString() const throw(activemq::exceptions::NoSuchElementException){
+                if( valueType != STRING_TYPE ){
+                    throw activemq::exceptions::NoSuchElementException( __FILE__,
+                        __LINE__, "Value is not STRING_TYPE" );
+                }
+                
+                if( value.stringValue == NULL ){
+                    return std::string();
+                }
+                
+                return *value.stringValue;
+            }
+                        
+        };
+        
+    private:
+    
+        activemq::util::Map<std::string, ValueNode> valueNodeMap;
+        
+    public:
+    
+    	PrimitiveMap();
+    	virtual ~PrimitiveMap();
+        
+        /**
+         * Removes all keys and values from all maps.
+         */
+        virtual void clear();
+        
+        /**
+         * Indicates whether or this map contains a value for the
+         * given key.
+         * @param key The key to look up.
+         * @return true if this map contains the value, otherwise false.
+         */
+        virtual bool contains( const std::string& key ) const;
+        
+        /**
+         * @return The number of elements (key/value pairs) in this map.
+         */
+        virtual int count() const;
+        
+
+        virtual bool getBool( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setBool( const std::string& key, bool value );
+        
+        virtual unsigned char getByte( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setByte( const std::string& key, unsigned char value );
+
+        virtual char getChar( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setChar( const std::string& key, char value );
+
+        virtual short getShort( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setShort( const std::string& key, short value );
+        
+        virtual int getInt( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setInt( const std::string& key, int value );
+        
+        virtual long long getLong( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setLong( const std::string& key, long long value );
+        
+        virtual double getDouble( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setDouble( const std::string& key, double value );
+        
+        virtual float getFloat( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setFloat( const std::string& key, float value );
+        
+        virtual std::string getString( const std::string& key ) const 
+            throw(activemq::exceptions::NoSuchElementException);
+        virtual void setString( const std::string& key, std::string& value );
+        
+        /**
+         * Removes the value (key/value pair) for the specified key from 
+         * the map.
+         * @param key The search key.
+         */        
+        virtual void remove( const std::string& key );
+        
+        /**
+         * @return the entire set of keys in this map as a std::vector.
+         */
+        virtual std::vector<std::string> getKeys() const;
+        
+        /**
+         * @return the entire set of values in this map as a std::vector.
+         */
+        virtual std::vector<ValueNode> getValues() const;
+    };
+
+}}}
+
+#endif /*ACTIVEMQ_CONNECTOR_OPENWIRE_PRIMITIVEMAP_H_*/

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Properties.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Properties.h?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Properties.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/Properties.h Mon Nov 27 18:53:52 2006
@@ -77,6 +77,12 @@
         virtual bool hasProperty( const std::string& name ) const = 0;
 
         /**
+         * Removes the property with the given name.
+         * @param name the name of the property to be removed.s
+         */
+        virtual void remove( const std::string& name ) = 0;
+        
+        /**
          * Method that serializes the contents of the property map to
          * an arryay.
          * @return list of pairs where the first is the name and the second

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/SimpleProperties.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/SimpleProperties.h?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/SimpleProperties.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/SimpleProperties.h Mon Nov 27 18:53:52 2006
@@ -92,20 +92,28 @@
             properties[name] = value;
         }
         
-      /**
-       * Check to see if the Property exists in the set
-       * @param name - property name to check for in this properties set.
-       * @return true if property exists, false otherwise.
-       */
-      virtual bool hasProperty( const std::string& name ) const
-      {
-         if(properties.find(name) != properties.end())
-         {
-            return true;
-         }
+        /**
+         * Check to see if the Property exists in the set
+         * @param name - property name to check for in this properties set.
+         * @return true if property exists, false otherwise.
+         */
+        virtual bool hasProperty( const std::string& name ) const
+        {
+            if(properties.find(name) != properties.end())
+            {
+                return true;
+            }
          
-         return false;
-      }
+            return false;
+        }
+        
+        /**
+         * Removes the property with the given name.
+         * @param name the name of the property to remove.
+         */
+        virtual void remove( const std::string& name ){
+            properties.erase( name );
+        }
 
         /**
          * Method that serializes the contents of the property map to

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Message.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Message.h?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Message.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Message.h Mon Nov 27 18:53:52 2006
@@ -27,34 +27,198 @@
 namespace cms{
    
     /**
-     * Root of all messages.
+     * Root of all messages.  As in JMS, a message is comprised of
+     * 3 parts: CMS-specific headers, user-defined properties, and
+     * the body.
      */
     class Message
     {         
     public:
    
-        virtual ~Message(void){}
+        virtual ~Message(){}
       
         /**
          * Clonse this message exactly, returns a new instance that the
          * caller is required to delete.
          * @return new copy of this message
          */
-        virtual Message* clone(void) const = 0;
+        virtual Message* clone() const = 0;                
         
         /**
          * Acknowledges all consumed messages of the session 
          * of this consumed message.
          */
-        virtual void acknowledge(void) const throw( CMSException ) = 0;
+        virtual void acknowledge() const throw( CMSException ) = 0;
       
         /**
-         * Retrieves a reference to the properties object owned
-         * by this message
-         * @return A Properties Object reference
+         * Clears out the body of the message.  This does not clear the
+         * headers or properties.
          */
-        virtual activemq::util::Properties& getProperties(void) = 0;
-        virtual const activemq::util::Properties& getProperties(void) const = 0;
+        virtual void clearBody() = 0;
+        
+        /**
+         * Clears the message properties.  Does not clear the body or
+         * header values.
+         */
+        virtual void clearProperties() = 0;
+        
+        /**
+         * Retrieves the propery names.
+         * @return The complete set of property names currently in this
+         * message.
+         */
+        virtual std::vector<std::string> getPropertyNames() const = 0;
+        
+        /**
+         * Indicates whether or not a given property exists.
+         * @param name The name of the property to look up.
+         * @return True if the property exists in this message.
+         */
+        virtual bool propertyExists( const std::string& name ) const = 0;
+        
+        /**
+         * Gets a boolean property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual bool getBooleanProperty( const std::string& name ) const 
+            throw( CMSException ) = 0;
+            
+        /**
+         * Gets a byte property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual unsigned char getByteProperty( const std::string& name ) const 
+            throw( CMSException ) = 0;
+            
+        /**
+         * Gets a double property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual double getDoubleProperty( const std::string& name ) const 
+            throw( CMSException ) = 0;
+            
+        /**
+         * Gets a float property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual float getFloatProperty( const std::string& name ) const 
+            throw( CMSException ) = 0;
+            
+        /**
+         * Gets a int property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual int getIntProperty( const std::string& name ) const 
+            throw( CMSException ) = 0;
+            
+        /**
+         * Gets a long property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual long long getLongProperty( const std::string& name ) const 
+            throw( CMSException ) = 0;
+            
+        /**
+         * Gets a short property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual short getShortProperty( const std::string& name ) const 
+            throw( CMSException ) = 0;
+            
+        /**
+         * Gets a string property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual std::string getStringProperty( const std::string& name ) const 
+            throw( CMSException ) = 0;
+        
+        /**
+         * Sets a boolean property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setBooleanProperty( const std::string& name,
+            bool value ) throw( CMSException ) = 0;
+            
+        /**
+         * Sets a byte property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setByteProperty( const std::string& name,
+            unsigned char value ) throw( CMSException ) = 0;
+            
+        /**
+         * Sets a double property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setDoubleProperty( const std::string& name,
+            double value ) throw( CMSException ) = 0;
+            
+        /**
+         * Sets a float property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setFloatProperty( const std::string& name,
+            float value ) throw( CMSException ) = 0;
+            
+        /**
+         * Sets a int property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setIntProperty( const std::string& name,
+            int value ) throw( CMSException ) = 0;
+            
+        /**
+         * Sets a long property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setLongProperty( const std::string& name,
+            long long value ) throw( CMSException ) = 0;
+            
+        /**
+         * Sets a short property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setShortProperty( const std::string& name,
+            short value ) throw( CMSException ) = 0;
+            
+        /**
+         * Sets a string property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setStringProperty( const std::string& name,
+            const std::string& value ) throw( CMSException ) = 0;
       
         /**
          * Get the Correlation Id for this message
@@ -72,7 +236,7 @@
          * Gets the DeliveryMode for this message
          * @return DeliveryMode enumerated value.
          */
-        virtual int getCMSDeliveryMode(void) const = 0;
+        virtual int getCMSDeliveryMode() const = 0;
 
         /**
          * Sets the DeliveryMode for this message
@@ -84,7 +248,7 @@
          * Gets the Destination for this Message, returns a
          * @return Destination object
          */
-        virtual const Destination* getCMSDestination(void) const = 0;
+        virtual const Destination* getCMSDestination() const = 0;
       
         /**
          * Sets the Destination for this message
@@ -96,7 +260,7 @@
          * Gets the Expiration Time for this Message
          * @return time value
          */
-        virtual long long getCMSExpiration(void) const = 0;
+        virtual long long getCMSExpiration() const = 0;
       
         /**
          * Sets the Expiration Time for this message
@@ -108,7 +272,7 @@
          * Gets the CMS Message Id for this Message
          * @return time value
          */
-        virtual std::string getCMSMessageId(void) const = 0;
+        virtual std::string getCMSMessageId() const = 0;
       
         /**
          * Sets the CMS Message Id for this message
@@ -120,7 +284,7 @@
          * Gets the Priority Value for this Message
          * @return priority value
          */
-        virtual int getCMSPriority(void) const = 0;
+        virtual int getCMSPriority() const = 0;
       
         /**
          * Sets the Priority Value for this message
@@ -132,7 +296,7 @@
          * Gets the Redelivered Flag for this Message
          * @return redelivered value
          */
-        virtual bool getCMSRedelivered(void) const = 0;
+        virtual bool getCMSRedelivered() const = 0;
       
         /**
          * Sets the Redelivered Flag for this message
@@ -144,7 +308,7 @@
          * Gets the CMS Reply To Address for this Message
          * @return Reply To Value
          */
-        virtual std::string getCMSReplyTo(void) const = 0;
+        virtual std::string getCMSReplyTo() const = 0;
       
         /**
          * Sets the CMS Reply To Address for this message
@@ -156,7 +320,7 @@
          * Gets the Time Stamp for this Message
          * @return time stamp value
          */
-        virtual long long getCMSTimeStamp(void) const = 0;
+        virtual long long getCMSTimeStamp() const = 0;
       
         /**
          * Sets the Time Stamp for this message
@@ -168,7 +332,7 @@
          * Gets the CMS Message Type for this Message
          * @return type value
          */
-        virtual std::string getCMSMessageType(void) const = 0;
+        virtual std::string getCMSMessageType() const = 0;
       
         /**
          * Sets the CMS Message Type for this message

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am Mon Nov 27 18:53:52 2006
@@ -68,6 +68,7 @@
   activemq/util/GuidTest.cpp \
   activemq/util/IntegerTest.cpp \
   activemq/util/LongTest.cpp \
+  activemq/util/MapTest.cpp \
   activemq/util/QueueTest.cpp \
   activemq/util/StringTokenizerTest.cpp \
   main.cpp

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/CommandConstantsTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/CommandConstantsTest.h?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/CommandConstantsTest.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/CommandConstantsTest.h Mon Nov 27 18:53:52 2006
@@ -32,6 +32,8 @@
     {
         CPPUNIT_TEST_SUITE( CommandConstantsTest );
         CPPUNIT_TEST( test );
+        CPPUNIT_TEST( testIsCommandId );
+        CPPUNIT_TEST( testIsStompHeader );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -89,6 +91,26 @@
             CPPUNIT_ASSERT( CommandConstants::queuePrefix != NULL );
             CPPUNIT_ASSERT( CommandConstants::topicPrefix != NULL );
 
+        }
+        
+        void testIsCommandId(){
+            
+            for( int ix=0; ix<CommandConstants::NUM_COMMANDS; ++ix ){
+                CPPUNIT_ASSERT( CommandConstants::isCommandId( 
+                    CommandConstants::toString( (CommandConstants::CommandId)ix ) ) );
+            }
+            
+            CPPUNIT_ASSERT( CommandConstants::isCommandId( "not-a-command-id" ) == false );
+        }
+        
+        void testIsStompHeader(){
+            
+            for( int ix=0; ix<CommandConstants::NUM_STOMP_HEADERS; ++ix ){
+                CPPUNIT_ASSERT( CommandConstants::isStompHeader( 
+                    CommandConstants::toString( (CommandConstants::StompHeader)ix ) ) );
+            }
+            
+            CPPUNIT_ASSERT( CommandConstants::isStompHeader( "not-a-header" ) == false );
         }
 
     };

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h?view=diff&rev=479862&r1=479861&r2=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/stomp/commands/MessageCommandTest.h Mon Nov 27 18:53:52 2006
@@ -35,6 +35,10 @@
     {
         CPPUNIT_TEST_SUITE( MessageCommandTest );
         CPPUNIT_TEST( test );
+        CPPUNIT_TEST( testSetProperties );
+        CPPUNIT_TEST( testFailedGetProperties );
+        CPPUNIT_TEST( testGetPropertyNames );
+        CPPUNIT_TEST( testClearProperties );
         CPPUNIT_TEST_SUITE_END();
 
     protected:
@@ -181,6 +185,92 @@
             delete cmd2;
         }
 
+        void testSetProperties(){
+            MessageCommand cmd;
+            
+            cmd.setBooleanProperty( "bool", true );
+            CPPUNIT_ASSERT( cmd.getBooleanProperty( "bool" ) == true );
+            
+            cmd.setByteProperty( "byte", 1 );
+            CPPUNIT_ASSERT( cmd.getByteProperty( "byte" ) == 1 );
+            
+            cmd.setDoubleProperty( "double", 2.2 );
+            CPPUNIT_ASSERT( cmd.getDoubleProperty( "double" ) == 2.2 );
+            
+            cmd.setFloatProperty( "float", 3.3f );
+            CPPUNIT_ASSERT( cmd.getFloatProperty( "float" ) == 3.3f );
+            
+            cmd.setIntProperty( "int", 4 );
+            CPPUNIT_ASSERT( cmd.getIntProperty( "int" ) == 4 );
+            
+            cmd.setLongProperty( "long", 5LL );
+            CPPUNIT_ASSERT( cmd.getLongProperty( "long" ) == 5LL );
+            
+            cmd.setShortProperty( "short", 6 );
+            CPPUNIT_ASSERT( cmd.getShortProperty( "short" ) == 6 );
+            
+            cmd.setStringProperty( "string", "hello" );
+            CPPUNIT_ASSERT( cmd.getStringProperty( "string" ) == "hello" );                        
+        }
+
+        void testFailedGetProperties(){
+            MessageCommand cmd;
+            
+            // Test accessing non-existent property
+            try{
+                cmd.getIntProperty("string");
+                CPPUNIT_ASSERT(false);
+            } catch( cms::CMSException& e ){                
+            }
+            
+            // Test failed extraction
+            try{
+                cmd.setStringProperty("string", "hello");
+                cmd.getIntProperty("string");
+                CPPUNIT_ASSERT(false);
+            } catch( cms::CMSException& e ){                
+            }
+        }      
+        
+        void testGetPropertyNames(){
+            
+            MessageCommand cmd;
+            
+            std::vector<std::string> names = cmd.getPropertyNames();
+            CPPUNIT_ASSERT( names.size() == 0 );
+            
+            cmd.setIntProperty( "int1", 1 );
+            names = cmd.getPropertyNames();
+            CPPUNIT_ASSERT( names.size() == 1 );
+            CPPUNIT_ASSERT( names[0] == "int1" );
+            
+            cmd.setIntProperty( "int2", 2 );
+            names = cmd.getPropertyNames();
+            CPPUNIT_ASSERT( names.size() == 2 );
+            CPPUNIT_ASSERT( names[0] == "int1" || names[1] == "int1" );
+            CPPUNIT_ASSERT( names[0] == "int2" || names[1] == "int2" );
+            
+            // Make sure headers aren't included in the property names.
+            cmd.setCMSExpiration( 10000 );
+            names = cmd.getPropertyNames();
+            CPPUNIT_ASSERT( names.size() == 2 );
+        }
+        
+        void testClearProperties(){
+            MessageCommand cmd;
+            
+            cmd.setIntProperty( "int1", 1 );
+            cmd.setIntProperty( "int2", 2 );
+            
+            CPPUNIT_ASSERT( cmd.propertyExists( "int1" ) == true );
+            CPPUNIT_ASSERT( cmd.propertyExists( "int2" ) == true );
+            
+            cmd.clearProperties();
+            
+            CPPUNIT_ASSERT( cmd.propertyExists( "int1" ) == false );
+            CPPUNIT_ASSERT( cmd.propertyExists( "int2" ) == false );                        
+        }
+          
     };
 
 }}}}

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.cpp?view=auto&rev=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.cpp Mon Nov 27 18:53:52 2006
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "MapTest.h"
+#include <string>
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::MapTest );
+
+using namespace activemq::util;
+using namespace std;
+
+MapTest::MapTest()
+{
+}
+
+MapTest::~MapTest()
+{
+}
+
+void MapTest::testContains(){
+    
+    Map<string, bool> boolMap;
+    CPPUNIT_ASSERT(boolMap.contains("bob") == false);
+    
+    boolMap.setValue( "bob", true );
+    
+    CPPUNIT_ASSERT(boolMap.contains("bob") == true );
+    CPPUNIT_ASSERT(boolMap.contains("fred") == false );
+}
+
+void MapTest::testClear(){
+    
+    Map<string, bool> boolMap;
+    boolMap.setValue( "bob", true );
+    boolMap.setValue( "fred", true );
+    
+    CPPUNIT_ASSERT(boolMap.count() == 2 );
+    
+    boolMap.clear();
+    
+    CPPUNIT_ASSERT(boolMap.count() == 0 );
+}
+
+void MapTest::testCount(){
+    
+    Map<string, bool> boolMap;
+    
+    CPPUNIT_ASSERT(boolMap.count() == 0 );
+    
+    boolMap.setValue( "bob", true );
+    
+    CPPUNIT_ASSERT(boolMap.count() == 1 );
+    
+    boolMap.setValue( "fred", true );
+    
+    CPPUNIT_ASSERT(boolMap.count() == 2 );
+}
+
+void MapTest::testValue(){
+    
+    Map<string, bool> boolMap;
+    
+    boolMap.setValue( "fred", true );    
+    CPPUNIT_ASSERT( boolMap.getValue("fred") == true );
+    
+    boolMap.setValue( "bob", false );
+    CPPUNIT_ASSERT( boolMap.getValue("bob") == false );
+    CPPUNIT_ASSERT( boolMap.getValue("fred") == true );
+    
+    try{
+        boolMap.getValue( "mike" );
+        CPPUNIT_ASSERT(false);
+    } catch( activemq::exceptions::NoSuchElementException& e ){        
+    }
+}
+
+void MapTest::testRemove(){
+    Map<string, bool> boolMap;
+    
+    boolMap.setValue( "fred", true );    
+    CPPUNIT_ASSERT( boolMap.contains("fred") == true );
+    boolMap.remove( "fred" );
+    CPPUNIT_ASSERT( boolMap.contains("fred") == false );    
+}
+

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.h?view=auto&rev=479862
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/util/MapTest.h Mon Nov 27 18:53:52 2006
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACTIVEMQ_UTIL_MAPTEST_H_
+#define ACTIVEMQ_UTIL_MAPTEST_H_
+
+#include <activemq/util/Map.h>
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq{
+namespace util{
+    
+    class MapTest : public CppUnit::TestFixture
+    {
+        CPPUNIT_TEST_SUITE( MapTest );
+        CPPUNIT_TEST( testContains );
+        CPPUNIT_TEST( testClear );
+        CPPUNIT_TEST( testCount );
+        CPPUNIT_TEST( testValue );
+        CPPUNIT_TEST( testRemove );
+        CPPUNIT_TEST_SUITE_END();
+        
+    public:
+    	MapTest();
+    	virtual ~MapTest();
+        
+        void testContains();
+        void testClear();
+        void testCount();
+        void testValue();
+        void testRemove();
+    };
+
+}}
+
+#endif /*ACTIVEMQ_UTIL_MAPTEST_H_*/



Mime
View raw message