activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r745987 - in /activemq/activemq-cpp/trunk/src/main: activemq/commands/ActiveMQBytesMessage.h activemq/commands/ActiveMQTextMessage.h activemq/state/ConnectionStateTracker.cpp cms/BytesMessage.h
Date Thu, 19 Feb 2009 20:37:20 GMT
Author: tabish
Date: Thu Feb 19 20:37:20 2009
New Revision: 745987

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

Refactoring of the Transports and Commands to use Smart Pointers to pass data around and avoid
making copies as much as possible.  Simplified code in many of the classes as there's less
lifetime management needed for the self managed commands.

Modified:
    activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQBytesMessage.h
    activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQTextMessage.h
    activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp
    activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h

Modified: activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQBytesMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQBytesMessage.h?rev=745987&r1=745986&r2=745987&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQBytesMessage.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQBytesMessage.h Thu Feb
19 20:37:20 2009
@@ -39,6 +39,36 @@
 
     class AMQCPP_API ActiveMQBytesMessage :
         public ActiveMQMessageTemplate< cms::BytesMessage > {
+    private:
+
+        /**
+         * Flag that indicates what state the stream is in.  If true, the
+         * message may only be read from.  If false, the message may only be
+         * written to.
+         */
+        bool readOnly;
+
+        /**
+         * InputStream that wraps around the command's content when in
+         * read-only mode.
+         */
+        mutable decaf::io::ByteArrayInputStream inputStream;
+
+        /**
+         * OutputStream that wraps around the command's content when in
+         * write-only mode.
+         */
+        decaf::io::ByteArrayOutputStream outputStream;
+
+        /**
+         * DataInputStream wrapper around the input stream.
+         */
+        mutable decaf::io::DataInputStream dataInputStream;
+
+        /**
+         * DataOutputStream wrapper around the output stream.
+         */
+        decaf::io::DataOutputStream dataOutputStream;
 
     public:
 
@@ -407,37 +437,6 @@
             }
         }
 
-    private:
-
-        /**
-         * Flag that indicates what state the stream is in.  If true, the
-         * message may only be read from.  If false, the message may only be
-         * written to.
-         */
-        bool readOnly;
-
-        /**
-         * InputStream that wraps around the command's content when in
-         * read-only mode.
-         */
-        mutable decaf::io::ByteArrayInputStream inputStream;
-
-        /**
-         * OutputStream that wraps around the command's content when in
-         * write-only mode.
-         */
-        decaf::io::ByteArrayOutputStream outputStream;
-
-        /**
-         * DataInputStream wrapper around the input stream.
-         */
-        mutable decaf::io::DataInputStream dataInputStream;
-
-        /**
-         * DataOutputStream wrapper around the output stream.
-         */
-        decaf::io::DataOutputStream dataOutputStream;
-
     };
 
 }}

Modified: activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQTextMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQTextMessage.h?rev=745987&r1=745986&r2=745987&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQTextMessage.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/commands/ActiveMQTextMessage.h Thu Feb 19
20:37:20 2009
@@ -98,7 +98,7 @@
          * caller is required to delete.
          * @return new copy of this message
          */
