You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2006/07/21 13:36:16 UTC
svn commit: r424272 [2/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...
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/concurrent/ThreadPool.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/concurrent/ThreadPool.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/concurrent/ThreadPool.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/concurrent/ThreadPool.h Fri Jul 21 04:36:09 2006
@@ -30,209 +30,202 @@
namespace activemq{
namespace concurrent{
- /**
- * Defines a Thread Pool object that implements the functionality
- * of pooling threads to perform user tasks. The Thread Poll has
- * max size that it will grow to. The thread pool allocates threads
- * in blocks. When there are no waiting worker threads and a task
- * is queued then a new batch is allocated. The user can specify
- * the size of the blocks, otherwise a default value is used.
- * <P>
- * When the user queues a task they must also queue a listner to
- * be notified when the task has completed, this provides the user
- * with a mechanism to know when a task object can be freed.
- * <P>
- * To have the Thread Pool perform a task, the user enqueue's an
- * object that implements the <code>Runnable</code> insterface and
- * one of the worker threads will executing it in its thread context.
- */
- class ThreadPool : public PooledThreadListener
- {
- public:
+ /**
+ * Defines a Thread Pool object that implements the functionality
+ * of pooling threads to perform user tasks. The Thread Poll has
+ * max size that it will grow to. The thread pool allocates threads
+ * in blocks. When there are no waiting worker threads and a task
+ * is queued then a new batch is allocated. The user can specify
+ * the size of the blocks, otherwise a default value is used.
+ * <P>
+ * When the user queues a task they must also queue a listner to
+ * be notified when the task has completed, this provides the user
+ * with a mechanism to know when a task object can be freed.
+ * <P>
+ * To have the Thread Pool perform a task, the user enqueue's an
+ * object that implements the <code>Runnable</code> insterface and
+ * one of the worker threads will executing it in its thread context.
+ */
+ class ThreadPool : public PooledThreadListener
+ {
+ public:
- // Constants
- static const size_t DEFAULT_MAX_POOL_SIZE = 10;
- static const size_t DEFAULT_MAX_BLOCK_SIZE = 3;
+ // Constants
+ static const size_t DEFAULT_MAX_POOL_SIZE = 10;
+ static const size_t DEFAULT_MAX_BLOCK_SIZE = 3;
- // Types
- typedef std::pair<Runnable*, TaskListener*> Task;
+ // Types
+ typedef std::pair<Runnable*, TaskListener*> Task;
- private:
+ private:
- // Vector of threads that this object has created for its pool.
- std::vector< PooledThread* > pool;
-
- // Queue of Task that are in need of completion
- util::Queue<Task> queue;
+ // Vector of threads that this object has created for its pool.
+ std::vector< PooledThread* > pool;
+
+ // Queue of Task that are in need of completion
+ util::Queue<Task> queue;
- // Max number of Threads this Pool can contian
- unsigned long maxThreads;
+ // Max number of Threads this Pool can contian
+ unsigned long maxThreads;
- // Max number of tasks that can be allocated at a time
- unsigned long blockSize;
+ // Max number of tasks that can be allocated at a time
+ unsigned long blockSize;
- // boolean flag use to indocate that this object is shutting down.
- bool shutdown;
+ // boolean flag use to indocate that this object is shutting down.
+ bool shutdown;
- // Count of threads that are currently free to perfom some work.
- unsigned long freeThreads;
+ // Count of threads that are currently free to perfom some work.
+ unsigned long freeThreads;
- // Mutex for locking operations that affect the pool.
- Mutex poolLock;
+ // Mutex for locking operations that affect the pool.
+ Mutex poolLock;
- // Logger Init
- LOGCMS_DECLARE(logger);
- LOGCMS_DECLARE(marker);
+ // Logger Init
+ LOGCMS_DECLARE(logger);
+ LOGCMS_DECLARE(marker);
- private: // Statics
+ private: // Statics
- // The singleton instance of this class
- static ThreadPool instance;
+ // The singleton instance of this class
+ static ThreadPool instance;
- public:
+ public:
- /**
- * Constructor
- */
- ThreadPool(void);
-
- /**
- * Destructor
- */
- virtual ~ThreadPool(void);
-
- /**
- * Queue a task to be completed by one of the Pooled Threads.
- * tasks are serviced as soon as a <code>PooledThread</code>
- * is available to run it.
- * @param object that derives from Runnable
- * @throws ActiveMQException
- */
- virtual void queueTask(Task task)
- throw ( exceptions::ActiveMQException );
-
- /**
- * DeQueue a task to be completed by one of the Pooled Threads.
- * A caller of this method will block until there is something
- * in the tasks queue, therefore care must be taken when calling
- * this function. Normally clients of ThreadPool don't use
- * this, only the <code>PooledThread</code> objects owned by
- * this ThreadPool.
- * @return object that derives from Runnable
- * @throws ActiveMQException
- */
- virtual Task deQueueTask(void)
- throw ( exceptions::ActiveMQException );
-
- /**
- * Returns the current number of Threads in the Pool, this is
- * how many there are now, not how many are active or the max
- * number that might exist.
- * @return integer number of threads in existance.
- */
- virtual unsigned long getPoolSize(void) const { return pool.size(); }
-
- /**
- * Returns the current backlog of items in the tasks queue, this
- * is how much work is still waiting to get done.
- * @return number of outstanding tasks.
- */
- virtual unsigned long getBacklog(void) const { return queue.size(); }
-
- /**
- * Ensures that there is at least the specified number of Threads
- * allocated to the pool. If the size is greater than the MAX
- * number of threads in the pool, then only MAX threads are
- * reservved. If the size is smaller than the number of threads
- * currently in the pool, than nothing is done.
- * @param number of threads to reserve.
- */
- virtual void reserve(unsigned long size);
-
- /**
- * Get the Max Number of Threads this Pool can contain
- * @return max size
- */
- virtual unsigned long getMaxThreads(void) const { return maxThreads; }
-
- /**
- * Sets the Max number of threads this pool can contian.
- * if this value is smaller than the current size of the
- * pool nothing is done.
- */
- virtual void setMaxThreads(unsigned long maxThreads);
-
- /**
- * Gets the Max number of threads that can be allocated at a time
- * when new threads are needed.
- * @return max Thread Block Size
- */
- virtual unsigned long getBlockSize(void) const { return blockSize; }
-
- /**
- * Sets the Max number of Threads that can be allocated at a time
- * when the Thread Pool determines that more Threads are needed.
- * @param Max Thread Block Size
- */
- virtual void setBlockSize(unsigned long blockSize);
-
- /**
- * Returns the current number of available threads in the pool, threads
- * that are performing a user task are considered unavailable. This value
- * could change immeadiately after calling as Threads could finish right
- * after and be available again. This is informational only.
- * @return totoal free threads
- */
- virtual unsigned long getFreeThreadCount(void) const { return freeThreads; }
-
- public: // PooledThreadListener Callbacks
-
- /**
- * Called by a pooled thread when it is about to begin
- * executing a new task. This will decrement the available
- * threads counter so that this object knows when there are
- * no more free threads and must create new ones.
- * @param Pointer to the Pooled Thread that is making this call
- */
- virtual void onTaskStarted(PooledThread* thread);
+ ThreadPool(void);
+ virtual ~ThreadPool(void);
+
+ /**
+ * Queue a task to be completed by one of the Pooled Threads.
+ * tasks are serviced as soon as a <code>PooledThread</code>
+ * is available to run it.
+ * @param object that derives from Runnable
+ * @throws ActiveMQException
+ */
+ virtual void queueTask(Task task)
+ throw ( exceptions::ActiveMQException );
+
+ /**
+ * DeQueue a task to be completed by one of the Pooled Threads.
+ * A caller of this method will block until there is something
+ * in the tasks queue, therefore care must be taken when calling
+ * this function. Normally clients of ThreadPool don't use
+ * this, only the <code>PooledThread</code> objects owned by
+ * this ThreadPool.
+ * @return object that derives from Runnable
+ * @throws ActiveMQException
+ */
+ virtual Task deQueueTask(void)
+ throw ( exceptions::ActiveMQException );
+
+ /**
+ * Returns the current number of Threads in the Pool, this is
+ * how many there are now, not how many are active or the max
+ * number that might exist.
+ * @return integer number of threads in existance.
+ */
+ virtual unsigned long getPoolSize(void) const { return pool.size(); }
+
+ /**
+ * Returns the current backlog of items in the tasks queue, this
+ * is how much work is still waiting to get done.
+ * @return number of outstanding tasks.
+ */
+ virtual unsigned long getBacklog(void) const { return queue.size(); }
+
+ /**
+ * Ensures that there is at least the specified number of Threads
+ * allocated to the pool. If the size is greater than the MAX
+ * number of threads in the pool, then only MAX threads are
+ * reservved. If the size is smaller than the number of threads
+ * currently in the pool, than nothing is done.
+ * @param number of threads to reserve.
+ */
+ virtual void reserve( unsigned long size );
+
+ /**
+ * Get the Max Number of Threads this Pool can contain
+ * @return max size
+ */
+ virtual unsigned long getMaxThreads(void) const { return maxThreads; }
+
+ /**
+ * Sets the Max number of threads this pool can contian.
+ * if this value is smaller than the current size of the
+ * pool nothing is done.
+ */
+ virtual void setMaxThreads( unsigned long maxThreads );
+
+ /**
+ * Gets the Max number of threads that can be allocated at a time
+ * when new threads are needed.
+ * @return max Thread Block Size
+ */
+ virtual unsigned long getBlockSize(void) const { return blockSize; }
+
+ /**
+ * Sets the Max number of Threads that can be allocated at a time
+ * when the Thread Pool determines that more Threads are needed.
+ * @param Max Thread Block Size
+ */
+ virtual void setBlockSize( unsigned long blockSize );
+
+ /**
+ * Returns the current number of available threads in the pool, threads
+ * that are performing a user task are considered unavailable. This value
+ * could change immeadiately after calling as Threads could finish right
+ * after and be available again. This is informational only.
+ * @return totoal free threads
+ */
+ virtual unsigned long getFreeThreadCount(void) const { return freeThreads; }
+
+ public: // PooledThreadListener Callbacks
+
+ /**
+ * Called by a pooled thread when it is about to begin
+ * executing a new task. This will decrement the available
+ * threads counter so that this object knows when there are
+ * no more free threads and must create new ones.
+ * @param Pointer to the Pooled Thread that is making this call
+ */
+ virtual void onTaskStarted( PooledThread* thread );
- /**
- * Called by a pooled thread when it has completed a task
- * and is going back to waiting for another task to run,
- * this will increment the free threads counter.
- * @param Pointer the the Pooled Thread that is making this call.
- */
- virtual void onTaskCompleted(PooledThread* thread);
-
- /**
- * Called by a pooled thread when it has encountered an exception
- * while running a user task, after receiving this notification
- * the callee should assume that the PooledThread is now no longer
- * running.
- * @param Pointer to the Pooled Thread that is making this call
- * @param The Exception that occured.
- */
- virtual void onTaskException(PooledThread* thread,
- exceptions::ActiveMQException& ex);
-
- public: // Statics
-
- /**
- * Return the one and only Thread Pool instance.
- * @return The Thread Pool Pointer
- */
- static ThreadPool* getInstance(void) { return &instance; }
+ /**
+ * Called by a pooled thread when it has completed a task
+ * and is going back to waiting for another task to run,
+ * this will increment the free threads counter.
+ * @param Pointer the the Pooled Thread that is making this call.
+ */
+ virtual void onTaskCompleted( PooledThread* thread );
+
+ /**
+ * Called by a pooled thread when it has encountered an exception
+ * while running a user task, after receiving this notification
+ * the callee should assume that the PooledThread is now no longer
+ * running.
+ * @param Pointer to the Pooled Thread that is making this call
+ * @param The Exception that occured.
+ */
+ virtual void onTaskException( PooledThread* thread,
+ exceptions::ActiveMQException& ex);
+
+ public: // Statics
+
+ /**
+ * Return the one and only Thread Pool instance.
+ * @return The Thread Pool Pointer
+ */
+ static ThreadPool* getInstance(void) { return &instance; }
- private:
+ private:
- /**
- * Allocates the requested ammount of Threads, won't exceed
- * <code>maxThreads</code>.
- * @param the number of threads to create
- */
- void AllocateThreads(unsigned long count);
+ /**
+ * Allocates the requested ammount of Threads, won't exceed
+ * <code>maxThreads</code>.
+ * @param the number of threads to create
+ */
+ void AllocateThreads( unsigned long count );
- };
+ };
}}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/Connector.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/Connector.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/Connector.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/Connector.h Fri Jul 21 04:36:09 2006
@@ -73,6 +73,20 @@
virtual std::string getClientId(void) const = 0;
/**
+ * Gets the Username for this connection, if this
+ * connection has been closed, then this method returns ""
+ * @return Username String
+ */
+ virtual std::string getUsername(void) const = 0;
+
+ /**
+ * Gets the Password for this connection, if this
+ * connection has been closed, then this method returns ""
+ * @return Password String
+ */
+ virtual std::string getPassword(void) const = 0;
+
+ /**
* Gets a reference to the Transport that this connection
* is using.
* @param reference to a transport
@@ -88,7 +102,7 @@
* @throws ConnectorException
*/
virtual SessionInfo* createSession(
- cms::Session::AcknowledgeMode ackMode)
+ cms::Session::AcknowledgeMode ackMode )
throw( ConnectorException ) = 0;
/**
@@ -99,9 +113,9 @@
* @throws ConnectorException
*/
virtual ConsumerInfo* createConsumer(
- cms::Destination* destination,
+ const cms::Destination* destination,
SessionInfo* session,
- const std::string& selector = "")
+ const std::string& selector = "" )
throw ( ConnectorException ) = 0;
/**
@@ -116,11 +130,11 @@
* @throws ConnectorException
*/
virtual ConsumerInfo* createDurableConsumer(
- cms::Topic* topic,
+ const cms::Topic* topic,
SessionInfo* session,
const std::string& name,
const std::string& selector = "",
- bool noLocal = false)
+ bool noLocal = false )
throw ( ConnectorException ) = 0;
/**
@@ -131,8 +145,8 @@
* @throws ConnectorException
*/
virtual ProducerInfo* createProducer(
- cms::Destination* destination,
- SessionInfo* session)
+ const cms::Destination* destination,
+ SessionInfo* session )
throw ( ConnectorException ) = 0;
/**
@@ -142,8 +156,8 @@
* @return a newly created Topic Object
* @throws ConnectorException
*/
- virtual cms::Topic* createTopic(const std::string& name,
- SessionInfo* session)
+ virtual cms::Topic* createTopic( const std::string& name,
+ SessionInfo* session )
throw ( ConnectorException ) = 0;
/**
@@ -153,8 +167,8 @@
* @return a newly created Queue Object
* @throws ConnectorException
*/
- virtual cms::Queue* createQueue(const std::string& name,
- SessionInfo* session)
+ virtual cms::Queue* createQueue( const std::string& name,
+ SessionInfo* session )
throw ( ConnectorException ) = 0;
/**
@@ -165,7 +179,7 @@
* @throws ConnectorException
*/
virtual cms::TemporaryTopic* createTemporaryTopic(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException ) = 0;
/**
@@ -176,7 +190,7 @@
* @throws ConnectorException
*/
virtual cms::TemporaryQueue* createTemporaryQueue(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException ) = 0;
/**
@@ -185,7 +199,7 @@
* @param Producer Info for the sender of this message
* @throws ConnectorException
*/
- virtual void send(cms::Message* message, ProducerInfo* producerInfo)
+ virtual void send( cms::Message* message, ProducerInfo* producerInfo )
throw ( ConnectorException ) = 0;
/**
@@ -194,8 +208,8 @@
* @param Producer Info for the sender of this message
* @throws ConnectorException
*/
- virtual void send(std::list<cms::Message*>& messages,
- ProducerInfo* producerInfo)
+ virtual void send( std::list<cms::Message*>& messages,
+ ProducerInfo* producerInfo)
throw ( ConnectorException ) = 0;
/**
@@ -203,9 +217,9 @@
* @param An ActiveMQMessage to Ack.
* @throws ConnectorException
*/
- virtual void acknowledge(const SessionInfo* session,
- const cms::Message* message,
- AckType ackType = ConsumedAck)
+ virtual void acknowledge( const SessionInfo* session,
+ const cms::Message* message,
+ AckType ackType = ConsumedAck)
throw ( ConnectorException ) = 0;
/**
@@ -214,7 +228,7 @@
* @throws ConnectorException
*/
virtual TransactionInfo* startTransaction(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException ) = 0;
/**
@@ -223,8 +237,8 @@
* @param Session Information
* @throws ConnectorException
*/
- virtual void commit(TransactionInfo* transaction,
- SessionInfo* session)
+ virtual void commit( TransactionInfo* transaction,
+ SessionInfo* session )
throw ( ConnectorException ) = 0;
/**
@@ -233,8 +247,8 @@
* @param Session Information
* @throws ConnectorException
*/
- virtual void rollback(TransactionInfo* transaction,
- SessionInfo* session)
+ virtual void rollback( TransactionInfo* transaction,
+ SessionInfo* session )
throw ( ConnectorException ) = 0;
/**
@@ -245,7 +259,7 @@
*/
virtual cms::Message* createMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException ) = 0;
/**
@@ -256,7 +270,7 @@
*/
virtual cms::BytesMessage* createBytesMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException ) = 0;
/**
@@ -267,7 +281,7 @@
*/
virtual cms::TextMessage* createTextMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException ) = 0;
/**
@@ -278,7 +292,7 @@
*/
virtual cms::MapMessage* createMapMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException ) = 0;
/**
@@ -286,7 +300,7 @@
* @param name of the Subscription
* @throws ConnectorException
*/
- virtual void unsubscribe(const std::string& name)
+ virtual void unsubscribe( const std::string& name )
throw ( ConnectorException ) = 0;
/**
@@ -302,14 +316,14 @@
* @param listener the observer.
*/
virtual void setConsumerMessageListener(
- ConsumerMessageListener* listener) = 0;
+ ConsumerMessageListener* listener ) = 0;
/**
* Sets the Listner of exceptions for this connector
* @param ExceptionListener the observer.
*/
virtual void setExceptionListener(
- cms::ExceptionListener* listener) = 0;
+ cms::ExceptionListener* listener ) = 0;
};
}}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorException.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorException.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorException.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorException.h Fri Jul 21 04:36:09 2006
@@ -22,42 +22,44 @@
namespace activemq{
namespace connector{
- /*
- * Signals that an Connector exception of some sort has occurred.
- */
- class ConnectorException : public exceptions::ActiveMQException
- {
- public:
+ /*
+ * Signals that an Connector exception of some sort has occurred.
+ */
+ class ConnectorException : public exceptions::ActiveMQException
+ {
+ public:
- ConnectorException() {}
- ConnectorException( const exceptions::ActiveMQException& ex ){
- *(ActiveMQException*)this = ex;
- }
- ConnectorException( const ConnectorException& ex ){
- *(exceptions::ActiveMQException*)this = ex;
- }
- ConnectorException(const char* file, const int lineNumber,
- const char* msg, ...)
- {
- va_list vargs ;
- va_start(vargs, msg) ;
- buildMessage(msg, vargs) ;
+ ConnectorException() {}
+ ConnectorException( const exceptions::ActiveMQException& ex ){
+ *(ActiveMQException*)this = ex;
+ }
+ ConnectorException( const ConnectorException& ex ){
+ *(exceptions::ActiveMQException*)this = ex;
+ }
+ ConnectorException( const char* file,
+ const int lineNumber,
+ const char* msg, ... )
+ {
+ va_list vargs;
+ va_start( vargs, msg );
+ buildMessage( msg, vargs );
- // Set the first mark for this exception.
- setMark( file, lineNumber );
- }
+ // Set the first mark for this exception.
+ setMark( file, lineNumber );
+ }
- /**
- * Clones this exception. This is useful for cases where you need
- * to preserve the type of the original exception as well as the message.
- * All subclasses should override.
- */
- virtual exceptions::ActiveMQException* clone() const{
- return new ConnectorException( *this );
- }
- virtual ~ConnectorException() {}
+ /**
+ * Clones this exception. This is useful for cases where you need
+ * to preserve the type of the original exception as well as the message.
+ * All subclasses should override.
+ */
+ virtual exceptions::ActiveMQException* clone() const{
+ return new ConnectorException( *this );
+ }
+
+ virtual ~ConnectorException() {}
- };
+ };
}}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactory.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactory.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactory.h Fri Jul 21 04:36:09 2006
@@ -36,10 +36,11 @@
/**
* Creates a connector
* @param The Properties that the new connector is configured with
+ * @param the Transport that the connector should use
*/
virtual Connector* createConnector(
const activemq::util::Properties& properties,
- activemq::transport::Transport* transport) = 0;
+ activemq::transport::Transport* transport ) = 0;
};
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMap.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMap.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMap.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMap.cpp Fri Jul 21 04:36:09 2006
@@ -31,25 +31,25 @@
}
////////////////////////////////////////////////////////////////////////////////
-void ConnectorFactoryMap::registerConnectorFactory(const std::string& name,
- ConnectorFactory* factory)
+void ConnectorFactoryMap::registerConnectorFactory( const std::string& name,
+ ConnectorFactory* factory )
{
factoryMap[name] = factory;
}
////////////////////////////////////////////////////////////////////////////////
-void ConnectorFactoryMap::unregisterConnectorFactory(const std::string& name)
+void ConnectorFactoryMap::unregisterConnectorFactory( const std::string& name )
{
- factoryMap.erase(name);
+ factoryMap.erase( name );
}
////////////////////////////////////////////////////////////////////////////////
-ConnectorFactory* ConnectorFactoryMap::lookup(const std::string& name)
+ConnectorFactory* ConnectorFactoryMap::lookup( const std::string& name )
{
std::map<std::string, ConnectorFactory*>::const_iterator itr =
- factoryMap.find(name);
+ factoryMap.find( name );
- if(itr != factoryMap.end())
+ if( itr != factoryMap.end() )
{
return itr->second;
}
@@ -60,14 +60,14 @@
////////////////////////////////////////////////////////////////////////////////
std::size_t ConnectorFactoryMap::getFactoryNames(
- std::vector<std::string>& factoryList)
+ std::vector<std::string>& factoryList )
{
std::map<std::string, ConnectorFactory*>::const_iterator itr =
factoryMap.begin();
- for(; itr != factoryMap.end(); ++itr)
+ for( ; itr != factoryMap.end(); ++itr )
{
- factoryList.insert(factoryList.end(), itr->first);
+ factoryList.insert( factoryList.end(), itr->first );
}
return factoryMap.size();
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMap.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMap.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMap.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMap.h Fri Jul 21 04:36:09 2006
@@ -27,66 +27,66 @@
namespace activemq{
namespace connector{
- /**
- * Lookup Map for Connector Factories. Use the Connector name to
- * find the associated factory. This class does not take ownership
- * of the stored factories, they must be deallocated somewhere.
- */
- class ConnectorFactoryMap
- {
- public:
-
- /**
- * Gets a singleton instance of this class.
- */
- static ConnectorFactoryMap* getInstance(void);
+ /**
+ * Lookup Map for Connector Factories. Use the Connector name to
+ * find the associated factory. This class does not take ownership
+ * of the stored factories, they must be deallocated somewhere.
+ */
+ class ConnectorFactoryMap
+ {
+ public:
+
+ /**
+ * Gets a singleton instance of this class.
+ */
+ static ConnectorFactoryMap* getInstance(void);
- /**
- * Registers a new Connector Factory with this map
- * @param name to associate the factory with
- * @param factory to store.
- */
- void registerConnectorFactory(const std::string& name,
- ConnectorFactory* factory);
-
- /**
- * Unregisters a Connector Factory with this map
- * @param name of the factory to remove
- */
- void unregisterConnectorFactory(const std::string& name);
+ /**
+ * Registers a new Connector Factory with this map
+ * @param name to associate the factory with
+ * @param factory to store.
+ */
+ void registerConnectorFactory( const std::string& name,
+ ConnectorFactory* factory );
+
+ /**
+ * Unregisters a Connector Factory with this map
+ * @param name of the factory to remove
+ */
+ void unregisterConnectorFactory( const std::string& name );
- /**
- * Lookup the named factory in the Map
- * @param the factory name to lookup
- * @return the factory assciated with the name, or NULL
- */
- ConnectorFactory* lookup(const std::string& name);
-
- /**
- * Fetch a list of factory names that this Map contains
- * @param vector object to receive the list
- * @returns count of factories.
- */
- std::size_t getFactoryNames(std::vector<std::string>& factoryList);
+ /**
+ * Lookup the named factory in the Map
+ * @param the factory name to lookup
+ * @return the factory assciated with the name, or NULL
+ */
+ ConnectorFactory* lookup( const std::string& name );
+
+ /**
+ * Fetch a list of factory names that this Map contains
+ * @param vector object to receive the list
+ * @returns count of factories.
+ */
+ std::size_t getFactoryNames( std::vector< std::string >& factoryList );
- private:
+ private:
- // Hidden Contrustor, prevents instantiation
- ConnectorFactoryMap() {};
+ // Hidden Contrustor, prevents instantiation
+ ConnectorFactoryMap() {};
- // Hidden Destructor.
- virtual ~ConnectorFactoryMap() {};
+ // Hidden Destructor.
+ virtual ~ConnectorFactoryMap() {};
- // Hidden Copy Constructore
- ConnectorFactoryMap(const ConnectorFactoryMap& factoryMap);
+ // Hidden Copy Constructore
+ ConnectorFactoryMap( const ConnectorFactoryMap& factoryMap );
- // Hidden Assignment operator
- ConnectorFactoryMap operator=(const ConnectorFactoryMap& factoryMap);
+ // Hidden Assignment operator
+ ConnectorFactoryMap operator=( const ConnectorFactoryMap& factoryMap );
- // Map of Factories
- std::map<std::string, ConnectorFactory*> factoryMap;
+ // Map of Factories
+ std::map< std::string, ConnectorFactory* > factoryMap;
- };
+ };
}}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMapRegistrar.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMapRegistrar.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMapRegistrar.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorFactoryMapRegistrar.h Fri Jul 21 04:36:09 2006
@@ -59,9 +59,9 @@
{
// UnRegister it in the map.
ConnectorFactoryMap::getInstance()->
- unregisterConnectorFactory(name);
+ unregisterConnectorFactory( name );
- if(manageLifetime)
+ if( manageLifetime )
{
delete factory;
}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorResource.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorResource.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorResource.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConnectorResource.h Fri Jul 21 04:36:09 2006
@@ -14,10 +14,8 @@
{
public:
- /**
- * Destructor
- */
virtual ~ConnectorResource() {}
+
};
}}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConsumerInfo.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConsumerInfo.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConsumerInfo.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConsumerInfo.h Fri Jul 21 04:36:09 2006
@@ -29,9 +29,6 @@
{
public:
- /**
- * Destructor
- */
virtual ~ConsumerInfo(void) {}
/**
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConsumerMessageListener.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConsumerMessageListener.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConsumerMessageListener.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/ConsumerMessageListener.h Fri Jul 21 04:36:09 2006
@@ -37,8 +37,10 @@
* @param consumer the target consumer of the dispatch.
* @param msg the message to be dispatched.
*/
- virtual void onConsumerMessage( ConsumerInfo* consumer,
+ virtual void onConsumerMessage(
+ ConsumerInfo* consumer,
core::ActiveMQMessage* msg ) = 0;
+
};
}}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/SessionInfo.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/SessionInfo.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/SessionInfo.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/SessionInfo.h Fri Jul 21 04:36:09 2006
@@ -28,9 +28,6 @@
{
public:
- /**
- * Destructor
- */
virtual ~SessionInfo(void) {}
/**
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/TransactionInfo.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/TransactionInfo.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/TransactionInfo.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/TransactionInfo.h Fri Jul 21 04:36:09 2006
@@ -28,9 +28,6 @@
{
public:
- /**
- * Destructor
- */
virtual ~TransactionInfo(void) {}
/**
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandListener.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandListener.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandListener.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandListener.h Fri Jul 21 04:36:09 2006
@@ -33,7 +33,7 @@
{
public:
- virtual ~StompCommandListener(void) {}
+ virtual ~StompCommandListener(void) {}
/**
* Process the Stomp Command
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp Fri Jul 21 04:36:09 2006
@@ -35,14 +35,14 @@
}
////////////////////////////////////////////////////////////////////////////////
-StompCommandReader::StompCommandReader(InputStream* is)
+StompCommandReader::StompCommandReader( InputStream* is )
{
inputStream = is;
}
////////////////////////////////////////////////////////////////////////////////
Command* StompCommandReader::readCommand(void)
- throw (CommandIOException)
+ throw ( CommandIOException )
{
try
{
@@ -70,53 +70,53 @@
void StompCommandReader::readStompCommand( StompFrame& frame )
throw ( StompConnectorException )
{
- while( true )
- {
- // Clean up the mess.
- buffer.clear();
+ while( true )
+ {
+ // Clean up the mess.
+ buffer.clear();
- // Read the command;
- readStompHeaderLine();
+ // Read the command;
+ readStompHeaderLine();
// Ignore all white space before the command.
int offset=-1;
for( size_t ix = 0; ix < buffer.size()-1; ++ix )
{
- // Find the first non space character
- char b = buffer[ix];
+ // Find the first non space character
+ char b = buffer[ix];
switch ( b )
{
- case '\n':
- case '\t':
- case '\r':
- break;
-
- default:
- offset = ix;
- break;
+ case '\n':
+ case '\t':
+ case '\r':
+ break;
+
+ default:
+ offset = ix;
+ break;
}
- if( offset != -1 )
- {
- break;
- }
+ if( offset != -1 )
+ {
+ break;
+ }
}
-
- if( offset >= 0 )
- {
- // Set the command in the frame - copy the memory.
- frame.setCommand( reinterpret_cast<char*>(&buffer[offset]) );
- break;
- }
-
- }
+
+ if( offset >= 0 )
+ {
+ // Set the command in the frame - copy the memory.
+ frame.setCommand( reinterpret_cast<char*>(&buffer[offset]) );
+ break;
+ }
+
+ }
// Clean up the mess.
buffer.clear();
}
////////////////////////////////////////////////////////////////////////////////
void StompCommandReader::readStompHeaders( StompFrame& frame )
- throw (StompConnectorException)
+ throw ( StompConnectorException )
{
// Read the command;
bool endOfHeaders = false;
@@ -173,7 +173,7 @@
////////////////////////////////////////////////////////////////////////////////
int StompCommandReader::readStompHeaderLine(void)
- throw (StompConnectorException)
+ throw ( StompConnectorException )
{
int count = 0;
@@ -223,10 +223,10 @@
content_length = strtoul(
length.c_str(),
&stopped_string,
- 10);
+ 10 );
}
- if(content_length != 0)
+ if( content_length != 0 )
{
// For this case its assumed that content length indicates how
// much to read. We reserve space in the buffer for it to
@@ -271,7 +271,7 @@
content_length++;
- if(byte != '\0')
+ if( byte != '\0' )
{
continue;
}
@@ -283,7 +283,7 @@
if( content_length != 0 )
{
char* cpyBody = new char[content_length];
- memcpy(cpyBody, &buffer[0], content_length);
+ memcpy( cpyBody, &buffer[0], content_length );
// Set the body contents in the frame - copy the memory
frame.setBody( cpyBody, content_length );
@@ -294,8 +294,8 @@
}
////////////////////////////////////////////////////////////////////////////////
-int StompCommandReader::read(unsigned char* buffer, int count)
- throw(io::IOException)
+int StompCommandReader::read( unsigned char* buffer, int count )
+ throw( io::IOException )
{
if( inputStream == NULL )
{
@@ -312,9 +312,9 @@
// pause in hopes that some more data will show up.
while( true )
{
- head += inputStream->read(&buffer[head], count - head);
+ head += inputStream->read( &buffer[head], count - head );
- if(head == count)
+ if( head == count )
{
return count;
}
@@ -325,7 +325,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-unsigned char StompCommandReader::readByte(void) throw(io::IOException)
+unsigned char StompCommandReader::readByte(void) throw( io::IOException )
{
if( inputStream == NULL )
{
@@ -335,6 +335,6 @@
}
unsigned char c = 0;
- inputStream->read(&c, 1);
+ inputStream->read( &c, 1 );
return c;
}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h Fri Jul 21 04:36:09 2006
@@ -53,7 +53,7 @@
/**
* Deafult Constructor
*/
- StompCommandReader( void );
+ StompCommandReader( void );
/**
* Constructor.
@@ -61,24 +61,21 @@
*/
StompCommandReader( io::InputStream* is );
- /**
- * Destructor
- */
- virtual ~StompCommandReader(void) {}
+ virtual ~StompCommandReader(void) {}
/**
* Reads a command from the given input stream.
* @return The next command available on the stream.
* @throws CommandIOException if a problem occurs during the read.
*/
- virtual transport::Command* readCommand( void )
+ virtual transport::Command* readCommand(void)
throw ( transport::CommandIOException );
/**
* Sets the target input stream.
* @param Target Input Stream
*/
- virtual void setInputStream(io::InputStream* is){
+ virtual void setInputStream( io::InputStream* is ){
inputStream = is;
}
@@ -86,7 +83,7 @@
* Gets the target input stream.
* @return Target Input Stream
*/
- virtual io::InputStream* getInputStream( void ){
+ virtual io::InputStream* getInputStream(void){
return inputStream;
}
@@ -97,7 +94,7 @@
* @return The number of bytes read.
* @throws IOException thrown if an error occurs.
*/
- virtual int read(unsigned char* buffer, int count)
+ virtual int read( unsigned char* buffer, int count )
throw( io::IOException );
/**
@@ -130,7 +127,7 @@
* @return number of bytes read, zero if there was a problem.
* @throws StompConnectorException
*/
- int readStompHeaderLine( void ) throw ( StompConnectorException );
+ int readStompHeaderLine(void) throw ( StompConnectorException );
/**
* Reads the Stomp Body from the Wire and store it in the frame.
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp Fri Jul 21 04:36:09 2006
@@ -35,7 +35,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-StompCommandWriter::StompCommandWriter(OutputStream* os)
+StompCommandWriter::StompCommandWriter( OutputStream* os )
{
outputStream = os;
}
@@ -103,8 +103,8 @@
}
////////////////////////////////////////////////////////////////////////////////
-void StompCommandWriter::write(const unsigned char* buffer, int count)
- throw(IOException)
+void StompCommandWriter::write( const unsigned char* buffer, int count )
+ throw( IOException )
{
if( outputStream == NULL )
{
@@ -117,7 +117,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-void StompCommandWriter::writeByte(unsigned char v) throw(IOException)
+void StompCommandWriter::writeByte( unsigned char v ) throw( IOException )
{
if( outputStream == NULL )
{
@@ -130,8 +130,8 @@
}
////////////////////////////////////////////////////////////////////////////////
-void StompCommandWriter::write(const char* buffer, int count)
- throw(io::IOException)
+void StompCommandWriter::write( const char* buffer, int count )
+ throw( io::IOException )
{
- write(reinterpret_cast<const unsigned char*>(buffer), count);
+ write( reinterpret_cast<const unsigned char*>( buffer ), count );
}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h Fri Jul 21 04:36:09 2006
@@ -48,7 +48,7 @@
/**
* Default Constructor
*/
- StompCommandWriter(void);
+ StompCommandWriter(void);
/**
* Constructor.
@@ -56,15 +56,12 @@
*/
StompCommandWriter( io::OutputStream* os );
- /**
- * Destructor
- */
- virtual ~StompCommandWriter(void) {}
+ virtual ~StompCommandWriter(void) {}
/**
* Sets the target output stream.
*/
- virtual void setOutputStream(io::OutputStream* os){
+ virtual void setOutputStream( io::OutputStream* os ){
outputStream = os;
}
@@ -90,7 +87,7 @@
* @param count the number of bytes in the array to write.
* @throws IOException thrown if an error occurs.
*/
- virtual void write(const unsigned char* buffer, int count)
+ virtual void write( const unsigned char* buffer, int count )
throw( io::IOException );
/**
@@ -98,7 +95,7 @@
* @param v The value to be written.
* @throws IOException thrown if an error occurs.
*/
- virtual void writeByte(unsigned char v) throw( io::IOException );
+ virtual void writeByte( unsigned char v ) throw( io::IOException );
private:
@@ -108,7 +105,7 @@
* @param count the number of bytes in the array to write.
* @throws IOException thrown if an error occurs.
*/
- virtual void write(const char* buffer, int count)
+ virtual void write( const char* buffer, int count )
throw( io::IOException );
};
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.cpp Fri Jul 21 04:36:09 2006
@@ -52,7 +52,7 @@
const util::Properties& properties )
throw ( IllegalArgumentException )
{
- if(transport == NULL)
+ if( transport == NULL )
{
throw IllegalArgumentException(
__FILE__, __LINE__,
@@ -64,8 +64,8 @@
this->exceptionListener = NULL;
this->messageListener = NULL;
this->sessionManager = NULL;
- this->nextProducerId = 0;
- this->nextTransactionId = 0;
+ this->nextProducerId = 1;
+ this->nextTransactionId = 1;
this->properties.copy( &properties );
// Observe the transport for events.
@@ -96,7 +96,7 @@
////////////////////////////////////////////////////////////////////////////////
unsigned int StompConnector::getNextProducerId(void)
{
- synchronized(&mutex)
+ synchronized( &mutex )
{
return nextProducerId++;
}
@@ -107,7 +107,7 @@
////////////////////////////////////////////////////////////////////////////////
unsigned int StompConnector::getNextTransactionId(void)
{
- synchronized(&mutex)
+ synchronized( &mutex )
{
return nextTransactionId++;
}
@@ -138,7 +138,7 @@
void StompConnector::removeCmdListener(
commands::CommandConstants::CommandId commandId )
{
- cmdListenerMap.erase(commandId);
+ cmdListenerMap.erase( commandId );
}
////////////////////////////////////////////////////////////////////////////////
@@ -199,7 +199,7 @@
ConnectCommand cmd;
// Encode User Name and Password and Client ID
- string login = getLogin();
+ string login = getUsername();
if( login.length() > 0 ){
cmd.setLogin( login );
}
@@ -216,6 +216,8 @@
if( dynamic_cast< ExceptionResponse* >( response ) != NULL )
{
+ delete response;
+
throw StompConnectorException(
__FILE__, __LINE__,
"StompConnector::connect - Failed on Connect Request" );
@@ -226,6 +228,8 @@
if( connected == NULL )
{
+ delete response;
+
throw StompConnectorException(
__FILE__, __LINE__,
"StompConnector::connect - "
@@ -281,7 +285,7 @@
////////////////////////////////////////////////////////////////////////////////
SessionInfo* StompConnector::createSession(
- cms::Session::AcknowledgeMode ackMode)
+ cms::Session::AcknowledgeMode ackMode )
throw( ConnectorException )
{
try
@@ -296,9 +300,9 @@
////////////////////////////////////////////////////////////////////////////////
ConsumerInfo* StompConnector::createConsumer(
- cms::Destination* destination,
+ const cms::Destination* destination,
SessionInfo* session,
- const std::string& selector)
+ const std::string& selector )
throw ( ConnectorException )
{
try
@@ -314,11 +318,11 @@
////////////////////////////////////////////////////////////////////////////////
ConsumerInfo* StompConnector::createDurableConsumer(
- cms::Topic* topic,
+ const cms::Topic* topic,
SessionInfo* session,
const std::string& name,
const std::string& selector,
- bool noLocal)
+ bool noLocal )
throw ( ConnectorException )
{
try
@@ -334,8 +338,8 @@
////////////////////////////////////////////////////////////////////////////////
ProducerInfo* StompConnector::createProducer(
- cms::Destination* destination,
- SessionInfo* session)
+ const cms::Destination* destination,
+ SessionInfo* session )
throw ( ConnectorException )
{
try
@@ -355,30 +359,30 @@
}
////////////////////////////////////////////////////////////////////////////////
-cms::Topic* StompConnector::createTopic(const std::string& name,
- SessionInfo* session)
+cms::Topic* StompConnector::createTopic( const std::string& name,
+ SessionInfo* session )
throw ( ConnectorException )
{
try
{
enforceConnected();
- return new StompTopic(name);
+ return new StompTopic( name );
}
AMQ_CATCH_RETHROW( ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
}
////////////////////////////////////////////////////////////////////////////////
-cms::Queue* StompConnector::createQueue(const std::string& name,
- SessionInfo* session)
+cms::Queue* StompConnector::createQueue( const std::string& name,
+ SessionInfo* session )
throw ( ConnectorException )
{
try
{
enforceConnected();
- return new StompQueue(name);
+ return new StompQueue( name );
}
AMQ_CATCH_RETHROW( ConnectorException )
AMQ_CATCHALL_THROW( ConnectorException );
@@ -386,7 +390,7 @@
////////////////////////////////////////////////////////////////////////////////
cms::TemporaryTopic* StompConnector::createTemporaryTopic(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException )
{
try
@@ -401,7 +405,7 @@
////////////////////////////////////////////////////////////////////////////////
cms::TemporaryQueue* StompConnector::createTemporaryQueue(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException )
{
try
@@ -416,7 +420,7 @@
////////////////////////////////////////////////////////////////////////////////
void StompConnector::send(cms::Message* message,
- ProducerInfo* producerInfo)
+ ProducerInfo* producerInfo )
throw ( ConnectorException )
{
try
@@ -434,7 +438,7 @@
"Message is not a valid stomp type.");
}
- if( session->getAckMode() == cms::Session::Transactional )
+ if( session->getAckMode() == cms::Session::SESSION_TRANSACTED )
{
StompCommand* stompCommand =
dynamic_cast< StompCommand* >( message );
@@ -460,19 +464,19 @@
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::send(std::list<cms::Message*>& messages,
- ProducerInfo* producerInfo)
+void StompConnector::send( std::list<cms::Message*>& messages,
+ ProducerInfo* producerInfo )
throw ( ConnectorException )
{
try
{
enforceConnected();
- list<cms::Message*>::const_iterator itr = messages.begin();
+ list< cms::Message* >::const_iterator itr = messages.begin();
- for(; itr != messages.end(); ++itr)
+ for( ; itr != messages.end(); ++itr )
{
- this->send(*itr, producerInfo);
+ this->send( *itr, producerInfo );
}
}
AMQ_CATCH_RETHROW( ConnectorException )
@@ -491,7 +495,7 @@
// Auto to Stomp means don't do anything, so we drop it here
// for client acknowledge we have to send and ack.
- if( session->getAckMode() == cms::Session::ClientAcknowledge )
+ if( session->getAckMode() == cms::Session::CLIENT_ACKNOWLEDGE )
{
AckCommand cmd;
@@ -505,7 +509,7 @@
cmd.setMessageId( message->getCMSMessageId() );
- if( session->getAckMode() == cms::Session::Transactional )
+ if( session->getAckMode() == cms::Session::SESSION_TRANSACTED )
{
cmd.setTransactionId(
Integer::toString(
@@ -521,7 +525,7 @@
////////////////////////////////////////////////////////////////////////////////
TransactionInfo* StompConnector::startTransaction(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException )
{
try
@@ -548,8 +552,8 @@
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::commit(TransactionInfo* transaction,
- SessionInfo* session)
+void StompConnector::commit( TransactionInfo* transaction,
+ SessionInfo* session )
throw ( ConnectorException )
{
try
@@ -568,8 +572,8 @@
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::rollback(TransactionInfo* transaction,
- SessionInfo* session)
+void StompConnector::rollback( TransactionInfo* transaction,
+ SessionInfo* session )
throw ( ConnectorException )
{
try
@@ -590,7 +594,7 @@
////////////////////////////////////////////////////////////////////////////////
cms::Message* StompConnector::createMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException )
{
try
@@ -614,7 +618,7 @@
////////////////////////////////////////////////////////////////////////////////
cms::BytesMessage* StompConnector::createBytesMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException )
{
try
@@ -638,7 +642,7 @@
////////////////////////////////////////////////////////////////////////////////
cms::TextMessage* StompConnector::createTextMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException )
{
try
@@ -662,7 +666,7 @@
////////////////////////////////////////////////////////////////////////////////
cms::MapMessage* StompConnector::createMapMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException )
{
try
@@ -676,7 +680,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-void StompConnector::unsubscribe(const std::string& name)
+void StompConnector::unsubscribe( const std::string& name )
throw ( ConnectorException )
{
try
@@ -723,7 +727,7 @@
{
StompCommand* stompCommand = dynamic_cast< StompCommand* >(command);
- if(stompCommand == NULL)
+ if( stompCommand == NULL )
{
fire( ConnectorException(
__FILE__, __LINE__,
@@ -777,18 +781,21 @@
try
{
ErrorCommand* error =
- dynamic_cast<ErrorCommand*>(command);
+ dynamic_cast<ErrorCommand*>( command );
- if(error != NULL)
+ if( error != NULL )
{
fire( StompConnectorException(
- __FILE__, __LINE__,
- (string( "StompConnector::onStompCommand - " ) +
- error->getErrorMessage() ).c_str() ) );
+ __FILE__, __LINE__,
+ ( string( "StompConnector::onStompCommand - " ) +
+ error->getErrorMessage() ).c_str() ) );
// Shutdown
close();
}
+
+ // command is done here, delete it.
+ delete command;
}
AMQ_CATCH_RETHROW( StompConnectorException )
AMQ_CATCHALL_THROW( StompConnectorException );
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnector.h Fri Jul 21 04:36:09 2006
@@ -29,6 +29,7 @@
#include <activemq/connector/stomp/StompCommandListener.h>
#include <activemq/connector/stomp/StompSessionManager.h>
#include <activemq/connector/stomp/commands/CommandConstants.h>
+#include <activemq/core/ActiveMQConstants.h>
#include <activemq/exceptions/IllegalArgumentException.h>
namespace activemq{
@@ -57,7 +58,7 @@
// Maps Command Ids to listener that are interested
typedef std::map< commands::CommandConstants::CommandId,
- StompCommandListener*> CmdListenerMap;
+ StompCommandListener* > CmdListenerMap;
private:
@@ -192,20 +193,30 @@
*/
virtual std::string getClientId(void) const {
return properties.getProperty(
- commands::CommandConstants::toString(
- commands::CommandConstants::HEADER_CLIENT_ID ), "" );
+ core::ActiveMQConstants::toString(
+ core::ActiveMQConstants::PARAM_CLIENTID ), "" );
}
- virtual std::string getLogin(void) const {
+ /**
+ * Gets the Username for this connection, if this
+ * connection has been closed, then this method returns ""
+ * @return Username String
+ */
+ virtual std::string getUsername(void) const {
return properties.getProperty(
- commands::CommandConstants::toString(
- commands::CommandConstants::HEADER_LOGIN ), "" );
+ core::ActiveMQConstants::toString(
+ core::ActiveMQConstants::PARAM_USERNAME ), "" );
}
+ /**
+ * Gets the Password for this connection, if this
+ * connection has been closed, then this method returns ""
+ * @return Password String
+ */
virtual std::string getPassword(void) const {
return properties.getProperty(
- commands::CommandConstants::toString(
- commands::CommandConstants::HEADER_PASSWORD ), "" );
+ core::ActiveMQConstants::toString(
+ core::ActiveMQConstants::PARAM_PASSWORD ), "" );
}
/**
@@ -215,7 +226,7 @@
* @throws InvalidStateException if the Transport is not set
*/
virtual transport::Transport& getTransport(void) const
- throw (exceptions::InvalidStateException ) {
+ throw ( exceptions::InvalidStateException ) {
if( transport == NULL ) {
throw exceptions::InvalidStateException(
@@ -234,7 +245,7 @@
* @throws ConnectorException
*/
virtual SessionInfo* createSession(
- cms::Session::AcknowledgeMode ackMode)
+ cms::Session::AcknowledgeMode ackMode )
throw( ConnectorException );
/**
@@ -245,9 +256,9 @@
* @throws ConnectorException
*/
virtual ConsumerInfo* createConsumer(
- cms::Destination* destination,
+ const cms::Destination* destination,
SessionInfo* session,
- const std::string& selector = "")
+ const std::string& selector = "" )
throw ( ConnectorException );
/**
@@ -262,11 +273,11 @@
* @throws ConnectorException
*/
virtual ConsumerInfo* createDurableConsumer(
- cms::Topic* topic,
+ const cms::Topic* topic,
SessionInfo* session,
const std::string& name,
const std::string& selector = "",
- bool noLocal = false)
+ bool noLocal = false )
throw ( ConnectorException );
/**
@@ -277,7 +288,7 @@
* @throws ConnectorException
*/
virtual ProducerInfo* createProducer(
- cms::Destination* destination,
+ const cms::Destination* destination,
SessionInfo* session)
throw ( ConnectorException );
@@ -311,7 +322,7 @@
* @throws ConnectorException
*/
virtual cms::TemporaryTopic* createTemporaryTopic(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException );
/**
@@ -322,7 +333,7 @@
* @throws ConnectorException
*/
virtual cms::TemporaryQueue* createTemporaryQueue(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException );
/**
@@ -351,7 +362,7 @@
*/
virtual void acknowledge( const SessionInfo* session,
const cms::Message* message,
- AckType ackType)
+ AckType ackType )
throw ( ConnectorException );
/**
@@ -360,7 +371,7 @@
* @throws ConnectorException
*/
virtual TransactionInfo* startTransaction(
- SessionInfo* session)
+ SessionInfo* session )
throw ( ConnectorException );
/**
@@ -369,8 +380,8 @@
* @param Session Information
* @throws ConnectorException
*/
- virtual void commit(TransactionInfo* transaction,
- SessionInfo* session)
+ virtual void commit( TransactionInfo* transaction,
+ SessionInfo* session )
throw ( ConnectorException );
/**
@@ -379,8 +390,8 @@
* @param Session Information
* @throws ConnectorException
*/
- virtual void rollback(TransactionInfo* transaction,
- SessionInfo* session)
+ virtual void rollback( TransactionInfo* transaction,
+ SessionInfo* session )
throw ( ConnectorException );
/**
@@ -391,7 +402,7 @@
*/
virtual cms::Message* createMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException );
/**
@@ -402,7 +413,7 @@
*/
virtual cms::BytesMessage* createBytesMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException );
/**
@@ -413,7 +424,7 @@
*/
virtual cms::TextMessage* createTextMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException );
/**
@@ -424,7 +435,7 @@
*/
virtual cms::MapMessage* createMapMessage(
SessionInfo* session,
- TransactionInfo* transaction)
+ TransactionInfo* transaction )
throw ( ConnectorException );
/**
@@ -448,7 +459,7 @@
* @param listener the observer.
*/
virtual void setConsumerMessageListener(
- ConsumerMessageListener* listener)
+ ConsumerMessageListener* listener )
{
this->messageListener = listener;
@@ -463,7 +474,7 @@
* @param ExceptionListener the observer.
*/
virtual void setExceptionListener(
- cms::ExceptionListener* listener)
+ cms::ExceptionListener* listener )
{
this->exceptionListener = listener;
}
@@ -520,8 +531,8 @@
private:
- unsigned int getNextProducerId( void );
- unsigned int getNextTransactionId( void );
+ unsigned int getNextProducerId(void);
+ unsigned int getNextTransactionId(void);
// Check for Connected State and Throw an exception if not.
void enforceConnected( void ) throw ( ConnectorException );
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorException.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorException.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorException.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorException.h Fri Jul 21 04:36:09 2006
@@ -40,9 +40,9 @@
StompConnectorException(const char* file, const int lineNumber,
const char* msg, ...)
{
- va_list vargs ;
- va_start(vargs, msg) ;
- buildMessage(msg, vargs) ;
+ va_list vargs;
+ va_start( vargs, msg );
+ buildMessage( msg, vargs );
// Set the first mark for this exception.
setMark( file, lineNumber );
@@ -56,6 +56,7 @@
virtual exceptions::ActiveMQException* clone() const{
return new StompConnectorException( *this );
}
+
virtual ~StompConnectorException() {}
};
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorFactory.cpp?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorFactory.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorFactory.cpp Fri Jul 21 04:36:09 2006
@@ -31,10 +31,10 @@
////////////////////////////////////////////////////////////////////////////////
Connector* StompConnectorFactory::createConnector(
const activemq::util::Properties& properties,
- activemq::transport::Transport* transport)
+ activemq::transport::Transport* transport )
{
return dynamic_cast<Connector*>(
- new StompConnector(transport, properties));
+ new StompConnector( transport, properties ) );
}
////////////////////////////////////////////////////////////////////////////////
@@ -43,7 +43,7 @@
// Create a static instance of the registrar and return a reference to
// its internal instance of this class.
static ConnectorFactoryMapRegistrar registrar(
- "stomp", new StompConnectorFactory());
+ "stomp", new StompConnectorFactory() );
return registrar.getFactory();
}
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorFactory.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorFactory.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConnectorFactory.h Fri Jul 21 04:36:09 2006
@@ -26,9 +26,6 @@
class StompConnectorFactory : public connector::ConnectorFactory
{
- private:
-
-
public:
virtual ~StompConnectorFactory(void) {}
@@ -39,7 +36,7 @@
*/
virtual Connector* createConnector(
const activemq::util::Properties& properties,
- activemq::transport::Transport* transport);
+ activemq::transport::Transport* transport );
/**
* Returns an instance of this Factory by reference
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConsumerInfo.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConsumerInfo.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConsumerInfo.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompConsumerInfo.h Fri Jul 21 04:36:09 2006
@@ -45,7 +45,8 @@
consumerId = 0;
destination = NULL;
}
- virtual ~StompConsumerInfo(void) { delete destination; }
+
+ virtual ~StompConsumerInfo(void) { delete destination; }
/**
* Gets this message consumer's message selector expression.
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompDestination.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompDestination.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompDestination.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompDestination.h Fri Jul 21 04:36:09 2006
@@ -20,7 +20,7 @@
#include <string>
-#include <cms/Destination.h>
+#include <activemq/core/ActiveMQDestination.h>
namespace activemq{
namespace connector{
@@ -32,26 +32,25 @@
* one of Topic, Queue, TemporaryTopic, or TemporaryQueue.
*/
template <typename T>
- class StompDestination : public T
+ class StompDestination : public core::ActiveMQDestination<T>
{
- private:
-
- // Destination type
- cms::Destination::DestinationType destType;
-
- // Name of the Destination
- std::string name;
-
public:
- StompDestination(void) {}
+ /**
+ * Copy Consturctor
+ * @param CMS Dest to Copy, must be a compatible type
+ */
+ StompDestination( const cms::Destination* source ) :
+ core::ActiveMQDestination<T>( source ) {}
+ /**
+ * Custom Constructor
+ * @param string destination name plus any params
+ * @param type of destination this represents.
+ */
StompDestination( const std::string& name,
- cms::Destination::DestinationType type )
- {
- this->name = name;
- this->destType = type;
- }
+ cms::Destination::DestinationType type ) :
+ core::ActiveMQDestination<T>( name, type ){}
virtual ~StompDestination(void) {}
@@ -61,15 +60,7 @@
* @return name
*/
virtual std::string toProviderString(void) const {
- return getPrefix() + name;
- }
-
- /**
- * Retrieve the Destination Type for this Destination
- * @return The Destination Type
- */
- virtual cms::Destination::DestinationType getDestinationType(void) const {
- return destType;
+ return getPrefix() + core::ActiveMQDestination<T>::getName();
}
/**
@@ -78,16 +69,7 @@
* @return string name
*/
virtual std::string toString(void) const {
- return name;
- }
-
- /**
- * Copies the contents of the given Destinastion object to this one.
- * @param source The source Destination object.
- */
- virtual void copy( const cms::Destination& source ) {
- this->destType = source.getDestinationType();
- this->name = source.toString();
+ return core::ActiveMQDestination<T>::getName();
}
protected:
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompQueue.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompQueue.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompQueue.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompQueue.h Fri Jul 21 04:36:09 2006
@@ -26,17 +26,27 @@
namespace connector{
namespace stomp{
- class StompQueue : public StompDestination<cms::Queue>
+ class StompQueue : public StompDestination< cms::Queue >
{
public:
- StompQueue(void) : StompDestination< cms::Queue >() {}
+ /**
+ * Copy Consturctor
+ * @param CMS Dest to Copy, must be a compatible type
+ */
+ StompQueue( const cms::Destination* source ) :
+ StompDestination< cms::Queue >( source ) {}
+ /**
+ * Custom Constructor
+ * @param string destination name plus any params
+ * @param type of destination this represents.
+ */
StompQueue(const std::string& name) :
StompDestination< cms::Queue >( name, cms::Destination::QUEUE )
{}
- virtual ~StompQueue(void) {}
+ virtual ~StompQueue(void) {}
/**
* Gets the name of this queue.
Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionInfo.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionInfo.h?rev=424272&r1=424271&r2=424272&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionInfo.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompSessionInfo.h Fri Jul 21 04:36:09 2006
@@ -44,18 +44,12 @@
public:
- /**
- * Constructor
- */
StompSessionInfo(void)
{
sessionId = 0;
- ackMode = cms::Session::AutoAcknowledge;
+ ackMode = cms::Session::AUTO_ACKNOWLEDGE;
}
- /**
- * Destructor
- */
virtual ~StompSessionInfo(void) {}
/**