activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r775980 [2/4] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/activemq/cmsutil/ main/activemq/commands/ main/activemq/core/ main/activemq/transport/mock/ main/activemq/wireformat/openwire/ main/activemq/wireformat/stomp/ main...
Date Mon, 18 May 2009 15:13:33 GMT
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQSession.h Mon May 18 15:13:29 2009
@@ -201,6 +201,28 @@
         virtual void rollback() throw ( cms::CMSException );
 
         /**
+         * Stops message delivery in this session, and restarts message delivery with the
+         * oldest unacknowledged message.
+         *
+         * All consumers deliver messages in a serial order. Acknowledging a received message
+         * automatically acknowledges all messages that have been delivered to the client.
+         *
+         * Restarting a session causes it to take the following actions:
+         *
+         *  - Stop message delivery
+         *  - Mark all messages that might have been delivered but not acknowledged
+         *    as "redelivered"
+         *  - Restart the delivery sequence including all unacknowledged messages that had
+         *    been previously delivered.  Redelivered messages do not have to be delivered in
+         *    exactly their original delivery order.
+         *
+         * @throws CMSException - if the CMS provider fails to stop and restart message
+         *                        delivery due to some internal error.
+         * @throws IllegalStateException - if the method is called by a transacted session.
+         */
+        virtual void recover() throw( cms::CMSException );
+
+        /**
          * Creates a MessageConsumer for the specified destination.
          * @param the Destination that this consumer receiving messages for.
          * @throws CMSException
@@ -263,6 +285,34 @@
                 throw ( cms::CMSException );
 
         /**
+         * Creates a new QueueBrowser to peek at Messages on the given Queue.
+         *
+         * @param queue
+         *      the Queue to browse
+         * @return New QueueBrowser that is owned by the caller.
+         *
+         * @throws CMSException - If an internal error occurs.
+         * @throws InvalidDestinationException - if the destination given is invalid.
+         */
+        virtual cms::QueueBrowser* createBrowser( const cms::Queue* queue )
+            throw( cms::CMSException );
+
+        /**
+         * Creates a new QueueBrowser to peek at Messages on the given Queue.
+         *
+         * @param queue
+         *      the Queue to browse
+         * @param selector
+         *      the Message selector to filter which messages are browsed.
+         * @return New QueueBrowser that is owned by the caller.
+         *
+         * @throws CMSException - If an internal error occurs.
+         * @throws InvalidDestinationException - if the destination given is invalid.
+         */
+        virtual cms::QueueBrowser* createBrowser( const cms::Queue* queue, const std::string& selector )
+            throw( cms::CMSException );
+
+        /**
          * Creates a queue identity given a Queue name.
          * @param the name of the new Queue
          * @throws CMSException
@@ -349,13 +399,13 @@
          * Returns the acknowledgment mode of the session.
          * @return the Sessions Acknowledge Mode
          */
-        virtual cms::Session::AcknowledgeMode getAcknowledgeMode() const;
+        virtual cms::Session::AcknowledgeMode getAcknowledgeMode() const throw ( cms::CMSException );
 
         /**
          * Gets if the Sessions is a Transacted Session
          * @return transacted true - false.
          */
