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 2007/10/29 16:20:35 UTC
svn commit: r589668 - in /activemq/activemq-cpp/trunk/src: examples/main.cpp
main/activemq/core/ActiveMQConnectionFactory.cpp main/cms/ConnectionFactory.h
Author: tabish
Date: Mon Oct 29 08:20:27 2007
New Revision: 589668
URL: http://svn.apache.org/viewvc?rev=589668&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-151
Adding in static CMS ConnectionFactory create support.
Modified:
activemq/activemq-cpp/trunk/src/examples/main.cpp
activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
activemq/activemq-cpp/trunk/src/main/cms/ConnectionFactory.h
Modified: activemq/activemq-cpp/trunk/src/examples/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/examples/main.cpp?rev=589668&r1=589667&r2=589668&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/examples/main.cpp (original)
+++ activemq/activemq-cpp/trunk/src/examples/main.cpp Mon Oct 29 08:20:27 2007
@@ -71,8 +71,8 @@
virtual void run() {
try {
// Create a ConnectionFactory
- ActiveMQConnectionFactory* connectionFactory =
- new ActiveMQConnectionFactory( brokerURI );
+ ConnectionFactory* connectionFactory =
+ ConnectionFactory::createCMSConnectionFactory( brokerURI );
// Create a Connection
connection = connectionFactory->createConnection();
@@ -195,8 +195,8 @@
try {
// Create a ConnectionFactory
- ActiveMQConnectionFactory* connectionFactory =
- new ActiveMQConnectionFactory( brokerURI );
+ ConnectionFactory* connectionFactory =
+ ConnectionFactory::createCMSConnectionFactory( brokerURI );
// Create a Connection
connection = connectionFactory->createConnection();
Modified: activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp?rev=589668&r1=589667&r2=589668&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/core/ActiveMQConnectionFactory.cpp Mon Oct 29 08:20:27 2007
@@ -34,10 +34,16 @@
using namespace activemq::transport;
////////////////////////////////////////////////////////////////////////////////
-ActiveMQConnectionFactory::ActiveMQConnectionFactory()
-{
- brokerURL = "tcp://localhost:61616";
+cms::ConnectionFactory* cms::ConnectionFactory::createCMSConnectionFactory( const std::string& brokerURI )
+ throw ( cms::CMSException ) {
+
+ return new ActiveMQConnectionFactory( brokerURI );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ActiveMQConnectionFactory::ActiveMQConnectionFactory() {
+ brokerURL = "tcp://localhost:61616";
this->username = "";
this->password = "";
}
@@ -46,18 +52,17 @@
ActiveMQConnectionFactory::ActiveMQConnectionFactory(
const std::string& url,
const std::string& username,
- const std::string& password )
-{
- brokerURL = url;
+ const std::string& password ) {
+ brokerURL = url;
this->username = username;
this->password = password;
}
////////////////////////////////////////////////////////////////////////////////
cms::Connection* ActiveMQConnectionFactory::createConnection()
- throw ( cms::CMSException )
-{
+ throw ( cms::CMSException ) {
+
return createConnection( brokerURL, username, password, Guid::createGUIDString() );
}
@@ -65,8 +70,8 @@
cms::Connection* ActiveMQConnectionFactory::createConnection(
const std::string& username,
const std::string& password )
- throw ( cms::CMSException )
-{
+ throw ( cms::CMSException ) {
+
return createConnection( brokerURL, username, password, Guid::createGUIDString() );
}
@@ -75,8 +80,8 @@
const std::string& username,
const std::string& password,
const std::string& clientId )
- throw ( cms::CMSException )
-{
+ throw ( cms::CMSException ) {
+
return createConnection( brokerURL, username, password, clientId );
}
@@ -86,8 +91,8 @@
const std::string& username,
const std::string& password,
const std::string& clientId )
- throw ( cms::CMSException )
-{
+ throw ( cms::CMSException ) {
+
// Declared here so that they can be deleted in the catch block
Properties* properties = NULL;
Transport* transport = NULL;
@@ -97,13 +102,12 @@
std::string clientIdLocal = clientId;
TransportBuilder transportBuilder;
- try
- {
+ try{
+
properties = new Properties;
// if no Client Id specified, create one
- if( clientIdLocal == "" )
- {
+ if( clientIdLocal == "" ) {
clientIdLocal = Guid::createGUIDString();
}
@@ -136,8 +140,7 @@
ConnectorFactory* connectorfactory =
ConnectorFactoryMap::getInstance()->lookup( wireFormat );
- if( connectorfactory == NULL )
- {
+ if( connectorfactory == NULL ) {
throw NullPointerException(
__FILE__, __LINE__,
"ActiveMQConnectionFactory::createConnection - "
@@ -147,8 +150,7 @@
// Create the Connector.
connector = connectorfactory->createConnector( *properties, transport );
- if( connector == NULL )
- {
+ if( connector == NULL ) {
throw NullPointerException(
__FILE__, __LINE__,
"ActiveMQConnectionFactory::createConnection - "
@@ -166,9 +168,8 @@
connection = new ActiveMQConnection( connectionData );
return connection;
- }
- catch( exceptions::ActiveMQException& ex )
- {
+
+ } catch( exceptions::ActiveMQException& ex ) {
ex.setMark( __FILE__, __LINE__ );
delete connection;
@@ -177,9 +178,8 @@
delete properties;
throw ex;
- }
- catch( ... )
- {
+
+ } catch( ... ) {
exceptions::ActiveMQException ex(
__FILE__, __LINE__,
"ActiveMQConnectionFactory::create - "
Modified: activemq/activemq-cpp/trunk/src/main/cms/ConnectionFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/cms/ConnectionFactory.h?rev=589668&r1=589667&r2=589668&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/cms/ConnectionFactory.h (original)
+++ activemq/activemq-cpp/trunk/src/main/cms/ConnectionFactory.h Mon Oct 29 08:20:27 2007
@@ -40,7 +40,7 @@
* connection is created in stopped mode. No messages will be
* delivered until the Connection.start method is explicitly
* called.
- *
+ *
* @return Pointer to a connection object, caller owns the pointer
* @throws CMSException
*/
@@ -54,10 +54,10 @@
* change the defaults, subsequent calls to the parameterless
* createConnection will continue to use the default values that
* were set in the Constructor.
- *
- * @param username
+ *
+ * @param username
* to authenticate with
- * @param password
+ * @param password
* to authenticate with
* @returns a Connection Pointer
* @throws CMSException
@@ -74,13 +74,13 @@
* change the defaults, subsequent calls to the parameterless
* createConnection will continue to use the default values that
* were set in the Constructor.
- *
- * @param username
+ *
+ * @param username
* to authenticate with
- * @param password
+ * @param password
* to authenticate with
- * @param clientId
- * to assign to connection if "" then a random client Id is
+ * @param clientId
+ * to assign to connection if "" then a random client Id is
* created for this connection.
* @returns a Connection Pointer
* @throws CMSException
@@ -89,6 +89,18 @@
const std::string& password,
const std::string& clientId )
throw ( cms::CMSException ) = 0;
+
+ public:
+
+ /**
+ * Static method that is used to create a provider specfic connection
+ * factory. The provider implements this method in their library and
+ * returns an instance of a ConnectionFactory dervied object.
+ * @returns Provider specific ConnectionFactory
+ * @throws CMSException if and error occurs.
+ */
+ static ConnectionFactory* createCMSConnectionFactory( const std::string& brokerURI )
+ throw ( cms::CMSException );
};