You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/11/20 00:37:27 UTC

svn commit: r882361 [2/4] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/commands/ main/activemq/wireformat/openwire/utils/ main/cms/ test/activemq/commands/ test/activemq/wireformat/openwire/utils/

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQMessageTemplate.h Thu Nov 19 23:37:26 2009
@@ -26,6 +26,10 @@
 #include <activemq/wireformat/openwire/marshal/BaseDataStreamMarshaller.h>
 #include <activemq/util/CMSExceptionSupport.h>
 
+#include <decaf/lang/exceptions/UnsupportedOperationException.h>
+
+#include <cms/IllegalStateException.h>
+#include <cms/MessageFormatException.h>
 #include <cms/MessageNotReadableException.h>
 #include <cms/MessageNotWriteableException.h>
 
@@ -54,7 +58,7 @@
          * Acknowledges all consumed messages of the session
          * of this consumed message.
          */
-        virtual void acknowledge() const throw( cms::CMSException ) {
+        virtual void acknowledge() const throw( cms::IllegalStateException, cms::CMSException ) {
             try{
                 this->getAckHandler()->acknowledgeMessage( this );
             }
@@ -62,12 +66,51 @@
         }
 
         /**
+         * Resets the Message to a Read-Only state.
+         */
+        virtual void onSend() {
+            this->setReadOnlyBody(true);
+            this->setReadOnlyProperties(true);
+        }
+
+        /**
+         * Compares the DataStructure passed in to this one, and returns if
+         * they are equivalent.  Equivalent here means that they are of the
+         * same type, and that each element of the objects are the same.
+         * @returns true if DataStructure's are Equal.
+         */
+        virtual bool equals( const DataStructure* value ) const {
+            try{
+
+                if( this == value ) {
+                    return true;
+                }
+
+                const ActiveMQMessageTemplate<T>* object =
+                    dynamic_cast< const ActiveMQMessageTemplate<T>* >( value );
+
+                if( object == NULL ) {
+                    return false;
+                }
+
+                decaf::lang::Pointer<MessageId> thisMsgId = this->getMessageId();
+                decaf::lang::Pointer<MessageId> otherMsgId = object->getMessageId();
+
+                return thisMsgId != NULL && otherMsgId != NULL && otherMsgId->equals( thisMsgId.get() );
+            }
+            AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
+        }
+
+        /**
          * Clears out the body of the message.  This does not clear the
          * headers or properties.
          */
         virtual void clearBody() throw( cms::CMSException ) {
-            this->setContent( std::vector<unsigned char>() );
-            this->setReadOnlyBody( false );
+            try{
+                this->setContent( std::vector<unsigned char>() );
+                this->setReadOnlyBody( false );
+            }
+            AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
@@ -75,8 +118,11 @@
          * header values.
          */
         virtual void clearProperties() throw( cms::CMSException ) {
-            this->getMessageProperties().clear();
-            this->setReadOnlyProperties( false );
+            try{
+                this->getMessageProperties().clear();
+                this->setReadOnlyProperties( false );
+            }
+            AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
@@ -85,7 +131,10 @@
          * message.
          */
         virtual std::vector<std::string> getPropertyNames() const throw( cms::CMSException ) {
-            return getMessageProperties().keySet();
+            try{
+                return getMessageProperties().keySet();
+            }
+            AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
@@ -94,141 +143,200 @@
          * @return True if the property exists in this message.
          */
         virtual bool propertyExists( const std::string& name ) const throw( cms::CMSException ) {
-            return getMessageProperties().containsKey( name );
+            try{
+                return getMessageProperties().containsKey( name );
+            }
+            AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Gets a boolean property.
-         * @param name The name of the property to retrieve.
+         *
+         * @param name
+         *      The name of the property to retrieve.
          * @return The value for the named property.
+         *
          * @throws CMSException if the property does not exist.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual bool getBooleanProperty( const std::string& name ) const
-            throw( cms::CMSException ) {
+            throw( cms::MessageFormatException, cms::CMSException ) {
 
             try{
                 return this->propertiesInterceptor->getBooleanProperty( name );
+            } catch( decaf::lang::exceptions::UnsupportedOperationException& ex ) {
+                throw activemq::util::CMSExceptionSupport::createMessageFormatException( ex );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Gets a byte property.
-         * @param name The name of the property to retrieve.
+         *
+         * @param name
+         *      The name of the property to retrieve.
          * @return The value for the named property.
+         *
          * @throws CMSException if the property does not exist.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual unsigned char getByteProperty( const std::string& name ) const
-            throw( cms::CMSException ) {
+            throw( cms::MessageFormatException, cms::CMSException ) {
 
             try{
                 return this->propertiesInterceptor->getByteProperty( name );
+            } catch( decaf::lang::exceptions::UnsupportedOperationException& ex ) {
+                throw activemq::util::CMSExceptionSupport::createMessageFormatException( ex );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Gets a double property.
-         * @param name The name of the property to retrieve.
+         *
+         * @param name
+         *      The name of the property to retrieve.
          * @return The value for the named property.
+         *
          * @throws CMSException if the property does not exist.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual double getDoubleProperty( const std::string& name ) const
-            throw( cms::CMSException ) {
+            throw( cms::MessageFormatException, cms::CMSException ) {
 
             try{
                 return this->propertiesInterceptor->getDoubleProperty( name );
+            } catch( decaf::lang::exceptions::UnsupportedOperationException& ex ) {
+                throw activemq::util::CMSExceptionSupport::createMessageFormatException( ex );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Gets a float property.
-         * @param name The name of the property to retrieve.
+         *
+         * @param name
+         *      The name of the property to retrieve.
          * @return The value for the named property.
+         *
          * @throws CMSException if the property does not exist.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual float getFloatProperty( const std::string& name ) const
-            throw( cms::CMSException ) {
+            throw( cms::MessageFormatException, cms::CMSException ) {
 
             try{
                 return this->propertiesInterceptor->getFloatProperty( name );
+            } catch( decaf::lang::exceptions::UnsupportedOperationException& ex ) {
+                throw activemq::util::CMSExceptionSupport::createMessageFormatException( ex );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Gets a int property.
-         * @param name The name of the property to retrieve.
+         *
+         * @param name
+         *      The name of the property to retrieve.
          * @return The value for the named property.
+         *
          * @throws CMSException if the property does not exist.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual int getIntProperty( const std::string& name ) const
-            throw( cms::CMSException ) {
+            throw( cms::MessageFormatException, cms::CMSException ) {
 
             try{
                 return this->propertiesInterceptor->getIntProperty( name );
+            } catch( decaf::lang::exceptions::UnsupportedOperationException& ex ) {
+                throw activemq::util::CMSExceptionSupport::createMessageFormatException( ex );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Gets a long property.
-         * @param name The name of the property to retrieve.
+         *
+         * @param name
+         *      The name of the property to retrieve.
          * @return The value for the named property.
+         *
          * @throws CMSException if the property does not exist.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual long long getLongProperty( const std::string& name ) const
-            throw( cms::CMSException ) {
+            throw( cms::MessageFormatException, cms::CMSException ) {
 
             try{
                 return this->propertiesInterceptor->getLongProperty( name );
+            } catch( decaf::lang::exceptions::UnsupportedOperationException& ex ) {
+                throw activemq::util::CMSExceptionSupport::createMessageFormatException( ex );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Gets a short property.
-         * @param name The name of the property to retrieve.
+         *
+         * @param name
+         *      The name of the property to retrieve.
          * @return The value for the named property.
+         *
          * @throws CMSException if the property does not exist.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual short getShortProperty( const std::string& name ) const
-            throw( cms::CMSException ) {
+            throw( cms::MessageFormatException, cms::CMSException ) {
 
             try{
                 return this->propertiesInterceptor->getShortProperty( name );
+            } catch( decaf::lang::exceptions::UnsupportedOperationException& ex ) {
+                throw activemq::util::CMSExceptionSupport::createMessageFormatException( ex );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Gets a string property.
-         * @param name The name of the property to retrieve.
+         *
+         * @param name
+         *      The name of the property to retrieve.
          * @return The value for the named property.
+         *
          * @throws CMSException if the property does not exist.
+         * @throws MessageFormatException - if this type conversion is invalid.
          */
         virtual std::string getStringProperty( const std::string& name ) const
-            throw( cms::CMSException ) {
+            throw( cms::MessageFormatException, cms::CMSException ) {
 
             try{
                 return this->propertiesInterceptor->getStringProperty( name );
+            } catch( decaf::lang::exceptions::UnsupportedOperationException& ex ) {
+                throw activemq::util::CMSExceptionSupport::createMessageFormatException( ex );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
          * Sets a boolean property.
-         * @param name The name of the property to retrieve.
-         * @param value The value for the named property.
-         * @throws CMSException
+         *
+         * @param name
+         *      The name of the property to retrieve.
+         * @param value
+         *      The value for the named property.
+         *
+         * @throws CMSException - if the name is an empty string.
+         * @throws MessageNotWriteableException - if properties are read-only
          */
-        virtual void setBooleanProperty( const std::string& name,
-                                         bool value )
-                                            throw( cms::CMSException ) {
+        virtual void setBooleanProperty( const std::string& name, bool value )
+            throw( cms::MessageNotWriteableException, cms::CMSException ) {
+
+            if( name == "" ) {
+                throw cms::CMSException( "Message Property names must not be empty", NULL );
+            }
 
+            failIfReadOnlyProperties();
             try{
-                failIfReadOnlyProperties();
                 this->propertiesInterceptor->setBooleanProperty( name, value );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -236,16 +344,24 @@
 
         /**
          * Sets a byte property.
-         * @param name The name of the property to retrieve.
-         * @param value The value for the named property.
-         * @throws CMSException
+         *
+         * @param name
+         *      The name of the property to retrieve.
+         * @param value
+         *      The value for the named property.
+         *
+         * @throws CMSException - if the name is an empty string.
+         * @throws MessageNotWriteableException - if properties are read-only
          */
-        virtual void setByteProperty( const std::string& name,
-                                      unsigned char value )
-                                        throw( cms::CMSException ) {
+        virtual void setByteProperty( const std::string& name, unsigned char value )
+            throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+            if( name == "" ) {
+                throw cms::CMSException( "Message Property names must not be empty", NULL );
+            }
+
+            failIfReadOnlyProperties();
             try{
-                failIfReadOnlyProperties();
                 this->propertiesInterceptor->setByteProperty( name, value );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -253,16 +369,24 @@
 
         /**
          * Sets a double property.
-         * @param name The name of the property to retrieve.
-         * @param value The value for the named property.
-         * @throws CMSException
+         *
+         * @param name
+         *      The name of the property to retrieve.
+         * @param value
+         *      The value for the named property.
+         *
+         * @throws CMSException - if the name is an empty string.
+         * @throws MessageNotWriteableException - if properties are read-only
          */
-        virtual void setDoubleProperty( const std::string& name,
-                                        double value )
-                                            throw( cms::CMSException ) {
+        virtual void setDoubleProperty( const std::string& name, double value )
+            throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+            if( name == "" ) {
+                throw cms::CMSException( "Message Property names must not be empty", NULL );
+            }
+
+            failIfReadOnlyProperties();
             try{
-                failIfReadOnlyProperties();
                 this->propertiesInterceptor->setDoubleProperty( name, value );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -270,16 +394,23 @@
 
         /**
          * Sets a float property.
-         * @param name The name of the property to retrieve.
-         * @param value The value for the named property.
-         * @throws CMSException
+         * @param name
+         *      The name of the property to retrieve.
+         * @param value
+         *      The value for the named property.
+         *
+         * @throws CMSException - if the name is an empty string.
+         * @throws MessageNotWriteableException - if properties are read-only
          */
-        virtual void setFloatProperty( const std::string& name,
-                                       float value )
-                                        throw( cms::CMSException ) {
+        virtual void setFloatProperty( const std::string& name, float value )
+            throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+            if( name == "" ) {
+                throw cms::CMSException( "Message Property names must not be empty", NULL );
+            }
+
+            failIfReadOnlyProperties();
             try{
-                failIfReadOnlyProperties();
                 this->propertiesInterceptor->setFloatProperty( name, value );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -287,16 +418,24 @@
 
         /**
          * Sets a int property.
-         * @param name The name of the property to retrieve.
-         * @param value The value for the named property.
-         * @throws CMSException
+         *
+         * @param name
+         *      The name of the property to retrieve.
+         * @param value
+         *      The value for the named property.
+         *
+         * @throws CMSException - if the name is an empty string.
+         * @throws MessageNotWriteableException - if properties are read-only
          */
-        virtual void setIntProperty( const std::string& name,
-                                     int value )
-                                        throw( cms::CMSException ) {
+        virtual void setIntProperty( const std::string& name, int value )
+            throw( cms::MessageNotWriteableException, cms::CMSException ) {
+
+            if( name == "" ) {
+                throw cms::CMSException( "Message Property names must not be empty", NULL );
+            }
 
+            failIfReadOnlyProperties();
             try{
-                failIfReadOnlyProperties();
                 this->propertiesInterceptor->setIntProperty( name, value );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -304,16 +443,24 @@
 
         /**
          * Sets a long property.
-         * @param name The name of the property to retrieve.
-         * @param value The value for the named property.
-         * @throws CMSException
+         *
+         * @param name
+         *      The name of the property to retrieve.
+         * @param value
+         *      The value for the named property.
+         *
+         * @throws CMSException - if the name is an empty string.
+         * @throws MessageNotWriteableException - if properties are read-only
          */
-        virtual void setLongProperty( const std::string& name,
-                                      long long value )
-                                        throw( cms::CMSException ) {
+        virtual void setLongProperty( const std::string& name, long long value )
+            throw( cms::MessageNotWriteableException, cms::CMSException ) {
+
+            if( name == "" ) {
+                throw cms::CMSException( "Message Property names must not be empty", NULL );
+            }
 
+            failIfReadOnlyProperties();
             try{
-                failIfReadOnlyProperties();
                 this->propertiesInterceptor->setLongProperty( name, value );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -321,16 +468,24 @@
 
         /**
          * Sets a short property.
-         * @param name The name of the property to retrieve.
-         * @param value The value for the named property.
-         * @throws CMSException
+         *
+         * @param name
+         *      The name of the property to retrieve.
+         * @param value
+         *      The value for the named property.
+         *
+         * @throws CMSException - if the name is an empty string.
+         * @throws MessageNotWriteableException - if properties are read-only
          */
-        virtual void setShortProperty( const std::string& name,
-                                       short value )
-                                        throw( cms::CMSException ) {
+        virtual void setShortProperty( const std::string& name, short value )
+            throw( cms::MessageNotWriteableException, cms::CMSException ) {
 
+            if( name == "" ) {
+                throw cms::CMSException( "Message Property names must not be empty", NULL );
+            }
+
+            failIfReadOnlyProperties();
             try{
-                failIfReadOnlyProperties();
                 this->propertiesInterceptor->setShortProperty( name, value );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -338,16 +493,24 @@
 
         /**
          * Sets a string property.
-         * @param name The name of the property to retrieve.
-         * @param value The value for the named property.
-         * @throws CMSException
+         *
+         * @param name
+         *      The name of the property to retrieve.
+         * @param value
+         *      The value for the named property.
+         *
+         * @throws CMSException - if the name is an empty string.
+         * @throws MessageNotWriteableException - if properties are read-only
          */
-        virtual void setStringProperty( const std::string& name,
-                                        const std::string& value )
-                                            throw( cms::CMSException ) {
+        virtual void setStringProperty( const std::string& name, const std::string& value )
+            throw( cms::MessageNotWriteableException, cms::CMSException ) {
+
+            if( name == "" ) {
+                throw cms::CMSException( "Message Property names must not be empty", NULL );
+            }
 
+            failIfReadOnlyProperties();
             try{
-                failIfReadOnlyProperties();
                 this->propertiesInterceptor->setStringProperty( name, value );
             }
             AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
@@ -377,7 +540,7 @@
          * @throw CMSException
          */
         virtual int getCMSDeliveryMode() const throw( cms::CMSException ) {
-            return this->isPersistent();
+            return !this->isPersistent();
         }
 
         /**
@@ -406,13 +569,16 @@
         virtual void setCMSDestination( const cms::Destination* destination )
             throw( cms::CMSException ) {
 
-            if( destination != NULL ) {
-                this->setDestination(
-                    decaf::lang::Pointer<ActiveMQDestination>(
-                        dynamic_cast<ActiveMQDestination*>( destination->clone() ) ) );
-            } else {
-                this->getDestination().reset( NULL );
+            try{
+                if( destination != NULL ) {
+                    this->setDestination(
+                        decaf::lang::Pointer<ActiveMQDestination>(
+                            dynamic_cast<ActiveMQDestination*>( destination->clone() ) ) );
+                } else {
+                    this->getDestination().reset( NULL );
+                }
             }
+            AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
@@ -439,7 +605,10 @@
          * @throw CMSException
          */
         virtual std::string getCMSMessageID() const throw( cms::CMSException ) {
-            return wireformat::openwire::marshal::BaseDataStreamMarshaller::toString( this->getMessageId().get() );
+            try{
+                return wireformat::openwire::marshal::BaseDataStreamMarshaller::toString( this->getMessageId().get() );
+            }
+            AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
@@ -491,8 +660,7 @@
          * @throw CMSException
          */
         virtual const cms::Destination* getCMSReplyTo() const throw( cms::CMSException ) {
-            return dynamic_cast< const cms::Destination* >(
-                this->getReplyTo().get() );
+            return dynamic_cast< const cms::Destination* >( this->getReplyTo().get() );
         }
 
         /**
@@ -505,13 +673,16 @@
          */
         virtual void setCMSReplyTo( const cms::Destination* destination ) throw( cms::CMSException ) {
 
-            if( destination != NULL ) {
-                this->setReplyTo(
-                    decaf::lang::Pointer<ActiveMQDestination>(
-                        dynamic_cast<ActiveMQDestination*>( destination->clone() ) ) );
-            } else {
-                this->setReplyTo( decaf::lang::Pointer<ActiveMQDestination>() );
+            try{
+                if( destination != NULL ) {
+                    this->setReplyTo(
+                        decaf::lang::Pointer<ActiveMQDestination>(
+                            dynamic_cast<ActiveMQDestination*>( destination->clone() ) ) );
+                } else {
+                    this->setReplyTo( decaf::lang::Pointer<ActiveMQDestination>() );
+                }
             }
+            AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
         }
 
         /**
@@ -552,11 +723,6 @@
 
     protected:
 
-        virtual void onSend() {
-            this->setReadOnlyBody(true);
-            this->setReadOnlyProperties(true);
-        }
-
         void failIfWriteOnlyBody() const {
             if( !this->isReadOnlyBody() ){
                 throw cms::MessageNotReadableException(

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.cpp Thu Nov 19 23:37:26 2009
@@ -28,9 +28,11 @@
 using namespace activemq;
 using namespace activemq::exceptions;
 using namespace activemq::commands;
+using namespace activemq::util;
 using namespace activemq::wireformat;
 using namespace activemq::wireformat::openwire;
 using namespace activemq::wireformat::openwire::utils;
+using namespace decaf::io;
 using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -56,6 +58,23 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 void ActiveMQTextMessage::copyDataStructure( const DataStructure* src ) {
+
+    if( this == src ) {
+        return;
+    }
+
+    const ActiveMQTextMessage* srcPtr = dynamic_cast<const ActiveMQTextMessage*>( src );
+
+    if( srcPtr == NULL || src == NULL ) {
+        throw decaf::lang::exceptions::NullPointerException(
+            __FILE__, __LINE__,
+            "ActiveMQTextMessage::copyDataStructure - src is NULL or invalid" );
+    }
+
+    if( srcPtr->text.get() != NULL ) {
+        this->text.reset( new std::string( *( srcPtr->text.get() ) ) );
+    }
+
     ActiveMQMessageTemplate<cms::TextMessage>::copyDataStructure( src );
 }
 
@@ -76,23 +95,82 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void ActiveMQTextMessage::clearBody() throw( cms::CMSException ) {
+    ActiveMQMessageTemplate<cms::TextMessage>::clearBody();
+    this->text.reset( NULL );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQTextMessage::beforeMarshal( wireformat::WireFormat* wireFormat )
+    throw ( decaf::io::IOException ) {
+
+    ActiveMQMessageTemplate<cms::TextMessage>::beforeMarshal( wireFormat );
+
+    if( this->text.get() != NULL ) {
+
+        ByteArrayOutputStream bytesOut;
+        DataOutputStream dataOut( &bytesOut );
+
+        OpenwireStringSupport::writeString( dataOut, this->text.get() );
+
+        dataOut.close();
+
+        this->setContent( bytesOut.toByteArrayRef() );
+        this->text.reset( NULL );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned int ActiveMQTextMessage::getSize() const {
+
+    if( this->text.get() != NULL ) {
+        unsigned int size = commands::Message::DEFAULT_MESSAGE_SIZE;
+
+        size += getMarshalledProperties().size();
+        size += this->text->size() * 2;
+
+        return size;
+    }
+
+    return ActiveMQMessageTemplate<cms::TextMessage>::getSize();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 std::string ActiveMQTextMessage::getText() const throw( cms::CMSException ) {
 
     try{
-        if( getContent().size() <= 4 ) {
-            return "";
-        }
 
-        decaf::io::ByteArrayInputStream bais( getContent() );
-        decaf::io::DataInputStream dataIn( &bais );
+        if( this->text.get() != NULL ) {
+            return *( this->text.get() );
+        } else {
 
-        return OpenwireStringSupport::readString( dataIn );
+            if( this->getContent().size() <= 4 ) {
+                return "";
+            }
+
+            try {
+
+                decaf::io::ByteArrayInputStream bais( getContent() );
+                decaf::io::DataInputStream dataIn( &bais );
+
+                dataIn.close();
+
+                this->text.reset( new std::string( OpenwireStringSupport::readString( dataIn ) ) );
+
+            } catch( IOException& ioe ) {
+                throw CMSExceptionSupport::create( ioe );
+            }
+        }
+
+        return *( this->text.get() );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQTextMessage::setText( const char* msg ) throw( cms::CMSException ) {
+void ActiveMQTextMessage::setText( const char* msg )
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
+
     try{
         setText( std::string(msg) );
     }
@@ -100,15 +178,12 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQTextMessage::setText( const std::string& msg ) throw( cms::CMSException ) {
+void ActiveMQTextMessage::setText( const std::string& msg )
+    throw( cms::MessageNotWriteableException, cms::CMSException ) {
+
     try{
         failIfReadOnlyBody();
-        std::vector<unsigned char>& content = getContent();
-        content.clear();
-        decaf::io::ByteArrayOutputStream bos( content );
-        decaf::io::DataOutputStream dataOut( &bos );
-
-        OpenwireStringSupport::writeString( dataOut, &msg );
+        this->text.reset( new std::string( msg ) );
     }
     AMQ_CATCH_ALL_THROW_CMSEXCEPTION()
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQTextMessage.h Thu Nov 19 23:37:26 2009
@@ -39,6 +39,8 @@
 
         const static unsigned char ID_ACTIVEMQTEXTMESSAGE = 28;
 
+        mutable std::auto_ptr<std::string> text;
+
     public:
 
         ActiveMQTextMessage();
@@ -75,6 +77,27 @@
          */
         virtual bool equals( const DataStructure* value ) const;
 
+        /**
+         * Clears out the body of the message.  This does not clear the
+         * headers or properties.
+         */
+        virtual void clearBody() throw( cms::CMSException );
+
+        /**
+         * Performs any cleanup or other tasks that must be done before the Message is
+         * marshalled to its binary WireFormat version.
+         *
+         * @param wireFormat the WireFormat instance that is marshalling this message.
+         */
+        virtual void beforeMarshal( wireformat::WireFormat* wireFormat )
+            throw ( decaf::io::IOException );
+
+        /**
+         * Returns the Size of this message in Bytes.
+         * @returns number of bytes this message equates to.
+         */
+        virtual unsigned int getSize() const;
+
     public:   // CMS Message
 
         /**
@@ -90,22 +113,37 @@
 
         /**
          * Gets the message character buffer.
+         *
          * @return The message character buffer.
+         *
+         * @throws CMSException - if an internal error occurs.
          */
         virtual std::string getText() const throw( cms::CMSException );
 
         /**
          * Sets the message contents, does not take ownership of the passed
          * char*, but copies it instead.
-         * @param msg The message buffer.
+         *
+         * @param msg
+         *      The message buffer.
+         *
+         * @throws CMSException - if an internal error occurs.
+         * @throws MessageNotWriteableException - if the message is in read-only mode..
          */
-        virtual void setText( const char* msg ) throw( cms::CMSException );
+        virtual void setText( const char* msg ) throw( cms::MessageNotWriteableException,
+                                                       cms::CMSException );
 
         /**
          * Sets the message contents
-         * @param msg The message buffer.
+         *
+         * @param msg
+         *      The message buffer.
+         *
+         * @throws CMSException - if an internal error occurs.
+         * @throws MessageNotWriteableException - if the message is in read-only mode..
          */
-        virtual void setText( const std::string& msg ) throw( cms::CMSException );
+        virtual void setText( const std::string& msg ) throw( cms::MessageNotWriteableException,
+                                                              cms::CMSException );
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.cpp Thu Nov 19 23:37:26 2009
@@ -56,319 +56,207 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool MessagePropertyInterceptor::getBooleanProperty( const std::string& name ) const
-	throw( activemq::exceptions::ActiveMQException ) {
+bool MessagePropertyInterceptor::getBooleanProperty( const std::string& name ) const {
 
-    try{
-
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
-
-        return this->properties->getBool( name );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    return this->properties->getBool( name );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-unsigned char MessagePropertyInterceptor::getByteProperty( const std::string& name ) const
-    throw( activemq::exceptions::ActiveMQException ) {
+unsigned char MessagePropertyInterceptor::getByteProperty( const std::string& name ) const {
 
-    try{
-
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
-
-        return this->properties->getByte( name );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    return this->properties->getByte( name );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-double MessagePropertyInterceptor::getDoubleProperty( const std::string& name ) const
-    throw( activemq::exceptions::ActiveMQException ) {
+double MessagePropertyInterceptor::getDoubleProperty( const std::string& name ) const {
 
-    try{
-
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
-
-        return this->properties->getDouble( name );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    return this->properties->getDouble( name );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-float MessagePropertyInterceptor::getFloatProperty( const std::string& name ) const
-    throw( activemq::exceptions::ActiveMQException ) {
+float MessagePropertyInterceptor::getFloatProperty( const std::string& name ) const {
 
-    try{
-
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
-
-        return this->properties->getFloat( name );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    return this->properties->getFloat( name );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int MessagePropertyInterceptor::getIntProperty( const std::string& name ) const
-    throw( activemq::exceptions::ActiveMQException ) {
+int MessagePropertyInterceptor::getIntProperty( const std::string& name ) const {
 
-    try{
-
-        if( name == "JMSXGroupID" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        } else if( name == "JMSXDeliveryCount" ) {
-            return this->message->getRedeliveryCounter();
-        } else if( name == "JMSXGroupSeq" ) {
-            return this->message->getGroupSequence();
-        }
-
-        return this->properties->getInt( name );
+    if( name == "JMSXGroupID" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
+    } else if( name == "JMSXDeliveryCount" ) {
+        return this->message->getRedeliveryCounter();
+    } else if( name == "JMSXGroupSeq" ) {
+        return this->message->getGroupSequence();
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    return this->properties->getInt( name );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long MessagePropertyInterceptor::getLongProperty( const std::string& name ) const
-    throw( activemq::exceptions::ActiveMQException ) {
+long long MessagePropertyInterceptor::getLongProperty( const std::string& name ) const {
 
-    try{
-
-        if( name == "JMSXGroupID" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        } else if( name == "JMSXDeliveryCount" ) {
-            return (long long)this->message->getRedeliveryCounter();
-        } else if( name == "JMSXGroupSeq" ) {
-            return (long long)this->message->getGroupSequence();
-        }
-
-        return this->properties->getLong( name );
+    if( name == "JMSXGroupID" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
+    } else if( name == "JMSXDeliveryCount" ) {
+        return (long long)this->message->getRedeliveryCounter();
+    } else if( name == "JMSXGroupSeq" ) {
+        return (long long)this->message->getGroupSequence();
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    return this->properties->getLong( name );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-short MessagePropertyInterceptor::getShortProperty( const std::string& name ) const
-    throw( activemq::exceptions::ActiveMQException ) {
+short MessagePropertyInterceptor::getShortProperty( const std::string& name ) const {
 
-    try{
-
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
-
-        return this->properties->getShort( name );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    return this->properties->getShort( name );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string MessagePropertyInterceptor::getStringProperty( const std::string& name ) const
-    throw( activemq::exceptions::ActiveMQException ) {
-
-    try{
-
-        if( name == "JMSXGroupID" ) {
-            return this->message->getGroupID();
-        } else if( name == "JMSXDeliveryCount" ) {
-            return Integer::toString( this->message->getRedeliveryCounter() );
-        } else if( name == "JMSXGroupSeq" ) {
-            return Integer::toString( this->message->getGroupSequence() );
-        }
+std::string MessagePropertyInterceptor::getStringProperty( const std::string& name ) const {
 
-        return this->properties->getString( name );
+    if( name == "JMSXGroupID" ) {
+        return this->message->getGroupID();
+    } else if( name == "JMSXDeliveryCount" ) {
+        return Integer::toString( this->message->getRedeliveryCounter() );
+    } else if( name == "JMSXGroupSeq" ) {
+        return Integer::toString( this->message->getGroupSequence() );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    return this->properties->getString( name );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void MessagePropertyInterceptor::setBooleanProperty( const std::string& name, bool value )
-	throw( activemq::exceptions::ActiveMQException ) {
-
-    try{
-
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
+void MessagePropertyInterceptor::setBooleanProperty( const std::string& name, bool value ) {
 
-        this->properties->setBool( name, value );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    this->properties->setBool( name, value );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void MessagePropertyInterceptor::setByteProperty( const std::string& name, unsigned char value )
-	throw( activemq::exceptions::ActiveMQException ) {
-
-    try{
-
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
+void MessagePropertyInterceptor::setByteProperty( const std::string& name, unsigned char value ) {
 
-        this->properties->setByte( name, value );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    this->properties->setByte( name, value );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void MessagePropertyInterceptor::setDoubleProperty( const std::string& name, double value )
-	throw( activemq::exceptions::ActiveMQException ) {
-
-    try{
-
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
+void MessagePropertyInterceptor::setDoubleProperty( const std::string& name, double value ) {
 
-        this->properties->setDouble( name, value );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    this->properties->setDouble( name, value );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void MessagePropertyInterceptor::setFloatProperty( const std::string& name, float value )
-	throw( activemq::exceptions::ActiveMQException ) {
-
-    try{
+void MessagePropertyInterceptor::setFloatProperty( const std::string& name, float value ) {
 
-        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        }
-
-        this->properties->setFloat( name, value );
+    if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    this->properties->setFloat( name, value );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void MessagePropertyInterceptor::setIntProperty( const std::string& name, int value )
-    throw( activemq::exceptions::ActiveMQException ) {
-
-    try{
+void MessagePropertyInterceptor::setIntProperty( const std::string& name, int value ) {
 
-        if( name == "JMSXGroupID" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        } else if( name == "JMSXDeliveryCount" ) {
-            this->message->setRedeliveryCounter( value );
-        } else if( name == "JMSXGroupSeq" ) {
-            this->message->setGroupSequence( value );
-        }
-
-        this->properties->setInt( name, value );
+    if( name == "JMSXGroupID" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
+    } else if( name == "JMSXDeliveryCount" ) {
+        this->message->setRedeliveryCounter( value );
+    } else if( name == "JMSXGroupSeq" ) {
+        this->message->setGroupSequence( value );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    this->properties->setInt( name, value );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void MessagePropertyInterceptor::setLongProperty( const std::string& name, long long value )
-    throw( activemq::exceptions::ActiveMQException ) {
-
-    try{
-        this->properties->setLong( name, value );
-    }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+void MessagePropertyInterceptor::setLongProperty( const std::string& name, long long value ) {
+    this->properties->setLong( name, value );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void MessagePropertyInterceptor::setShortProperty( const std::string& name, short value )
-    throw( activemq::exceptions::ActiveMQException ) {
-
-    try{
-
-        if( name == "JMSXGroupID" ) {
-            throw ActiveMQException(
-                __FILE__, __LINE__,
-                "Cannot Convert Reserved Property to this Type." );
-        } else if( name == "JMSXDeliveryCount" ) {
-            this->message->setRedeliveryCounter( (int)value );
-        } else if( name == "JMSXGroupSeq" ) {
-            this->message->setGroupSequence( (int)value );
-        }
+void MessagePropertyInterceptor::setShortProperty( const std::string& name, short value ) {
 
-        this->properties->setShort( name, value );
+    if( name == "JMSXGroupID" ) {
+        throw ActiveMQException(
+            __FILE__, __LINE__,
+            "Cannot Convert Reserved Property to this Type." );
+    } else if( name == "JMSXDeliveryCount" ) {
+        this->message->setRedeliveryCounter( (int)value );
+    } else if( name == "JMSXGroupSeq" ) {
+        this->message->setGroupSequence( (int)value );
     }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+
+    this->properties->setShort( name, value );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void MessagePropertyInterceptor::setStringProperty( const std::string& name,
-                                                    const std::string& value )
-    throw( activemq::exceptions::ActiveMQException ) {
+                                                    const std::string& value ) {
 
-    try{
+    if( name == "JMSXGroupID" ) {
+        this->message->setGroupID( value );
+    } else if( name == "JMSXDeliveryCount" ) {
+        this->message->setRedeliveryCounter( Integer::parseInt( value ) );
+    } else if( name == "JMSXGroupSeq" ) {
+        this->message->setGroupSequence( Integer::parseInt( value ) );
+    }
 
-        if( name == "JMSXGroupID" ) {
-            this->message->setGroupID( value );
-        } else if( name == "JMSXDeliveryCount" ) {
-            this->message->setRedeliveryCounter( Integer::parseInt( value ) );
-        } else if( name == "JMSXGroupSeq" ) {
-            this->message->setGroupSequence( Integer::parseInt( value ) );
-        }
-
-        this->properties->setString( name, value );
-    }
-    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
-    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+    this->properties->setString( name, value );
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/utils/MessagePropertyInterceptor.h Thu Nov 19 23:37:26 2009
@@ -70,152 +70,113 @@
          * 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( exceptions::ActiveMQException );
+        virtual bool getBooleanProperty( const std::string& name ) const;
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual unsigned char getByteProperty( const std::string& name ) const;
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual double getDoubleProperty( const std::string& name ) const;
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual float getFloatProperty( const std::string& name ) const;
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual int getIntProperty( const std::string& name ) const;
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual long long getLongProperty( const std::string& name ) const;
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual short getShortProperty( const std::string& name ) const;
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual std::string getStringProperty( const std::string& name ) const;
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual void setBooleanProperty( const std::string& name, bool value );
+
         /**
          * 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( exceptions::ActiveMQException );
+        virtual void setByteProperty( const std::string& name, unsigned char value );
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual void setDoubleProperty( const std::string& name, double value );
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual void setFloatProperty( const std::string& name, float value );
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual void setIntProperty( const std::string& name, int value );
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual void setLongProperty( const std::string& name, long long value );
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual void setShortProperty( const std::string& name, short value );
 
         /**
          * 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( exceptions::ActiveMQException );
+        virtual void setStringProperty( const std::string& name, const std::string& value );
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h?rev=882361&r1=882360&r2=882361&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/BytesMessage.h Thu Nov 19 23:37:26 2009
@@ -21,6 +21,12 @@
 #include <cms/Config.h>
 #include <cms/Message.h>
 
+#include <cms/CMSException.h>
+#include <cms/MessageNotReadableException.h>
+#include <cms/MessageNotWriteableException.h>
+#include <cms/MessageEOFException.h>
+#include <cms/MessageFormatException.h>
+
 namespace cms{
 
     /**
@@ -74,20 +80,22 @@
          * @throws MessageNotWriteableException - if in Read Only Mode.
          */
         virtual void setBodyBytes( const unsigned char* buffer, std::size_t numBytes )
-            throw( CMSException ) = 0;
+            throw( cms::MessageNotWriteableException, cms::CMSException ) = 0;
 
         /**
-         * Gets the bytes that are contained in this message, user should
-         * copy this data into a user allocated buffer.  Call
-         * <code>getBodyLength</code> to determine the number of bytes
-         * to expect.
+         * Gets the bytes that are contained in this message and returns them in a newly
+         * allocated array that becomes the property of the caller.  This is a copy of the
+         * data contained in this message, changing the value contained in this array has
+         * no effect on the data contained in this message.
          *
-         * @return const pointer to a byte buffer
+         * @return pointer to a byte buffer that the call owns upon completion of this
+         *         method.
          *
          * @throws CMSException - If an internal error occurs.
          * @throws MessageNotReadableException - If the message is in Write Only Mode.
          */
-        virtual const unsigned char* getBodyBytes() const throw( CMSException ) = 0;
+        virtual unsigned char* getBodyBytes() const
+            throw( cms::MessageNotReadableException, cms::CMSException ) = 0;
 
         /**
          * Returns the number of bytes contained in the body of this message.
@@ -97,7 +105,8 @@
          * @throws CMSException - If an internal error occurs.
          * @throws MessageNotReadableException - If the message is in Write Only Mode.
          */
-        virtual std::size_t getBodyLength() const throw( CMSException ) = 0;
+        virtual std::size_t getBodyLength() const
+            throw( cms::MessageNotReadableException, cms::CMSException ) = 0;
 
         /**
          * Puts the message body in read-only mode and repositions the stream
@@ -106,7 +115,7 @@
          * @throws CMSException - If the provider fails to perform the reset operation.
          * @throws MessageFormatException - If the Message has an invalid format.
          */
-        virtual void reset() throw ( cms::CMSException ) = 0;
+        virtual void reset() throw ( cms::MessageFormatException, cms::CMSException ) = 0;
 
         /**
          * Reads a Boolean from the Bytes message stream
@@ -117,7 +126,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual bool readBoolean() const throw ( cms::CMSException ) = 0;
+        virtual bool readBoolean() const throw ( cms::MessageEOFException,
+                                                 cms::MessageNotReadableException,
+                                                 cms::CMSException ) = 0;
 
         /**
          * Writes a boolean to the bytes message stream as a 1-byte value.
@@ -131,7 +142,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeBoolean( bool value ) throw ( cms::CMSException ) = 0;
+        virtual void writeBoolean( bool value ) throw ( cms::MessageNotWriteableException,
+                                                        cms::CMSException ) = 0;
 
         /**
          * Reads a Byte from the Bytes message stream
@@ -143,7 +155,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual unsigned char readByte() const throw ( cms::CMSException ) = 0;
+        virtual unsigned char readByte() const throw ( cms::MessageEOFException,
+                                                       cms::MessageNotReadableException,
+                                                       cms::CMSException ) = 0;
 
         /**
          * Writes a byte to the bytes message stream as a 1-byte value
@@ -155,7 +169,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeByte( unsigned char value ) throw ( cms::CMSException ) = 0;
+        virtual void writeByte( unsigned char value ) throw ( cms::MessageNotWriteableException,
+                                                              cms::CMSException ) = 0;
 
         /**
          * Reads a byte array from the bytes message stream.
@@ -182,7 +197,9 @@
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
         virtual std::size_t readBytes( std::vector<unsigned char>& value ) const
-            throw ( cms::CMSException ) = 0;
+            throw ( cms::MessageEOFException,
+                    cms::MessageNotReadableException,
+                    cms::CMSException ) = 0;
 
         /**
          * Writes a byte array to the bytes message stream using the vector
@@ -196,7 +213,8 @@
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeBytes( const std::vector<unsigned char>& value )
-            throw ( cms::CMSException ) = 0;
+            throw ( cms::MessageNotWriteableException,
+                    cms::CMSException ) = 0;
 
         /**
          * Reads a portion of the bytes message stream.
@@ -229,8 +247,10 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual std::size_t readBytes( unsigned char*& buffer, std::size_t length ) const
-            throw ( cms::CMSException ) = 0;
+        virtual std::size_t readBytes( unsigned char* buffer, std::size_t length ) const
+            throw ( cms::MessageEOFException,
+                    cms::MessageNotReadableException,
+                    cms::CMSException ) = 0;
 
         /**
          * Writes a portion of a byte array to the bytes message stream.
@@ -247,9 +267,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeBytes( const unsigned char* value,
-                                 std::size_t offset,
-                                 std::size_t length ) throw ( cms::CMSException ) = 0;
+        virtual void writeBytes( const unsigned char* value, std::size_t offset, std::size_t length )
+            throw ( cms::MessageNotWriteableException, cms::CMSException ) = 0;
 
         /**
          * Reads a Char from the Bytes message stream
@@ -261,7 +280,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual char readChar() const throw ( cms::CMSException ) = 0;
+        virtual char readChar() const throw ( cms::MessageEOFException,
+                                              cms::MessageNotReadableException,
+                                              cms::CMSException ) = 0;
 
         /**
          * Writes a char to the bytes message stream as a 1-byte value
@@ -273,7 +294,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeChar( char value ) throw ( cms::CMSException ) = 0;
+        virtual void writeChar( char value ) throw ( cms::MessageNotWriteableException,
+                                                     cms::CMSException ) = 0;
 
         /**
          * Reads a 32 bit float from the Bytes message stream
@@ -285,7 +307,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual float readFloat() const throw ( cms::CMSException ) = 0;
+        virtual float readFloat() const throw ( cms::MessageEOFException,
+                                                cms::MessageNotReadableException,
+                                                cms::CMSException ) = 0;
 
         /**
          * Writes a float to the bytes message stream as a 4 byte value
@@ -296,7 +320,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeFloat( float value ) throw ( cms::CMSException ) = 0;
+        virtual void writeFloat( float value ) throw ( cms::MessageNotWriteableException,
+                                                       cms::CMSException ) = 0;
 
         /**
          * Reads a 64 bit double from the Bytes message stream
@@ -308,7 +333,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual double readDouble() const throw ( cms::CMSException ) = 0;
+        virtual double readDouble() const throw ( cms::MessageEOFException,
+                                                  cms::MessageNotReadableException,
+                                                  cms::CMSException ) = 0;
 
         /**
          * Writes a double to the bytes message stream as a 8 byte value
@@ -319,7 +346,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeDouble( double value ) throw ( cms::CMSException ) = 0;
+        virtual void writeDouble( double value ) throw ( cms::MessageNotWriteableException,
+                                                         cms::CMSException ) = 0;
 
         /**
          * Reads a 16 bit signed short from the Bytes message stream
@@ -331,7 +359,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual short readShort() const throw ( cms::CMSException ) = 0;
+        virtual short readShort() const throw ( cms::MessageEOFException,
+                                                cms::MessageNotReadableException,
+                                                cms::CMSException ) = 0;
 
         /**
          * Writes a signed short to the bytes message stream as a 2 byte value
@@ -343,7 +373,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeShort( short value ) throw ( cms::CMSException ) = 0;
+        virtual void writeShort( short value ) throw ( cms::MessageNotWriteableException,
+                                                       cms::CMSException ) = 0;
 
         /**
          * Reads a 16 bit unsigned short from the Bytes message stream
@@ -355,7 +386,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual unsigned short readUnsignedShort() const throw ( cms::CMSException ) = 0;
+        virtual unsigned short readUnsignedShort() const throw ( cms::MessageEOFException,
+                                                                 cms::MessageNotReadableException,
+                                                                 cms::CMSException ) = 0;
 
         /**
          * Writes a unsigned short to the bytes message stream as a 2 byte value
@@ -367,7 +400,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeUnsignedShort( unsigned short value ) throw ( cms::CMSException ) = 0;
+        virtual void writeUnsignedShort( unsigned short value )
+            throw ( cms::MessageNotWriteableException, cms::CMSException ) = 0;
 
         /**
          * Reads a 32 bit signed integer from the Bytes message stream
@@ -379,7 +413,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual int readInt() const throw ( cms::CMSException ) = 0;
+        virtual int readInt() const throw ( cms::MessageEOFException,
+                                            cms::MessageNotReadableException,
+                                            cms::CMSException ) = 0;
 
         /**
          * Writes a signed int to the bytes message stream as a 4 byte value
@@ -391,7 +427,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeInt( int value ) throw ( cms::CMSException ) = 0;
+        virtual void writeInt( int value ) throw ( cms::MessageNotWriteableException,
+                                                   cms::CMSException ) = 0;
 
         /**
          * Reads a 64 bit long from the Bytes message stream
@@ -403,7 +440,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual long long readLong() const throw ( cms::CMSException ) = 0;
+        virtual long long readLong() const throw ( cms::MessageEOFException,
+                                                   cms::MessageNotReadableException,
+                                                   cms::CMSException ) = 0;
 
         /**
          * Writes a long long to the bytes message stream as a 8 byte value
@@ -415,7 +454,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeLong( long long value ) throw ( cms::CMSException ) = 0;
+        virtual void writeLong( long long value ) throw ( cms::MessageNotWriteableException,
+                                                          cms::CMSException ) = 0;
 
         /**
          * Reads an ASCII String from the Bytes message stream
@@ -427,7 +467,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual std::string readString() const throw ( cms::CMSException ) = 0;
+        virtual std::string readString() const throw ( cms::MessageEOFException,
+                                                       cms::MessageNotReadableException,
+                                                       cms::CMSException ) = 0;
 
         /**
          * Writes an ASCII String to the Bytes message stream
@@ -439,7 +481,8 @@
          *                        some internal error.
          * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
-        virtual void writeString( const std::string& value ) throw ( cms::CMSException ) = 0;
+        virtual void writeString( const std::string& value )
+            throw ( cms::MessageNotWriteableException, cms::CMSException ) = 0;
 
         /**
          * Reads an UTF String from the BytesMessage stream
@@ -451,7 +494,9 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual std::string readUTF() const throw ( cms::CMSException ) = 0;
+        virtual std::string readUTF() const throw ( cms::MessageEOFException,
+                                                    cms::MessageNotReadableException,
+                                                    cms::CMSException ) = 0;
 
         /**
          * Writes an UTF String to the BytesMessage stream
@@ -464,7 +509,8 @@
          * @throws MessageEOFException - if unexpected end of bytes stream has been reached.
          * @throws MessageNotReadableException - if the message is in write-only mode.
          */
-        virtual void writeUTF( const std::string& value ) throw ( cms::CMSException ) = 0;
+        virtual void writeUTF( const std::string& value )
+            throw ( cms::MessageNotWriteableException, cms::CMSException ) = 0;
 
         /**
          * Clones this message.