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 2009/04/27 20:20:42 UTC
svn commit: r769083 - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp:
StompCommandConstants.cpp StompCommandConstants.h StompFrame.h
StompWireFormat.cpp marshal/Marshaler.cpp marshal/Marshaler.h
Author: tabish
Date: Mon Apr 27 18:20:41 2009
New Revision: 769083
URL: http://svn.apache.org/viewvc?rev=769083&view=rev
Log:
Add more code to support Stomp WireFormat.
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompFrame.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.h
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp?rev=769083&r1=769082&r2=769083&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.cpp Mon Apr 27 18:20:41 2009
@@ -16,7 +16,6 @@
*/
#include "StompCommandConstants.h"
-#include <stdio.h>
#include <string.h>
using namespace std;
@@ -26,112 +25,74 @@
using namespace decaf::lang::exceptions;
////////////////////////////////////////////////////////////////////////////////
-const char* StompCommandConstants::queuePrefix = "/queue/";
-const char* StompCommandConstants::topicPrefix = "/topic/";
+// Stomp Command Ids
+const std::string StompCommandConstants::CONNECT = "CONNECT";
+const std::string StompCommandConstants::CONNECTED = "CONNECTED";
+const std::string StompCommandConstants::DISCONNECT = "DISCONNECT";
+const std::string StompCommandConstants::SUBSCRIBE = "SUBSCRIBE";
+const std::string StompCommandConstants::UNSUBSCRIBE = "UNSUBSCRIBE";
+const std::string StompCommandConstants::MESSAGE = "MESSAGE";
+const std::string StompCommandConstants::SEND = "SEND";
+const std::string StompCommandConstants::BEGIN = "BEGIN";
+const std::string StompCommandConstants::COMMIT = "COMMIT";
+const std::string StompCommandConstants::ABORT = "ABORT";
+const std::string StompCommandConstants::ACK = "ACK";
+const std::string StompCommandConstants::ERROR_CMD = "ERROR";
+const std::string StompCommandConstants::RECEIPT = "RECEIPT";
////////////////////////////////////////////////////////////////////////////////
-string StompCommandConstants::StaticInitializer::stompHeaders[NUM_STOMP_HEADERS];
-string StompCommandConstants::StaticInitializer::commands[NUM_COMMANDS];
-string StompCommandConstants::StaticInitializer::ackModes[NUM_ACK_MODES];
-string StompCommandConstants::StaticInitializer::msgTypes[NUM_MSG_TYPES];
-map<std::string, StompCommandConstants::StompHeader> StompCommandConstants::StaticInitializer::stompHeaderMap;
-map<std::string, StompCommandConstants::CommandId> StompCommandConstants::StaticInitializer::commandMap;
-map<std::string, StompCommandConstants::AckMode> StompCommandConstants::StaticInitializer::ackModeMap;
-map<std::string, StompCommandConstants::MessageType> StompCommandConstants::StaticInitializer::msgTypeMap;
-StompCommandConstants::StaticInitializer StompCommandConstants::staticInits;
+// Known Stomp Headers
+const std::string StompCommandConstants::HEADER_DESTINATION = "destination";
+const std::string StompCommandConstants::HEADER_TRANSACTIONID = "transaction";
+const std::string StompCommandConstants::HEADER_CONTENTLENGTH = "content-length";
+const std::string StompCommandConstants::HEADER_SESSIONID = "session";
+const std::string StompCommandConstants::HEADER_RECEIPT_REQUIRED = "receipt";
+const std::string StompCommandConstants::HEADER_RECEIPTID = "receipt-id";
+const std::string StompCommandConstants::HEADER_MESSAGEID = "message-id";
+const std::string StompCommandConstants::HEADER_ACK = "ack";
+const std::string StompCommandConstants::HEADER_LOGIN = "login";
+const std::string StompCommandConstants::HEADER_PASSWORD = "passcode";
+const std::string StompCommandConstants::HEADER_CLIENT_ID = "client-id";
+const std::string StompCommandConstants::HEADER_MESSAGE = "message";
+const std::string StompCommandConstants::HEADER_CORRELATIONID = "correlation-id";
+const std::string StompCommandConstants::HEADER_REQUESTID = "request-id";
+const std::string StompCommandConstants::HEADER_RESPONSEID = "response-id";
+const std::string StompCommandConstants::HEADER_EXPIRES = "expires";
+const std::string StompCommandConstants::HEADER_PERSISTENT = "persistent";
+const std::string StompCommandConstants::HEADER_REPLYTO = "reply-to";
+const std::string StompCommandConstants::HEADER_TYPE = "type";
+const std::string StompCommandConstants::HEADER_DISPATCH_ASYNC = "activemq.dispatchAsync";
+const std::string StompCommandConstants::HEADER_EXCLUSIVE = "activemq.exclusive";
+const std::string StompCommandConstants::HEADER_MAXPENDINGMSGLIMIT = "activemq.maximumPendingMessageLimit";
+const std::string StompCommandConstants::HEADER_NOLOCAL = "activemq.noLocal";
+const std::string StompCommandConstants::HEADER_PREFETCHSIZE = "activemq.prefetchSize";
+const std::string StompCommandConstants::HEADER_JMSPRIORITY = "priority";
+const std::string StompCommandConstants::HEADER_CONSUMERPRIORITY = "activemq.priority";
+const std::string StompCommandConstants::HEADER_RETROACTIVE = "activemq.retroactive";
+const std::string StompCommandConstants::HEADER_SUBSCRIPTIONNAME = "activemq.subcriptionName";
+const std::string StompCommandConstants::HEADER_TIMESTAMP = "timestamp";
+const std::string StompCommandConstants::HEADER_REDELIVERED = "redelivered";
+const std::string StompCommandConstants::HEADER_REDELIVERYCOUNT = "redelivery_count";
+const std::string StompCommandConstants::HEADER_SELECTOR = "selector";
+const std::string StompCommandConstants::HEADER_ID = "id";
+const std::string StompCommandConstants::HEADER_SUBSCRIPTION = "subscription";
+const std::string StompCommandConstants::HEADER_TRANSFORMATION = "transformation";
+const std::string StompCommandConstants::HEADER_TRANSFORMATION_ERROR = "transformation-error";
////////////////////////////////////////////////////////////////////////////////
-StompCommandConstants::StaticInitializer::StaticInitializer(){
-
- stompHeaders[HEADER_DESTINATION] = "destination";
- stompHeaders[HEADER_TRANSACTIONID] = "transaction";
- stompHeaders[HEADER_CONTENTLENGTH] = "content-length";
- stompHeaders[HEADER_SESSIONID] = "session";
- stompHeaders[HEADER_RECEIPTID] = "receipt-id";
- stompHeaders[HEADER_RECEIPT_REQUIRED] = "receipt";
- stompHeaders[HEADER_MESSAGEID] = "message-id";
- stompHeaders[HEADER_ACK] = "ack";
- stompHeaders[HEADER_LOGIN] = "login";
- stompHeaders[HEADER_PASSWORD] = "passcode";
- stompHeaders[HEADER_CLIENT_ID] = "client-id";
- stompHeaders[HEADER_MESSAGE] = "message";
- stompHeaders[HEADER_CORRELATIONID] = "correlation-id";
- stompHeaders[HEADER_REQUESTID] = "request-id";
- stompHeaders[HEADER_RESPONSEID] = "response-id";
- stompHeaders[HEADER_EXPIRES] = "expires";
- stompHeaders[HEADER_PERSISTENT] = "persistent";
- stompHeaders[HEADER_JMSPRIORITY] = "priority";
- stompHeaders[HEADER_CONSUMERPRIORITY] = "activemq.priority";
- stompHeaders[HEADER_REPLYTO] = "reply-to";
- stompHeaders[HEADER_TYPE] = "type";
- stompHeaders[HEADER_SELECTOR] = "selector";
- stompHeaders[HEADER_DISPATCH_ASYNC] = "activemq.dispatchAsync";
- stompHeaders[HEADER_EXCLUSIVE] = "activemq.exclusive";
- stompHeaders[HEADER_MAXPENDINGMSGLIMIT] = "activemq.maximumPendingMessageLimit";
- stompHeaders[HEADER_NOLOCAL] = "activemq.noLocal";
- stompHeaders[HEADER_PREFETCHSIZE] = "activemq.prefetchSize";
- stompHeaders[HEADER_CONSUMERPRIORITY] = "activemq.priority";
- stompHeaders[HEADER_RETROACTIVE] = "activemq.retroactive";
- stompHeaders[HEADER_SUBSCRIPTIONNAME] = "activemq.subcriptionName";
- stompHeaders[HEADER_TIMESTAMP] = "timestamp";
- stompHeaders[HEADER_REDELIVERED] = "redelivered";
- stompHeaders[HEADER_REDELIVERYCOUNT] = "redelivery_count";
- stompHeaders[HEADER_SELECTOR] = "selector";
- stompHeaders[HEADER_ID] = "id";
- stompHeaders[HEADER_SUBSCRIPTION] = "subscription";
- commands[CONNECT] = "CONNECT";
- commands[CONNECTED] = "CONNECTED";
- commands[DISCONNECT] = "DISCONNECT";
- commands[SUBSCRIBE] = "SUBSCRIBE";
- commands[UNSUBSCRIBE] = "UNSUBSCRIBE";
- commands[MESSAGE] = "MESSAGE";
- commands[SEND] = "SEND";
- commands[BEGIN] = "BEGIN";
- commands[COMMIT] = "COMMIT";
- commands[ABORT] = "ABORT";
- commands[ACK] = "ACK";
- commands[ERROR_CMD] = "ERROR";
- commands[RECEIPT] = "RECEIPT";
- ackModes[ACK_CLIENT] = "client";
- ackModes[ACK_AUTO] = "auto";
- msgTypes[TEXT] = "text";
- msgTypes[BYTES] = "bytes";
-
- for( int ix=0; ix<NUM_STOMP_HEADERS; ++ix ){
- stompHeaderMap[stompHeaders[ix]] = (StompHeader)ix;
- }
-
- for( int ix=0; ix<NUM_COMMANDS; ++ix ){
- commandMap[commands[ix]] = (CommandId)ix;
- }
-
- for( int ix=0; ix<NUM_ACK_MODES; ++ix ){
- ackModeMap[ackModes[ix]] = (AckMode)ix;
- }
-
- for( int ix=0; ix<NUM_MSG_TYPES; ++ix ){
- msgTypeMap[msgTypes[ix]] = (MessageType)ix;
- }
-}
+// Stomp Ack Modes
+const std::string StompCommandConstants::ACK_CLIENT = "client";
+const std::string StompCommandConstants::ACK_AUTO = "auto";
+const std::string StompCommandConstants::ACK_INDIVIDUAL = "client-individual";
////////////////////////////////////////////////////////////////////////////////
-cms::Destination* StompCommandConstants::toDestination( const std::string& dest )
- throw ( decaf::lang::exceptions::IllegalArgumentException )
-{
-// std::size_t qpos = dest.find( queuePrefix );
-// std::size_t tpos = dest.find( topicPrefix );
-//
-// if( tpos == 0 ) {
-// return new StompTopic(dest.substr(strlen(topicPrefix)));
-// } else if( qpos == 0 ) {
-// return new StompQueue(dest.substr(strlen(queuePrefix)));
-// } else {
-// throw IllegalArgumentException(
-// __FILE__, __LINE__,
-// "StompCommandConstants::toDestination - Not a valid Stomp Dest [%s]", dest.c_str());
-// }
-
- return NULL;
-}
-
+// Supported Stomp Message Types
+const std::string StompCommandConstants::TEXT = "text";
+const std::string StompCommandConstants::BYTES = "bytes";
+////////////////////////////////////////////////////////////////////////////////
+// Prefix Id's for Topics and Queues
+const std::string StompCommandConstants::QUEUE_PREFIX = "/queue/";
+const std::string StompCommandConstants::TOPIC_PREFIX = "/topic/";
+const std::string StompCommandConstants::TEMPQUEUE_PREFIX = "/temp-queue/";
+const std::string StompCommandConstants::TEMPTOPIC_PREFIX = "/temp-topic/";
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h?rev=769083&r1=769082&r2=769083&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompCommandConstants.h Mon Apr 27 18:20:41 2009
@@ -31,172 +31,74 @@
class AMQCPP_API StompCommandConstants{
public:
- enum CommandId{
- CONNECT,
- CONNECTED,
- DISCONNECT,
- SUBSCRIBE,
- UNSUBSCRIBE,
- MESSAGE,
- SEND,
- BEGIN,
- COMMIT,
- ABORT,
- ACK,
- ERROR_CMD,
- RECEIPT,
- NUM_COMMANDS
- };
-
- enum StompHeader{
- HEADER_DESTINATION,
- HEADER_TRANSACTIONID,
- HEADER_CONTENTLENGTH,
- HEADER_SESSIONID,
- HEADER_RECEIPT_REQUIRED,
- HEADER_RECEIPTID,
- HEADER_MESSAGEID,
- HEADER_ACK,
- HEADER_LOGIN,
- HEADER_PASSWORD,
- HEADER_CLIENT_ID,
- HEADER_MESSAGE,
- HEADER_CORRELATIONID,
- HEADER_REQUESTID,
- HEADER_RESPONSEID,
- HEADER_EXPIRES,
- HEADER_PERSISTENT,
- HEADER_REPLYTO,
- HEADER_TYPE,
- HEADER_DISPATCH_ASYNC,
- HEADER_EXCLUSIVE,
- HEADER_MAXPENDINGMSGLIMIT,
- HEADER_NOLOCAL,
- HEADER_PREFETCHSIZE,
- HEADER_JMSPRIORITY,
- HEADER_CONSUMERPRIORITY,
- HEADER_RETROACTIVE,
- HEADER_SUBSCRIPTIONNAME,
- HEADER_TIMESTAMP,
- HEADER_REDELIVERED,
- HEADER_REDELIVERYCOUNT,
- HEADER_SELECTOR,
- HEADER_ID,
- HEADER_SUBSCRIPTION,
- NUM_STOMP_HEADERS
- };
-
- enum AckMode {
- ACK_CLIENT,
- ACK_AUTO,
- NUM_ACK_MODES
- };
-
- enum MessageType {
- TEXT,
- BYTES,
- NUM_MSG_TYPES
- };
-
- static const char* queuePrefix;
- static const char* topicPrefix;
-
- static const std::string& toString( const CommandId cmd ){
- return StaticInitializer::commands[cmd];
- }
-
- static CommandId toCommandId( const std::string& cmd ){
- std::map<std::string, CommandId>::iterator iter =
- StaticInitializer::commandMap.find(cmd);
-
- if( iter == StaticInitializer::commandMap.end() ){
- return NUM_COMMANDS;
- }
-
- return iter->second;
- }
-
- static bool isCommandId( const std::string& str ){
- std::map<std::string, CommandId>::iterator iter =
- StaticInitializer::commandMap.find(str);
-
- return iter != StaticInitializer::commandMap.end();
- }
-
- static std::string toString( const StompHeader header ){
- return StaticInitializer::stompHeaders[header];
- }
-
- static StompHeader toStompHeader( const std::string& header ){
-
- std::map<std::string, StompHeader>::iterator iter =
- StaticInitializer::stompHeaderMap.find(header);
-
- if( iter == StaticInitializer::stompHeaderMap.end() ){
- return NUM_STOMP_HEADERS;
- }
-
- return iter->second;
- }
-
- static bool isStompHeader( const std::string& str ){
- std::map<std::string, StompHeader>::iterator iter =
- StaticInitializer::stompHeaderMap.find(str);
-
- return iter != StaticInitializer::stompHeaderMap.end();
- }
-
- static std::string toString( const AckMode mode ){
- return StaticInitializer::ackModes[mode];
- }
-
- static AckMode toAckMode( const std::string& mode ){
- std::map<std::string, AckMode>::iterator iter =
- StaticInitializer::ackModeMap.find(mode);
-
- if( iter == StaticInitializer::ackModeMap.end() ){
- return NUM_ACK_MODES;
- }
-
- return iter->second;
- }
-
- static std::string toString( const MessageType type ){
- return StaticInitializer::msgTypes[type];
- }
-
- static MessageType toMessageType( const std::string& type ){
- std::map<std::string, MessageType>::iterator iter =
- StaticInitializer::msgTypeMap.find(type);
-
- if( iter == StaticInitializer::msgTypeMap.end() ){
- return NUM_MSG_TYPES;
- }
-
- return iter->second;
- }
-
- static cms::Destination* toDestination( const std::string& dest )
- throw ( decaf::lang::exceptions::IllegalArgumentException );
-
- class StaticInitializer{
- public:
- StaticInitializer();
- virtual ~StaticInitializer(){}
-
- static std::string stompHeaders[NUM_STOMP_HEADERS];
- static std::string commands[NUM_COMMANDS];
- static std::string ackModes[NUM_ACK_MODES];
- static std::string msgTypes[NUM_MSG_TYPES];
- static std::map<std::string, StompHeader> stompHeaderMap;
- static std::map<std::string, CommandId> commandMap;
- static std::map<std::string, AckMode> ackModeMap;
- static std::map<std::string, MessageType> msgTypeMap;
- };
+ // Stomp Command Ids
+ static const std::string CONNECT;
+ static const std::string CONNECTED;
+ static const std::string DISCONNECT;
+ static const std::string SUBSCRIBE;
+ static const std::string UNSUBSCRIBE;
+ static const std::string MESSAGE;
+ static const std::string SEND;
+ static const std::string BEGIN;
+ static const std::string COMMIT;
+ static const std::string ABORT;
+ static const std::string ACK;
+ static const std::string ERROR_CMD;
+ static const std::string RECEIPT;
+
+ // Known Stomp Headers
+ static const std::string HEADER_DESTINATION;
+ static const std::string HEADER_TRANSACTIONID;
+ static const std::string HEADER_CONTENTLENGTH;
+ static const std::string HEADER_SESSIONID;
+ static const std::string HEADER_RECEIPT_REQUIRED;
+ static const std::string HEADER_RECEIPTID;
+ static const std::string HEADER_MESSAGEID;
+ static const std::string HEADER_ACK;
+ static const std::string HEADER_LOGIN;
+ static const std::string HEADER_PASSWORD;
+ static const std::string HEADER_CLIENT_ID;
+ static const std::string HEADER_MESSAGE;
+ static const std::string HEADER_CORRELATIONID;
+ static const std::string HEADER_REQUESTID;
+ static const std::string HEADER_RESPONSEID;
+ static const std::string HEADER_EXPIRES;
+ static const std::string HEADER_PERSISTENT;
+ static const std::string HEADER_REPLYTO;
+ static const std::string HEADER_TYPE;
+ static const std::string HEADER_DISPATCH_ASYNC;
+ static const std::string HEADER_EXCLUSIVE;
+ static const std::string HEADER_MAXPENDINGMSGLIMIT;
+ static const std::string HEADER_NOLOCAL;
+ static const std::string HEADER_PREFETCHSIZE;
+ static const std::string HEADER_JMSPRIORITY;
+ static const std::string HEADER_CONSUMERPRIORITY;
+ static const std::string HEADER_RETROACTIVE;
+ static const std::string HEADER_SUBSCRIPTIONNAME;
+ static const std::string HEADER_TIMESTAMP;
+ static const std::string HEADER_REDELIVERED;
+ static const std::string HEADER_REDELIVERYCOUNT;
+ static const std::string HEADER_SELECTOR;
+ static const std::string HEADER_ID;
+ static const std::string HEADER_SUBSCRIPTION;
+ static const std::string HEADER_TRANSFORMATION;
+ static const std::string HEADER_TRANSFORMATION_ERROR;
+
+ // Stomp Ack Modes
+ static const std::string ACK_CLIENT;
+ static const std::string ACK_AUTO;
+ static const std::string ACK_INDIVIDUAL;
+
+ // Supported Stomp Message Types
+ static const std::string TEXT;
+ static const std::string BYTES;
+
+ // Prefix Id's for Topics and Queues
+ static const std::string QUEUE_PREFIX;
+ static const std::string TOPIC_PREFIX;
+ static const std::string TEMPQUEUE_PREFIX;
+ static const std::string TEMPTOPIC_PREFIX;
- private:
-
- static StaticInitializer staticInits;
};
}}}
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=769083&r1=769082&r2=769083&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 Apr 27 18:20:41 2009
@@ -33,6 +33,17 @@
* to and from the broker.
*/
class AMQCPP_API StompFrame{
+ private:
+
+ // String Name of this command.
+ std::string command;
+
+ // Properties of the Stomp Message
+ decaf::util::Properties properties;
+
+ // Byte data of Body.
+ std::vector<unsigned char> body;
+
public:
/**
@@ -84,6 +95,48 @@
}
/**
+ * Checks if the given property is present in the Frame.
+ *
+ * @param name - The name of the property to check for.
+ */
+ bool hasProperty( const std::string& name ) const {
+ return this->properties.hasProperty( name );
+ }
+
+ /**
+ * Gets a property from this Frame's properties and returns it, or the
+ * default value given.
+ *
+ * @param name - The name of the property to lookup
+ * @param fallback - The default value to return if this value isn't set
+ *
+ * @return string value of the property asked for.
+ */
+ std::string getProperty( const std::string& name, const std::string& fallback = "" ) const {
+ return this->properties.getProperty( name, fallback );
+ }
+
+ /**
+ * Gets and remove the property specified, if the property is not set, this method
+ * returns the empty string.
+ *
+ * @param name - the Name of the property to get and return.
+ */
+ std::string removeProperty( const std::string& name ) {
+ return this->properties.getProperty( name, "" );
+ }
+
+ /**
+ * Sets the property given to the value specified in this Frame's Properties
+ *
+ * @param name - Name of the property.
+ * @param value - Value to set the property to.
+ */
+ void setProperty( const std::string& name, const std::string& value ) {
+ this->properties.setProperty( name, value );
+ }
+
+ /**
* Gets access to the header properties for this frame.
* @return the Properties object owned by this Frame
*/
@@ -128,16 +181,6 @@
std::copy( bytes, bytes + numBytes, iter );
}
- private:
-
- // String Name of this command.
- std::string command;
-
- // Properties of the Stomp Message
- decaf::util::Properties properties;
-
- // Byte data of Body.
- std::vector<unsigned char> body;
};
}}}
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=769083&r1=769082&r2=769083&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 Apr 27 18:20:41 2009
@@ -83,9 +83,7 @@
}
if( ( frame->getBodyLength() == 0 ) ||
- ( frame->getProperties().getProperty(
- StompCommandConstants::toString(
- StompCommandConstants::HEADER_CONTENTLENGTH ), "" ) != "" ) ) {
+ ( frame->getProperty( StompCommandConstants::HEADER_CONTENTLENGTH ) != "" ) ) {
out->writeByte( '\0' );
}
@@ -279,15 +277,8 @@
unsigned int content_length = 0;
- if( frame->getProperties().hasProperty(
- StompCommandConstants::toString(
- StompCommandConstants::HEADER_CONTENTLENGTH ) ) ) {
-
- string length =
- frame->getProperties().getProperty(
- StompCommandConstants::toString(
- StompCommandConstants::HEADER_CONTENTLENGTH ) );
-
+ if( frame->hasProperty( StompCommandConstants::HEADER_CONTENTLENGTH ) ) {
+ string length = frame->getProperty( StompCommandConstants::HEADER_CONTENTLENGTH );
content_length = (unsigned int)Integer::parseInt( length );
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.cpp?rev=769083&r1=769082&r2=769083&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.cpp Mon Apr 27 18:20:41 2009
@@ -26,6 +26,10 @@
#include <activemq/commands/ActiveMQBytesMessage.h>
#include <activemq/commands/Response.h>
#include <activemq/commands/BrokerError.h>
+#include <activemq/commands/ExceptionResponse.h>
+
+#include <decaf/lang/Integer.h>
+#include <decaf/io/IOException.h>
using namespace activemq;
using namespace activemq::commands;
@@ -34,6 +38,7 @@
using namespace activemq::wireformat::stomp;
using namespace activemq::wireformat::stomp::marshal;
using namespace decaf::lang;
+using namespace decaf::io;
////////////////////////////////////////////////////////////////////////////////
Pointer<Command> Marshaler::marshal( const Pointer<StompFrame>& frame )
@@ -41,10 +46,7 @@
try {
- StompCommandConstants::CommandId commandId =
- StompCommandConstants::toCommandId( frame->getCommand().c_str() );
-
- Pointer<Command> command;
+ const std::string commandId = frame->getCommand();
if( commandId == StompCommandConstants::CONNECTED ){
return this->unmarshalConnected( frame );
@@ -81,9 +83,13 @@
return this->marshalShutdownInfo( command );
} else if( command->isMessageAck() ) {
return this->marshalAck( command );
+ } else if( command->isConnectionInfo() ) {
+ return this->marshalConnectionInfo( command );
+ } else if( command->isTransactionInfo() ) {
+ return this->marshalTransactionInfo( command );
}
- // Ignoreing this command.
+ // Ignoring this command.
return Pointer<StompFrame>();
}
AMQ_CATCH_RETHROW( decaf::io::IOException )
@@ -115,18 +121,36 @@
////////////////////////////////////////////////////////////////////////////////
Pointer<Command> Marshaler::unmarshalConnected( const Pointer<StompFrame>& frame ) {
- return Pointer<Command>();
+ 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." );
+ }
+
+ return response;
}
////////////////////////////////////////////////////////////////////////////////
Pointer<Command> Marshaler::unmarshalError( const Pointer<StompFrame>& frame ) {
+ Pointer<Command> result;
+
Pointer<BrokerError> error( new BrokerError() );
error->setMessage(
- frame->getProperties().getProperty(
- StompCommandConstants::toString( StompCommandConstants::HEADER_MESSAGE ), "" ) );
+ frame->removeProperty( StompCommandConstants::HEADER_MESSAGE ) );
- return error;
+ if( frame->hasProperty( StompCommandConstants::HEADER_RECEIPTID ) ) {
+ Pointer<ExceptionResponse> errorResponse( new ExceptionResponse() );
+ errorResponse->setException( error );
+ errorResponse->setCorrelationId( Integer::parseInt(
+ frame->removeProperty( StompCommandConstants::HEADER_RECEIPTID ) ) );
+ return errorResponse;
+ } else {
+ return error;
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -142,7 +166,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-Pointer<StompFrame> Marshaler::marshalConnect( const Pointer<Command>& command ) {
+Pointer<StompFrame> Marshaler::marshalConnectionInfo( const Pointer<Command>& command ) {
return Pointer<StompFrame>();
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.h?rev=769083&r1=769082&r2=769083&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshaler.h Mon Apr 27 18:20:41 2009
@@ -68,7 +68,7 @@
Pointer<StompFrame> marshalMessage( const Pointer<Command>& command );
Pointer<StompFrame> marshalAck( const Pointer<Command>& command );
- Pointer<StompFrame> marshalConnect( 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 );