-        virtual bool isTransacted() const;
+        virtual bool isTransacted() const throw ( cms::CMSException );
 
         /**
          * Unsubscribes a durable subscription that has been created by a

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/mock/MockTransportFactory.cpp Mon May 18 15:13:29 2009
@@ -18,7 +18,6 @@
 #include <activemq/transport/mock/MockTransportFactory.h>
 #include <activemq/transport/correlator/ResponseCorrelator.h>
 #include <activemq/transport/logging/LoggingTransport.h>
-//#include <activemq/wireformat/stomp/StompResponseBuilder.h>
 #include <activemq/wireformat/openwire/OpenWireResponseBuilder.h>
 #include <activemq/transport/Transport.h>
 #include <activemq/transport/mock/MockTransport.h>
@@ -110,10 +109,12 @@
 
         Pointer<ResponseBuilder> builder;
 
-        if( wireFormatName == "stomp" ) {
-//            builder.reset( new wireformat::stomp::StompResponseBuilder() );
-        } else if( wireFormatName == "openwire" ) {
+        if( wireFormatName == "openwire" || wireFormatName == "stomp" ) {
             builder.reset( new wireformat::openwire::OpenWireResponseBuilder() );
+        } else {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "No Response Builder known for this Wireformat, can't create a Mock." );
         }
 
         Pointer<MockTransport> transport( new MockTransport( wireFormat, builder ) );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/openwire/OpenWireFormat.cpp Mon May 18 15:13:29 2009
@@ -165,6 +165,11 @@
 
     try {
 
+        if( transport == NULL ) {
+            throw decaf::io::IOException(
+                __FILE__, __LINE__, "Transport passed is NULL" );
+        }
+
         if( dataOut == NULL ) {
             throw decaf::io::IOException(
                 __FILE__, __LINE__, "DataOutputStream passed is NULL" );

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.cpp Mon May 18 15:13:29 2009
@@ -20,13 +20,19 @@
 #include <string>
 
 #include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/Character.h>
+#include <decaf/lang/Integer.h>
+
 #include <activemq/wireformat/stomp/StompCommandConstants.h>
+#include <activemq/exceptions/ActiveMQException.h>
 
 using namespace std;
 using namespace activemq;
+using namespace activemq::exceptions;
 using namespace activemq::wireformat;
 using namespace activemq::wireformat::stomp;
 using namespace decaf;
+using namespace decaf::io;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
@@ -58,7 +64,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void StompFrame::toStream( decaf::io::OutputStream* stream ) const {
+void StompFrame::toStream( decaf::io::DataOutputStream* stream ) const
+    throw( decaf::io::IOException ) {
 
     if( stream == NULL ) {
         throw NullPointerException(
@@ -102,3 +109,230 @@
     // Flush the stream.
     stream->flush();
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void StompFrame::fromStream( decaf::io::DataInputStream* in )
+    throw ( decaf::io::IOException ) {
+
+    if( in == NULL ) {
+        throw decaf::io::IOException(
+            __FILE__, __LINE__, "DataInputStream passed is NULL" );
+    }
+
+    try{
+
+        // Read the command header.
+        readCommandHeader( in );
+
+        // Read the headers.
+        readHeaders( in );
+
+        // Read the body.
+        readBody( in );
+    }
+    AMQ_CATCH_RETHROW( decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
+    AMQ_CATCHALL_THROW( decaf::io::IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompFrame::readCommandHeader( decaf::io::DataInputStream* in )
+   throw ( decaf::io::IOException ) {
+
+    try{
+
+        std::vector<unsigned char> buffer;
+
+        while( true ) {
+
+            // The command header is formatted just like any other stomp header.
+            readHeaderLine( buffer, in );
+
+            // Ignore all white space before the command.
+            long long offset = -1;
+            for( size_t ix = 0; ix < buffer.size()-1; ++ix ) {
+
+                // Find the first non whitespace character
+                if( !Character::isWhitespace( buffer[ix] ) ){
+                    offset = (long long)ix;
+                    break;
+                }
+            }
+
+            if( offset >= 0 ) {
+                // Set the command in the frame - copy the memory.
+                this->setCommand( reinterpret_cast<char*>( &buffer[(size_t)offset] ) );
+                break;
+            }
+        }
+    }
+    AMQ_CATCH_RETHROW( decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
+    AMQ_CATCHALL_THROW( decaf::io::IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompFrame::readHeaders( decaf::io::DataInputStream* in )
+    throw ( decaf::io::IOException ) {
+
+    try{
+
+        // Read the command;
+        bool endOfHeaders = false;
+        std::vector<unsigned char> buffer;
+
+        while( !endOfHeaders ) {
+
+            // Read in the next header line.
+            std::size_t numChars = readHeaderLine( buffer, in );
+
+            if( numChars == 0 ) {
+
+                // should never get here
+                throw decaf::io::IOException(
+                    __FILE__, __LINE__,
+                    "StompWireFormat::readStompHeaders: no characters read" );
+            }
+
+            // Check for an empty line to demark the end of the header section.
+            // if its not the end then we have a header to process, so parse it.
+            if( numChars == 1 && buffer[0] == '\0' ) {
+
+                endOfHeaders = true;
+
+            } else {
+
+                // Search through this line to separate the key/value pair.
+                for( size_t ix = 0; ix < buffer.size(); ++ix ) {
+
+                    // If found the key/value separator...
+                    if( buffer[ix] == ':' ) {
+
+                        // Null-terminate the key.
+                        buffer[ix] = '\0';
+
+                        const char* key = reinterpret_cast<char*>( &buffer[0] );
+                        const char* value = reinterpret_cast<char*>( &buffer[ix+1] );
+
+                        // Assign the header key/value pair.
+                        this->getProperties().setProperty( key, value );
+
+                        // Break out of the for loop.
+                        break;
+                    }
+                }
+            }
+        }
+    }
+    AMQ_CATCH_RETHROW( decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
+    AMQ_CATCHALL_THROW( decaf::io::IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::size_t StompFrame::readHeaderLine( std::vector<unsigned char>& buffer,
+                                        decaf::io::DataInputStream* in )
+    throw ( decaf::io::IOException ) {
+
+    try{
+
+        // Clear any data from the buffer.
+        buffer.clear();
+
+        std::size_t count = 0;
+
+        while( true ) {
+
+            // Read the next char from the stream.
+            buffer.push_back( in->readByte() );
+
+            // Increment the position pointer.
+            count++;
+
+            // If we reached the line terminator, return the total number
+            // of characters read.
+            if( buffer[count-1] == '\n' ) {
+                // Overwrite the line feed with a null character.
+                buffer[count-1] = '\0';
+                return count;
+            }
+        }
+
+        // If we get here something bad must have happened.
+        throw decaf::io::IOException(
+            __FILE__, __LINE__,
+            "StompWireFormat::readStompHeaderLine: "
+            "Unrecoverable, error condition");
+    }
+    AMQ_CATCH_RETHROW( decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
+    AMQ_CATCHALL_THROW( decaf::io::IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompFrame::readBody( decaf::io::DataInputStream* in )
+   throw ( decaf::io::IOException ) {
+
+    try{
+
+        // Clear any data from the body.
+        this->body.clear();
+
+        unsigned int content_length = 0;
+
+        if( this->hasProperty( StompCommandConstants::HEADER_CONTENTLENGTH ) ) {
+            string length = this->getProperty( StompCommandConstants::HEADER_CONTENTLENGTH );
+            content_length = (unsigned int)Integer::parseInt( length );
+         }
+
+         if( content_length != 0 ) {
+            // For this case its assumed that content length indicates how
+            // much to read.  We reserve space in the buffer for it to
+            // minimize the number of reallocs that might occur.  We are
+            // assuming that content length doesn't count the trailing null
+            // that indicates the end of frame.  The reserve won't do anything
+            // if the buffer already has that much capacity.  The resize call
+            // basically sets the end iterator to the correct location since
+            // this is a char vector and we already reserve enough space.
+            // Resize doesn't realloc the vector smaller if content_length
+            // is less than capacity of the buffer, it just move the end
+            // iterator.  Reserve adds the benefit that the mem is set to
+            // zero.
+
+            this->body.reserve( (std::size_t)content_length );
+            this->body.resize( (std::size_t)content_length );
+
+            // Read the Content Length now
+            in->read( &body[0], 0, content_length );
+
+            // Content Length read, now pop the end terminator off (\0\n).
+            if( in->readByte() != '\0' ) {
+
+                throw decaf::io::IOException(
+                    __FILE__, __LINE__,
+                    "StompWireFormat::readStompBody: "
+                    "Read Content Length, and no trailing null");
+            }
+
+        } else {
+
+            // Content length was either zero, or not set, so we read until the
+            // first null is encountered.
+            while( true ) {
+
+                char byte = in->readByte();
+
+                this->body.push_back( byte );
+
+                if( byte != '\0' ) {
+                    continue;
+                }
+
+                break;  // Read null and newline we are done.
+            }
+        }
+    }
+    AMQ_CATCH_RETHROW( decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
+    AMQ_CATCHALL_THROW( decaf::io::IOException )
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.h Mon May 18 15:13:29 2009
@@ -22,7 +22,8 @@
 #include <string.h>
 #include <map>
 #include <decaf/util/Properties.h>
-#include <decaf/io/OutputStream.h>
+#include <decaf/io/DataOutputStream.h>
+#include <decaf/io/DataInputStream.h>
 #include <activemq/util/Config.h>
 
 namespace activemq{
@@ -165,11 +166,61 @@
         void setBody( const unsigned char* bytes, std::size_t numBytes );
 
         /**
-         * Writes this Frame to an OuputStream in the Stomp Frame Format.
+         * Writes this Frame to an OuputStream in the Stomp Wire Format.
          *
          * @param stream - The stream to write the Frame to.
+         *
+         * @throw IOException if an error occurs while reading the Frame.
+         */
+        void toStream( decaf::io::DataOutputStream* stream ) const
+            throw ( decaf::io::IOException );
+
+        /**
+         * Reads a Stop Frame from a DataInputStream in the Stomp Wire format.
+         *
+         * @param stream - The stream to read the Frame from.
+         *
+         * @throw IOException if an error occurs while writing the Frame.
+         */
+        void fromStream( decaf::io::DataInputStream* stream )
+            throw ( decaf::io::IOException );
+
+    private:
+
+        /**
+         * Read the Stomp Command from the Frame
+         * @param in - The stream to read the Frame from.
+         * @throws IOException
+         */
+        void readCommandHeader( decaf::io::DataInputStream* in )
+            throw ( decaf::io::IOException );
+
+        /**
+         * Read all the Stomp Headers for the incoming Frame
+         * @param in - The stream to read the Frame from.
+         * @throws IOException
+         */
+        void readHeaders( decaf::io::DataInputStream* in )
+            throw ( decaf::io::IOException );
+
+        /**
+         * Reads a Stomp Header line and stores it in the buffer object
+         * @param buffer - reference to a memory buffer to store the read line in.
+         * @param in - The stream to read the Frame from.
+         * @return number of bytes read, zero if there was a problem.
+         * @throws IOException
+         */
+        std::size_t readHeaderLine( std::vector<unsigned char>& buffer,
+                                    decaf::io::DataInputStream* in )
+            throw ( decaf::io::IOException );
+
+        /**
+         * Reads the Stomp Body from the Wire and store it in the frame.
+         * @param in - The stream to read the Frame from.
+         * @throws IOException
          */
-        void toStream( decaf::io::OutputStream* stream ) const;
+        void readBody( decaf::io::DataInputStream* in )
+            throw ( decaf::io::IOException );
 
     };
 

Copied: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompHelper.cpp (from r774862, activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/MarshalerHelper.cpp)
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompHelper.cpp?p2=activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompHelper.cpp&p1=activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/MarshalerHelper.cpp&r1=774862&r2=775980&rev=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/MarshalerHelper.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompHelper.cpp Mon May 18 15:13:29 2009
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-#include "MarshalerHelper.h"
+#include "StompHelper.h"
 
 #include <activemq/wireformat/stomp/StompCommandConstants.h>
 #include <activemq/commands/LocalTransactionId.h>
@@ -30,13 +30,12 @@
 using namespace activemq::commands;
 using namespace activemq::wireformat;
 using namespace activemq::wireformat::stomp;
-using namespace activemq::wireformat::stomp::marshal;
 using namespace decaf;
 using namespace decaf::lang;
 using namespace decaf::util;
 
 ////////////////////////////////////////////////////////////////////////////////
