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/26 20:40:14 UTC

svn commit: r768739 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp: ./ marshal/

Author: tabish
Date: Sun Apr 26 18:40:13 2009
New Revision: 768739

URL: http://svn.apache.org/viewvc?rev=768739&view=rev
Log:
Implement the basic of the StompWireFormat.

Removed:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/MarshalException.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/marshal/Marshalable.h
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/StompResponseBuilder.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.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/StompWireFormat.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h
    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=768739&r1=768738&r2=768739&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 Sun Apr 26 18:40:13 2009
@@ -23,8 +23,6 @@
 using namespace activemq;
 using namespace activemq::wireformat;
 using namespace activemq::wireformat::stomp;
-using namespace activemq::wireformat::stomp::commands;
-using namespace activemq::connector::stomp;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -120,18 +118,20 @@
 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 );
+//    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());
+//    }
 
-    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;
 }
 
 

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=768739&r1=768738&r2=768739&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 Sun Apr 26 18:40:13 2009
@@ -27,9 +27,8 @@
 namespace activemq{
 namespace wireformat{
 namespace stomp{
-namespace commands{
 
-    class AMQCPP_API CommandConstants{
+    class AMQCPP_API StompCommandConstants{
     public:
 
         enum CommandId{
@@ -200,6 +199,6 @@
         static StaticInitializer staticInits;
     };
 
-}}}}
+}}}
 
 #endif /*_ACTIVEMQ_WIREFORMAT_STOMP_COMMANDS_COMMANDCONSTANTS_H_*/

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.cpp?rev=768739&r1=768738&r2=768739&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.cpp Sun Apr 26 18:40:13 2009
@@ -17,11 +17,7 @@
 
 #include "StompResponseBuilder.h"
 
-#include <activemq/connector/stomp/commands/ConnectCommand.h>
-#include <activemq/connector/stomp/commands/ConnectedCommand.h>
-#include <activemq/connector/stomp/commands/SubscribeCommand.h>
-#include <activemq/connector/stomp/commands/UnsubscribeCommand.h>
-
+#include <decaf/io/IOException.h>
 #include <decaf/util/UUID.h>
 
 using namespace activemq;
@@ -31,39 +27,40 @@
 using namespace activemq::transport::mock;
 using namespace decaf;
 using namespace decaf::util;
+using namespace decaf::io;
 
 ////////////////////////////////////////////////////////////////////////////////
