activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nmitt...@apache.org
Subject svn commit: r424272 [3/10] - in /incubator/activemq/trunk/activemq-cpp: ./ src/examples/ src/main/activemq/concurrent/ src/main/activemq/connector/ src/main/activemq/connector/stomp/ src/main/activemq/connector/stomp/commands/ src/main/activemq/connect...
Date Fri, 21 Jul 2006 11:36:16 GMT
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.cpp Fri Jul 21 04:36:09 2006
@@ -18,16 +18,19 @@
 #include "StompSessionManager.h"
 
 #include <activemq/core/ActiveMQMessage.h>
+#include <activemq/core/ActiveMQConstants.h>
 #include <activemq/concurrent/Concurrent.h>
 #include <activemq/connector/stomp/StompSessionInfo.h>
 #include <activemq/connector/stomp/StompConsumerInfo.h>
 #include <activemq/connector/stomp/commands/SubscribeCommand.h>
 #include <activemq/connector/stomp/commands/UnsubscribeCommand.h>
 #include <activemq/connector/stomp/StompSelector.h>
+#include <activemq/util/Properties.h>
 
 using namespace std;
 using namespace activemq;
 using namespace activemq::core;
+using namespace activemq::util;
 using namespace activemq::exceptions;
 using namespace activemq::transport;
 using namespace activemq::connector;
@@ -65,7 +68,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 unsigned int StompSessionManager::getNextSessionId(void)
 {
-    synchronized(&mutex)
+    synchronized( &mutex )
     {
         return nextSessionId++;
     }
@@ -76,7 +79,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 unsigned int StompSessionManager::getNextConsumerId(void)
 {
-    synchronized(&mutex)
+    synchronized( &mutex )
     {
         return nextConsumerId++;
     }
@@ -86,7 +89,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 connector::SessionInfo* StompSessionManager::createSession(
-    cms::Session::AcknowledgeMode ackMode) 
+    cms::Session::AcknowledgeMode ackMode ) 
         throw ( exceptions::ActiveMQException )
 {
     try
@@ -94,7 +97,7 @@
         SessionInfo* session = new StompSessionInfo();
         
         // Init data
-        session->setAckMode(ackMode);
+        session->setAckMode( ackMode );
         session->setConnectionId( connectionId );
         session->setSessionId( getNextSessionId() );
         
@@ -114,10 +117,10 @@
     
 ////////////////////////////////////////////////////////////////////////////////
 connector::ConsumerInfo* StompSessionManager::createConsumer(
-    cms::Destination* destination, 
+    const cms::Destination* destination, 
     SessionInfo* session,
-    const std::string& selector)
-        throw( ConnectorException )
+    const std::string& selector )
+        throw( StompConnectorException )
 {
     try
     {
@@ -127,46 +130,54 @@
         return createDurableConsumer( 
             destination, session, "", selector, false );    
     }
-    AMQ_CATCH_RETHROW( ConnectorException )
-    AMQ_CATCHALL_THROW( ConnectorException )
+    AMQ_CATCH_RETHROW( StompConnectorException )
+    AMQ_CATCHALL_THROW( StompConnectorException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 connector::ConsumerInfo* StompSessionManager::createDurableConsumer(
-    cms::Destination* destination, 
+    const cms::Destination* destination, 
     SessionInfo* session,
     const std::string& name,
     const std::string& selector,
     bool noLocal )
-        throw ( ConnectorException )
+        throw ( StompConnectorException )
 {
     try
     {
-        synchronized(&mutex)
+        synchronized( &mutex )
         {
             // Find the right mapping to consumers        
             ConsumerMap& consumerMap = 
                 destinationMap[ destination->toString() ];
-            
+
             // We only need to send a sub request if there are no active 
             // consumers on this destination.  
             if( consumerMap.empty() )
             {
                 // Send the request to the Broker
                 SubscribeCommand cmd;
-                
-                if( session->getAckMode() == cms::Session::ClientAcknowledge )
+
+                if( session->getAckMode() == cms::Session::CLIENT_ACKNOWLEDGE )
                 {
                     cmd.setAckMode( CommandConstants::ACK_CLIENT );
                 }
                 cmd.setDestination( destination->toProviderString() );
-                cmd.setNoLocal( noLocal );
+                
+                if( noLocal == true ) 
+                {
+                    cmd.setNoLocal( noLocal );
+                }
 
                 if( name != "" )
                 {
                     cmd.setSubscriptionName( name );
                 }
                 
+                // Grab any options from the destination and set them
+                // for this subscription.
+                setSubscribeOptions( destination, cmd );
+                
                 // The Selector is set on the first subscribe on this dest,
                 // and if another consumer is created on this destination
                 // that specifies a selector it will be ignored.  While 
@@ -198,18 +209,18 @@
         
         return NULL;
     }
-    AMQ_CATCH_RETHROW( ConnectorException )
-    AMQ_CATCHALL_THROW( ConnectorException )
+    AMQ_CATCH_RETHROW( StompConnectorException )
+    AMQ_CATCHALL_THROW( StompConnectorException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void StompSessionManager::removeConsumer(
-    connector::ConsumerInfo* consumer)
-        throw( ConnectorException )
+    connector::ConsumerInfo* consumer )
+        throw( StompConnectorException )
 {
     try
     {
-        synchronized(&mutex)
+        synchronized( &mutex )
         {
             DestinationMap::iterator itr = 
                 destinationMap.find( consumer->getDestination().toString() );
@@ -238,8 +249,8 @@
             }    
         }
     }
-    AMQ_CATCH_RETHROW( ConnectorException )
-    AMQ_CATCHALL_THROW( ConnectorException )
+    AMQ_CATCH_RETHROW( StompConnectorException )
+    AMQ_CATCHALL_THROW( StompConnectorException )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -265,10 +276,10 @@
                 "No Message Listener Registered." );
         }
                 
-        synchronized(&mutex)
+        synchronized( &mutex )
         {
             DestinationMap::iterator itr = 
-                destinationMap.find( message->getCMSDestination().toString() );
+                destinationMap.find( message->getCMSDestination()->toString() );
 
             if( itr == destinationMap.end() )
             {
@@ -280,7 +291,7 @@
 
             // If we only have 1 consumer, we don't need to clone the original
             // message.
-            if(itr->second.size() == 1)
+            if( itr->second.size() == 1 )
             {
                 ConsumerInfo* consumerInfo = itr->second.begin()->second;
                 
@@ -301,7 +312,7 @@
             // message.
             ConsumerMap::iterator c_itr = itr->second.begin();
             
-            for(; c_itr != itr->second.end(); ++c_itr )
+            for( ; c_itr != itr->second.end(); ++c_itr )
             {
                 ConsumerInfo* consumerInfo = c_itr->second;
                 
@@ -318,6 +329,113 @@
             // We got here which means that we sent copies, so remove
             // the original.
             delete command;
+        }
+    }
+    AMQ_CATCH_RETHROW( StompConnectorException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, StompConnectorException )
+    AMQ_CATCHALL_THROW( StompConnectorException )
+}
+
+void StompSessionManager::setSubscribeOptions( const cms::Destination* dest,
+                                               SubscribeCommand& command )
+    throw ( StompConnectorException )
+{
+    try
+    {
+        // Get the properties of this destination
+        const Properties& destProperties = dest->getProperties(); 
+
+        if( destProperties.isEmpty() )
+        {
+            // Nothing to do, so save some work and quit now.
+            return;
+        }
+
+        std::string noLocalStr = 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::CONSUMER_NOLOCAL );
+
+        if( destProperties.getProperty( noLocalStr, "false" ) == "true" )
+        {
+            command.setNoLocal(
+                Boolean::parseBoolean( 
+                    destProperties.getProperty( noLocalStr ) ) );
+        }
+
+        std::string selectorStr = 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::CONSUMER_SELECTOR );
+
+        if( destProperties.hasProperty( selectorStr ) )
+        {
+            command.setMessageSelector(
+                destProperties.getProperty( selectorStr ) );
+        }
+
+        std::string priorityStr = 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::CONSUMER_PRIORITY );
+
+        if( destProperties.hasProperty( priorityStr ) )
+        {
+            command.setPriority(
+                Integer::parseInt( 
+                    destProperties.getProperty( priorityStr ) ) );
+        }
+
+        std::string dispatchAsyncStr = 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::CONSUMER_DISPATCHASYNC );
+        
+        if( destProperties.hasProperty( dispatchAsyncStr ) )
+        {
+            command.setDispatchAsync(
+                Boolean::parseBoolean( 
+                    destProperties.getProperty( dispatchAsyncStr ) ) );
+        }
+
+        std::string exclusiveStr = 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::CONSUMER_EXCLUSIVE );
+        
+        if( destProperties.hasProperty( exclusiveStr ) )
+        {
+            command.setExclusive(
+                Boolean::parseBoolean( 
+                    destProperties.getProperty( exclusiveStr ) ) );
+        }
+
+        std::string maxPendingMsgLimitStr = 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::CUNSUMER_MAXPENDINGMSGLIMIT );
+        
+        if( destProperties.hasProperty( maxPendingMsgLimitStr ) )
+        {
+            command.setMaxPendingMsgLimit(
+                Integer::parseInt( 
+                    destProperties.getProperty( maxPendingMsgLimitStr ) ) );
+        }
+ 
+        std::string prefetchSizeStr = 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::CONSUMER_PREFECTCHSIZE );
+        
+        if( destProperties.hasProperty( prefetchSizeStr ) )
+        {
+            command.setPrefetchSize(
+                Integer::parseInt( 
+                    destProperties.getProperty( prefetchSizeStr ) ) );
+        }
+
+        std::string retroactiveStr = 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::CONSUMER_RETROACTIVE );
+        
+        if( destProperties.hasProperty( retroactiveStr ) )
+        {
+            command.setRetroactive(
+                Boolean::parseBoolean( 
+                    destProperties.getProperty( retroactiveStr ) ) );
         }
     }
     AMQ_CATCH_RETHROW( StompConnectorException )

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionManager.h Fri Jul 21 04:36:09 2006
@@ -25,6 +25,7 @@
 #include <activemq/connector/ConnectorException.h>
 #include <activemq/connector/stomp/StompCommandListener.h>
 #include <activemq/connector/ConsumerMessageListener.h>
