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 2007/01/30 02:08:20 UTC
svn commit: r501265 - in
/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands:
ActiveMQMapMessage.cpp ActiveMQMapMessage.h
Author: tabish
Date: Mon Jan 29 17:08:18 2007
New Revision: 501265
URL: http://svn.apache.org/viewvc?view=rev&rev=501265
Log:
http://issues.apache.org/activemq/browse/AMQCPP-30
Modified:
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp?view=diff&rev=501265&r1=501264&r2=501265
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.cpp Mon Jan 29 17:08:18 2007
@@ -15,26 +15,76 @@
* limitations under the License.
*/
#include <activemq/connector/openwire/commands/ActiveMQMapMessage.h>
+#include <activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h>
using namespace std;
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::commands;
+using namespace activemq::connector::openwire::marshal;
////////////////////////////////////////////////////////////////////////////////
ActiveMQMapMessage::ActiveMQMapMessage() :
ActiveMQMessageBase<cms::MapMessage>()
{
+ this->map = NULL;
}
////////////////////////////////////////////////////////////////////////////////
ActiveMQMapMessage::~ActiveMQMapMessage()
{
+ delete map;
}
////////////////////////////////////////////////////////////////////////////////
unsigned char ActiveMQMapMessage::getDataStructureType() const
{
return ActiveMQMapMessage::ID_ACTIVEMQMAPMESSAGE;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQMapMessage::beforeMarshall( OpenWireFormat* wireFormat AMQCPP_UNUSED ) {
+
+ try{
+
+ if( map != NULL && !map->isEmpty() ) {
+ // Marshal as Content.
+ PrimitiveMapMarshaller::marshal( map, getContent() );
+ } else {
+ clearBody();
+ }
+ }
+ AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+ AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+util::PrimitiveMap& ActiveMQMapMessage::getMap() throw ( NullPointerException ) {
+
+ try{
+
+ if( map == NULL ) {
+
+ if( getContent().size() == 0 ){
+ map = new PrimitiveMap;
+ } else {
+ map = PrimitiveMapMarshaller::unmarshal( getContent() );
+ }
+
+ if( map == NULL ) {
+ throw NullPointerException(
+ __FILE__,
+ __LINE__,
+ "ActiveMQMapMessage::getMap() - All attempts to create a "
+ "map have fialed." );
+ }
+ }
+
+ return *map;
+ }
+ AMQ_CATCH_RETHROW( exceptions::ActiveMQException )
+ AMQ_CATCHALL_THROW( exceptions::ActiveMQException )
}
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h?view=diff&rev=501265&r1=501264&r2=501265
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/commands/ActiveMQMapMessage.h Mon Jan 29 17:08:18 2007
@@ -24,6 +24,8 @@
#endif
#include <activemq/connector/openwire/commands/ActiveMQMessageBase.h>
+#include <activemq/util/PrimitiveMap.h>
+#include <activemq/exceptions/NullPointerException.h>
#include <cms/MapMessage.h>
#include <vector>
#include <string>
@@ -48,6 +50,15 @@
virtual unsigned char getDataStructureType() const;
/**
+ * Determine if this object is aware of marshalling and should have
+ * its before and after marshalling methods called. Defaults to false.
+ * @returns true if aware of marshalling
+ */
+ virtual bool isMarshallAware() const {
+ return true;
+ }
+
+ /**
* Clone this object and return a new instance that the
* caller now owns, this will be an exact copy of this one
* @returns new copy of this object.
@@ -67,6 +78,12 @@
ActiveMQMessageBase<cms::MapMessage>::copyDataStructure( src );
}
+ /**
+ * Perform any processing needed before an marshal
+ * @param wireformat - the OpenWireFormat object in use.
+ */
+ virtual void beforeMarshall( OpenWireFormat* wireFormat AMQCPP_UNUSED );
+
public: // CMS Message
/**
@@ -252,6 +269,20 @@
virtual void setString( const std::string& name,
const std::string& value );
+ protected:
+
+ /**
+ * Fetches a reference to this objects PrimitiveMap, if one needs
+ * to be created or unmarshalled, this will perform the correct steps.
+ * @returns reference to a PrimtiveMap.
+ */
+ util::PrimitiveMap& getMap() throw ( exceptions::NullPointerException );
+
+ private:
+
+ // Map Structure to hold unmarshalled Map Data
+ util::PrimitiveMap* map;
+
};
}}}}