-Response* StompResponseBuilder::buildResponse( const commands::Command* cmd ){
+Pointer<Response> StompResponseBuilder::buildResponse( const Pointer<Command>& command ) {
 
     // If this command requires a response we don't know what it is
     // so we throw an exception.
-    if( cmd->isResponseRequired() ) {
+    if( command->isResponseRequired() ) {
 
-        throw commands::CommandIOException( __FILE__, __LINE__,
+        throw IOException( __FILE__, __LINE__,
             "StompResponseBuilder - unrecognized command" );
     }
 
-    return NULL;
+    return Pointer<Response>();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void StompResponseBuilder::buildIncomingCommands(
-    const commands::Command* command, decaf::util::Queue<commands::Command*>& queue ){
-
-    const connector::stomp::commands::ConnectCommand* connectCommand =
-        dynamic_cast<const connector::stomp::commands::ConnectCommand*>( command );
+void StompResponseBuilder::buildIncomingCommands( const Pointer<Command>& command,
+                                                  decaf::util::StlQueue< Pointer<Command> >& queue ) {
 
-    if( connectCommand != NULL ) {
-        connector::stomp::commands::ConnectedCommand* resp =
-            new connector::stomp::commands::ConnectedCommand();
-        resp->setCorrelationId( connectCommand->getCommandId() );
-
-        if( connectCommand->getClientId() == NULL ) {
-            resp->setSessionId( UUID::randomUUID().toString() );
-        } else {
-            resp->setSessionId( connectCommand->getClientId() );
-        }
-
-        queue.push( resp );
-    }
+//    const connector::stomp::commands::ConnectCommand* connectCommand =
+//        dynamic_cast<const connector::stomp::commands::ConnectCommand*>( command );
+//
+//    if( connectCommand != NULL ) {
+//        connector::stomp::commands::ConnectedCommand* resp =
+//            new connector::stomp::commands::ConnectedCommand();
+//        resp->setCorrelationId( connectCommand->getCommandId() );
+//
+//        if( connectCommand->getClientId() == NULL ) {
+//            resp->setSessionId( UUID::randomUUID().toString() );
+//        } else {
+//            resp->setSessionId( connectCommand->getClientId() );
+//        }
+//
+//        queue.push( resp );
+//    }
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.h?rev=768739&r1=768738&r2=768739&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompResponseBuilder.h Sun Apr 26 18:40:13 2009
@@ -18,23 +18,32 @@
 #ifndef _ACTIVEMQ_WIREFORMAT_STOMP_STOMPRESPONSEBUILDER_H_
 #define _ACTIVEMQ_WIREFORMAT_STOMP_STOMPRESPONSEBUILDER_H_
 
-#include <activemq/transport/mock/MockTransport.h>
+#include <activemq/transport/mock/ResponseBuilder.h>
 #include <activemq/util/Config.h>
+#include <activemq/commands/Command.h>
+#include <activemq/commands/Response.h>
+#include <decaf/lang/Pointer.h>
+#include <decaf/util/StlQueue.h>
 
 namespace activemq{
 namespace wireformat{
 namespace stomp{
 
-    class AMQCPP_API StompResponseBuilder :
-        public transport::mock::MockTransport::ResponseBuilder{
+    using decaf::lang::Pointer;
+    using activemq::commands::Command;
+    using activemq::commands::Response;
+
+    class AMQCPP_API StompResponseBuilder : public transport::mock::ResponseBuilder{
     public:
 
         StompResponseBuilder() {}
         virtual ~StompResponseBuilder() {}
 
-        virtual commands::Response* buildResponse( const commands::Command* cmd );
+        virtual Pointer<Response> buildResponse( const Pointer<Command>& command );
+
         virtual void buildIncomingCommands(
-            const commands::Command* cmd, decaf::util::Queue<commands::Command*>& queue );
+            const Pointer<Command>& command,
+            decaf::util::StlQueue< Pointer<Command> >& queue ) = 0;
 
     };
 

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=768739&r1=768738&r2=768739&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 Sun Apr 26 18:40:13 2009
@@ -18,7 +18,7 @@
 #include "StompWireFormat.h"
 
 #include <activemq/wireformat/stomp/StompFrame.h>
-#include <activemq/wireformat/stomp/commands/CommandConstants.h>
+#include <activemq/wireformat/stomp/StompCommandConstants.h>
 #include <decaf/lang/Character.h>
 #include <decaf/lang/Integer.h>
 #include <decaf/io/IOException.h>
@@ -28,7 +28,6 @@
 using namespace activemq;
 using namespace activemq::wireformat;
 using namespace activemq::wireformat::stomp;
-using namespace activemq::wireformat::stomp::commands;
 using namespace decaf;
 using namespace decaf::io;
 using namespace decaf::lang;
@@ -43,7 +42,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void StompWireFormat::marshal( commands::Command* command, decaf::io::DataOutputStream* out )
+void StompWireFormat::marshal( const Pointer<Command>& command, decaf::io::DataOutputStream* out )
     throw ( decaf::io::IOException ) {
 
     try{
@@ -55,15 +54,15 @@
                 "output stream is NULL" );
         }
 
-        const StompFrame& frame = marshaler.marshal( command );
+        Pointer<StompFrame> frame = marshaler.marshal( command );
 
         // Write the command.
-        const string& cmdString = frame.getCommand();
+        const string& cmdString = frame->getCommand();
         out->write( (unsigned char*)cmdString.c_str(), 0, cmdString.length() );
         out->writeByte( '\n' );
 
         // Write all the headers.
-        vector< pair<string,string> > headers = frame.getProperties().toArray();
+        vector< pair<string,string> > headers = frame->getProperties().toArray();
         for( std::size_t ix=0; ix < headers.size(); ++ix ) {
             string& name = headers[ix].first;
             string& value = headers[ix].second;
@@ -78,15 +77,15 @@
         out->writeByte( '\n' );
 
         // Write the body.
-        const std::vector<unsigned char>& body = frame.getBody();
+        const std::vector<unsigned char>& body = frame->getBody();
         if( body.size() > 0 ) {
             out->write( &body[0], 0, body.size() );
         }
 
-        if( ( frame.getBodyLength() == 0 ) ||
-            ( frame.getProperties().getProperty(
-                  CommandConstants::toString(
-                      CommandConstants::HEADER_CONTENTLENGTH ), "" ) != "" ) ) {
+        if( ( frame->getBodyLength() == 0 ) ||
+            ( frame->getProperties().getProperty(
+                  StompCommandConstants::toString(
+                      StompCommandConstants::HEADER_CONTENTLENGTH ), "" ) != "" ) ) {
 
             out->writeByte( '\0' );
         }
@@ -102,10 +101,10 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-commands::Command* StompWireFormat::unmarshal( decaf::io::DataInputStream* in )
+Pointer<Command> StompWireFormat::unmarshal( decaf::io::DataInputStream* in )
     throw ( decaf::io::IOException ) {
 
-    auto_ptr<StompFrame> frame;
+    Pointer<StompFrame> frame;
 
     try{
 
@@ -121,8 +120,8 @@
         // Read the body.
         readStompBody( *( frame.get() ), in );
 
-        // Return the Command, caller must delete it.
-        return marshaler.marshal( frame.release() );
+        // Return the Command.
+        return marshaler.marshal( frame );
     }
     AMQ_CATCH_RETHROW( decaf::io::IOException )
     AMQ_CATCH_EXCEPTION_CONVERT( decaf::lang::Exception, decaf::io::IOException )
@@ -130,8 +129,9 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-WireFormatNegotiator* StompWireFormat::createNegotiator( transport::Transport* transport )
-    throw( decaf::lang::exceptions::UnsupportedOperationException ) {
+Pointer<transport::Transport> StompWireFormat::createNegotiator(
+    const Pointer<transport::Transport>& transport AMQCPP_UNUSED )
+        throw( decaf::lang::exceptions::UnsupportedOperationException ) {
 
     throw UnsupportedOperationException( __FILE__, __LINE__,
         "No Negotiator is required to use this WireFormat." );
@@ -282,13 +282,13 @@
         unsigned int content_length = 0;
 
         if(frame.getProperties().hasProperty(
-            commands::CommandConstants::toString(
-                commands::CommandConstants::HEADER_CONTENTLENGTH))) {
+            StompCommandConstants::toString(
+                StompCommandConstants::HEADER_CONTENTLENGTH ) ) ) {
 
             string length =
                 frame.getProperties().getProperty(
-                    commands::CommandConstants::toString(
-                        commands::CommandConstants::HEADER_CONTENTLENGTH));
+                    StompCommandConstants::toString(
+                        StompCommandConstants::HEADER_CONTENTLENGTH ) );
 
             content_length = (unsigned int)Integer::parseInt( length );
          }
@@ -327,7 +327,7 @@
         } else {
 
             // Content length was either zero, or not set, so we read until the
-            // first null is encounted.
+            // first null is encountered.
             while( true ) {
 
                 char byte = in->readByte();
@@ -336,8 +336,7 @@
 
                 content_length++;
 
-                if( byte != '\0' )
-                {
+                if( byte != '\0' ) {
                     continue;
                 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h?rev=768739&r1=768738&r2=768739&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormat.h Sun Apr 26 18:40:13 2009
@@ -23,11 +23,15 @@
 #include <activemq/wireformat/stomp/StompFrame.h>
 #include <activemq/wireformat/stomp/marshal/Marshaler.h>
 #include <decaf/io/IOException.h>
+#include <decaf/lang/Pointer.h>
 
 namespace activemq {
 namespace wireformat {
 namespace stomp {
 
+    using decaf::lang::Pointer;
+    using activemq::commands::Command;
+
     class AMQCPP_API StompWireFormat : public WireFormat {
     private:
 
@@ -52,7 +56,7 @@
          * @param out - the output stream to write the command to.
          * @throws IOException
          */
-        virtual void marshal( commands::Command* command, decaf::io::DataOutputStream* out )
+        virtual void marshal( const Pointer<Command>& command, decaf::io::DataOutputStream* out )
             throw ( decaf::io::IOException );
 
         /**
@@ -61,7 +65,7 @@
          * @returns the newly marshaled Command, caller owns the pointer
          * @throws IOException
          */
-        virtual commands::Command* unmarshal( decaf::io::DataInputStream* in )
+        virtual Pointer<Command> unmarshal( decaf::io::DataInputStream* in )
             throw ( decaf::io::IOException );
 
         /**
@@ -93,8 +97,9 @@
          * @returns new instance of a WireFormatNegotiator.
          * @throws UnsupportedOperationException if the WireFormat doesn't have a Negotiator.
          */
-        virtual WireFormatNegotiator* createNegotiator( transport::Transport* transport )
-            throw( decaf::lang::exceptions::UnsupportedOperationException );
+        virtual Pointer<transport::Transport> createNegotiator(
+            const Pointer<transport::Transport>& transport )
+                throw( decaf::lang::exceptions::UnsupportedOperationException );
 
     private:
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp?rev=768739&r1=768738&r2=768739&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.cpp Sun Apr 26 18:40:13 2009
@@ -26,12 +26,12 @@
 using namespace activemq::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-StompWireFormat* StompWireFormatFactory::createWireFormat(
-    const decaf::util::Properties& properties )
+Pointer<WireFormat> StompWireFormatFactory::createWireFormat(
+    const decaf::util::Properties& properties AMQCPP_UNUSED )
         throw ( decaf::lang::exceptions::IllegalStateException ) {
 
     try{
-        return new StompWireFormat();
+        return Pointer<WireFormat>( new StompWireFormat() );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
     AMQ_CATCHALL_THROW( ActiveMQException )

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h?rev=768739&r1=768738&r2=768739&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/stomp/StompWireFormatFactory.h Sun Apr 26 18:40:13 2009
@@ -21,15 +21,18 @@
 #include <activemq/util/Config.h>
 #include <activemq/wireformat/WireFormatFactory.h>
 #include <activemq/wireformat/stomp/StompWireFormat.h>
+#include <decaf/lang/Pointer.h>
 
 namespace activemq {
 namespace wireformat {
 namespace stomp {
 
+    using decaf::lang::Pointer;
+
     /**
      * Factory used to create the Stomp Wire Format instance.
      */
-    class StompWireFormatFactory : public WireFormatFactory {
+    class AMQCPP_API StompWireFormatFactory : public WireFormatFactory {
     public:
 
         StompWireFormatFactory() {}
@@ -40,7 +43,7 @@
          * properties from which it can obtain any optional settings
          * @param properties - the Properties for this WireFormat
          */
-        virtual StompWireFormat* createWireFormat( const decaf::util::Properties& properties )
+        virtual Pointer<WireFormat> createWireFormat( const decaf::util::Properties& properties )
             throw ( decaf::lang::exceptions::IllegalStateException );
 
     };

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=768739&r1=768738&r2=768739&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 Sun Apr 26 18:40:13 2009
@@ -17,98 +17,80 @@
 
 #include <activemq/wireformat/stomp/marshal/Marshaler.h>
 
-#include <activemq/transport/Command.h>
-#include <activemq/connector/stomp/commands/CommandConstants.h>
-#include <activemq/connector/stomp/commands/AbstractCommand.h>
-
+#include <activemq/commands/Command.h>
+#include <activemq/wireformat/stomp/StompCommandConstants.h>
 #include <activemq/wireformat/stomp/StompFrame.h>
-#include <activemq/wireformat/stomp/marshal/MarshalException.h>
 
-// Commands we can receive
-#include <activemq/connector/stomp/commands/ConnectedCommand.h>
-#include <activemq/connector/stomp/commands/ReceiptCommand.h>
-#include <activemq/connector/stomp/commands/ErrorCommand.h>
-
-// Message Commands we can receive
-#include <activemq/connector/stomp/commands/MessageCommand.h>
-#include <activemq/connector/stomp/commands/BytesMessageCommand.h>
-#include <activemq/connector/stomp/commands/TextMessageCommand.h>
+#include <activemq/commands/ActiveMQMessage.h>
+#include <activemq/commands/ActiveMQTextMessage.h>
+#include <activemq/commands/ActiveMQBytesMessage.h>
+#include <activemq/commands/Response.h>
+#include <activemq/commands/BrokerError.h>
 
 using namespace activemq;
 using namespace activemq::exceptions;
-using namespace activemq::transport;
-using namespace activemq::connector::stomp::commands;
 using namespace activemq::wireformat;
 using namespace activemq::wireformat::stomp;
 using namespace activemq::wireformat::stomp::marshal;
 using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
-commands::Command* Marshaler::marshal( StompFrame* frame )
-    throw ( MarshalException ) {
+Pointer<Command> Marshaler::marshal( const Pointer<StompFrame>& frame )
+    throw ( decaf::io::IOException ) {
 
     try {
 
-        CommandConstants::CommandId commandId =
-            CommandConstants::toCommandId(frame->getCommand().c_str());
-        commands::Command* command = NULL;
+        StompCommandConstants::CommandId commandId =
+            StompCommandConstants::toCommandId( frame->getCommand().c_str() );
+
+        Pointer<Command> command;
 
-        if(commandId == CommandConstants::CONNECTED){
-            command = new ConnectedCommand( frame );
+        if( commandId == StompCommandConstants::CONNECTED ){
+//            command = new ConnectedCommand( frame );
         }
-        else if(commandId == CommandConstants::ERROR_CMD){
-            command = new ErrorCommand( frame );
+        else if( commandId == StompCommandConstants::ERROR_CMD ){
+//            command = new ErrorCommand( frame );
         }
-        else if(commandId == CommandConstants::RECEIPT){
-            command = new ReceiptCommand( frame );
+        else if( commandId == StompCommandConstants::RECEIPT ){
+//            command = new ReceiptCommand( frame );
         }
-        else if(commandId == CommandConstants::MESSAGE){
+        else if( commandId == StompCommandConstants::MESSAGE ){
 
-            if( !frame->getProperties().hasProperty(
-                    CommandConstants::toString(
-                        CommandConstants::HEADER_CONTENTLENGTH ) ) ) {
-                command = new TextMessageCommand( frame );
-            } else {
-                command = new BytesMessageCommand( frame );
-            }
+//            if( !frame->getProperties().hasProperty(
+//                    CommandConstants::toString(
+//                        CommandConstants::HEADER_CONTENTLENGTH ) ) ) {
+//                command = new TextMessageCommand( frame );
+//            } else {
+//                command = new BytesMessageCommand( frame );
+//            }
         }
 
         // We either got a command or a response, but if we got neither
         // then complain, something went wrong.
-        if(command == NULL) {
-            throw MarshalException(
+        if( command == NULL ) {
+            throw decaf::io::IOException(
                 __FILE__, __LINE__,
                 "Marshaler::marshal - No Command Created from frame");
         }
 
         return command;
     }
-    AMQ_CATCH_RETHROW( MarshalException )
-    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, MarshalException )
-    AMQ_CATCH_EXCEPTION_CONVERT( Exception, MarshalException )
-    AMQ_CATCHALL_THROW( MarshalException )
+    AMQ_CATCH_RETHROW( decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( Exception, decaf::io::IOException )
+    AMQ_CATCHALL_THROW( decaf::io::IOException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-const StompFrame& Marshaler::marshal( commands::Command* command )
-    throw ( MarshalException ) {
+Pointer<StompFrame> Marshaler::marshal( const Pointer<Command>& command )
+    throw ( decaf::io::IOException ) {
 
     try{
 
-        Marshalable* marshalable =
-            dynamic_cast<Marshalable*>(command);
-
-        // Easy, just get the frame from the command
-        if( marshalable != NULL ) {
-            return marshalable->marshal();
-        } else {
-            throw MarshalException(
-                __FILE__, __LINE__,
-                "Marshaler::marshal - Invalid Command Type!");
-        }
+        return Pointer<StompFrame>();
     }
-    AMQ_CATCH_RETHROW( MarshalException )
-    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, MarshalException )
-    AMQ_CATCH_EXCEPTION_CONVERT( Exception, MarshalException )
-    AMQ_CATCHALL_THROW( MarshalException )
+    AMQ_CATCH_RETHROW( decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, decaf::io::IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( Exception, decaf::io::IOException )
+    AMQ_CATCHALL_THROW( decaf::io::IOException )
 }

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=768739&r1=768738&r2=768739&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 Sun Apr 26 18:40:13 2009
@@ -19,17 +19,21 @@
 #define _ACTIVEMQ_WIREFORMAT_STOMP_MARSHALER_H_
 
 #include <activemq/util/Config.h>
-#include <activemq/transport/Command.h>
+#include <activemq/commands/Command.h>
 #include <activemq/wireformat/stomp/StompFrame.h>
-#include <activemq/wireformat/stomp/marshal/MarshalException.h>
+#include <decaf/io/IOException.h>
+#include <decaf/lang/Pointer.h>
 
 namespace activemq{
 namespace wireformat{
 namespace stomp{
 namespace marshal{
 
+    using decaf::lang::Pointer;
+    using activemq::commands::Command;
+
     /**
-     * Interface for all marshalers between Commands and stomp frames.
+     * Interface for all marshalers between Commands and Stomp frames.
      */
     class AMQCPP_API Marshaler {
     public:
@@ -38,26 +42,22 @@
         virtual ~Marshaler() {}
 
         /**
-         * Marshal a Stomp Frame to a Stomp Command, the frame is now
-         * owned by this Command, caller should not use the frame again.
-         * @param frame Frame to Marshal
-         * @return Newly Marshaled Stomp Message
-         * @throws MarshalException
+         * Marshal a Stomp Frame read in from the Transport to a Command object.
+         * @param frame Frame to Marshal.
+         * @return Newly Marshaled Command.
+         * @throws IOException
          */
-        virtual commands::Command* marshal( StompFrame* frame )
-            throw ( MarshalException );
+        virtual Pointer<Command> marshal( const Pointer<StompFrame>& frame )
+            throw ( decaf::io::IOException );
 
         /**
-         * Marshal a Stomp Command to a Stomp Frame, if the command that
-         * is past is not castable to a Stomp Command an Exception will
-         * be thrown
-         * @param command The Stomp Command to Marshal
-         * @return newly Marshaled Stomp Frame
-         * @throws MarshalException
+         * Marshal a Command to a Stomp Frame to write out to the Transport.
+         * @param command The Command to Marshal.
+         * @return newly Marshaled Stomp Frame.
+         * @throws IOException
          */
-        virtual const StompFrame& marshal(
-            commands::Command* command )
-                throw ( MarshalException );
+        virtual Pointer<StompFrame> marshal( const Pointer<Command>& command )
+            throw ( decaf::io::IOException );
 
     };