You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2008/12/10 22:46:14 UTC

svn commit: r725451 - in /activemq/activemq-cpp/trunk/src: main/ main/activemq/connector/openwire/commands/ main/activemq/connector/openwire/utils/ test/ test/activemq/connector/openwire/utils/

Author: tabish
Date: Wed Dec 10 13:46:14 2008
New Revision: 725451

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

Add interceptor to ensure that the JMSX properties get set into the correct atributes of the Message class when they are applied the an ActiveMQMessage type.

Added unit tests for the interceptor as well.

Added:
    activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.cpp   (with props)
    activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.h   (with props)
    activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/MessagePropertyInterceptorTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/MessagePropertyInterceptorTest.h   (with props)
Modified:
    activemq/activemq-cpp/trunk/src/main/Makefile.am
    activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h
    activemq/activemq-cpp/trunk/src/test/Makefile.am
    activemq/activemq-cpp/trunk/src/test/testRegistry.cpp

Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/Makefile.am?rev=725451&r1=725450&r2=725451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/main/Makefile.am Wed Dec 10 13:46:14 2008
@@ -63,6 +63,7 @@
     activemq/connector/openwire/utils/HexTable.cpp \
     activemq/connector/openwire/utils/BooleanStream.cpp \
     activemq/connector/openwire/utils/OpenwireStringSupport.cpp \
+    activemq/connector/openwire/utils/MessagePropertyInterceptor.cpp \
     activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp \
     activemq/connector/ConnectorFactoryMap.cpp \
     activemq/connector/BaseConnectorResource.cpp \
@@ -248,6 +249,7 @@
     activemq/connector/openwire/utils/HexTable.h \
     activemq/connector/openwire/utils/BooleanStream.h \
     activemq/connector/openwire/utils/OpenwireStringSupport.h \
+    activemq/connector/openwire/utils/MessagePropertyInterceptor.h \
     activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h \
     activemq/connector/ConnectorFactoryMap.h \
     activemq/connector/Connector.h \

Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h?rev=725451&r1=725450&r2=725451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/commands/ActiveMQMessageBase.h Wed Dec 10 13:46:14 2008
@@ -22,11 +22,13 @@
 #include <activemq/core/ActiveMQMessage.h>
 #include <activemq/connector/openwire/marshal/BaseDataStreamMarshaller.h>
 #include <activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h>
+#include <activemq/connector/openwire/utils/MessagePropertyInterceptor.h>
 #include <activemq/core/ActiveMQAckHandler.h>
 #include <decaf/util/Date.h>
 #include <activemq/util/PrimitiveMap.h>
 #include <cms/DeliveryMode.h>
 #include <activemq/util/Config.h>