+#include <activemq/connector/stomp/commands/SubscribeCommand.h>
 
 namespace activemq{
 namespace connector{
@@ -44,8 +45,8 @@
     private:
     
         // Map Types
-        typedef std::map<unsigned int, ConsumerInfo*>  ConsumerMap;
-        typedef std::map<std::string, ConsumerMap>     DestinationMap;        
+        typedef std::map< unsigned int, ConsumerInfo* > ConsumerMap;
+        typedef std::map< std::string, ConsumerMap >    DestinationMap;        
 
     private:
     
@@ -85,7 +86,7 @@
          * @return new SessionInfo object
          */
         virtual connector::SessionInfo* createSession(
-            cms::Session::AcknowledgeMode ackMode)
+            cms::Session::AcknowledgeMode ackMode )
                 throw ( exceptions::ActiveMQException );
 
         /**
@@ -108,10 +109,10 @@
          * @return new ConsumerInfo object.
          */
         virtual connector::ConsumerInfo* createConsumer(
-            cms::Destination* destination, 
+            const cms::Destination* destination, 
             SessionInfo* session,
-            const std::string& selector)
-                throw( ConnectorException );
+            const std::string& selector )
+                throw( StompConnectorException );
 
         /**
          * Creates a new durable consumer to the specified session, will 
@@ -126,12 +127,12 @@
          * @return new ConsumerInfo object.
          */
         virtual connector::ConsumerInfo* createDurableConsumer(
-            cms::Destination* destination, 
+            const cms::Destination* destination, 
             SessionInfo* session,
             const std::string& name,
             const std::string& selector,
             bool noLocal )
-                throw ( ConnectorException );
+                throw ( StompConnectorException );
 
         /**
          * Removes the Consumer from the session, will unsubscrive if the
@@ -142,7 +143,7 @@
          * @throws ConnectorException
          */            
         virtual void removeConsumer( connector::ConsumerInfo* consumer )
-            throw( ConnectorException );
+            throw( StompConnectorException );
 
         /** 
          * Sets the listener of consumer messages.
@@ -162,7 +163,19 @@
          * @throw ConnterException
          */
         virtual void onStompCommand( commands::StompCommand* command ) 