-void MarshalerHelper::convertProperties( const Pointer<StompFrame>& frame,
+void StompHelper::convertProperties( const Pointer<StompFrame>& frame,
                                          const Pointer<Message>& message ) {
 
     const std::string destination =
@@ -103,7 +102,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void MarshalerHelper::convertProperties( const Pointer<Message>& message,
+void StompHelper::convertProperties( const Pointer<Message>& message,
                                          const Pointer<StompFrame>& frame ) {
 
     frame->setProperty( StompCommandConstants::HEADER_DESTINATION,
@@ -163,7 +162,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string MarshalerHelper::convertDestination( const Pointer<ActiveMQDestination>& destination ) {
+std::string StompHelper::convertDestination( const Pointer<ActiveMQDestination>& destination ) {
 
     if( destination == NULL ) {
         return "";
@@ -196,7 +195,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Pointer<ActiveMQDestination> MarshalerHelper::convertDestination( const std::string& destination ) {
+Pointer<ActiveMQDestination> StompHelper::convertDestination( const std::string& destination ) {
 
     if( destination == "" ) {
         return Pointer<ActiveMQDestination>();
@@ -227,7 +226,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string MarshalerHelper::convertMessageId( const Pointer<MessageId>& messageId ) {
+std::string StompHelper::convertMessageId( const Pointer<MessageId>& messageId ) {
 
     // The Stomp MessageId is always hidden solely in the Producer Id.
     std::string result = convertProducerId( messageId->getProducerId() );
@@ -236,7 +235,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Pointer<MessageId> MarshalerHelper::convertMessageId( const std::string& messageId ) {
+Pointer<MessageId> StompHelper::convertMessageId( const std::string& messageId ) {
 
     if( messageId == "" ) {
         return Pointer<MessageId>();
@@ -251,7 +250,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string MarshalerHelper::convertConsumerId( const Pointer<ConsumerId>& consumerId ) {
+std::string StompHelper::convertConsumerId( const Pointer<ConsumerId>& consumerId ) {
 
     return consumerId->getConnectionId() + ":" +
            Long::toString( consumerId->getSessionId() ) + ":" +
@@ -259,7 +258,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Pointer<ConsumerId> MarshalerHelper::convertConsumerId( const std::string& consumerId ) {
+Pointer<ConsumerId> StompHelper::convertConsumerId( const std::string& consumerId ) {
 
     if( consumerId == "" ) {
         return Pointer<ConsumerId>();
@@ -284,13 +283,13 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string MarshalerHelper::convertProducerId( const Pointer<ProducerId>& producerId ) {
+std::string StompHelper::convertProducerId( const Pointer<ProducerId>& producerId ) {
 
     return producerId->getConnectionId();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Pointer<ProducerId> MarshalerHelper::convertProducerId( const std::string& producerId ) {
+Pointer<ProducerId> StompHelper::convertProducerId( const std::string& producerId ) {
 
     if( producerId == "" ) {
         return Pointer<ProducerId>();
@@ -306,7 +305,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string MarshalerHelper::convertTransactionId( const Pointer<TransactionId>& transactionId ) {
+std::string StompHelper::convertTransactionId( const Pointer<TransactionId>& transactionId ) {
 
     Pointer<LocalTransactionId> id = transactionId.dynamicCast<LocalTransactionId>();
     std::string result = id->getConnectionId()->getValue() + ":" + Long::toString( id->getValue() );
@@ -314,7 +313,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Pointer<TransactionId> MarshalerHelper::convertTransactionId( const std::string& transactionId ) {
+Pointer<TransactionId> StompHelper::convertTransactionId( const std::string& transactionId ) {
 
     if( transactionId == "" ) {
         return Pointer<TransactionId>();

Copied: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompHelper.h (from r774862, activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/MarshalerHelper.h)
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompHelper.h?p2=activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompHelper.h&p1=activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/MarshalerHelper.h&r1=774862&r2=775980&rev=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/MarshalerHelper.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompHelper.h Mon May 18 15:13:29 2009
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-#ifndef _ACTIVEMQ_WIREFORMAT_STOMP_MARSHAL_MARSHALERHELPER_H_
-#define _ACTIVEMQ_WIREFORMAT_STOMP_MARSHAL_MARSHALERHELPER_H_
+#ifndef _ACTIVEMQ_WIREFORMAT_STOMP_MARSHAL_STOMPHELPER_H_
+#define _ACTIVEMQ_WIREFORMAT_STOMP_MARSHAL_STOMPHELPER_H_
 
 #include <activemq/util/Config.h>
 #include <activemq/util/LongSequenceGenerator.h>
@@ -32,7 +32,6 @@
 namespace activemq {
 namespace wireformat {
 namespace stomp {
-namespace marshal {
 
     using decaf::lang::Pointer;
     using activemq::commands::Message;
@@ -47,15 +46,15 @@
      *
      * @since 3.0
      */
-    class MarshalerHelper {
+    class StompHelper {
     private:
 
         activemq::util::LongSequenceGenerator messageIdGenerator;
 
     public:
 
-        MarshalerHelper() {}
-        virtual ~MarshalerHelper() {}
+        StompHelper() {}
+        virtual ~StompHelper() {}
 
         /**
          * Converts the Headers in a Stomp Frame into Headers in the given Message
@@ -157,6 +156,6 @@
 
     };
 
-}}}}
+}}}
 
-#endif /* _ACTIVEMQ_WIREFORMAT_STOMP_MARSHAL_MARSHALERHELPER_H_ */
+#endif /* _ACTIVEMQ_WIREFORMAT_STOMP_MARSHAL_STOMPHELPER_H_ */

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp Mon May 18 15:13:29 2009
@@ -19,15 +19,40 @@
 
 #include <activemq/wireformat/stomp/StompFrame.h>
 #include <activemq/wireformat/stomp/StompCommandConstants.h>
+#include <activemq/core/ActiveMQConstants.h>
 #include <activemq/commands/Response.h>
+#include <activemq/commands/ActiveMQMessage.h>
+#include <activemq/commands/ActiveMQTextMessage.h>
+#include <activemq/commands/ActiveMQBytesMessage.h>
+#include <activemq/commands/Response.h>
+#include <activemq/commands/BrokerError.h>
+#include <activemq/commands/MessageAck.h>
+#include <activemq/commands/MessageDispatch.h>
+#include <activemq/commands/ConnectionInfo.h>
+#include <activemq/commands/ConsumerId.h>
+#include <activemq/commands/ExceptionResponse.h>
+#include <activemq/commands/ShutdownInfo.h>
+#include <activemq/commands/RemoveInfo.h>
+#include <activemq/commands/TransactionInfo.h>
+#include <activemq/commands/LocalTransactionId.h>
+#include <activemq/commands/ProducerInfo.h>
+#include <activemq/commands/ConsumerInfo.h>
+#include <activemq/commands/RemoveSubscriptionInfo.h>
+
 #include <decaf/lang/Character.h>
 #include <decaf/lang/Integer.h>
+#include <decaf/lang/Boolean.h>
+#include <decaf/lang/Long.h>
+#include <decaf/lang/exceptions/ClassCastException.h>
 #include <decaf/io/IOException.h>
+#include <decaf/io/ByteArrayOutputStream.h>
+#include <decaf/io/DataOutputStream.h>
 #include <memory>
 
 using namespace std;
 using namespace activemq;
 using namespace activemq::commands;
+using namespace activemq::core;
 using namespace activemq::wireformat;
 using namespace activemq::wireformat::stomp;
 using namespace decaf;
@@ -58,7 +83,25 @@
                 "output stream is NULL" );
         }
 
-        Pointer<StompFrame> frame = marshaler.marshal( command );
+        Pointer<StompFrame> frame;
+
+        if( command->isMessage() ) {
+            frame = this->marshalMessage( command );
+        } else if( command->isRemoveInfo() ) {
+            frame = this->marshalRemoveInfo( command );
+        } else if( command->isShutdownInfo() ) {
+            frame = this->marshalShutdownInfo( command );
+        } else if( command->isMessageAck() ) {
+            frame = this->marshalAck( command );
+        } else if( command->isConnectionInfo() ) {
+            frame = this->marshalConnectionInfo( command );
+        } else if( command->isTransactionInfo() ) {
+            frame = this->marshalTransactionInfo( command );
+        } else if( command->isConsumerInfo() ) {
+            frame = this->marshalConsumerInfo( command );
+        } else if( command->isRemoveSubscriptionInfo() ) {
+            frame = this->marshalRemoveSubscriptionInfo( command );
+        }
 
         // Some commands just don't translate to Stomp Commands, unless they require
         // a response we can just ignore them.
@@ -90,6 +133,16 @@
                                              decaf::io::DataInputStream* in )
     throw ( decaf::io::IOException ) {
 
+    if( transport == NULL ) {
+        throw decaf::io::IOException(
+            __FILE__, __LINE__, "Transport passed is NULL" );
+    }
+
+    if( in == NULL ) {
+        throw decaf::io::IOException(
+            __FILE__, __LINE__, "DataInputStream passed is NULL" );
+    }
+
     Pointer<StompFrame> frame;
 
     try{
@@ -98,16 +151,25 @@
         frame.reset( new StompFrame() );
 
         // Read the command header.
-        readStompCommandHeader( frame, in );
+        frame->fromStream( in );
 
-        // Read the headers.
-        readStompHeaders( frame, in );
+        // Return the Command.
+        const std::string commandId = frame->getCommand();
 
-        // Read the body.
-        readStompBody( frame, in );
+        if( commandId == StompCommandConstants::CONNECTED ){
+            return this->unmarshalConnected( frame );
+        } else if( commandId == StompCommandConstants::ERROR_CMD ){
+            return this->unmarshalError( frame );
+        } else if( commandId == StompCommandConstants::RECEIPT ){
+            return this->unmarshalReceipt( frame );
+        } else if( commandId == StompCommandConstants::MESSAGE ){
+            return this->unmarshalMessage( frame );
+        }
 
-        // Return the Command.
-        return marshaler.marshal( frame );
+        // We didn't seem to know what it was we got, so throw an exception.
+        throw decaf::io::IOException(
+            __FILE__, __LINE__,
+            "StompWireFormat::marshal - No Command Created from frame" );
     }
     AMQ_CATCH_RETHROW( decaf::io::IOException )
     AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
@@ -124,209 +186,341 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void StompWireFormat::readStompCommandHeader( Pointer<StompFrame>& frame, decaf::io::DataInputStream* in )
-   throw ( decaf::io::IOException ) {
+Pointer<Command> StompWireFormat::unmarshalMessage( const Pointer<StompFrame>& frame ) {
 
-    try{
-
-        while( true ) {
+    Pointer<MessageDispatch> messageDispatch( new MessageDispatch() );
 
-            // The command header is formatted
-            // just like any other stomp header.
-            readStompHeaderLine( in );
-
-            // Ignore all white space before the command.
-            long long offset = -1;
-            for( size_t ix = 0; ix < buffer.size()-1; ++ix ) {
-
-                // Find the first non whitespace character
-                if( !Character::isWhitespace( buffer[ix] ) ){
-                    offset = (long long)ix;
-                    break;
-                }
-            }
+    // We created a unique id when we registered the subscription for the consumer
+    // now extract it back to a consumer Id so the ActiveMQConnection can dispatch it
+    // correctly.
+    Pointer<ConsumerId> consumerId = helper.convertConsumerId(
+        frame->removeProperty( StompCommandConstants::HEADER_SUBSCRIPTION ) );
+    messageDispatch->setConsumerId( consumerId );
+
+    if( frame->hasProperty( StompCommandConstants::HEADER_CONTENTLENGTH ) ) {
+
+        Pointer<ActiveMQBytesMessage> message( new ActiveMQBytesMessage() );
+        frame->removeProperty( StompCommandConstants::HEADER_CONTENTLENGTH );
+        helper.convertProperties( frame, message );
+        message->setContent( frame->getBody() );
+        messageDispatch->setMessage( message );
+        messageDispatch->setDestination( message->getDestination() );
+
+    } else {
+
+        Pointer<ActiveMQTextMessage> message( new ActiveMQTextMessage() );
+        helper.convertProperties( frame, message );
+        message->setText( (char*)&(frame->getBody()[0]) );
+        messageDispatch->setMessage( message );
+        messageDispatch->setDestination( message->getDestination() );
 
-            if( offset >= 0 ) {
-                // Set the command in the frame - copy the memory.
-                frame->setCommand( reinterpret_cast<char*>( &buffer[(size_t)offset] ) );
-                break;
-            }
-        }
     }
-    AMQ_CATCH_RETHROW( decaf::io::IOException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
-    AMQ_CATCHALL_THROW( decaf::io::IOException )
+
+    return messageDispatch;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void StompWireFormat::readStompHeaders( Pointer<StompFrame>& frame, decaf::io::DataInputStream* in )
-    throw ( decaf::io::IOException ) {
+Pointer<Command> StompWireFormat::unmarshalReceipt( const Pointer<StompFrame>& frame ){
 
-    try{
+    Pointer<Response> response( new Response() );
+    if( frame->hasProperty( StompCommandConstants::HEADER_RECEIPTID ) ) {
 
-        // Read the command;
-        bool endOfHeaders = false;
+        std::string responseId = frame->getProperty( StompCommandConstants::HEADER_RECEIPTID );
+        if( responseId.find( "ignore:" ) == 0 ) {
+            responseId = responseId.substr( 7 );
+        }
 
-        while( !endOfHeaders ) {
+        response->setCorrelationId( Integer::parseInt( responseId ) );
+    } else {
+        throw IOException(
+            __FILE__, __LINE__, "Error, Connected Command has no Response ID." );
+    }
 
-            // Read in the next header line.
-            std::size_t numChars = readStompHeaderLine( in );
+    return response;
+}
 
-            if( numChars == 0 ) {
+////////////////////////////////////////////////////////////////////////////////
+Pointer<Command> StompWireFormat::unmarshalConnected( const Pointer<StompFrame>& frame ) {
 
-                // should never get here
-                throw decaf::io::IOException(
-                    __FILE__, __LINE__,
-                    "StompWireFormat::readStompHeaders: no characters read" );
-            }
+    Pointer<Response> response( new Response() );
+    if( frame->hasProperty( StompCommandConstants::HEADER_RESPONSEID ) ) {
+        response->setCorrelationId( Integer::parseInt(
+            frame->getProperty( StompCommandConstants::HEADER_RESPONSEID ) ) );
+    } else {
+        throw IOException(
+            __FILE__, __LINE__, "Error, Connected Command has no Response ID." );
+    }
 
-            // Check for an empty line to demark the end of the header section.
-            // if its not the end then we have a header to process, so parse it.
-            if( numChars == 1 && buffer[0] == '\0' ) {
+    return response;
+}
 
-                endOfHeaders = true;
+////////////////////////////////////////////////////////////////////////////////
+Pointer<Command> StompWireFormat::unmarshalError( const Pointer<StompFrame>& frame ) {
 
-            } else {
+    Pointer<BrokerError> error( new BrokerError() );
+    error->setMessage(
+        frame->removeProperty( StompCommandConstants::HEADER_MESSAGE ) );
 
-                // Search through this line to separate the key/value pair.
-                for( size_t ix = 0; ix < buffer.size(); ++ix ) {
+    if( frame->hasProperty( StompCommandConstants::HEADER_RECEIPTID ) ) {
 
-                    // If found the key/value separator...
-                    if( buffer[ix] == ':' ) {
+        std::string responseId = frame->removeProperty( StompCommandConstants::HEADER_RECEIPTID );
 
-                        // Null-terminate the key.
-                        buffer[ix] = '\0';
+        // If we indicated that we don't care if the request failed then just create a
+        // response command to answer the request.
+        if( responseId.find( "ignore:" ) == 0 ) {
 
-                        const char* key = reinterpret_cast<char*>( &buffer[0] );
-                        const char* value = reinterpret_cast<char*>( &buffer[ix+1] );
+            Pointer<Response> response( new Response() );
+            response->setCorrelationId( Integer::parseInt( responseId.substr( 7 ) ) );
+            return response;
 
-                        // Assign the header key/value pair.
-                        frame->getProperties().setProperty( key, value );
+        } else {
 
-                        // Break out of the for loop.
-                        break;
-                    }
-                }
-            }
+            Pointer<ExceptionResponse> errorResponse( new ExceptionResponse() );
+            errorResponse->setException( error );
+            errorResponse->setCorrelationId( Integer::parseInt( responseId ) );
+            return errorResponse;
         }
+
+    } else {
+        return error;
     }
-    AMQ_CATCH_RETHROW( decaf::io::IOException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
-    AMQ_CATCHALL_THROW( decaf::io::IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::size_t StompWireFormat::readStompHeaderLine( decaf::io::DataInputStream* in )
-    throw ( decaf::io::IOException ) {
+Pointer<StompFrame> StompWireFormat::marshalMessage( const Pointer<Command>& command ) {
+
+    Pointer<Message> message = command.dynamicCast<Message>();
+
+    Pointer<StompFrame> frame( new StompFrame() );
+    frame->setCommand( StompCommandConstants::SEND );
 
+    if( command->isResponseRequired() ) {
+        frame->setProperty( StompCommandConstants::HEADER_RECEIPT_REQUIRED,
+                            Integer::toString( command->getCommandId() ) );
+    }
+
+    // Convert the standard headers to the Stomp Format.
+    helper.convertProperties( message, frame );
+
+    // Convert the Content
     try{
+        Pointer<ActiveMQTextMessage> txtMessage = message.dynamicCast<ActiveMQTextMessage>();
+        std::string text = txtMessage->getText();
+        frame->setBody( (unsigned char*)text.c_str(), text.length() + 1 );
+        return frame;
+    } catch( ClassCastException& ex ) {}
 
-        // Clear any data from the buffer.
-        buffer.clear();
+    try{
+        Pointer<ActiveMQBytesMessage> bytesMessage = message.dynamicCast<ActiveMQBytesMessage>();
+        frame->setBody( bytesMessage->getBodyBytes(), bytesMessage->getBodyLength() );
+        frame->setProperty( StompCommandConstants::HEADER_CONTENTLENGTH,
+                            Long::toString( bytesMessage->getBodyLength() ) );
+        return frame;
+    } catch( ClassCastException& ex ) {}
+
+    throw UnsupportedOperationException(
+        __FILE__, __LINE__,
+        "Stomp StompWireFormat can't marshal message of type: %s",
+        typeid( message.get() ).name() );
+}
 
-        std::size_t count = 0;
+////////////////////////////////////////////////////////////////////////////////
+Pointer<StompFrame> StompWireFormat::marshalAck( const Pointer<Command>& command ) {
 
-        while( true ) {
+    Pointer<MessageAck> ack = command.dynamicCast<MessageAck>();
 
-            // Read the next char from the stream.
-            buffer.push_back( in->readByte() );
+    Pointer<StompFrame> frame( new StompFrame() );
+    frame->setCommand( StompCommandConstants::ACK );
 
-            // Increment the position pointer.
-            count++;
+    if( command->isResponseRequired() ) {
+        frame->setProperty( StompCommandConstants::HEADER_RECEIPT_REQUIRED,
+                            std::string( "ignore:" ) + Integer::toString( command->getCommandId() ) );
+    }
 
-            // If we reached the line terminator, return the total number
-            // of characters read.
-            if( buffer[count-1] == '\n' ) {
-                // Overwrite the line feed with a null character.
-                buffer[count-1] = '\0';
-                return count;
-            }
-        }
+    frame->setProperty( StompCommandConstants::HEADER_MESSAGEID,
+                        helper.convertMessageId( ack->getLastMessageId() ) );
 
-        // If we get here something bad must have happened.
-        throw decaf::io::IOException(
-            __FILE__, __LINE__,
-            "StompWireFormat::readStompHeaderLine: "
-            "Unrecoverable, error condition");
+    if( ack->getTransactionId() != NULL ) {
+        frame->setProperty( StompCommandConstants::HEADER_TRANSACTIONID,
+                            helper.convertTransactionId( ack->getTransactionId() ) );
     }
-    AMQ_CATCH_RETHROW( decaf::io::IOException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
-    AMQ_CATCHALL_THROW( decaf::io::IOException )
+
+    return frame;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void StompWireFormat::readStompBody( Pointer<StompFrame>& frame, decaf::io::DataInputStream* in )
-   throw ( decaf::io::IOException ) {
+Pointer<StompFrame> StompWireFormat::marshalConnectionInfo( const Pointer<Command>& command ) {
 
-    try{
+    Pointer<ConnectionInfo> info = command.dynamicCast<ConnectionInfo>();
 
-        // Clear any data from the buffer.
-        buffer.clear();
+    Pointer<StompFrame> frame( new StompFrame() );
+    frame->setCommand( StompCommandConstants::CONNECT );
+    frame->setProperty( StompCommandConstants::HEADER_CLIENT_ID, info->getClientId() );
+    frame->setProperty( StompCommandConstants::HEADER_LOGIN, info->getUserName() );
+    frame->setProperty( StompCommandConstants::HEADER_PASSWORD, info->getPassword() );
+    frame->setProperty( StompCommandConstants::HEADER_REQUESTID,
+                        Integer::toString( info->getCommandId() ) );
 
-        unsigned int content_length = 0;
+    // Store this for later.
+    this->clientId = info->getClientId();
 
-        if( frame->hasProperty( StompCommandConstants::HEADER_CONTENTLENGTH ) ) {
-            string length = frame->getProperty( StompCommandConstants::HEADER_CONTENTLENGTH );
-            content_length = (unsigned int)Integer::parseInt( length );
-         }
-
-         if( content_length != 0 ) {
-            // For this case its assumed that content length indicates how
-            // much to read.  We reserve space in the buffer for it to
-            // minimize the number of reallocs that might occur.  We are
-            // assuming that content length doesn't count the trailing null
-            // that indicates the end of frame.  The reserve won't do anything
-            // if the buffer already has that much capacity.  The resize call
-            // basically sets the end iterator to the correct location since
-            // this is a char vector and we already reserve enough space.
-            // Resize doesn't realloc the vector smaller if content_length
-            // is less than capacity of the buffer, it just move the end
-            // iterator.  Reserve adds the benefit that the mem is set to
-            // zero.  Over time as larger messages come in this will cause
-            // us to adapt to that size so that future messages that are
-            // around that size won't alloc any new memory.
-
-            buffer.reserve( (std::size_t)content_length );
-            buffer.resize( (std::size_t)content_length );
-
-            // Read the Content Length now
-            in->read( &buffer[0], 0, content_length );
-
-            // Content Length read, now pop the end terminator off (\0\n).
-            if( in->readByte() != '\0' ) {
-
-                throw decaf::io::IOException(
-                    __FILE__, __LINE__,
-                    "StompWireFormat::readStompBody: "
-                    "Read Content Length, and no trailing null");
-            }
+    return frame;
+}
 
-        } else {
+////////////////////////////////////////////////////////////////////////////////
+Pointer<StompFrame> StompWireFormat::marshalTransactionInfo( const Pointer<Command>& command ) {
 
-            // Content length was either zero, or not set, so we read until the
-            // first null is encountered.
-            while( true ) {
+    Pointer<TransactionInfo> info = command.dynamicCast<TransactionInfo>();
+    Pointer<LocalTransactionId> id = info->getTransactionId().dynamicCast<LocalTransactionId>();
 
-                char byte = in->readByte();
+    Pointer<StompFrame> frame( new StompFrame() );
 
-                buffer.push_back(byte);
+    if( info->getType() == ActiveMQConstants::TRANSACTION_STATE_BEGIN ) {
+        frame->setCommand( StompCommandConstants::BEGIN );
+    } else if( info->getType() == ActiveMQConstants::TRANSACTION_STATE_ROLLBACK ) {
+        frame->setCommand( StompCommandConstants::ABORT );
+    } else if( info->getType() == ActiveMQConstants::TRANSACTION_STATE_COMMITONEPHASE ) {
+        frame->setCommand( StompCommandConstants::COMMIT );
+    }
 
-                content_length++;
+    if( command->isResponseRequired() ) {
+        frame->setProperty( StompCommandConstants::HEADER_RECEIPT_REQUIRED,
+                            Integer::toString( command->getCommandId() ) );
+    }
 
-                if( byte != '\0' ) {
-                    continue;
-                }
+    frame->setProperty( StompCommandConstants::HEADER_TRANSACTIONID,
+                        helper.convertTransactionId( info->getTransactionId() ) );
 
-                break;  // Read null and newline we are done.
-            }
-        }
+    return frame;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Pointer<StompFrame> StompWireFormat::marshalShutdownInfo( const Pointer<Command>& command AMQCPP_UNUSED ) {
+
+    Pointer<StompFrame> frame( new StompFrame() );
+    frame->setCommand( StompCommandConstants::DISCONNECT );
+
+    if( command->isResponseRequired() ) {
+        frame->setProperty( StompCommandConstants::HEADER_RECEIPT_REQUIRED,
+                            Integer::toString( command->getCommandId() ) );
+    }
+
+    return frame;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Pointer<StompFrame> StompWireFormat::marshalRemoveInfo( const Pointer<Command>& command ) {
+
+    Pointer<RemoveInfo> info = command.dynamicCast<RemoveInfo>();
+    Pointer<StompFrame> frame( new StompFrame() );
+    frame->setCommand( StompCommandConstants::UNSUBSCRIBE );
+
+    if( command->isResponseRequired() ) {
+        frame->setProperty( StompCommandConstants::HEADER_RECEIPT_REQUIRED,
+                            Integer::toString( command->getCommandId() ) );
+    }
+
+    try{
+        Pointer<ConsumerId> id = info->getObjectId().dynamicCast<ConsumerId>();
+        frame->setProperty( StompCommandConstants::HEADER_ID, helper.convertConsumerId( id ) );
+        return frame;
+    } catch( ClassCastException& ex ) {}
+
+    return Pointer<StompFrame>();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Pointer<StompFrame> StompWireFormat::marshalConsumerInfo( const Pointer<Command>& command ) {
+
+    Pointer<ConsumerInfo> info = command.dynamicCast<ConsumerInfo>();
+
+    Pointer<StompFrame> frame( new StompFrame() );
+    frame->setCommand( StompCommandConstants::SUBSCRIBE );
 
-        if( content_length != 0 ) {
-            // Set the body contents in the frame - copy the memory
-            frame->getBody() = buffer;
+    if( command->isResponseRequired() ) {
+        frame->setProperty( StompCommandConstants::HEADER_RECEIPT_REQUIRED,
+                            Integer::toString( command->getCommandId() ) );
+    }
+
+    frame->setProperty( StompCommandConstants::HEADER_DESTINATION,
+                        helper.convertDestination( info->getDestination() ) );
+
+    // This creates a unique Id for this consumer using the connection id, session id and
+    // the consumers's id value, when we get a message this Id will be embedded in the
+    // Message's "subscription" property.
+    frame->setProperty( StompCommandConstants::HEADER_ID,
+                        helper.convertConsumerId( info->getConsumerId() ) );
+
+    if( info->getSubscriptionName() != "" ) {
+
+        if( this->clientId != info->getSubscriptionName() ) {
+            throw UnsupportedOperationException(
+                __FILE__, __LINE__,
+                "Stomp Durable Subscriptions require that the ClientId and the Subscription "
+                "Name match, clientId = {%s} : subscription name = {%s}.",
+                this->clientId.c_str(), info->getSubscriptionName().c_str() );
         }
+
+        frame->setProperty( StompCommandConstants::HEADER_SUBSCRIPTIONNAME,
+                            info->getSubscriptionName() );
+        // Older Brokers had an misspelled property name, this ensure we can talk to them as well.
+        frame->setProperty( StompCommandConstants::HEADER_OLDSUBSCRIPTIONNAME,
+                            info->getSubscriptionName() );
     }
-    AMQ_CATCH_RETHROW( decaf::io::IOException )
-    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
-    AMQ_CATCHALL_THROW( decaf::io::IOException )
+
+    if( info->getSelector() != "" ) {
+        frame->setProperty( StompCommandConstants::HEADER_SELECTOR,
+                            info->getSelector() );
+    }
+
+    // TODO - This should eventually check the session to see what its mode really is.
+    //        This will work for now but in order to add individual ack we need to check.
+    frame->setProperty( StompCommandConstants::HEADER_ACK, "client" );
+
+    if( info->isNoLocal() ) {
+        frame->setProperty( StompCommandConstants::HEADER_NOLOCAL, "true" );
+    }
+
+    frame->setProperty( StompCommandConstants::HEADER_DISPATCH_ASYNC,
+                        Boolean::toString( info->isDispatchAsync() ) );
+
+    if( info->isExclusive() ) {
+        frame->setProperty( StompCommandConstants::HEADER_EXCLUSIVE, "true" );
+    }
+
+    frame->setProperty( StompCommandConstants::HEADER_MAXPENDINGMSGLIMIT,
+                        Integer::toString( info->getMaximumPendingMessageLimit() ) );
+    frame->setProperty( StompCommandConstants::HEADER_PREFETCHSIZE,
+                        Integer::toString( info->getPrefetchSize() ) );
+    frame->setProperty( StompCommandConstants::HEADER_CONSUMERPRIORITY,
+                        Integer::toString( info->getPriority() ) );
+
+    if( info->isRetroactive() ) {
+        frame->setProperty( StompCommandConstants::HEADER_RETROACTIVE, "true" );
+    }
+
+    return frame;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Pointer<StompFrame> StompWireFormat::marshalRemoveSubscriptionInfo( const Pointer<Command>& command ) {
+
+    Pointer<RemoveSubscriptionInfo> info = command.dynamicCast<RemoveSubscriptionInfo>();
+    Pointer<StompFrame> frame( new StompFrame() );
+    frame->setCommand( StompCommandConstants::UNSUBSCRIBE );
+
+    if( command->isResponseRequired() ) {
+        frame->setProperty( StompCommandConstants::HEADER_RECEIPT_REQUIRED,
+                            std::string( "ignore:" ) + Integer::toString( command->getCommandId() ) );
+    }
+
+    frame->setProperty( StompCommandConstants::HEADER_ID, info->getClientId() );
+    frame->setProperty( StompCommandConstants::HEADER_SUBSCRIPTIONNAME,
+                        info->getClientId() );
+
+    // Older Brokers had an misspelled property name, this ensure we can talk to them as well.
+    frame->setProperty( StompCommandConstants::HEADER_OLDSUBSCRIPTIONNAME,
+                        info->getClientId() );
+
+    return frame;
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h Mon May 18 15:13:29 2009
@@ -21,7 +21,7 @@
 #include <activemq/util/Config.h>
 #include <activemq/wireformat/WireFormat.h>
 #include <activemq/wireformat/stomp/StompFrame.h>
-#include <activemq/wireformat/stomp/marshal/Marshaler.h>
+#include <activemq/wireformat/stomp/StompHelper.h>
 #include <decaf/io/IOException.h>
 #include <decaf/lang/Pointer.h>
 
@@ -36,14 +36,13 @@
     private:
 
         /**
-         * Vector Object used to buffer data
+         * Performs conversions for stomp types and canonical types.
          */
-        std::vector<unsigned char> buffer;
+        StompHelper helper;
 
-        /**
-         * Marshaler of Stomp Commands
-         */
-        marshal::Marshaler marshaler;
+        // Stored after we connect to use when validating that a durable subscribe
+        // and unsubscribe are set to use the client Id.
+        std::string clientId;
 
     public:
 
@@ -112,36 +111,19 @@
 
     private:
 
-        /**
-         * Read the Stomp Command from the Frame
-         * @param reference to a Stomp Frame
-         * @throws StompConnectorException
-         */
-        void readStompCommandHeader( Pointer<StompFrame>& frame, decaf::io::DataInputStream* in )
-            throw ( decaf::io::IOException );
-
-        /**
-         * Read all the Stomp Headers for the incoming Frame
-         * @param Frame to place data into
-         * @throws StompConnectorException
-         */
-        void readStompHeaders( Pointer<StompFrame>& frame, decaf::io::DataInputStream* in )
-            throw ( decaf::io::IOException );
-
-        /**
-         * Reads a Stomp Header line and stores it in the buffer object
-         * @return number of bytes read, zero if there was a problem.
-         * @throws StompConnectorException
-         */
-        std::size_t readStompHeaderLine( decaf::io::DataInputStream* in )
-            throw ( decaf::io::IOException );
-
-        /**
-         * Reads the Stomp Body from the Wire and store it in the frame.
-         * @param Stomp Frame to place data in
-         */
-        void readStompBody( Pointer<StompFrame>& frame, decaf::io::DataInputStream* in )
-            throw ( decaf::io::IOException );
+        Pointer<Command> unmarshalMessage( const Pointer<StompFrame>& frame );
+        Pointer<Command> unmarshalReceipt( const Pointer<StompFrame>& frame );
+        Pointer<Command> unmarshalConnected( const Pointer<StompFrame>& frame );
+        Pointer<Command> unmarshalError( const Pointer<StompFrame>& frame );
+
+        Pointer<StompFrame> marshalMessage( const Pointer<Command>& command );
+        Pointer<StompFrame> marshalAck( const Pointer<Command>& command );
+        Pointer<StompFrame> marshalConnectionInfo( const Pointer<Command>& command );
+        Pointer<StompFrame> marshalTransactionInfo( const Pointer<Command>& command );
+        Pointer<StompFrame> marshalShutdownInfo( const Pointer<Command>& command );
+        Pointer<StompFrame> marshalRemoveInfo( const Pointer<Command>& command );
+        Pointer<StompFrame> marshalConsumerInfo( const Pointer<Command>& command );
+        Pointer<StompFrame> marshalRemoveSubscriptionInfo( const Pointer<Command>& command );
 
     };
 

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=775980&r1=775979&r2=775980&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 Mon May 18 15:13:29 2009
@@ -24,7 +24,38 @@
 namespace cms{
 
     /**
-     * A message used for sending a stream of uninterpreted bytes.
+     * A BytesMessage object is used to send a message containing a stream of unsigned
+     * bytes. It inherits from the Message interface and adds a bytes message body. The
+     * receiver of the message supplies the interpretation of the bytes using the methods
+     * added by the BytesMessage interface.
+     *
+     * The BytesMessage methods are based largely on those found in decaf.io.DataInputStream
+     * and decaf.io.DataOutputStream.
+     *
+     * Although the CMS API allows the use of message properties with byte messages, they are
+     * typically not used, since the inclusion of properties may affect the format.
+     *
+     * The primitive types can be written explicitly using methods for each type.  Because the
+     * C++ language is more limited when dealing with primtive types the JMS equivalent generic
+     * read and write methods that take Java objects cannot be provided in the CMS API.
+     *
+     * When the message is first created, and when clearBody is called, the body of the message
+     * is in write-only mode. After the first call to reset has been made, the message body is
+     * in read-only mode. After a message has been sent, the client that sent it can retain and
+     * modify it without affecting the message that has been sent. The same message object can
+     * be sent multiple times. When a message has been received, the provider has called reset
+     * so that the message body is in read-only mode for the client.
+     *
+     * If clearBody is called on a message in read-only mode, the message body is cleared and
+     * the message is in write-only mode.
+     *
+     * If a client attempts to read a message in write-only mode, a MessageNotReadableException
+     * is thrown.
+     *
+     * If a client attempts to write a message in read-only mode, a MessageNotWriteableException
+     * is thrown.
+     *
+     * @since 1.0
      */
     class CMS_API BytesMessage : public Message{
     public:
@@ -38,11 +69,12 @@
          *      Byte Buffer to copy
          * @param numBytes
          *      Number of bytes in Buffer to copy
-         * @throws CMSException
+         *
+         * @throws CMSException - If an internal error occurs.
+         * @throws MessageNotWriteableException - if in Read Only Mode.
          */
-        virtual void setBodyBytes(
-            const unsigned char* buffer, std::size_t numBytes )
-                throw( CMSException ) = 0;
+        virtual void setBodyBytes( const unsigned char* buffer, std::size_t numBytes )
+            throw( CMSException ) = 0;
 
         /**
          * Gets the bytes that are contained in this message, user should
@@ -51,21 +83,28 @@
          * to expect.
          *
          * @return const pointer to a byte buffer
+         *
+         * @throws CMSException - If an internal error occurs.
+         * @throws MessageNotReadableException - If the message is in Write Only Mode.
          */
-        virtual const unsigned char* getBodyBytes() const = 0;
+        virtual const unsigned char* getBodyBytes() const throw( CMSException ) = 0;
 
         /**
          * Returns the number of bytes contained in the body of this message.
          *
          * @return number of bytes.
+         *
+         * @throws CMSException - If an internal error occurs.
+         * @throws MessageNotReadableException - If the message is in Write Only Mode.
          */
-        virtual std::size_t getBodyLength() const = 0;
+        virtual std::size_t getBodyLength() const throw( CMSException ) = 0;
 
         /**
          * Puts the message body in read-only mode and repositions the stream
          * of bytes to the beginning.
          *
-         * @throws CMSException
+         * @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;
 
@@ -73,7 +112,10 @@
          * Reads a Boolean from the Bytes message stream
          * @returns boolean value from stream
          *
-         * @throws CMSException
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -84,7 +126,10 @@
          *
          * @param value
          *      boolean to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeBoolean( bool value ) throw ( cms::CMSException ) = 0;
 
@@ -92,7 +137,11 @@
          * Reads a Byte from the Bytes message stream
          *
          * @returns unsigned char value from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -101,7 +150,10 @@
          *
          * @param value
          *      byte to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeByte( unsigned char value ) throw ( cms::CMSException ) = 0;
 
@@ -123,7 +175,11 @@
          * @returns the total number of bytes read into the buffer, or -1 if
          *          there is no more data because the end of the stream has
          *          been reached
-         * @throws CMSException if an error occurs.
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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( std::vector<unsigned char>& value ) const
             throw ( cms::CMSException ) = 0;
@@ -134,7 +190,10 @@
          *
          * @param value
          *      bytes to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeBytes( const std::vector<unsigned char>& value )
             throw ( cms::CMSException ) = 0;
@@ -164,7 +223,11 @@
          * @returns the total number of bytes read into the buffer, or -1 if
          *          there is no more data because the end of the stream has
          *          been reached
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
@@ -179,7 +242,10 @@
          *      the initial offset within the byte array
          * @param length
          *      the number of bytes to use
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeBytes( const unsigned char* value,
                                  std::size_t offset,
@@ -189,7 +255,11 @@
          * Reads a Char from the Bytes message stream
          *
          * @returns char value from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -198,7 +268,10 @@
          *
          * @param value
          *      char to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeChar( char value ) throw ( cms::CMSException ) = 0;
 
@@ -206,7 +279,11 @@
          * Reads a 32 bit float from the Bytes message stream
          *
          * @returns double value from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -214,7 +291,10 @@
          * Writes a float to the bytes message stream as a 4 byte value
          * @param value
          *      float to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeFloat( float value ) throw ( cms::CMSException ) = 0;
 
@@ -222,7 +302,11 @@
          * Reads a 64 bit double from the Bytes message stream
          *
          * @returns double value from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -230,7 +314,10 @@
          * Writes a double to the bytes message stream as a 8 byte value
          * @param value
          *      double to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeDouble( double value ) throw ( cms::CMSException ) = 0;
 
@@ -238,7 +325,11 @@
          * Reads a 16 bit signed short from the Bytes message stream
          *
          * @returns short value from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -247,7 +338,10 @@
          *
          * @param value
          *      signed short to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeShort( short value ) throw ( cms::CMSException ) = 0;
 
@@ -255,7 +349,11 @@
          * Reads a 16 bit unsigned short from the Bytes message stream
          *
          * @returns unsigned short value from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -264,7 +362,10 @@
          *
          * @param value
          *      unsigned short to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeUnsignedShort( unsigned short value ) throw ( cms::CMSException ) = 0;
 
@@ -272,7 +373,11 @@
          * Reads a 32 bit signed integer from the Bytes message stream
          *
          * @returns int value from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -281,7 +386,10 @@
          *
          * @param value
          *      signed int to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeInt( int value ) throw ( cms::CMSException ) = 0;
 
@@ -289,7 +397,11 @@
          * Reads a 64 bit long from the Bytes message stream
          *
          * @returns long long value from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -298,7 +410,10 @@
          *
          * @param value
          *      signed long long to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeLong( long long value ) throw ( cms::CMSException ) = 0;
 
@@ -306,7 +421,11 @@
          * Reads an ASCII String from the Bytes message stream
          *
          * @returns String from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -315,7 +434,10 @@
          *
          * @param value
          *      String to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to write the message due to
+         *                        some internal error.
+         * @throws MessageNotWriteableException - if the message is in read-only mode.
          */
         virtual void writeString( const std::string& value ) throw ( cms::CMSException ) = 0;
 
@@ -323,7 +445,11 @@
          * Reads an UTF String from the BytesMessage stream
          *
          * @returns String from stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
@@ -332,13 +458,20 @@
          *
          * @param value
          *      String to write to the stream
-         * @throws CMSException
+         *
+         * @throws CMSException - if the CMS provider fails to read the message due to
+         *                        some internal error.
+         * @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;
 
         /**
          * Clones this message.
+         *
          * @return a deep copy of this message.
+         *
+         * @throws CMSException - if an internal error occurs while cloning the Message.
          */
         virtual BytesMessage* clone() const = 0;
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSProperties.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSProperties.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSProperties.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSProperties.h Mon May 18 15:13:29 2009
@@ -28,6 +28,8 @@
     /**
      * Interface for a Java-like properties object.  This is essentially
      * a map of key-value string pairs.
+     *
+     * @since 1.1
      */
     class CMS_API CMSProperties {
     public:
@@ -36,15 +38,15 @@
 
         /**
          * Returns true if the properties object is empty
-         * 
+         *
          * @return true if empty
          */
         virtual bool isEmpty() const = 0;
 
         /**
          * Looks up the value for the given property.
-         * 
-         * @param name 
+         *
+         * @param name
          *      The name of the property to be looked up.
          * @return the value of the property with the given name, if it
          *         exists.  If it does not exist, returns NULL.
@@ -53,10 +55,10 @@
 
         /**
          * Looks up the value for the given property.
-         * 
-         * @param name 
+         *
+         * @param name
          *      the name of the property to be looked up.
-         * @param defaultValue 
+         * @param defaultValue
          *      The value to be returned if the given property does not exist.
          * @return The value of the property specified by <code>name</code>, if it
          *         exists, otherwise the <code>defaultValue</code>.
@@ -68,10 +70,10 @@
         /**
          * Sets the value for a given property.  If the property already
          * exists, overwrites the value.
-         * 
-         * @param name 
+         *
+         * @param name
          *      The name of the value to be written.
-         * @param value 
+         * @param value
          *      The value to be written.
          */
         virtual void setProperty(
@@ -80,8 +82,8 @@
 
         /**
          * Check to see if the Property exists in the set
-         * 
-         * @param name 
+         *
+         * @param name
          *      the name of the property to check
          * @return true if property exists, false otherwise.
          */
@@ -89,8 +91,8 @@
 
         /**
          * Removes the property with the given name.
-         * 
-         * @param name 
+         *
+         * @param name
          *      the name of the property to be removed.s
          */
         virtual void remove( const std::string& name ) = 0;
@@ -98,7 +100,7 @@
         /**
          * 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
          *         is the value.
          */
@@ -106,15 +108,15 @@
 
         /**
          * Copies the contents of the given properties object to this one.
-         * 
-         * @param source 
+         *
+         * @param source
          *      The source properties object.
          */
         virtual void copy( const CMSProperties* source ) = 0;
 
         /**
          * Clones this object.
-         * 
+         *
          * @returns a replica of this object.
          */
         virtual CMSProperties* clone() const = 0;
@@ -127,7 +129,7 @@
         /**
          * Formats the contents of the Properties Object into a string
          * that can be logged, etc.
-         * 
+         *
          * @returns string value of this object.
          */
         virtual std::string toString() const = 0;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSSecurityException.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSSecurityException.cpp?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSSecurityException.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSSecurityException.cpp Mon May 18 15:13:29 2009
@@ -24,7 +24,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-CMSSecurityException::CMSSecurityException( const CMSSecurityException& ex ) throw() : CMSException() {
+CMSSecurityException::CMSSecurityException( const CMSSecurityException& ex )
+    throw() : CMSException( ex ) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSSecurityException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSSecurityException.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSSecurityException.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/CMSSecurityException.h Mon May 18 15:13:29 2009
@@ -21,14 +21,14 @@
 #include <cms/Config.h>
 #include <cms/CMSException.h>
 
-namespace cms {
+namespace cms{
 
     /**
      * This exception must be thrown when a provider rejects a user name/password submitted
      * by a client. It may also be thrown for any case where a security restriction prevents
      * a method from completing.
      *
-     * @since 1.2
+     * @since 1.3
      */
     class CMS_API CMSSecurityException : public CMSException {
     public:

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Closeable.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Closeable.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Closeable.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Closeable.h Mon May 18 15:13:29 2009
@@ -14,33 +14,35 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
-#ifndef CMS_CLOSEABLE_H
-#define CMS_CLOSEABLE_H
- 
+
+#ifndef _CMS_CLOSEABLE_H
+#define _CMS_CLOSEABLE_H
+
 #include <cms/Config.h>
 #include <cms/CMSException.h>
 
 namespace cms{
-    
+
     /**
      * Interface for a class that implements the close method.
+     *
+     * @since 1.0
      */
     class CMS_API Closeable{
-        
+
     public:
-    
-        virtual ~Closeable(){}
-        
+
+        virtual ~Closeable() {}
+
         /**
          * Closes this object and deallocates the appropriate resources.
          * The object is generally no longer usable after calling close.
-         * 
-         * @throws CMSException
+         *
+         * @throws CMSException - If an error occurs while the resource is being closed.
          */
         virtual void close() throw( CMSException ) = 0;
 
     };
 }
 
-#endif /*CMS_CLOSEABLE_H*/
+#endif /*_CMS_CLOSEABLE_H*/

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Config.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Config.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Config.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Config.h Mon May 18 15:13:29 2009
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 
-#ifndef CMS_CONFIG_H
-#define CMS_CONFIG_H
+#ifndef _CMS_CONFIG_H_
+#define _CMS_CONFIG_H_
 
 #ifdef CMS_DLL
  #ifdef CMS_EXPORTS
@@ -32,4 +32,4 @@
  #endif
 #endif
 
-#endif /*CMS_CONFIG_H*/
+#endif /*_CMS_CONFIG_H_*/

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Connection.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Connection.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Connection.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Connection.h Mon May 18 15:13:29 2009
@@ -43,7 +43,7 @@
      *  - It supports an optional ExceptionListener object.
      *
      * Because the creation of a connection involves setting up authentication and communication,
-     * a connection is a relatively heavyweight object. Most clients will do all their messaging
+     * a connection is a relatively heavy-weight object. Most clients will do all their messaging
      * with a single connection. Other more advanced applications may use several connections.
      * The CMS API does not architect a reason for using multiple connections; however, there
      * may be operational reasons for doing so.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionFactory.h Mon May 18 15:13:29 2009
@@ -23,8 +23,7 @@
 
 #include <string>
 
-namespace cms
-{
+namespace cms{
 
     /**
      * Defines the interface for a factory that creates connection objects, the Connection
@@ -36,8 +35,7 @@
      *
      * @since 1.0
      */
-    class CMS_API ConnectionFactory
-    {
+    class CMS_API ConnectionFactory {
     public:
 
         virtual ~ConnectionFactory() {}
@@ -77,7 +75,7 @@
          * Creates a connection with the specified user identity. The
          * connection is created in stopped mode. No messages will be
          * delivered until the Connection.start method is explicitly
-         * called.  The username and password values passed here do not
+         * called.  The user name and password values passed here do not
          * change the defaults, subsequent calls to the parameterless
          * createConnection will continue to use the default values that
          * were set in the Constructor.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionMetaData.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionMetaData.h?rev=775980&r1=775979&r2=775980&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionMetaData.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/ConnectionMetaData.h Mon May 18 15:13:29 2009
@@ -21,10 +21,12 @@
 #include <cms/Config.h>
 #include <cms/CMSException.h>
 
-namespace cms {
+namespace cms{
 
     /**
      * A ConnectionMetaData object provides information describing the Connection object.
+     *
+     * @since 1.3
      */
     class CMS_API ConnectionMetaData {
     public:



Mime
View raw message