activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r514493 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire: OpenWireConnector.cpp commands/WireFormatInfo.cpp commands/WireFormatInfo.h
Date Sun, 04 Mar 2007 23:10:18 GMT
Author: tabish
Date: Sun Mar  4 15:10:17 2007
New Revision: 514493

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

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp?view=diff&rev=514493&r1=514492&r2=514493
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/OpenWireConnector.cpp
Sun Mar  4 15:10:17 2007
@@ -1162,34 +1162,21 @@
 {
     try
     {
-        commands::MessageDispatch* dispatch =
-            dynamic_cast<commands::MessageDispatch*>( command );
-        commands::WireFormatInfo* brokerWireFormatInfo =
-            dynamic_cast<commands::WireFormatInfo*>( command );
-        commands::BrokerInfo* brokerInfo =
-            dynamic_cast<commands::BrokerInfo*>( command );
-        commands::ShutdownInfo* shutdownInfo =
-            dynamic_cast<commands::ShutdownInfo*>( command );
+        if( typeid( *command ) == typeid( commands::MessageDispatch ) ) {
 
-        if( dispatch != NULL ) {
+            commands::MessageDispatch* dispatch =
+                dynamic_cast<commands::MessageDispatch*>( command );
 
             // Due to the severe suckiness of C++, in order to cast to
             // a type that is in a different branch of the inheritence hierarchy
             // we have to cast to the type at the "crotch" of the branch and then
             // we can implicitly cast up the other branch.
-            core::ActiveMQMessage* message = dynamic_cast<commands::ActiveMQMessage*>(dispatch->getMessage());
-            if( message == NULL ) {
-                message = dynamic_cast<commands::ActiveMQTextMessage*>(dispatch->getMessage());
-            }
-            if( message == NULL ) {
-                message = dynamic_cast<commands::ActiveMQBytesMessage*>(dispatch->getMessage());
-            }
-            if( message == NULL ) {
-                message = dynamic_cast<commands::ActiveMQMapMessage*>(dispatch->getMessage());
-            }
+            core::ActiveMQMessage* message = dynamic_cast<core::ActiveMQMessage*>(dispatch->getMessage());
             if( message == NULL ) {
                 delete command;
-                throw OpenWireConnectorException( __FILE__, __LINE__,
+                throw OpenWireConnectorException(
+                    __FILE__, __LINE__,
+                    "OpenWireConnector::onCommand - "
                     "Received unsupported dispatch message" );
             }
 
@@ -1199,7 +1186,9 @@
                 info = consumerInfoMap.getValue( dispatch->getConsumerId()->getValue()
);
                 if( info == NULL ){
                     delete command;
-                    throw OpenWireConnectorException( __FILE__, __LINE__,
+                    throw OpenWireConnectorException(
+                        __FILE__, __LINE__,
+                        "OpenWireConnector::onCommand - "
                         "Received dispatch message for unregistered consumer" );
                 }
             }
@@ -1221,11 +1210,13 @@
 
             delete command;
 
-        } else if( brokerWireFormatInfo != NULL ) {
-            this->brokerWireFormatInfo = brokerWireFormatInfo;
-        } else if( brokerInfo != NULL ) {
-            this->brokerInfo = brokerInfo;
-        } else if( shutdownInfo != NULL ) {
+        } else if( typeid( *command ) == typeid( commands::WireFormatInfo ) ) {
+            this->brokerWireFormatInfo =
+                dynamic_cast<commands::WireFormatInfo*>( command );
+        } else if( typeid( *command ) == typeid( commands::BrokerInfo ) ) {
+            this->brokerInfo =
+                dynamic_cast<commands::BrokerInfo*>( command );
+        } else if( typeid( *command ) == typeid( commands::ShutdownInfo ) ) {
 
             try {
                 if( state != DISCONNECTED ) {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp?view=diff&rev=514493&r1=514492&r2=514493
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.cpp
Sun Mar  4 15:10:17 2007
@@ -26,31 +26,20 @@
 using namespace activemq::connector::openwire::commands;
 
 ////////////////////////////////////////////////////////////////////////////////
-std::vector<char> WireFormatInfo::MAGIC;
-
-////////////////////////////////////////////////////////////////////////////////
 WireFormatInfo::WireFormatInfo()
 {
     // Init to our prefered version
     this->version = 2;
 
-    // Initialize the static MAGIC buffer.
-    if( MAGIC.empty() ) {
-        MAGIC.push_back( 'A' );
-        MAGIC.push_back( 'c' );
-        MAGIC.push_back( 't' );
-        MAGIC.push_back( 'i' );
-        MAGIC.push_back( 'v' );
-        MAGIC.push_back( 'e' );
-        MAGIC.push_back( 'M' );
-        MAGIC.push_back( 'Q' );
-    }
-
-    // Initialize member magic buffer to the static buffer.
-    magic.resize( MAGIC.size() );
-    for( std::size_t ix=0; ix<MAGIC.size(); ++ix ){
-        magic[ix] = MAGIC[ix];
-    }
+    // Initialize the MAGIC buffer.
+    magic.push_back( 'A' );
+    magic.push_back( 'c' );
+    magic.push_back( 't' );
+    magic.push_back( 'i' );
+    magic.push_back( 'v' );
+    magic.push_back( 'e' );
+    magic.push_back( 'M' );
+    magic.push_back( 'Q' );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -168,14 +157,20 @@
 ////////////////////////////////////////////////////////////////////////////////
 bool WireFormatInfo::isValid() const {
 
-    if( magic.size() != MAGIC.size() ) {
+    if( magic.size() != std::string( "ActiveMQ" ).size() ) {
         return false;
     }
 
-    for( size_t i = 0; i < magic.size(); i++ ) {
-        if( magic[i] != MAGIC[i] ) {
-            return false;
-        }
+    if( magic[0] != 'A' ||
+        magic[1] != 'c' ||
+        magic[2] != 't' ||
+        magic[3] != 'i' ||
+        magic[4] != 'v' ||
+        magic[5] != 'e' ||
+        magic[6] != 'M' ||
+        magic[7] != 'Q' ) {
+
+        return false;
     }
 
     return true;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h?view=diff&rev=514493&r1=514492&r2=514493
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/WireFormatInfo.h
Sun Mar  4 15:10:17 2007
@@ -265,8 +265,6 @@
 
     private:
 
-        static std::vector<char> MAGIC;
-
         std::vector<unsigned char> magic;
         std::vector<unsigned char> marshalledProperties;
 



Mime
View raw message