-            throw ( StompConnectorException );    
+            throw ( StompConnectorException );
+            
+    protected: 
+    
+        /**
+         * Sets Subscribe Command options from the properties of a 
+         * destination object.
+         * @param The destination that we are subscribing to.
+         * @param The pending Subscribe command
+         */
+        virtual void setSubscribeOptions( const cms::Destination* dest,
+                                          commands::SubscribeCommand& command )
+            throw ( StompConnectorException );
             
     protected:
     

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompTopic.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompTopic.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompTopic.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompTopic.h Fri Jul 21 04:36:09 2006
@@ -30,8 +30,18 @@
     {
     public:
 
-        StompTopic(void) : StompDestination<cms::Topic>() {}
+        /**
+         * Copy Consturctor
+         * @param CMS Dest to Copy, must be a compatible type
+         */
+        StompTopic( const cms::Destination* source ) : 
+            StompDestination< cms::Topic >( source ) {}
 
+        /**
+         * Custom Constructor
+         * @param string destination name plus any params
+         * @param type of destination this represents.
+         */
         StompTopic(const std::string& name) : 
             StompDestination< cms::Topic >( name, cms::Destination::TOPIC )
         {}

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompTransactionInfo.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompTransactionInfo.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompTransactionInfo.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompTransactionInfo.h Fri Jul 21 04:36:09 2006
@@ -37,16 +37,13 @@
     public:
 
         /**
-         * TransactionInfo Constructor
+         * Default Constructor
          */
         StompTransactionInfo(void) {
             transactionId = 0;
             session = NULL;
         }
 
-        /**
-         * Destructor
-         */
         virtual ~StompTransactionInfo(void) {}
 
         /**

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AbstractCommand.h Fri Jul 21 04:36:09 2006
@@ -113,13 +113,24 @@
         AbstractCommand(void){ 
             frame = new StompFrame;
         }
-        AbstractCommand(StompFrame* frame){ 
+        AbstractCommand( StompFrame* frame ){ 
             this->frame = frame;
         }
         virtual ~AbstractCommand(void){
             destroyFrame();
         }
         
+        /**
+         * Gets the properties map for this command.
+         * @return Reference to a Properties object
+         */
+        virtual util::Properties& getProperties(void){
+            return getFrame().getProperties();
+        }   
+        virtual const util::Properties& getProperties(void) const{
+            return getFrame().getProperties();
+        }   
+
         /**
          * Sets the Command Id of this Message
          * @param Command Id

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AckCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AckCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AckCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/AckCommand.h Fri Jul 21 04:36:09 2006
@@ -44,7 +44,7 @@
                 initialize( getFrame() );
         }
         AckCommand( StompFrame* frame ) : 
-            AbstractCommand<transport::Command>(frame) {
+            AbstractCommand<transport::Command>( frame ) {
                 validate( getFrame() );
         }
         virtual ~AckCommand(void) {}

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BeginCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BeginCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BeginCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BeginCommand.h Fri Jul 21 04:36:09 2006
@@ -45,7 +45,7 @@
                 initialize( getFrame() );
         }
         BeginCommand( StompFrame* frame ) : 
-            AbstractCommand<transport::Command>(frame) {
+            AbstractCommand<transport::Command>( frame ) {
                 validate( getFrame() );
         }
         virtual ~BeginCommand(void) {}

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/BytesMessageCommand.h Fri Jul 21 04:36:09 2006
@@ -41,7 +41,7 @@
                 initialize( getFrame() );
         }
         BytesMessageCommand( StompFrame* frame ) : 
-            StompMessage< cms::BytesMessage >(frame) {
+            StompMessage< cms::BytesMessage >( frame ) {
                 validate( getFrame() );
         }
     	virtual ~BytesMessageCommand(void) {}

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.cpp Fri Jul 21 04:36:09 2006
@@ -62,7 +62,8 @@
     stompHeaders[HEADER_RESPONSEID] = "response-id";
     stompHeaders[HEADER_EXPIRES] = "expires";
     stompHeaders[HEADER_PERSISTANT] = "persistent";
-    stompHeaders[HEADER_PRIORITY] = "priority";
+    stompHeaders[HEADER_JMSPRIORITY] = "priority";
+    stompHeaders[HEADER_CONSUMERPRIORITY] = "activemq.priority";
     stompHeaders[HEADER_REPLYTO] = "reply-to";
     stompHeaders[HEADER_TYPE] = "type";
     stompHeaders[HEADER_AMQMSGTYPE] = "amq-msg-type";
@@ -74,7 +75,7 @@
     stompHeaders[HEADER_MAXPENDINGMSGLIMIT] = "activemq.maximumPendingMessageLimit";
     stompHeaders[HEADER_NOLOCAL] = "activemq.noLocal";
     stompHeaders[HEADER_PREFETCHSIZE] = "activemq.prefetchSize";
-    stompHeaders[HEADER_PRIORITY] = "activemq.priority";
+    stompHeaders[HEADER_CONSUMERPRIORITY] = "activemq.priority";
     stompHeaders[HEADER_RETROACTIVE] = "activemq.retroactive";
     stompHeaders[HEADER_SUBSCRIPTIONNAME] = "activemq.subscriptionName";
     stompHeaders[HEADER_TIMESTAMP] = "timestamp";

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommandConstants.h Fri Jul 21 04:36:09 2006
@@ -76,7 +76,8 @@
             HEADER_MAXPENDINGMSGLIMIT,
             HEADER_NOLOCAL,
             HEADER_PREFETCHSIZE,
-            HEADER_PRIORITY,
+            HEADER_JMSPRIORITY,
+            HEADER_CONSUMERPRIORITY,
             HEADER_RETROACTIVE,
             HEADER_SUBSCRIPTIONNAME,
             HEADER_TIMESTAMP,

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommitCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommitCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommitCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/CommitCommand.h Fri Jul 21 04:36:09 2006
@@ -40,7 +40,7 @@
                 initialize( getFrame() );
         }
         CommitCommand( StompFrame* frame ) : 
-            AbstractCommand<transport::Command>(frame) {
+            AbstractCommand<transport::Command>( frame ) {
                 validate( getFrame() );
         }
         virtual ~CommitCommand(void) {}

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ConnectCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ConnectCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ConnectCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ConnectCommand.h Fri Jul 21 04:36:09 2006
@@ -39,7 +39,7 @@
                 initialize( getFrame() );
         }
         ConnectCommand( StompFrame* frame ) : 
-            AbstractCommand<transport::Command>(frame) {
+            AbstractCommand<transport::Command>( frame ) {
                 validate( getFrame() );
         }
         virtual ~ConnectCommand(void) {};

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/DisconnectCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/DisconnectCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/DisconnectCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/DisconnectCommand.h Fri Jul 21 04:36:09 2006
@@ -40,7 +40,7 @@
                 initialize( getFrame() );
         }
         DisconnectCommand( StompFrame* frame ) : 
-            AbstractCommand<transport::Command>(frame) {
+            AbstractCommand<transport::Command>( frame ) {
                 validate( getFrame() );
         }
         virtual ~DisconnectCommand(void){};

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ErrorCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ErrorCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ErrorCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ErrorCommand.h Fri Jul 21 04:36:09 2006
@@ -40,7 +40,7 @@
                 initialize( getFrame() );
         }
         ErrorCommand( StompFrame* frame ) : 
-            AbstractCommand<transport::Command>(frame) {
+            AbstractCommand<transport::Command>( frame ) {
                 validate( getFrame() );
         }
         virtual ~ErrorCommand(void) {};

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ReceiptCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ReceiptCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ReceiptCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/ReceiptCommand.h Fri Jul 21 04:36:09 2006
@@ -40,7 +40,7 @@
                 initialize( getFrame() );
         }
         ReceiptCommand( StompFrame* frame ) : 
-            AbstractCommand<transport::Response>(frame) {
+            AbstractCommand<transport::Response>( frame ) {
                 validate( getFrame() );
         }
         virtual ~ReceiptCommand(void) {}
@@ -60,7 +60,7 @@
         virtual void setReceiptId( const std::string& id ){
             setPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_RECEIPTID),
+                    CommandConstants::HEADER_RECEIPTID ),
                 id );
         }
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompCommand.h Fri Jul 21 04:36:09 2006
@@ -103,6 +103,13 @@
          * @return Stomp CommandId enum
          */
         virtual CommandConstants::CommandId getStompCommandId(void) const = 0;
+        
+        /**
+         * Retrieves the Properties that are part of this command
+         * @return const reference to a properties object
+         */
+        virtual util::Properties& getProperties(void) = 0;
+        virtual const util::Properties& getProperties(void) const = 0;
 
     };
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/StompMessage.h Fri Jul 21 04:36:09 2006
@@ -62,7 +62,7 @@
 
         StompMessage(void) :
             AbstractCommand< transport::Command >(),
-            ackHandler( NULL ) { dest = new StompTopic(); }
+            ackHandler( NULL ) { dest = NULL; }
         StompMessage( StompFrame* frame ) : 
             AbstractCommand< transport::Command >( frame ),
             ackHandler( NULL )
@@ -112,55 +112,57 @@
          * of this consumed message.
          */
         virtual void acknowledge(void) const throw( cms::CMSException ) {
-            if(ackHandler != NULL) ackHandler->acknowledgeMessage(this);
+            if(ackHandler != NULL) ackHandler->acknowledgeMessage( this );
         }
 
         /**
          * Sets the DeliveryMode for this message
          * @return DeliveryMode enumerated value.
          */
-        virtual cms::Message::DeliveryMode getCMSDeliveryMode(void) const {
+        virtual int getCMSDeliveryMode(void) const {
             if(!getFrame().getProperties().hasProperty( 
                    CommandConstants::toString( 
                        CommandConstants::HEADER_PERSISTANT ) ) ) {
-                return cms::Message::PERSISTANT;
+                return cms::DeliveryMode::PERSISTANT;
             }
             
-            return (cms::Message::DeliveryMode)(
-                util::Integer::parseInt( getPropertyValue( 
-                    CommandConstants::toString( 
-                        CommandConstants::HEADER_PERSISTANT ) ) ) );
+            return util::Integer::parseInt( getPropertyValue( 
+                       CommandConstants::toString( 
+                           CommandConstants::HEADER_PERSISTANT ) ) );
         }
 
         /**
          * Sets the DeliveryMode for this message
          * @param DeliveryMode enumerated value.
          */
-        virtual void setCMSDeliveryMode(cms::Message::DeliveryMode mode) {
+        virtual void setCMSDeliveryMode( int mode ) {
             setPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_PERSISTANT ) ,
-                util::Integer::toString((int)mode) );
+                util::Integer::toString( mode ) );
         }
       
         /**
          * Gets the Destination for this Message
-         * @return Destination object
+         * @return Destination object can be NULL
          */
-        virtual const cms::Destination& getCMSDestination(void) const{
-            return *dest;
+        virtual const cms::Destination* getCMSDestination(void) const{
+            return dest;
         }
               
         /**
          * Sets the Destination for this message
          * @param Destination Object
          */
-        virtual void setCMSDestination(const cms::Destination& destination) {
-            dest->copy( destination );
-            setPropertyValue( 
-                CommandConstants::toString( 
-                    CommandConstants::HEADER_DESTINATION ),
-                dest->toProviderString() );
+        virtual void setCMSDestination( const cms::Destination* destination ) {
+            if( destination != NULL )
+            {
+                dest = destination->clone();
+                setPropertyValue( 
+                    CommandConstants::toString( 
+                        CommandConstants::HEADER_DESTINATION ),
+                    dest->toProviderString() );
+            }
         }
         
         /**
@@ -177,7 +179,7 @@
          * Sets the Expiration Time for this message
          * @param time value
          */
-        virtual void setCMSExpiration(long expireTime) {
+        virtual void setCMSExpiration( long expireTime ) {
             setPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_EXPIRES) ,
@@ -198,7 +200,7 @@
          * Sets the CMS Message Id for this message
          * @param time value
          */
-        virtual void setCMSMessageId(const std::string& id) {
+        virtual void setCMSMessageId( const std::string& id ) {
             setPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_MESSAGEID ),
@@ -212,17 +214,17 @@
         virtual int getCMSPriority(void) const {
             return util::Integer::parseInt( getPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_PRIORITY ), "0" ) );
+                    CommandConstants::HEADER_JMSPRIORITY ), "0" ) );
         }
       
         /**
          * Sets the Priority Value for this message
          * @param priority value
          */