+#include <memory>
 
 namespace activemq{
 namespace connector{
@@ -49,12 +51,15 @@
         core::ActiveMQAckHandler* ackHandler;
         int redeliveryCount;
         util::PrimitiveMap properties;
+        std::auto_ptr<utils::MessagePropertyInterceptor> propertiesInterceptor;
 
     public:
 
         ActiveMQMessageBase() {
             this->ackHandler = NULL;
             this->redeliveryCount = 0;
+            this->propertiesInterceptor.reset(
+                new utils::MessagePropertyInterceptor( this, &this->properties ) );
         }
 
         virtual ~ActiveMQMessageBase() {}
@@ -287,7 +292,7 @@
             throw( cms::CMSException ) {
 
             try{
-                return properties.getBool( name );
+                return this->propertiesInterceptor->getBooleanProperty( name );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -304,7 +309,7 @@
             throw( cms::CMSException ) {
 
             try{
-                return properties.getByte( name );
+                return this->propertiesInterceptor->getByteProperty( name );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -321,7 +326,7 @@
             throw( cms::CMSException ) {
 
             try{
-                return properties.getDouble( name );
+                return this->propertiesInterceptor->getDoubleProperty( name );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -338,7 +343,7 @@
             throw( cms::CMSException ) {
 
             try{
-                return properties.getFloat( name );
+                return this->propertiesInterceptor->getFloatProperty( name );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -355,7 +360,7 @@
             throw( cms::CMSException ) {
 
             try{
-                return properties.getInt( name );
+                return this->propertiesInterceptor->getIntProperty( name );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -372,7 +377,7 @@
             throw( cms::CMSException ) {
 
             try{
-                return properties.getLong( name );
+                return this->propertiesInterceptor->getLongProperty( name );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -389,7 +394,7 @@
             throw( cms::CMSException ) {
 
             try{
-                return properties.getShort( name );
+                return this->propertiesInterceptor->getShortProperty( name );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -406,7 +411,7 @@
             throw( cms::CMSException ) {
 
             try{
-                return properties.getString( name );
+                return this->propertiesInterceptor->getStringProperty( name );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -424,7 +429,7 @@
                                             throw( cms::CMSException ) {
 
             try{
-                properties.setBool( name, value );
+                this->propertiesInterceptor->setBooleanProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -442,7 +447,7 @@
                                         throw( cms::CMSException ) {
 
             try{
-                properties.setByte( name, value );
+                this->propertiesInterceptor->setByteProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -460,7 +465,7 @@
                                             throw( cms::CMSException ) {
 
             try{
-                properties.setDouble( name, value );
+                this->propertiesInterceptor->setDoubleProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -478,7 +483,7 @@
                                         throw( cms::CMSException ) {
 
             try{
-                properties.setFloat( name, value );
+                this->propertiesInterceptor->setFloatProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -496,7 +501,7 @@
                                         throw( cms::CMSException ) {
 
             try{
-                properties.setInt( name, value );
+                this->propertiesInterceptor->setIntProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -514,7 +519,7 @@
                                         throw( cms::CMSException ) {
 
             try{
-                properties.setLong( name, value );
+                this->propertiesInterceptor->setLongProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -532,7 +537,7 @@
                                         throw( cms::CMSException ) {
 
             try{
-                properties.setShort( name, value );
+                this->propertiesInterceptor->setShortProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
@@ -550,7 +555,7 @@
                                             throw( cms::CMSException ) {
 
             try{
-                properties.setString( name, value );
+                this->propertiesInterceptor->setStringProperty( name, value );
             }
             AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
             AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )

Added: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.cpp?rev=725451&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.cpp Wed Dec 10 13:46:14 2008
@@ -0,0 +1,377 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "MessagePropertyInterceptor.h"
+
+#include <decaf/lang/Integer.h>
+#include <activemq/exceptions/ActiveMQException.h>
+#include <cms/DeliveryMode.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::exceptions;
+using namespace activemq::connector;
+using namespace activemq::connector::openwire;
+using namespace activemq::connector::openwire::utils;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+MessagePropertyInterceptor::MessagePropertyInterceptor(
+    commands::Message* message, util::PrimitiveMap* properties )
+        throw( decaf::lang::exceptions::NullPointerException ) {
+
+    if( message == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__, "Message passed was NULL" );
+    }
+
+    if( properties == NULL ) {
+        throw NullPointerException(
+            __FILE__, __LINE__, "PrimitiveMap passed was NULL" );
+    }
+
+    this->message = message;
+    this->properties = properties;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MessagePropertyInterceptor::~MessagePropertyInterceptor() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool MessagePropertyInterceptor::getBooleanProperty( const std::string& name ) const
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        return this->properties->getBool( name );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char MessagePropertyInterceptor::getByteProperty( const std::string& name ) const
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        return this->properties->getByte( name );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double MessagePropertyInterceptor::getDoubleProperty( const std::string& name ) const
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        return this->properties->getDouble( name );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float MessagePropertyInterceptor::getFloatProperty( const std::string& name ) const
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        return this->properties->getFloat( name );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int MessagePropertyInterceptor::getIntProperty( const std::string& name ) const
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXGroupID" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        } else if( name == "JMSXDeliveryCount" ) {
+            return this->message->getRedeliveryCounter();
+        } else if( name == "JMSXGroupSeq" ) {
+            return this->message->getGroupSequence();
+        }
+
+        return this->properties->getInt( name );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long MessagePropertyInterceptor::getLongProperty( const std::string& name ) const
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXGroupID" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        } else if( name == "JMSXDeliveryCount" ) {
+            return (long long)this->message->getRedeliveryCounter();
+        } else if( name == "JMSXGroupSeq" ) {
+            return (long long)this->message->getGroupSequence();
+        }
+
+        return this->properties->getLong( name );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+short MessagePropertyInterceptor::getShortProperty( const std::string& name ) const
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        return this->properties->getShort( name );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string MessagePropertyInterceptor::getStringProperty( const std::string& name ) const
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXGroupID" ) {
+            return this->message->getGroupID();
+        } else if( name == "JMSXDeliveryCount" ) {
+            return Integer::toString( this->message->getRedeliveryCounter() );
+        } else if( name == "JMSXGroupSeq" ) {
+            return Integer::toString( this->message->getGroupSequence() );
+        }
+
+        return this->properties->getString( name );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptor::setBooleanProperty( const std::string& name,
+                                 bool value )
+                                    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        this->properties->setBool( name, value );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptor::setByteProperty( const std::string& name,
+                              unsigned char value )
+                                throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        this->properties->setByte( name, value );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptor::setDoubleProperty( const std::string& name,
+                                double value )
+                                    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        this->properties->setDouble( name, value );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptor::setFloatProperty( const std::string& name,
+                               float value )
+                                throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXDeliveryCount" || name == "JMSXGroupID" || name == "JMSXGroupSeq" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        }
+
+        this->properties->setFloat( name, value );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptor::setIntProperty( const std::string& name, int value )
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXGroupID" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        } else if( name == "JMSXDeliveryCount" ) {
+            this->message->setRedeliveryCounter( value );
+        } else if( name == "JMSXGroupSeq" ) {
+            this->message->setGroupSequence( value );
+        }
+
+        this->properties->setInt( name, value );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptor::setLongProperty( const std::string& name, long long value )
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+        this->properties->setLong( name, value );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptor::setShortProperty( const std::string& name, short value )
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXGroupID" ) {
+            throw ActiveMQException(
+                __FILE__, __LINE__,
+                "Cannot Convert Reserved Property to this Type." );
+        } else if( name == "JMSXDeliveryCount" ) {
+            this->message->setRedeliveryCounter( (int)value );
+        } else if( name == "JMSXGroupSeq" ) {
+            this->message->setGroupSequence( (int)value );
+        }
+
+        this->properties->setShort( name, value );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptor::setStringProperty( const std::string& name,
+                                                    const std::string& value )
+    throw( exceptions::ActiveMQException ) {
+
+    try{
+
+        if( name == "JMSXGroupID" ) {
+            this->message->setGroupID( value );
+        } else if( name == "JMSXDeliveryCount" ) {
+            this->message->setRedeliveryCounter( Integer::parseInt( value ) );
+        } else if( name == "JMSXGroupSeq" ) {
+            this->message->setGroupSequence( Integer::parseInt( value ) );
+        }
+
+        this->properties->setString( name, value );
+    }
+    AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+    AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, exceptions::ActiveMQException )
+    AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}

Propchange: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.h?rev=725451&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.h Wed Dec 10 13:46:14 2008
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_CONNECTOR_OPENWIRE_UTILS_MESSAGEPROPERTYINTERCEPTOR_H_
+#define _ACTIVEMQ_CONNECTOR_OPENWIRE_UTILS_MESSAGEPROPERTYINTERCEPTOR_H_
+
+#include <activemq/util/Config.h>
+#include <activemq/connector/openwire/commands/Message.h>
+#include <activemq/util/PrimitiveMap.h>
+#include <activemq/exceptions/ActiveMQException.h>
+
+#include <decaf/lang/exceptions/NullPointerException.h>
+
+namespace activemq {
+namespace connector {
+namespace openwire {
+namespace utils {
+
+    /**
+     * Used the base ActiveMQMessage class to intercept calls to get and set properties
+     * in order to capture the calls that use the reserved JMS properties and get and
+     * set them in the OpenWire Message properties.
+     *
+     * Currently the only properties that are intercepted and handled are:
+     *
+     * Name                | Conversion Supported
+     * ------------------------------------------------------
+     * JMSXDeliveryCount   | Int, Long, String
+     * JMSXGroupID         | String
+     * JMSXGroupSeq        | Int, Long, String
+     *
+     */
+    class AMQCPP_API MessagePropertyInterceptor {
+    private:
+
+        commands::Message* message;
+        util::PrimitiveMap* properties;
+
+    public:
+
+        /**
+         * Constructor, accepts the Message that will be used to store JMS reserved
+         * property values, and the PrimitiveMap to get and set the rest to.
+         *
+         * @param message - The Message to store reserved property data in
+         * @param properties - The PrimitiveMap to store the rest of the properties in.
+         *
+         * @throws NullPointerException if either param is NULL
+         */
+        MessagePropertyInterceptor( commands::Message* message, util::PrimitiveMap* properties )
+            throw( decaf::lang::exceptions::NullPointerException );
+
+        virtual ~MessagePropertyInterceptor();
+
+        /**
+         * Gets a boolean property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual bool getBooleanProperty( const std::string& name ) const
+            throw( exceptions::ActiveMQException );
+
+        /**
+         * Gets a byte property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual unsigned char getByteProperty( const std::string& name ) const
+            throw( exceptions::ActiveMQException );
+
+        /**
+         * Gets a double property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual double getDoubleProperty( const std::string& name ) const
+            throw( exceptions::ActiveMQException );
+
+        /**
+         * Gets a float property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual float getFloatProperty( const std::string& name ) const
+            throw( exceptions::ActiveMQException );
+
+        /**
+         * Gets a int property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual int getIntProperty( const std::string& name ) const
+            throw( exceptions::ActiveMQException );
+
+        /**
+         * Gets a long property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual long long getLongProperty( const std::string& name ) const
+            throw( exceptions::ActiveMQException );
+
+        /**
+         * Gets a short property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual short getShortProperty( const std::string& name ) const
+            throw( exceptions::ActiveMQException );
+
+        /**
+         * Gets a string property.
+         * @param name The name of the property to retrieve.
+         * @return The value for the named property.
+         * @throws CMSException if the property does not exist.
+         */
+        virtual std::string getStringProperty( const std::string& name ) const
+            throw( exceptions::ActiveMQException );
+
+        /**
+         * Sets a boolean property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setBooleanProperty( const std::string& name,
+                                         bool value )
+                                            throw( exceptions::ActiveMQException );
+        /**
+         * Sets a byte property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setByteProperty( const std::string& name,
+                                      unsigned char value )
+                                        throw( exceptions::ActiveMQException );
+
+        /**
+         * Sets a double property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setDoubleProperty( const std::string& name,
+                                        double value )
+                                            throw( exceptions::ActiveMQException );
+
+        /**
+         * Sets a float property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setFloatProperty( const std::string& name,
+                                       float value )
+                                        throw( exceptions::ActiveMQException );
+
+        /**
+         * Sets a int property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setIntProperty( const std::string& name,
+                                     int value )
+                                        throw( exceptions::ActiveMQException );
+
+        /**
+         * Sets a long property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setLongProperty( const std::string& name,
+                                      long long value )
+                                        throw( exceptions::ActiveMQException );
+
+        /**
+         * Sets a short property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setShortProperty( const std::string& name,
+                                       short value )
+                                        throw( exceptions::ActiveMQException );
+
+        /**
+         * Sets a string property.
+         * @param name The name of the property to retrieve.
+         * @param value The value for the named property.
+         * @throws CMSException
+         */
+        virtual void setStringProperty( const std::string& name,
+                                        const std::string& value )
+                                            throw( exceptions::ActiveMQException );
+
+    };
+
+}}}}
+
+#endif /* _ACTIVEMQ_CONNECTOR_OPENWIRE_UTILS_MESSAGEPROPERTYINTERCEPTOR_H_ */

Propchange: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/utils/MessagePropertyInterceptor.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=725451&r1=725450&r2=725451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Wed Dec 10 13:46:14 2008
@@ -46,6 +46,7 @@
   activemq/connector/openwire/utils/HexTableTest.cpp \
   activemq/connector/openwire/utils/BooleanStreamTest.cpp \
   activemq/connector/openwire/utils/OpenwireStringSupportTest.cpp \
+  activemq/connector/openwire/utils/MessagePropertyInterceptorTest.cpp \
   activemq/connector/openwire/commands/ActiveMQBytesMessageTest.cpp \
   activemq/connector/openwire/commands/ActiveMQMapMessageTest.cpp \
   activemq/connector/openwire/commands/ActiveMQMessageTest.cpp \
@@ -163,6 +164,7 @@
   activemq/connector/openwire/utils/HexTableTest.h \
   activemq/connector/openwire/utils/BooleanStreamTest.h \
   activemq/connector/openwire/utils/OpenwireStringSupportTest.h \
+  activemq/connector/openwire/utils/MessagePropertyInterceptorTest.h \
   activemq/connector/openwire/commands/ActiveMQBytesMessageTest.h \
   activemq/connector/openwire/commands/ActiveMQMapMessageTest.h \
   activemq/connector/openwire/commands/ActiveMQMessageTest.h \

Added: activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/MessagePropertyInterceptorTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/MessagePropertyInterceptorTest.cpp?rev=725451&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/MessagePropertyInterceptorTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/MessagePropertyInterceptorTest.cpp Wed Dec 10 13:46:14 2008
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "MessagePropertyInterceptorTest.h"
+
+#include <activemq/connector/openwire/utils/MessagePropertyInterceptor.h>
+#include <activemq/connector/openwire/commands/Message.h>
+#include <activemq/util/PrimitiveMap.h>
+#include <activemq/exceptions/ActiveMQException.h>
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::io;
+using namespace activemq;
+using namespace activemq::util;
+using namespace activemq::exceptions;
+using namespace activemq::connector;
+using namespace activemq::connector::openwire;
+using namespace activemq::connector::openwire::utils;
+using namespace activemq::connector::openwire::commands;
+
+////////////////////////////////////////////////////////////////////////////////
+void MessagePropertyInterceptorTest::test() {
+
+    PrimitiveMap properties;
+    Message message;
+
+    MessagePropertyInterceptor interceptor( &message, &properties );
+
+    CPPUNIT_ASSERT( message.getGroupID() == "" );
+    CPPUNIT_ASSERT( message.getGroupSequence() == 0 );
+    CPPUNIT_ASSERT( message.getRedeliveryCounter() == 0 );
+
+    interceptor.setStringProperty( "JMSXGroupID", "TEST" );
+    interceptor.setStringProperty( "JMSXGroupSeq", "15" );
+    interceptor.setStringProperty( "JMSXDeliveryCount", "12" );
+
+    CPPUNIT_ASSERT( message.getGroupID() == "TEST" );
+    CPPUNIT_ASSERT( message.getGroupSequence() == 15 );
+    CPPUNIT_ASSERT( message.getRedeliveryCounter() == 12 );
+    CPPUNIT_ASSERT( interceptor.getStringProperty( "JMSXGroupID" ) == "TEST" );
+    CPPUNIT_ASSERT( interceptor.getIntProperty( "JMSXGroupSeq" ) == 15 );
+    CPPUNIT_ASSERT( interceptor.getIntProperty( "JMSXDeliveryCount" ) == 12 );
+
+    interceptor.setStringProperty( "JMSXGroupSeq", "15" );
+    interceptor.setStringProperty( "JMSXDeliveryCount", "12" );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw an ActiveMQException",
+        interceptor.setBooleanProperty( "JMSXGroupSeq", false ),
+        ActiveMQException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw an ActiveMQException",
+        interceptor.setStringProperty( "JMSXGroupSeq", "FOO" ),
+        ActiveMQException );
+
+}

Propchange: activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/MessagePropertyInterceptorTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/MessagePropertyInterceptorTest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/testRegistry.cpp?rev=725451&r1=725450&r2=725451&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Wed Dec 10 13:46:14 2008
@@ -99,6 +99,8 @@
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::connector::openwire::utils::HexTableTest );
 #include <activemq/connector/openwire/utils/OpenwireStringSupportTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::connector::openwire::utils::OpenwireStringSupportTest );
+#include <activemq/connector/openwire/utils/MessagePropertyInterceptorTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::connector::openwire::utils::MessagePropertyInterceptorTest );
 
 #include <activemq/connector/openwire/OpenWireFormatTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::connector::openwire::OpenWireFormatTest );