-        virtual cms::TextMessage* clone(void) const {
+        virtual cms::TextMessage* clone() const {
             return dynamic_cast<cms::TextMessage*>( this->cloneDataStructure() );
         }
 

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp?rev=745987&r1=745986&r2=745987&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.cpp Thu Feb
19 20:37:20 2009
@@ -76,6 +76,36 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+Pointer<Command> ConnectionStateTracker::processMessageAck( MessageAck* ack )
+    throw ( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( trackTransactions && ack != NULL && ack->getTransactionId()
!= NULL) {
+            // TODO
+            Pointer<ConnectionId> connectionId;// =
+                //ack->getConsumerId()->getParentId().getParentId();
+            if( connectionId != NULL ) {
+                Pointer<ConnectionState> cs = connectionStates.get( connectionId );
+                if( cs != NULL ) {
+                    Pointer<TransactionState> transactionState =
+                        cs->getTransactionState( ack->getTransactionId() );
+                    if( transactionState != NULL ) {
+                        transactionState->addCommand(
+                            Pointer<Command>( ack->cloneDataStructure() ) );
+                    }
+                }
+            }
+            return TRACKED_RESPONSE_MARKER;
+        }
+        return Pointer<Response>();
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
 Pointer<Command> ConnectionStateTracker::processBeginTransaction( TransactionInfo*
info )
     throw ( exceptions::ActiveMQException ) {
 

Modified: activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h?rev=745987&r1=745986&r2=745987&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h (original)
+++ activemq/activemq-cpp/trunk/src/main/cms/BytesMessage.h Thu Feb 19 20:37:20 2009
@@ -33,10 +33,10 @@
 
         /**
          * sets the bytes given to the message body.
-         * 
-         * @param buffer 
+         *
+         * @param buffer
          *      Byte Buffer to copy
-         * @param numBytes 
+         * @param numBytes
          *      Number of bytes in Buffer to copy
          * @throws CMSException
          */
@@ -49,14 +49,14 @@
          * copy this data into a user allocated buffer.  Call
          * <code>getBodyLength</code> to determine the number of bytes
          * to expect.
-         * 
+         *
          * @return const pointer to a byte buffer
          */
         virtual const unsigned char* getBodyBytes() const = 0;
 
         /**
          * Returns the number of bytes contained in the body of this message.
-         * 
+         *
          * @return number of bytes.
          */
         virtual std::size_t getBodyLength() const = 0;
@@ -64,7 +64,7 @@
         /**
          * Puts the message body in read-only mode and repositions the stream
          * of bytes to the beginning.
-         * 
+         *
          * @throws CMSException
          */
         virtual void reset() throw ( cms::CMSException ) = 0;
@@ -72,7 +72,7 @@
         /**
          * Reads a Boolean from the Bytes message stream
          * @returns boolean value from stream
-         * 
+         *
          * @throws CMSException
          */
         virtual bool readBoolean() const throw ( cms::CMSException ) = 0;
@@ -81,8 +81,8 @@
          * Writes a boolean to the bytes message stream as a 1-byte value.
          * The value true is written as the value (byte)1; the value false
          * is written as the value (byte)0.
-         * 
-         * @param value 
+         *
+         * @param value
          *      boolean to write to the stream
          * @throws CMSException
          */
@@ -90,7 +90,7 @@
 
         /**
          * Reads a Byte from the Bytes message stream
-         * 
+         *
          * @returns unsigned char value from stream
          * @throws CMSException
          */
@@ -98,8 +98,8 @@
 
         /**
          * Writes a byte to the bytes message stream as a 1-byte value
-         * 
-         * @param value 
+         *
+         * @param value
          *      byte to write to the stream
          * @throws CMSException
          */
@@ -118,7 +118,7 @@
          * length of the vector, indicating that there are no more bytes left to
          * be read from the stream. The next read of the stream returns -1.
          *
-         * @param value 
+         * @param value
          *      buffer to place data in
          * @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
@@ -131,8 +131,8 @@
         /**
          * Writes a byte array to the bytes message stream using the vector
          * size as the number of bytes to write.
-         * 
-         * @param value 
+         *
+         * @param value
          *      bytes to write to the stream
          * @throws CMSException
          */
@@ -156,10 +156,10 @@
          * array value, then an IndexOutOfBoundsException is thrown. No bytes
          * will be read from the stream for this exception case.
          *
-         * @param buffer 
+         * @param buffer
          *      the buffer into which the data is read
-         * @param length 
-         *      the number of bytes to read; must be less than or equal to 
+         * @param length
+         *      the number of bytes to read; must be less than or equal to
          *      value.length
          * @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
@@ -172,12 +172,12 @@
         /**
          * Writes a portion of a byte array to the bytes message stream.
          * size as the number of bytes to write.
-         * 
-         * @param value 
+         *
+         * @param value
          *      bytes to write to the stream
-         * @param offset 
+         * @param offset
          *      the initial offset within the byte array
-         * @param length 
+         * @param length
          *      the number of bytes to use
          * @throws CMSException
          */
@@ -187,7 +187,7 @@
 
         /**
          * Reads a Char from the Bytes message stream
-         * 
+         *
          * @returns char value from stream
          * @throws CMSException
          */
@@ -195,7 +195,7 @@
 
         /**
          * Writes a char to the bytes message stream as a 1-byte value
-         * 
+         *
          * @param value
          *      char to write to the stream
          * @throws CMSException
@@ -204,7 +204,7 @@
 
         /**
          * Reads a 32 bit float from the Bytes message stream
-         * 
+         *
          * @returns double value from stream
          * @throws CMSException
          */
@@ -212,7 +212,7 @@
 
         /**
          * Writes a float to the bytes message stream as a 4 byte value
-         * @param value 
+         * @param value
          *      float to write to the stream
          * @throws CMSException
          */
@@ -220,7 +220,7 @@
 
         /**
          * Reads a 64 bit double from the Bytes message stream
-         * 
+         *
          * @returns double value from stream
          * @throws CMSException
          */
@@ -228,7 +228,7 @@
 
         /**
          * Writes a double to the bytes message stream as a 8 byte value
-         * @param value 
+         * @param value
          *      double to write to the stream
          * @throws CMSException
          */
@@ -236,7 +236,7 @@
 
         /**
          * Reads a 16 bit signed short from the Bytes message stream
-         * 
+         *
          * @returns short value from stream
          * @throws CMSException
          */
@@ -244,8 +244,8 @@
 
         /**
          * Writes a signed short to the bytes message stream as a 2 byte value
-         * 
-         * @param value 
+         *
+         * @param value
          *      signed short to write to the stream
          * @throws CMSException
          */
@@ -253,7 +253,7 @@
 
         /**
          * Reads a 16 bit unsigned short from the Bytes message stream
-         * 
+         *
          * @returns unsigned short value from stream
          * @throws CMSException
          */
@@ -261,16 +261,16 @@
 
         /**
          * Writes a unsigned short to the bytes message stream as a 2 byte value
-         * 
-         * @param value 
+         *
+         * @param value
          *      unsigned short to write to the stream
          * @throws CMSException
          */
         virtual void writeUnsignedShort( unsigned short value ) throw ( cms::CMSException
) = 0;
 
         /**
-         * Reads a 32 bit signed intger from the Bytes message stream
-         * 
+         * Reads a 32 bit signed integer from the Bytes message stream
+         *
          * @returns int value from stream
          * @throws CMSException
          */
@@ -278,8 +278,8 @@
 
         /**
          * Writes a signed int to the bytes message stream as a 4 byte value
-         * 
-         * @param value 
+         *
+         * @param value
          *      signed int to write to the stream
          * @throws CMSException
          */
@@ -287,7 +287,7 @@
 
         /**
          * Reads a 64 bit long from the Bytes message stream
-         * 
+         *
          * @returns long long value from stream
          * @throws CMSException
          */
@@ -295,8 +295,8 @@
 
         /**
          * Writes a long long to the bytes message stream as a 8 byte value
-         * 
-         * @param value 
+         *
+         * @param value
          *      signed long long to write to the stream
          * @throws CMSException
          */
@@ -304,7 +304,7 @@
 
         /**
          * Reads an ASCII String from the Bytes message stream
-         * 
+         *
          * @returns String from stream
          * @throws CMSException
          */
@@ -312,8 +312,8 @@
 
         /**
          * Writes an ASCII String to the Bytes message stream
-         * 
-         * @param value 
+         *
+         * @param value
          *      String to write to the stream
          * @throws CMSException
          */
@@ -321,7 +321,7 @@
 
         /**
          * Reads an UTF String from the BytesMessage stream
-         * 
+         *
          * @returns String from stream
          * @throws CMSException
          */
@@ -329,8 +329,8 @@
 
         /**
          * Writes an UTF String to the BytesMessage stream
-         * 
-         * @param value 
+         *
+         * @param value
          *      String to write to the stream
          * @throws CMSException
          */



Mime
View raw message