-        virtual void setCMSPriority(int priority) {
+        virtual void setCMSPriority( int priority ) {
             setPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_PRIORITY),
+                    CommandConstants::HEADER_JMSPRIORITY),
                 util::Integer::toString( priority ) );
         }
 
@@ -241,7 +243,7 @@
          * Sets the Redelivered Flag for this message
          * @param redelivered value
          */
-        virtual void setCMSRedelivered(bool redelivered) {
+        virtual void setCMSRedelivered( bool redelivered ) {
             setPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_REDELIVERED ),
@@ -262,7 +264,7 @@
          * Sets the CMS Reply To Address for this message
          * @param Reply To value
          */
-        virtual void setCMSReplyTo(const std::string& id) {
+        virtual void setCMSReplyTo( const std::string& id ) {
             setPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_REPLYTO ),
@@ -283,7 +285,7 @@
          * Sets the Time Stamp for this message
          * @param time stamp value
          */
-        virtual void setCMSTimeStamp(long timeStamp) {
+        virtual void setCMSTimeStamp( long timeStamp ) {
             setPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_TIMESTAMP ),
@@ -304,7 +306,7 @@
          * Sets the CMS Message Type for this message
          * @param type value
          */
-        virtual void setCMSMessageType(const std::string& type) {
+        virtual void setCMSMessageType( const std::string& type ) {
             setPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_TYPE ),
@@ -318,7 +320,7 @@
          * when the Acknowledge method is called.
          * @param ActiveMQAckHandler
          */
-        virtual void setAckHandler(core::ActiveMQAckHandler* handler) {
+        virtual void setAckHandler( core::ActiveMQAckHandler* handler ) {
             this->ackHandler = handler;
         }
         
@@ -338,7 +340,7 @@
          * redelivered
          * @param redelivery count
          */
-        virtual void setRedeliveryCount(int count) {
+        virtual void setRedeliveryCount( int count ) {
             setPropertyValue( 
                 CommandConstants::toString( 
                     CommandConstants::HEADER_REDELIVERYCOUNT ),

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/SubscribeCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/SubscribeCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/SubscribeCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/SubscribeCommand.h Fri Jul 21 04:36:09 2006
@@ -53,7 +53,7 @@
         virtual const char* getDestination(void) const{
             return getPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_DESTINATION) );
+                    CommandConstants::HEADER_DESTINATION ) );
         }
       
         /**
@@ -63,7 +63,7 @@
         virtual void setDestination( const std::string& dest ){
             setPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_DESTINATION),
+                    CommandConstants::HEADER_DESTINATION ),
                 dest );
         }
 
@@ -74,7 +74,7 @@
         virtual void setAckMode( const CommandConstants::AckMode mode ){
             setPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_ACK),
+                    CommandConstants::HEADER_ACK ),
                 CommandConstants::toString( mode ) );
         }
 
@@ -86,7 +86,7 @@
             return CommandConstants::toAckMode( 
                 getPropertyValue( 
                     CommandConstants::toString( 
-                        CommandConstants::HEADER_ACK) ) );
+                        CommandConstants::HEADER_ACK ) ) );
         }
         
         /**
@@ -97,7 +97,7 @@
         virtual void setMessageSelector( const std::string& selector ) {
             setPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_SELECTOR),
+                    CommandConstants::HEADER_SELECTOR ),
                 selector );
         }        
 
@@ -109,7 +109,7 @@
         virtual const char* getMessageSelector(void) const{
             return getPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_SELECTOR) );
+                    CommandConstants::HEADER_SELECTOR ) );
         }
 
         /**
@@ -120,7 +120,7 @@
         virtual void setSubscriptionName( const std::string& name ) {
             setPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_SUBSCRIPTIONNAME),
+                    CommandConstants::HEADER_SUBSCRIPTIONNAME ),
                 name );
         }        
 
@@ -132,11 +132,11 @@
         virtual const char* getSubscriptionName(void) const{
             return getPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_SUBSCRIPTIONNAME) );
+                    CommandConstants::HEADER_SUBSCRIPTIONNAME ) );
         }
 
         /**
-         * Gets hether or not locally sent messages should be ignored for 
+         * Gets whether or not locally sent messages should be ignored for 
          * subscriptions. Set to true to filter out locally sent messages
          * @return NoLocal value
          */
@@ -148,7 +148,7 @@
         }
       
         /**
-         * Gets hether or not locally sent messages should be ignored for 
+         * Sets whether or not locally sent messages should be ignored for 
          * subscriptions. Set to true to filter out locally sent messages
          * @param NoLocal value
          */
@@ -159,6 +159,162 @@
                 util::Boolean::toString( noLocal ) );
         }
 
+        /**
+         * Sets whether or not the broker is to dispatch messages in an 
+         * asynchronous manner. Set to true if you want Async.
+         * @return true if in dispatch async mode
+         */
+        virtual bool getDispatchAsync(void) const {
+            return util::Boolean::parseBoolean( getPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_DISPATCH_ASYNC ), 
+                "false" ) );
+        }
+      
+        /**
+         * Sets whether or not the broker is to dispatch messages in an 
+         * asynchronous manner. Set to true if you want Async.
+         * @param true for async dispatch mode
+         */
+        virtual void setDispatchAsync( bool dispatchAsync ) {
+            setPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_DISPATCH_ASYNC ),
+                util::Boolean::toString( dispatchAsync ) );
+        }
+        
+        /**
+         * Gets whether or not this consumer is an exclusive consumer for
+         * this destination.
+         * @return true for exclusive mode
+         */
+        virtual bool getExclusive(void) const {
+            return util::Boolean::parseBoolean( getPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_EXCLUSIVE ), 
+                "false" ) );
+        }
+      
+        /**
+         * Sets whether or not this consumer is an exclusive consumer for
+         * this destination.
+         * @param true if in exclusive mode
+         */
+        virtual void setExclusive( bool exclusive ) {
+            setPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_EXCLUSIVE ),
+                util::Boolean::toString( exclusive ) );
+        }
+
+        /**
+         * Get the max number of pending messages on a destination
+         * For Slow Consumer Handlingon non-durable topics by dropping old
+         * messages - we can set a maximum pending limit which once a slow 
+         * consumer backs up to this high water mark we begin to discard 
+         * old messages
+         * @return Max value
+         */
+        virtual int getMaxPendingMsgLimit(void) const {
+            return util::Integer::parseInt( getPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_MAXPENDINGMSGLIMIT ), 
+                "0" ) );
+        }
+      
+        /**
+         * Set the max number of pending messages on a destination
+         * For Slow Consumer Handlingon non-durable topics by dropping old
+         * messages - we can set a maximum pending limit which once a slow 
+         * consumer backs up to this high water mark we begin to discard 
+         * old messages
+         * @param Max value
+         */
+        virtual void setMaxPendingMsgLimit( int limit ) {
+            setPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_MAXPENDINGMSGLIMIT ),
+                util::Integer::toString( limit ) );
+        }
+        
+        /**
+         * Get the maximum number of pending messages that will be 
+         * dispatched to the client. Once this maximum is reached no more 
+         * messages are dispatched until the client acknowledges a message. 
+         * Set to 1 for very fair distribution of messages across consumers
+         * where processing messages can be slow
+         * @return prefetch size value
+         */
+        virtual int getPrefetchSize(void) const {
+            return util::Integer::parseInt( getPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_PREFETCHSIZE ), 
+                "1000" ) );
+        }
+      
+        /**
+         * Set the maximum number of pending messages that will be 
+         * dispatched to the client. Once this maximum is reached no more 
+         * messages are dispatched until the client acknowledges a message. 
+         * Set to 1 for very fair distribution of messages across consumers
+         * where processing messages can be slow
+         * @param prefetch size value
+         */
+        virtual void setPrefetchSize( int size ) {
+            setPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_PREFETCHSIZE ),
+                util::Integer::toString( size ) );
+        }
+
+        /**
+         * Gets the priority of the consumer so that dispatching can be 
+         * weighted in priority order
+         * @return priority level
+         */
+        virtual int getPriority(void) const {
+            return util::Integer::parseInt( getPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_CONSUMERPRIORITY ), 
+                "0" ) );
+        }
+      
+        /**
+         * Sets the priority of the consumer so that dispatching can be 
+         * weighted in priority order
+         * @param prioirty level
+         */
+        virtual void setPriority( int priority ) {
+            setPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_CONSUMERPRIORITY ),
+                util::Integer::toString( priority ) );
+        }
+
+        /**
+         * Get For non-durable topics if this subscription is set to be 
+         * retroactive
+         * @return true for retroactive mode
+         */
+        virtual bool getRetroactive(void) const {
+            return util::Boolean::parseBoolean( getPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_RETROACTIVE ), 
+                "false" ) );
+        }
+      
+        /**
+         * Set For non-durable topics if this subscription is set to be 
+         * retroactive
+         * @param true if in retroactive mode
+         */
+        virtual void setRetroactive( bool retroactive ) {
+            setPropertyValue( 
+                CommandConstants::toString( 
+                    CommandConstants::HEADER_RETROACTIVE ),
+                util::Boolean::toString( retroactive ) );
+        }
+        
     protected:
     
         /**
@@ -173,7 +329,7 @@
 
             setPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_ACK),
+                    CommandConstants::HEADER_ACK ),
                 CommandConstants::toString( 
                     CommandConstants::ACK_AUTO ) );
         }

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/TextMessageCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/TextMessageCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/TextMessageCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/TextMessageCommand.h Fri Jul 21 04:36:09 2006
@@ -68,6 +68,14 @@
             setBytes( msg, strlen(msg) + 1, false );
         }
 
+        /**
+         * Sets the message contents.
+         * @param msg The message buffer.
+         */
+        virtual void setText( const std::string& msg ) throw( cms::CMSException ) {
+            setBytes( msg.c_str(), msg.length() + 1, false );
+        }
+
     };
 
 }}}}

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/UnsubscribeCommand.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/UnsubscribeCommand.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/UnsubscribeCommand.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/commands/UnsubscribeCommand.h Fri Jul 21 04:36:09 2006
@@ -51,7 +51,7 @@
         virtual const char* getDestination(void) const{
             return getPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_DESTINATION) );
