You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/10/18 15:11:58 UTC
svn commit: r1399656 [2/2] - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/main: ./ activemq/cmsutil/
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp?rev=1399656&r1=1399655&r2=1399656&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.cpp Thu Oct 18 13:11:57 2012
@@ -34,27 +34,27 @@ using namespace activemq::cmsutil;
*/
#define CMSTEMPLATE_CATCHALL() \
catch( cms::CMSException& ex ){ \
- throw ex; \
+ throw; \
} catch( ... ){ \
- throw CMSException( "caught unknown exception", NULL ); \
+ throw CMSException("caught unknown exception", NULL); \
}
////////////////////////////////////////////////////////////////////////////////
-PooledSession::PooledSession( SessionPool* pool, cms::Session* session )
- : pool( pool ), session( session ), producerCache(), consumerCache() {
+PooledSession::PooledSession(SessionPool* pool, cms::Session* session) :
+ pool(pool), session(session), producerCache(), consumerCache() {
}
////////////////////////////////////////////////////////////////////////////////
PooledSession::~PooledSession() {
// Destroy cached producers.
- std::auto_ptr< Iterator<CachedProducer*> > producers(producerCache.values().iterator());
+ std::auto_ptr<Iterator<CachedProducer*> > producers(producerCache.values().iterator());
while (producers->hasNext()) {
delete producers->next();
}
// Destroy cached consumers.
- std::auto_ptr< Iterator<CachedConsumer*> > consumers(consumerCache.values().iterator());
+ std::auto_ptr<Iterator<CachedConsumer*> > consumers(consumerCache.values().iterator());
while (consumers->hasNext()) {
delete consumers->next();
}
@@ -63,28 +63,28 @@ PooledSession::~PooledSession() {
////////////////////////////////////////////////////////////////////////////////
void PooledSession::close() {
- if( pool != NULL ) {
- pool->returnSession( this );
+ if (pool != NULL) {
+ pool->returnSession(this);
}
}
////////////////////////////////////////////////////////////////////////////////
-cms::QueueBrowser* PooledSession::createBrowser( const cms::Queue* queue ) {
- return session->createBrowser( queue );
+cms::QueueBrowser* PooledSession::createBrowser(const cms::Queue* queue) {
+ return session->createBrowser(queue);
}
////////////////////////////////////////////////////////////////////////////////
-cms::QueueBrowser* PooledSession::createBrowser( const cms::Queue* queue, const std::string& selector ) {
- return session->createBrowser( queue, selector );
+cms::QueueBrowser* PooledSession::createBrowser(const cms::Queue* queue, const std::string& selector) {
+ return session->createBrowser(queue, selector);
}
////////////////////////////////////////////////////////////////////////////////
-cms::MessageProducer* PooledSession::createCachedProducer( const cms::Destination* destination ) {
+cms::MessageProducer* PooledSession::createCachedProducer(const cms::Destination* destination) {
try {
- if( destination == NULL ) {
- throw CMSException( "destination is NULL", NULL );
+ if (destination == NULL) {
+ throw CMSException("destination is NULL", NULL);
}
std::string key = getUniqueDestName(destination);
@@ -92,21 +92,21 @@ cms::MessageProducer* PooledSession::cre
// Check the cache - add it if necessary.
CachedProducer* cachedProducer = NULL;
try {
- cachedProducer = producerCache.get( key );
- } catch( decaf::util::NoSuchElementException& e ) {
+ cachedProducer = producerCache.get(key);
+ } catch (decaf::util::NoSuchElementException& e) {
// No producer exists for this destination - start by creating
// a new producer resource.
- cms::MessageProducer* p = session->createProducer( destination );
+ cms::MessageProducer* p = session->createProducer(destination);
// Add the producer resource to the resource lifecycle manager.
- pool->getResourceLifecycleManager()->addMessageProducer( p );
+ pool->getResourceLifecycleManager()->addMessageProducer(p);
// Create the cached producer wrapper.
- cachedProducer = new CachedProducer( p );
+ cachedProducer = new CachedProducer(p);
// Add it to the cache.
- producerCache.put( key, cachedProducer );
+ producerCache.put(key, cachedProducer);
}
return cachedProducer;
@@ -115,41 +115,39 @@ cms::MessageProducer* PooledSession::cre
}
////////////////////////////////////////////////////////////////////////////////
-cms::MessageConsumer* PooledSession::createCachedConsumer( const cms::Destination* destination,
- const std::string& selector,
- bool noLocal ) {
+cms::MessageConsumer* PooledSession::createCachedConsumer(const cms::Destination* destination, const std::string& selector, bool noLocal) {
try {
- if( destination == NULL ) {
- throw CMSException( "destination is NULL", NULL );
+ if (destination == NULL) {
+ throw CMSException("destination is NULL", NULL);
}
// Append the selector and noLocal flag onto the key.
- std::string key = getUniqueDestName( destination );
+ std::string key = getUniqueDestName(destination);
key += "s=";
key += selector;
key += ",nl=";
- key += ( noLocal? "t" : "f" );
+ key += (noLocal ? "t" : "f");
// Check the cache - add it if necessary.
CachedConsumer* cachedConsumer = NULL;
try {
- cachedConsumer = consumerCache.get( key );
- } catch( decaf::util::NoSuchElementException& e ) {
+ cachedConsumer = consumerCache.get(key);
+ } catch (decaf::util::NoSuchElementException& e) {
// No producer exists for this destination - start by creating
// a new consumer resource.
- cms::MessageConsumer* c = session->createConsumer( destination, selector, noLocal );
+ cms::MessageConsumer* c = session->createConsumer(destination, selector, noLocal);
// Add the consumer resource to the resource lifecycle manager.
- pool->getResourceLifecycleManager()->addMessageConsumer( c );
+ pool->getResourceLifecycleManager()->addMessageConsumer(c);
// Create the cached consumer wrapper.
- cachedConsumer = new CachedConsumer( c );
+ cachedConsumer = new CachedConsumer(c);
// Add it to the cache.
- consumerCache.put( key, cachedConsumer );
+ consumerCache.put(key, cachedConsumer);
}
return cachedConsumer;
@@ -158,15 +156,15 @@ cms::MessageConsumer* PooledSession::cre
}
////////////////////////////////////////////////////////////////////////////////
-std::string PooledSession::getUniqueDestName( const cms::Destination* dest ) {
+std::string PooledSession::getUniqueDestName(const cms::Destination* dest) {
std::string destName = "[";
- const cms::Queue* queue = dynamic_cast<const cms::Queue*>( dest );
- if( queue != NULL ) {
+ const cms::Queue* queue = dynamic_cast<const cms::Queue*>(dest);
+ if (queue != NULL) {
destName += "q:" + queue->getQueueName();
} else {
- const cms::Topic* topic = dynamic_cast<const cms::Topic*>( dest );
- if( topic != NULL ) {
+ const cms::Topic* topic = dynamic_cast<const cms::Topic*>(dest);
+ if (topic != NULL) {
destName += "t:" + topic->getTopicName();
}
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.h?rev=1399656&r1=1399655&r2=1399656&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/PooledSession.h Thu Oct 18 13:11:57 2012
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_
-#define ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_
+#ifndef _ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_
+#define _ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_
#include <cms/Session.h>
#include <decaf/util/StlMap.h>
@@ -47,12 +47,12 @@ namespace cmsutil {
private:
- PooledSession( const PooledSession& );
- PooledSession& operator= ( const PooledSession& );
+ PooledSession(const PooledSession&);
+ PooledSession& operator=(const PooledSession&);
public:
- PooledSession( SessionPool* pool, cms::Session* session );
+ PooledSession(SessionPool* pool, cms::Session* session);
/**
* Does nothing
@@ -105,25 +105,25 @@ namespace cmsutil {
session->recover();
}
- virtual cms::MessageConsumer* createConsumer( const cms::Destination* destination ) {
+ virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination) {
return session->createConsumer(destination);
}
- virtual cms::MessageConsumer* createConsumer( const cms::Destination* destination,
- const std::string& selector ) {
+ virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination,
+ const std::string& selector) {
return session->createConsumer(destination, selector);
}
- virtual cms::MessageConsumer* createConsumer( const cms::Destination* destination,
- const std::string& selector,
- bool noLocal ) {
+ virtual cms::MessageConsumer* createConsumer(const cms::Destination* destination,
+ const std::string& selector,
+ bool noLocal) {
return session->createConsumer(destination, selector, noLocal);
}
- virtual cms::MessageConsumer* createDurableConsumer( const cms::Topic* destination,
- const std::string& name,
- const std::string& selector,
- bool noLocal = false ) {
+ virtual cms::MessageConsumer* createDurableConsumer(const cms::Topic* destination,
+ const std::string& name,
+ const std::string& selector,
+ bool noLocal = false) {
return session->createDurableConsumer(destination, name, selector, noLocal);
}
@@ -143,11 +143,10 @@ namespace cmsutil {
*
* @throws cms::CMSException if something goes wrong.
*/
- virtual cms::MessageConsumer* createCachedConsumer( const cms::Destination* destination,
- const std::string& selector,
- bool noLocal );
+ virtual cms::MessageConsumer* createCachedConsumer(const cms::Destination* destination,
+ const std::string& selector, bool noLocal);
- virtual cms::MessageProducer* createProducer( const cms::Destination* destination ) {
+ virtual cms::MessageProducer* createProducer(const cms::Destination* destination) {
return session->createProducer(destination);
}
@@ -163,18 +162,18 @@ namespace cmsutil {
*
* @throws cms::CMSException if something goes wrong.
*/
- virtual cms::MessageProducer* createCachedProducer( const cms::Destination* destination );
+ virtual cms::MessageProducer* createCachedProducer(const cms::Destination* destination);
- virtual cms::QueueBrowser* createBrowser( const cms::Queue* queue );
+ virtual cms::QueueBrowser* createBrowser(const cms::Queue* queue);
- virtual cms::QueueBrowser* createBrowser( const cms::Queue* queue, const std::string& selector );
+ virtual cms::QueueBrowser* createBrowser(const cms::Queue* queue, const std::string& selector);
- virtual cms::Queue* createQueue( const std::string& queueName ) {
- return session->createQueue( queueName );
+ virtual cms::Queue* createQueue(const std::string& queueName) {
+ return session->createQueue(queueName);
}
- virtual cms::Topic* createTopic( const std::string& topicName ) {
- return session->createTopic( topicName );
+ virtual cms::Topic* createTopic(const std::string& topicName) {
+ return session->createTopic(topicName);
}
virtual cms::TemporaryQueue* createTemporaryQueue() {
@@ -193,8 +192,8 @@ namespace cmsutil {
return session->createBytesMessage();
}
- virtual cms::BytesMessage* createBytesMessage( const unsigned char* bytes, int bytesSize ) {
- return session->createBytesMessage( bytes, bytesSize );
+ virtual cms::BytesMessage* createBytesMessage(const unsigned char* bytes, int bytesSize) {
+ return session->createBytesMessage(bytes, bytesSize);
}
virtual cms::StreamMessage* createStreamMessage() {
@@ -205,8 +204,8 @@ namespace cmsutil {
return session->createTextMessage();
}
- virtual cms::TextMessage* createTextMessage( const std::string& text ) {
- return session->createTextMessage( text );
+ virtual cms::TextMessage* createTextMessage(const std::string& text) {
+ return session->createTextMessage(text);
}
virtual cms::MapMessage* createMapMessage() {
@@ -221,8 +220,8 @@ namespace cmsutil {
return session->isTransacted();
}
- virtual void unsubscribe( const std::string& name ) {
- session->unsubscribe( name );
+ virtual void unsubscribe(const std::string& name) {
+ session->unsubscribe(name);
}
virtual void setMessageTransformer(cms::MessageTransformer* transformer) {
@@ -235,10 +234,10 @@ namespace cmsutil {
private:
- std::string getUniqueDestName( const cms::Destination* dest );
+ std::string getUniqueDestName(const cms::Destination* dest);
};
}}
-#endif /*ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_*/
+#endif /*_ACTIVEMQ_CMSUTIL_POOLEDSESSION_H_*/
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.cpp?rev=1399656&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.cpp Thu Oct 18 13:11:57 2012
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "ProducerCallback.h"
+
+using namespace cms;
+using namespace activemq::cmsutil;
+
+////////////////////////////////////////////////////////////////////////////////
+ProducerCallback::~ProducerCallback() {
+
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.h?rev=1399656&r1=1399655&r2=1399656&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ProducerCallback.h Thu Oct 18 13:11:57 2012
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CMSUTIL_PRODUCERCALLBACK_H
-#define ACTIVEMQ_CMSUTIL_PRODUCERCALLBACK_H
+#ifndef _ACTIVEMQ_CMSUTIL_PRODUCERCALLBACK_H_
+#define _ACTIVEMQ_CMSUTIL_PRODUCERCALLBACK_H_
#include <cms/Session.h>
#include <cms/MessageProducer.h>
@@ -31,7 +31,7 @@ namespace cmsutil {
class AMQCPP_API ProducerCallback {
public:
- virtual ~ProducerCallback() {}
+ virtual ~ProducerCallback();
/**
* Execute an action given a session and producer.
@@ -43,10 +43,10 @@ namespace cmsutil {
*
* @throws cms::CMSException if thrown by CMS API methods
*/
- virtual void doInCms( cms::Session* session, cms::MessageProducer* producer ) = 0;
+ virtual void doInCms(cms::Session* session, cms::MessageProducer* producer) = 0;
};
}}
-#endif /*ACTIVEMQ_CMSUTIL_PRODUCERCALLBACK_H*/
+#endif /*_ACTIVEMQ_CMSUTIL_PRODUCERCALLBACK_H_*/
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp?rev=1399656&r1=1399655&r2=1399656&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.cpp Thu Oct 18 13:11:57 2012
@@ -25,16 +25,16 @@ using namespace activemq::cmsutil;
////////////////////////////////////////////////////////////////////////////////
#define CMSTEMPLATE_CATCHALL() \
catch( cms::CMSException& ex ){ \
- throw ex; \
- } catch( std::exception& ex ) { \
+ throw; \
+ } catch(std::exception& ex) { \
throw CMSException( ex.what(), NULL ); \
} catch( ... ){ \
- throw CMSException( "caught unknown exception", NULL ); \
+ throw CMSException("caught unknown exception", NULL); \
}
////////////////////////////////////////////////////////////////////////////////
#define CMSTEMPLATE_CATCHALL_NOTHROW( ) \
- catch( ... ){ \
+ catch(...){ \
}
////////////////////////////////////////////////////////////////////////////////
@@ -50,7 +50,6 @@ ResourceLifecycleManager::ResourceLifecy
ResourceLifecycleManager::~ResourceLifecycleManager() {
try {
-
// Destroy all the resources
destroy();
}
@@ -70,72 +69,74 @@ void ResourceLifecycleManager::releaseAl
////////////////////////////////////////////////////////////////////////////////
void ResourceLifecycleManager::destroy() {
- try{
+ try {
synchronized(&connections) {
+
// Close all the connections.
- std::auto_ptr< decaf::util::Iterator< cms::Connection* > > connIter(
- connections.iterator() );
+ std::auto_ptr<decaf::util::Iterator<cms::Connection*> > connIter(connections.iterator());
- while( connIter->hasNext() ) {
+ while (connIter->hasNext()) {
cms::Connection* conn = connIter->next();
try {
conn->close();
- } catch(...){}
+ } catch (...) {
+ }
}
// Destroy the producers.
- std::auto_ptr< decaf::util::Iterator< cms::MessageProducer* > > prodIter(
- producers.iterator() );
+ std::auto_ptr<decaf::util::Iterator<cms::MessageProducer*> > prodIter(producers.iterator());
- while( prodIter->hasNext() ) {
+ while (prodIter->hasNext()) {
cms::MessageProducer* producer = prodIter->next();
try {
delete producer;
- } catch( ... ) {}
+ } catch (...) {
+ }
}
// Destroy the consumers.
- std::auto_ptr< decaf::util::Iterator< cms::MessageConsumer* > > consIter(
- consumers.iterator() );
+ std::auto_ptr<decaf::util::Iterator<cms::MessageConsumer*> > consIter(consumers.iterator());
- while( consIter->hasNext() ) {
+ while (consIter->hasNext()) {
cms::MessageConsumer* consumer = consIter->next();
try {
delete consumer;
- } catch( ... ) {}
+ } catch (...) {
+ }
}
// Destroy the destinations.
- std::auto_ptr< decaf::util::Iterator< cms::Destination* > > destIter(
- destinations.iterator() );
+ std::auto_ptr<decaf::util::Iterator<cms::Destination*> > destIter(destinations.iterator());
- while( destIter->hasNext() ) {
+ while (destIter->hasNext()) {
cms::Destination* dest = destIter->next();
try {
delete dest;
- } catch( ... ) {}
+ } catch (...) {
+ }
}
// Destroy the sessions.
- std::auto_ptr< decaf::util::Iterator< cms::Session* > > sessIter(
- sessions.iterator() );
+ std::auto_ptr<decaf::util::Iterator<cms::Session*> > sessIter(sessions.iterator());
- while( sessIter->hasNext() ) {
+ while (sessIter->hasNext()) {
cms::Session* session = sessIter->next();
try {
delete session;
- } catch( ... ) {}
+ } catch (...) {
+ }
}
// Destroy the connections,
- connIter.reset( connections.iterator() );
+ connIter.reset(connections.iterator());
- while( connIter->hasNext() ) {
+ while (connIter->hasNext()) {
cms::Connection* conn = connIter->next();
try {
delete conn;
- } catch( ... ) {}
+ } catch (...) {
+ }
}
// Empty all the lists.
@@ -146,60 +147,60 @@ void ResourceLifecycleManager::destroy()
}
////////////////////////////////////////////////////////////////////////////////
-void ResourceLifecycleManager::addConnection( cms::Connection* connection ) {
+void ResourceLifecycleManager::addConnection(cms::Connection* connection) {
- try{
+ try {
// Add the connection to the list.
synchronized( &connections ) {
- connections.add( connection );
+ connections.add(connection);
}
}
CMSTEMPLATE_CATCHALL()
}
////////////////////////////////////////////////////////////////////////////////
-void ResourceLifecycleManager::addSession( cms::Session* session ) {
+void ResourceLifecycleManager::addSession(cms::Session* session) {
- try{
+ try {
// Add the session to the list.
- synchronized( &sessions ) {
- sessions.add( session );
+ synchronized(&sessions) {
+ sessions.add(session);
}
}
CMSTEMPLATE_CATCHALL()
}
////////////////////////////////////////////////////////////////////////////////
-void ResourceLifecycleManager::addDestination( cms::Destination* dest ) {
+void ResourceLifecycleManager::addDestination(cms::Destination* dest) {
- try{
+ try {
// Add the destination to the list.
- synchronized( &destinations ) {
- destinations.add( dest );
+ synchronized(&destinations) {
+ destinations.add(dest);
}
}
CMSTEMPLATE_CATCHALL()
}
////////////////////////////////////////////////////////////////////////////////
-void ResourceLifecycleManager::addMessageProducer( cms::MessageProducer* producer ) {
+void ResourceLifecycleManager::addMessageProducer(cms::MessageProducer* producer) {
- try{
+ try {
// Add the producer to the list.
- synchronized( &producers ) {
- producers.add( producer );
+ synchronized(&producers) {
+ producers.add(producer);
}
}
CMSTEMPLATE_CATCHALL()
}
////////////////////////////////////////////////////////////////////////////////
-void ResourceLifecycleManager::addMessageConsumer( cms::MessageConsumer* consumer ) {
+void ResourceLifecycleManager::addMessageConsumer(cms::MessageConsumer* consumer) {
- try{
+ try {
// Add the consumer to the list.
- synchronized( &consumers ) {
- consumers.add( consumer );
+ synchronized(&consumers) {
+ consumers.add(consumer);
}
}
CMSTEMPLATE_CATCHALL()
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.h?rev=1399656&r1=1399655&r2=1399656&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/ResourceLifecycleManager.h Thu Oct 18 13:11:57 2012
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CMSUTIL_RESOURCELIFECYCLEMANAGER_H_
-#define ACTIVEMQ_CMSUTIL_RESOURCELIFECYCLEMANAGER_H_
+#ifndef _ACTIVEMQ_CMSUTIL_RESOURCELIFECYCLEMANAGER_H_
+#define _ACTIVEMQ_CMSUTIL_RESOURCELIFECYCLEMANAGER_H_
#include <cms/Connection.h>
#include <cms/Session.h>
@@ -51,8 +51,8 @@ namespace cmsutil {
protected:
- ResourceLifecycleManager( const ResourceLifecycleManager& );
- ResourceLifecycleManager& operator= ( const ResourceLifecycleManager& );
+ ResourceLifecycleManager(const ResourceLifecycleManager&);
+ ResourceLifecycleManager& operator=(const ResourceLifecycleManager&);
public:
@@ -72,7 +72,7 @@ namespace cmsutil {
*
* @throws CMSException if an error occurs while performing this operation.
*/
- void addConnection( cms::Connection* connection );
+ void addConnection(cms::Connection* connection);
/**
* Adds a session so that its life will be managed by
@@ -83,7 +83,7 @@ namespace cmsutil {
*
* @throws CMSException if an error occurs while performing this operation.
*/
- void addSession( cms::Session* session );
+ void addSession(cms::Session* session);
/**
* Adds a destination so that its life will be managed by
@@ -94,7 +94,7 @@ namespace cmsutil {
*
* @throws CMSException if an error occurs while performing this operation.
*/
- void addDestination( cms::Destination* dest );
+ void addDestination(cms::Destination* dest);
/**
* Adds a message producer so that its life will be managed by
@@ -105,7 +105,7 @@ namespace cmsutil {
*
* @throws CMSException if an error occurs while performing this operation.
*/
- void addMessageProducer( cms::MessageProducer* producer );
+ void addMessageProducer(cms::MessageProducer* producer);
/**
* Adds a message consumer so that its life will be managed by
@@ -116,7 +116,7 @@ namespace cmsutil {
*
* @throws CMSException if an error occurs while performing this operation.
*/
- void addMessageConsumer( cms::MessageConsumer* consumer );
+ void addMessageConsumer(cms::MessageConsumer* consumer);
/**
* Closes and destroys the contained CMS resources.
@@ -135,4 +135,4 @@ namespace cmsutil {
}}
-#endif /*ACTIVEMQ_CMSUTIL_RESOURCELIFECYCLEMANAGER_H_*/
+#endif /*_ACTIVEMQ_CMSUTIL_RESOURCELIFECYCLEMANAGER_H_*/
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.cpp?rev=1399656&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.cpp Thu Oct 18 13:11:57 2012
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "SessionCallback.h"
+
+using namespace cms;
+using namespace activemq::cmsutil;
+
+////////////////////////////////////////////////////////////////////////////////
+SessionCallback::~SessionCallback() {
+
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.h?rev=1399656&r1=1399655&r2=1399656&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionCallback.h Thu Oct 18 13:11:57 2012
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CMSUTIL_SESSIONCALLBACK_H
-#define ACTIVEMQ_CMSUTIL_SESSIONCALLBACK_H
+#ifndef _ACTIVEMQ_CMSUTIL_SESSIONCALLBACK_H_
+#define _ACTIVEMQ_CMSUTIL_SESSIONCALLBACK_H_
#include <cms/Session.h>
#include <activemq/util/Config.h>
@@ -31,7 +31,7 @@ namespace cmsutil {
class AMQCPP_API SessionCallback {
public:
- virtual ~SessionCallback(){}
+ virtual ~SessionCallback();
/**
* Execute any number of operations against the supplied CMS
@@ -42,10 +42,10 @@ namespace cmsutil {
*
* @throws CMSException if thrown by CMS API methods
*/
- virtual void doInCms( cms::Session* session ) = 0;
+ virtual void doInCms(cms::Session* session) = 0;
};
}}
-#endif /*ACTIVEMQ_CMSUTIL_SESSIONCALLBACK_H*/
+#endif /*_ACTIVEMQ_CMSUTIL_SESSIONCALLBACK_H_*/
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp?rev=1399656&r1=1399655&r2=1399656&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.cpp Thu Oct 18 13:11:57 2012
@@ -22,27 +22,31 @@ using namespace activemq::cmsutil;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
-SessionPool::SessionPool( cms::Connection* connection,
- cms::Session::AcknowledgeMode ackMode,
- ResourceLifecycleManager* resourceLifecycleManager)
- : connection( connection ),
- resourceLifecycleManager( resourceLifecycleManager ),
+SessionPool::SessionPool(cms::Connection* connection,
+ cms::Session::AcknowledgeMode ackMode,
+ ResourceLifecycleManager* resourceLifecycleManager)
+ : connection(connection),
+ resourceLifecycleManager(resourceLifecycleManager),
mutex(),
available(),
sessions(),
- acknowledgeMode( ackMode ) {
+ acknowledgeMode(ackMode) {
}
////////////////////////////////////////////////////////////////////////////////
SessionPool::~SessionPool() {
- // Destroy all of the pooled session objects.
- list<PooledSession*>::iterator iter = sessions.begin();
- for( ; iter != sessions.end(); ++iter ) {
- delete *iter;
+ try {
+ // Destroy all of the pooled session objects.
+ list<PooledSession*>::iterator iter = sessions.begin();
+ for (; iter != sessions.end(); ++iter) {
+ delete *iter;
+ }
+
+ sessions.clear();
+ available.clear();
+ } catch(...) {
}
- sessions.clear();
- available.clear();
}
////////////////////////////////////////////////////////////////////////////////
@@ -53,20 +57,20 @@ PooledSession* SessionPool::takeSession(
PooledSession* pooledSession = NULL;
// If there are no sessions available, create a new one and return it.
- if( available.size() == 0 ) {
+ if (available.size() == 0) {
// No sessions were available - create a new one.
- cms::Session* session = connection->createSession( acknowledgeMode );
+ cms::Session* session = connection->createSession(acknowledgeMode);
// Give this resource to the life-cycle manager to manage. The pool
// will not be in charge of destroying this resource.
- resourceLifecycleManager->addSession( session );
+ resourceLifecycleManager->addSession(session);
// Now wrap the session with a pooled session.
- pooledSession = new PooledSession( this, session );
+ pooledSession = new PooledSession(this, session);
// Add to the sessions list.
- sessions.push_back( pooledSession );
+ sessions.push_back(pooledSession);
} else {
@@ -85,11 +89,10 @@ PooledSession* SessionPool::takeSession(
}
////////////////////////////////////////////////////////////////////////////////
-void SessionPool::returnSession( PooledSession* session ) {
-
- synchronized( &mutex ) {
+void SessionPool::returnSession(PooledSession* session) {
+ synchronized(&mutex) {
// Add to the available list.
- available.push_back( session );
+ available.push_back(session);
}
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.h?rev=1399656&r1=1399655&r2=1399656&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/cmsutil/SessionPool.h Thu Oct 18 13:11:57 2012
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef ACTIVEMQ_CMSUTIL_SESSIONPOOL_H_
-#define ACTIVEMQ_CMSUTIL_SESSIONPOOL_H_
+#ifndef _ACTIVEMQ_CMSUTIL_SESSIONPOOL_H_
+#define _ACTIVEMQ_CMSUTIL_SESSIONPOOL_H_
#include <activemq/cmsutil/PooledSession.h>
#include <decaf/util/concurrent/Mutex.h>
@@ -53,8 +53,8 @@ namespace cmsutil {
private:
- SessionPool( const SessionPool& );
- SessionPool& operator= ( const SessionPool& );
+ SessionPool(const SessionPool&);
+ SessionPool& operator=(const SessionPool&);
public:
@@ -68,9 +68,9 @@ namespace cmsutil {
* the object responsible for managing the lifecycle of
* any allocated cms::Session resources.
*/
- SessionPool( cms::Connection* connection,
- cms::Session::AcknowledgeMode ackMode,
- ResourceLifecycleManager* resourceLifecycleManager );
+ SessionPool(cms::Connection* connection,
+ cms::Session::AcknowledgeMode ackMode,
+ ResourceLifecycleManager* resourceLifecycleManager);
/**
* Destroys the pooled session objects, but not the underlying session
@@ -89,10 +89,11 @@ namespace cmsutil {
/**
* Returns a session to the pool.
+ *
* @param session
* the session to be returned.
*/
- virtual void returnSession( PooledSession* session );
+ virtual void returnSession(PooledSession* session);
ResourceLifecycleManager* getResourceLifecycleManager() {
return resourceLifecycleManager;
@@ -102,4 +103,4 @@ namespace cmsutil {
}}
-#endif /*ACTIVEMQ_CMSUTIL_SESSIONPOOL_H_*/
+#endif /*_ACTIVEMQ_CMSUTIL_SESSIONPOOL_H_*/