+                    CommandConstants::HEADER_DESTINATION ) );
         }
       
         /**
@@ -60,7 +60,7 @@
         virtual void setDestination( const std::string& dest ){
             setPropertyValue( 
                 CommandConstants::toString( 
-                    CommandConstants::HEADER_DESTINATION) ,
+                    CommandConstants::HEADER_DESTINATION ),
                 dest );
         }
       

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/marshal/Marshalable.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/marshal/Marshalable.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/marshal/Marshalable.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/marshal/Marshalable.h Fri Jul 21 04:36:09 2006
@@ -30,7 +30,7 @@
     {
     public:
 
-    	virtual ~Marshalable(void) {}
+        virtual ~Marshalable(void) {}
 
         /**
          * Marshals the command to a stomp frame.

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQAckHandler.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQAckHandler.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQAckHandler.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQAckHandler.h Fri Jul 21 04:36:09 2006
@@ -32,7 +32,7 @@
     {
     public:
     
-    	virtual ~ActiveMQAckHandler(void) {};
+        virtual ~ActiveMQAckHandler(void) {};
     
         /**
          * Method called to acknowledge the message passed

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.cpp Fri Jul 21 04:36:09 2006
@@ -34,6 +34,7 @@
 {
     this->connectionData = connectionData;
     this->started = false;
+    this->closed = false;
     this->exceptionListener = NULL;
 
     // We want to be the sink for all messages from the Connector
@@ -57,7 +58,7 @@
 {
     try
     {
-        return this->createSession( Session::AutoAcknowledge );
+        return this->createSession( Session::AUTO_ACKNOWLEDGE );
     }
     AMQ_CATCH_RETHROW( ActiveMQException )
     AMQ_CATCHALL_THROW( ActiveMQException )
@@ -90,10 +91,20 @@
 {
     try
     {
+        if( closed )
+        {
+            return;
+        }
+
         // Once current deliveries are done this stops the delivery 
         // of any new messages.
         started = false;
-    
+        closed = true;
+
+        // Shutdown connector and transport
+        connectionData->getConnector()->close();
+        connectionData->getTransport()->close();
+
         // Destroy the connection data
         delete connectionData;
         connectionData = NULL;
@@ -124,7 +135,7 @@
                                              ActiveMQMessageListener* listener )
 {
     // Place in Map
-    synchronized(&mutex)
+    synchronized( &mutex )
     {
         consumers[consumerId] = listener;
     }
@@ -134,7 +145,7 @@
 void ActiveMQConnection::removeMessageListener( const unsigned int consumerId )
 {
     // Remove from Map
-    synchronized(&mutex)
+    synchronized( &mutex )
     {
         consumers.erase( consumerId );
     }
@@ -175,9 +186,9 @@
         }
         
         // Started, so lock map and dispatch the message.
-        synchronized(&mutex)
+        synchronized( &mutex )
         {
-            if(consumers.find(consumer->getConsumerId()) != consumers.end())
+            if(consumers.find( consumer->getConsumerId()) != consumers.end() )
             {
                 consumers[consumer->getConsumerId()]->
                     onActiveMQMessage( message );

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnection.h Fri Jul 21 04:36:09 2006
@@ -32,147 +32,149 @@
 namespace activemq{
 namespace core{
 
-   class cms::Session;   
-   class ActiveMQConsumer;
+    class cms::Session;   
+    class ActiveMQConsumer;
 
-   class ActiveMQConnection : 
-      public cms::Connection,
-      public connector::ConsumerMessageListener
-   {
-   private:
-   
-      // the registered exception listener
-      cms::ExceptionListener* exceptionListener;
-      
-      // All the data that is used to connect this Connection
-      ActiveMQConnectionData* connectionData;
-      
-      // Indicates if this Connection is started
-      bool started;
-      
-      // Map of Consumer Ids to ActiveMQMessageListeners
-      std::map<unsigned int, ActiveMQMessageListener*> consumers;
-      
-      // Mutex to lock the Consumers Map
-      concurrent::Mutex mutex;
-   
-   public:
-
-      /**
-       * Constructor
-       */       
-      ActiveMQConnection(ActiveMQConnectionData* connectionData);
-
-      /**
-       * Destructor
-       */
-      virtual ~ActiveMQConnection(void);
-   
-   public:   // Connection Interface Methods
-   
-      /**
-       * Creates a new Session to work for this Connection
-       */
-      virtual cms::Session* createSession(void) throw ( cms::CMSException );
-      
-      /**
-       * Creates a new Session to work for this Connection using the
-       * specified acknowledgment mode
-       * @param the Acknowledgement Mode to use.
-       */
-      virtual cms::Session* createSession(cms::Session::AcknowledgeMode ackMode) 
-         throw ( cms::CMSException );
+    class ActiveMQConnection : 
+        public cms::Connection,
+        public connector::ConsumerMessageListener
+    {
+    private:
+   
+        // the registered exception listener
+        cms::ExceptionListener* exceptionListener;
+      
+        // All the data that is used to connect this Connection
+        ActiveMQConnectionData* connectionData;
+      
+        // Indicates if this Connection is started
+        bool started;
+
+        // Indicates that this connection has been closed, it is no longer
+        // usable after this becomes true
+        bool closed;
+      
+        // Map of Consumer Ids to ActiveMQMessageListeners
+        std::map< unsigned int, ActiveMQMessageListener* > consumers;
+      
+        // Mutex to lock the Consumers Map
+        concurrent::Mutex mutex;
+   
+    public:
+
+        /**
+         * Constructor
+         * @param Pointer to an ActiveMQConnectionData object, owned here
+         */       
+        ActiveMQConnection( ActiveMQConnectionData* connectionData );
+
+        virtual ~ActiveMQConnection(void);
+   
+    public:   // Connection Interface Methods
+   
+        /**
+         * Creates a new Session to work for this Connection
+         */
+        virtual cms::Session* createSession(void) throw ( cms::CMSException );
+      
+        /**
+         * Creates a new Session to work for this Connection using the
+         * specified acknowledgment mode
+         * @param the Acknowledgement Mode to use.
+         */
+        virtual cms::Session* createSession( cms::Session::AcknowledgeMode ackMode ) 
+            throw ( cms::CMSException );
          
-      /**
-       * Get the Client Id for this session
-       * @return string version of Client Id
-       */
-      virtual std::string getClientId(void) const;
-      
-      /**
-       * Retrieves the Connection Data object for this object.
-       * @return pointer to a connection data object.
-       */
-      virtual ActiveMQConnectionData* getConnectionData(void){
-         return connectionData;
-      } 
+        /**
+         * Get the Client Id for this session
+         * @return string version of Client Id
+         */
+        virtual std::string getClientId(void) const;
+      
+        /**
+         * Retrieves the Connection Data object for this object.
+         * @return pointer to a connection data object.
+         */
+        virtual ActiveMQConnectionData* getConnectionData(void){
+            return connectionData;
+        } 
          
-      /**
-       * Gets the registered Exception Listener for this connection
-       * @return pointer to an exception listnener or NULL
-       */
-      virtual cms::ExceptionListener* getExceptionListener(void) const{
-         return exceptionListener; };
-      
-      /**
-       * Sets the registed Exception Listener for this connection
-       * @param pointer to and <code>ExceptionListener</code>
-       */
-      virtual void setExceptionListener(cms::ExceptionListener* listener){
-         exceptionListener = listener; };
+        /**
+         * Gets the registered Exception Listener for this connection
+         * @return pointer to an exception listnener or NULL
+         */
+        virtual cms::ExceptionListener* getExceptionListener(void) const{
+            return exceptionListener; };
+      
+        /**
+         * Sets the registed Exception Listener for this connection
+         * @param pointer to and <code>ExceptionListener</code>
+         */
+        virtual void setExceptionListener( cms::ExceptionListener* listener ){
+            exceptionListener = listener; };
          
-      /**
-       * Close the currently open connection
-       * @throws CMSException
-       */
-      virtual void close(void) throw ( cms::CMSException );
-      
-      /**
-       * Starts or (restarts) a connections delivery of incoming messages
-       * @throws CMSException
-       */
-      virtual void start(void) throw ( cms::CMSException );
-      
-      /**
-       * Stop the flow of incoming messages
-       * @throws CMSException
-       */
-      virtual void stop(void) throw ( cms::CMSException );
-
-   public:   // ActiveMQConnection Methods
-   
-      /**
-       * Adds the ActiveMQMessageListener to the Mapping of Consumer Id's
-       * to listeners, all message to that id will be routed to the given
-       * listener
-       * @param Consumer Id String
-       * @param ActiveMQMessageListener Pointer
-       */
-      virtual void addMessageListener(const unsigned int consumerId,
-                                      ActiveMQMessageListener* listener); 
-      
-      /**
-       * Remove the Listener for the specified Consumer Id
-       * @param Consumer Id string
-       */
-      virtual void removeMessageListener(const unsigned int consumerId);
-
-   private:
-   
-      /**
-       * Notify the excpetion listener
-       */
-      void fire( exceptions::ActiveMQException& ex )
-      {
-         if( exceptionListener != NULL )
-         {
-            try
+        /**
+         * Close the currently open connection
+         * @throws CMSException
+         */
+        virtual void close(void) throw ( cms::CMSException );
+      
+        /**
+         * Starts or (restarts) a connections delivery of incoming messages
+         * @throws CMSException
+         */
+        virtual void start(void) throw ( cms::CMSException );
+      
+        /**
+         * Stop the flow of incoming messages
+         * @throws CMSException
+         */
+        virtual void stop(void) throw ( cms::CMSException );
+
+    public:   // ActiveMQConnection Methods
+   
+        /**
+         * Adds the ActiveMQMessageListener to the Mapping of Consumer Id's
+         * to listeners, all message to that id will be routed to the given
+         * listener
+         * @param Consumer Id String
+         * @param ActiveMQMessageListener Pointer
+         */
+        virtual void addMessageListener( const unsigned int consumerId,
+                                         ActiveMQMessageListener* listener ); 
+      
+        /**
+         * Remove the Listener for the specified Consumer Id
+         * @param Consumer Id string
+         */
+        virtual void removeMessageListener( const unsigned int consumerId );
+
+    private:
+   
+        /**
+         * Notify the excpetion listener
+         */
+        void fire( exceptions::ActiveMQException& ex )
+        {
+            if( exceptionListener != NULL )
             {
-               exceptionListener->onException( ex );
+                try
+                {
+                    exceptionListener->onException( ex );
+                }
+                catch(...){}
             }
-            catch(...){}
-         }
-      }
-
-      /**
-       * Called to dispatch a message to a particular consumer.
-       * @param consumer the target consumer of the dispatch.
-       * @param msg the message to be dispatched.
-       */
-      virtual void onConsumerMessage( connector::ConsumerInfo* consumer,
-                                      core::ActiveMQMessage* message );
+        }
+
+        /**
+         * Called to dispatch a message to a particular consumer.
+         * @param consumer the target consumer of the dispatch.
+         * @param msg the message to be dispatched.
+         */
+        virtual void onConsumerMessage( connector::ConsumerInfo* consumer,
+                                        core::ActiveMQMessage* message );
    
-   };
+    };
 
 }}
 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp Fri Jul 21 04:36:09 2006
@@ -25,6 +25,7 @@
 #include <activemq/network/Socket.h>
 #include <activemq/exceptions/NullPointerException.h>
 #include <activemq/core/ActiveMQConnection.h>
+#include <activemq/core/ActiveMQConstants.h>
 #include <activemq/util/StringTokenizer.h>
 #include <activemq/support/LibraryInit.h>
 
@@ -48,10 +49,11 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-ActiveMQConnectionFactory::ActiveMQConnectionFactory(const std::string& url,
-                                                     const std::string& username,
-                                                     const std::string& password,
-                                                     const std::string& clientId)
+ActiveMQConnectionFactory::ActiveMQConnectionFactory(
+    const std::string& url,
+    const std::string& username,
+    const std::string& password,
+    const std::string& clientId )
 {
     brokerURL = url;
 
@@ -64,7 +66,7 @@
 cms::Connection* ActiveMQConnectionFactory::createConnection(void) 
 throw ( cms::CMSException )
 {
-    return createConnection(username, password);
+    return createConnection( username, password, clientId );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -96,9 +98,18 @@
         }
 
         // Store login data in the properties
-        properties->setProperty( "username", this->username );
-        properties->setProperty( "password", this->password );
-        properties->setProperty( "clientId", this->clientId );
+        properties->setProperty( 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::PARAM_USERNAME ), 
+            this->username );
+        properties->setProperty( 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::PARAM_PASSWORD ), 
+            this->password );
+        properties->setProperty( 
+            ActiveMQConstants::toString(
+                ActiveMQConstants::PARAM_CLIENTID ), 
+            this->clientId );
 
         // Parse out the properties from the URI
         parseURL( brokerURL, *properties );
@@ -112,7 +123,7 @@
             throw ActiveMQException( 
                 __FILE__, __LINE__, 
                 "ActiveMQConnectionFactory::createConnection - "
-                "unknown transport factory");
+                "unknown transport factory" );
         }
         
         // Create the transport.
@@ -121,7 +132,7 @@
             throw ActiveMQException( 
                 __FILE__, __LINE__, 
                 "ActiveMQConnectionFactory::createConnection - "
-                "failed creating new Transport");
+                "failed creating new Transport" );
         }
 
         // What wire format are we using, defaults to Stomp
@@ -137,18 +148,18 @@
             throw NullPointerException(
                 __FILE__, __LINE__,
                 "ActiveMQConnectionFactory::createConnection - "
-                "Connector for Wire Format not registered in Map");
+                "Connector for Wire Format not registered in Map" );
         }
 
         // Create the Connector.
         connector = connectorfactory->createConnector( *properties, transport );
 
-        if(connector == NULL)
+        if( connector == NULL )
         {
             throw NullPointerException(
                 __FILE__, __LINE__,
                 "ActiveMQConnectionFactory::createConnection - "
-                "Failed to Create the Connector");
+                "Failed to Create the Connector" );
         }
         
         // Start the Connector
@@ -177,9 +188,9 @@
     catch( ... )
     {
         exceptions::ActiveMQException ex( 
-           __FILE__, __LINE__, 
-           "ActiveMQConnectionFactory::create - "
-           "caught unknown exception" );
+            __FILE__, __LINE__, 
+            "ActiveMQConnectionFactory::create - "
+            "caught unknown exception" );
 
         delete connection;
         delete connector;
@@ -191,8 +202,8 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void ActiveMQConnectionFactory::parseURL(const std::string& URI, 
-                                         Properties& properties)
+void ActiveMQConnectionFactory::parseURL( const std::string& URI, 
+                                          Properties& properties )
     throw ( exceptions::IllegalArgumentException )
 {
     try
@@ -203,14 +214,14 @@
     
         // Require that there be three tokens at the least, these are
         // transport, url, port.
-        if(tokenizer.countTokens() < 3)
+        if( tokenizer.countTokens() < 3 )
         {
             throw exceptions::IllegalArgumentException(
                 __FILE__, __LINE__,
                 (string("ActiveMQConnectionFactory::parseURL - "
                         "Marlformed URI: ") + URI).c_str());
         }
-    
+
         // First element should be the Transport Type, following that is the
         // URL and any params.  
         properties.setProperty( "transport", tokenizer.nextToken() );
@@ -219,24 +230,29 @@
         // and then each param set is delimited with & we extract first
         // three chars as they are the left over ://
         properties.setProperty( "uri", tokenizer.nextToken("&?").substr(3) );
-    
+
         // Now get all the optional parameters and store them as properties
         int count = tokenizer.toArray(tokens);
         
-        for(int i = 0; i < count; ++i)
+        for( int i = 0; i < count; ++i )
         {
-            tokenizer.reset(tokens[i], "=");
+            tokenizer.reset( tokens[i], "=" );
     
-            if(tokenizer.countTokens() != 2)
+            if( tokenizer.countTokens() != 2 )
             {
                 throw exceptions::IllegalArgumentException(
                     __FILE__, __LINE__,
-                    (string("ActiveMQConnectionFactory::parseURL - "
-                           "Marlformed Parameter = ") + tokens[i]).c_str());
+                    ( string( "ActiveMQConnectionFactory::parseURL - "
+                              "Marlformed Parameter = " ) + tokens[i] ).c_str() );
             }
+            
+            // Get them in order, passing both as nextToken calls in the
+            // set Property can cause reversed order.
+            string key   = tokenizer.nextToken();
+            string value = tokenizer.nextToken();
     
             // Store this param as a property
-            properties.setProperty(tokenizer.nextToken(), tokenizer.nextToken());
+            properties.setProperty( key, value );
         }
     }
     AMQ_CATCH_RETHROW( IllegalArgumentException )

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.h Fri Jul 21 04:36:09 2006
@@ -25,153 +25,150 @@
 namespace activemq{
 namespace core{
 
-   class util::Properties;
+    class util::Properties;
 
-   class ActiveMQConnectionFactory : public cms::ConnectionFactory
-   {
-   private:
+    class ActiveMQConnectionFactory : public cms::ConnectionFactory
+    {
+    private:
    
-      // The user name this factory will use to connect
-      std::string username;
+        // The user name this factory will use to connect
+        std::string username;
       
-      // The password this factory will use to connect
-      std::string password;
+        // The password this factory will use to connect
+        std::string password;
       
-      // The client id to assign to the connection created
-      std::string clientId;
+        // The client id to assign to the connection created
+        std::string clientId;
       
-      // The URL of the Broker, the default is:
-      // "tcp://localhost:61616"
-      std::string brokerURL;
-
-   public:
-      
-      /**
-       * Constructor
-       */
-   	  ActiveMQConnectionFactory(void);
-
-      /**
-       * Constructor
-       * @param the URL of the Broker we are connecting to.
-       * @param username to authenticate with, defaults to ""
-       * @param password to authenticate with, defaults to ""
-       * @param client Id to assign to connection, defaults to ""
-       */
-      ActiveMQConnectionFactory(const std::string& url,
-                                const std::string& username = "",
-                                const std::string& password = "",
-                                const std::string& clientId = "");
-
-      /**
-       * Destructor
-       */
-   	  virtual ~ActiveMQConnectionFactory(void) {}
-
-      /**
-       * Creates a connection with the default user identity. The 
-       * connection is created in stopped mode. No messages will be 
-       * delivered until the Connection.start method is explicitly 
-       * called. 
-       * @throws CMSException
-       */
-      virtual cms::Connection* createConnection(void) throw ( cms::CMSException );
-
-      /**
-       * Creates a connection with the specified user identity. The 
-       * connection is created in stopped mode. No messages will be 
-       * delivered until the Connection.start method is explicitly called.
-       * @throw CMSException.
-       */
-      virtual cms::Connection* createConnection(const std::string& username,
-                                                const std::string& password,
-                                                const std::string& clientId = "")
-         throw ( cms::CMSException );
+        // The URL of the Broker, the default is:
+        // "tcp://localhost:61616"
+        std::string brokerURL;
+
+    public:
+      
+        /**
+         * Constructor
+         */
+   	    ActiveMQConnectionFactory(void);
+
+        /**
+         * Constructor
+         * @param the URL of the Broker we are connecting to.
+         * @param username to authenticate with, defaults to ""
+         * @param password to authenticate with, defaults to ""
+         * @param client Id to assign to connection, defaults to ""
+         */
+        ActiveMQConnectionFactory( const std::string& url,
+                                   const std::string& username = "",
+                                   const std::string& password = "",
+                                   const std::string& clientId = "" );
+
+   	    virtual ~ActiveMQConnectionFactory(void) {}
+
+        /**
+         * Creates a connection with the default user identity. The 
+         * connection is created in stopped mode. No messages will be 
+         * delivered until the Connection.start method is explicitly 
+         * called. 
+         * @throws CMSException
+         */
+        virtual cms::Connection* createConnection(void) throw ( cms::CMSException );
+
+        /**
+         * Creates a connection with the specified user identity. The 
+         * connection is created in stopped mode. No messages will be 
+         * delivered until the Connection.start method is explicitly called.
+         * @throw CMSException.
+         */
+        virtual cms::Connection* createConnection( const std::string& username,
+                                                   const std::string& password,
+                                                   const std::string& clientId = "" )
+            throw ( cms::CMSException );
                                        
-      /**
-       * Sets the username that should be used when creating a new connection
-       * @param username string
-       */
-      virtual void setUsername(const std::string& username){
-         this->username = username;
-      }
-      
-      /**
-       * Gets the username that this factory will use when creating a new
-       * connection instance.
-       * @return username string, "" for default credentials
-       */
-      virtual const std::string& getUsername(void) const {
-         return username;
-      }
-      
-      /**
-       * Sets the password that should be used when creating a new connection
-       * @param password string
-       */
-      virtual void setPassword(const std::string& password){
-         this->password = password;
-      }
-      
-      /**
-       * Gets the password that this factory will use when creating a new
-       * connection instance.
-       * @return password string, "" for default credentials
-       */
-      virtual const std::string& getPassword(void) const {
-         return password;
-      }
-
-      /**
-       * Sets the Broker URL that should be used when creating a new 
-       * connection instance
-       * @param brokerURL string
-       */
-      virtual void setBrokerURL(const std::string& brokerURL){
-         this->brokerURL = brokerURL;
-      }
-      
-      /**
-       * Gets the Broker URL that this factory will use when creating a new
-       * connection instance.
-       * @return brokerURL string
-       */
-      virtual const std::string& getBrokerURL(void) const {
-         return brokerURL;
-      }
-
-      /**
-       * Sets the Client Id that should be used when creating a new 
-       * connection instance
-       * @param clientId string
-       */
-      virtual void setClientId(const std::string& clientId){
-         this->clientId = clientId;
-      }
-      
-      /**
-       * Gets the Client Id that this factory will use when creating a new
-       * connection instance.
-       * @return clientId string
-       */
-      virtual const std::string& getClientId(void) const {
-         return clientId;
-      }
-      
-   protected:
-
-      /**
-       * Parses the properties out of the provided Broker URI and sets
-       * them in the passed Properties Object.
-       * @param a Broker URI to parse
-       * @param a Properties object to set the parsed values in
-       * @throws IllegalArgumentException if the passed URI is invalid
-       */
-      virtual void parseURL(const std::string& URI, 
-                            util::Properties& properties)
-         throw ( exceptions::IllegalArgumentException );
+        /**
+         * Sets the username that should be used when creating a new connection
+         * @param username string
+         */
+        virtual void setUsername( const std::string& username ){
+            this->username = username;
+        }
+      
+        /**
+         * Gets the username that this factory will use when creating a new
+         * connection instance.
+         * @return username string, "" for default credentials
+         */
+        virtual const std::string& getUsername(void) const {
+            return username;
+        }
+      
+        /**
+         * Sets the password that should be used when creating a new connection
+         * @param password string
+         */
+        virtual void setPassword( const std::string& password ){
+            this->password = password;
+        }
+      
+        /**
+         * Gets the password that this factory will use when creating a new
+         * connection instance.
+         * @return password string, "" for default credentials
+         */
+        virtual const std::string& getPassword(void) const {
+            return password;
+        }
+
+        /**
+         * Sets the Broker URL that should be used when creating a new 
+         * connection instance
+         * @param brokerURL string
+         */
+        virtual void setBrokerURL( const std::string& brokerURL ){
+            this->brokerURL = brokerURL;
+        }
+      
+        /**
+         * Gets the Broker URL that this factory will use when creating a new
+         * connection instance.
+         * @return brokerURL string
+         */
+        virtual const std::string& getBrokerURL(void) const {
+            return brokerURL;
+        }
+
+        /**
+         * Sets the Client Id that should be used when creating a new 
+         * connection instance
+         * @param clientId string
+         */
+        virtual void setClientId( const std::string& clientId ){
+            this->clientId = clientId;
+        }
+      
+        /**
+         * Gets the Client Id that this factory will use when creating a new
+         * connection instance.
+         * @return clientId string
+         */
+        virtual const std::string& getClientId(void) const {
+            return clientId;
+        }
+      
+    protected:
+
+        /**
+         * Parses the properties out of the provided Broker URI and sets
+         * them in the passed Properties Object.
+         * @param a Broker URI to parse
+         * @param a Properties object to set the parsed values in
+         * @throws IllegalArgumentException if the passed URI is invalid
+         */
+        virtual void parseURL( const std::string& URI, 
+                               util::Properties& properties )
+            throw ( exceptions::IllegalArgumentException );
          
-   };
+    };
 
 }}
 

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConstants.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConstants.cpp?rev=424272&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConstants.cpp (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConstants.cpp Fri Jul 21 04:36:09 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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 "ActiveMQConstants.h"
+#include <stdio.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::core;
+
+////////////////////////////////////////////////////////////////////////////////
+string ActiveMQConstants::StaticInitializer::destOptions[NUM_OPTIONS];
+string ActiveMQConstants::StaticInitializer::uriParams[NUM_PARAMS];
+
+map< std::string, ActiveMQConstants::DestinationOption > 
+    ActiveMQConstants::StaticInitializer::destOptionMap;
+map< std::string, ActiveMQConstants::URIParam > 
+    ActiveMQConstants::StaticInitializer::uriParamsMap;
+
+ActiveMQConstants::StaticInitializer ActiveMQConstants::staticInits;
+
+////////////////////////////////////////////////////////////////////////////////
+ActiveMQConstants::StaticInitializer::StaticInitializer(){
+    
+    destOptions[CONSUMER_PREFECTCHSIZE] = "consumer.prefetchSize";
+    destOptions[CUNSUMER_MAXPENDINGMSGLIMIT] = "consumer.maximumPendingMessageLimit";
+    destOptions[CONSUMER_NOLOCAL] = "consumer.noLocal";
+    destOptions[CONSUMER_DISPATCHASYNC] = "consumer.dispatchAsync";
+    destOptions[CONSUMER_RETROACTIVE] = "consumer.retroactive";
+    destOptions[CONSUMER_SELECTOR] = "consumer.selector";
+    destOptions[CONSUMER_EXCLUSIVE] = "consumer.exclusive";
+    destOptions[CONSUMER_PRIORITY] = "consumer.priority";
+    
+    uriParams[PARAM_USERNAME] = "username";
+    uriParams[PARAM_PASSWORD] = "password";
+    uriParams[PARAM_CLIENTID] = "client-id";    
+
+    for( int ix=0; ix<NUM_OPTIONS; ++ix ){
+        destOptionMap[destOptions[ix]] = (DestinationOption)ix;
+    }
+    for( int ix=0; ix<NUM_PARAMS; ++ix ){
+        uriParamsMap[uriParams[ix]] = (URIParam)ix;
+    }
+}

Added: incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConstants.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConstants.h?rev=424272&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConstants.h (added)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConstants.h Fri Jul 21 04:36:09 2006
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed 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_CORE_ACTIVEMQCONSTANTS_H_
+#define ACTIVEMQ_CORE_ACTIVEMQCONSTANTS_H_
+
+#include <activemq/exceptions/IllegalArgumentException.h>
+
+#include <string>
+#include <map>
+
+namespace activemq{
+namespace core{
+    
+    /**
+     * Class holding constant values for various ActiveMQ specific things
+     * Each constant is defined as an enumeration and has functions that
+     * convert back an forth between string and enum values.
+     */
+    class ActiveMQConstants{    
+    public:
+    
+        /**
+         * These values represent the options that can be appended to an
+         * Destination name, i.e. /topic/foo?consumer.exclusive=true
+         */
+        enum DestinationOption{
+            CONSUMER_PREFECTCHSIZE,
+            CUNSUMER_MAXPENDINGMSGLIMIT,
+            CONSUMER_NOLOCAL,
+            CONSUMER_DISPATCHASYNC,
+            CONSUMER_RETROACTIVE,
+            CONSUMER_SELECTOR,
+            CONSUMER_EXCLUSIVE,
+            CONSUMER_PRIORITY,
+            NUM_OPTIONS
+        };
+
+        /**
+         * These values represent the parameters that can be added to the
+         * connection URI that affect the ActiveMQ Core API
+         */        
+        enum URIParam
+        {
+            PARAM_USERNAME,
+            PARAM_PASSWORD,
+            PARAM_CLIENTID,
+            NUM_PARAMS
+        };
+        
+        static const std::string& toString( const DestinationOption option ){
+            return StaticInitializer::destOptions[option];
+        }
+        
+        static DestinationOption toDestinationOption( const std::string& option ){     
+            std::map< std::string, DestinationOption >::iterator iter = 
+                StaticInitializer::destOptionMap.find( option );
+
+            if( iter == StaticInitializer::destOptionMap.end() ){
+                return NUM_OPTIONS;
+            }
+                    
+            return iter->second;
+        }             
+        
+        static const std::string& toString( const URIParam option ){
+            return StaticInitializer::uriParams[option];
+        }
+        
+        static URIParam toURIOption( const std::string& option ){     
+            std::map< std::string, URIParam >::iterator iter = 
+                StaticInitializer::uriParamsMap.find( option );
+
+            if( iter == StaticInitializer::uriParamsMap.end() ){
+                return NUM_PARAMS;
+            }
+                    
+            return iter->second;
+        }             
+
+        class StaticInitializer{
+        public:
+            StaticInitializer();
+            virtual ~StaticInitializer(){}
+            
+            static std::string destOptions[NUM_OPTIONS];
+            static std::string uriParams[NUM_PARAMS];
+            static std::map<std::string, DestinationOption> destOptionMap;
+            static std::map<std::string, URIParam> uriParamsMap;
+        };
+        
+    private:
+    
+        static StaticInitializer staticInits;        
+
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_CORE_ACTIVEMQCONSTANTS_H_*/



Mime
View raw message