activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1026474 - in /activemq/activemq-cpp/trunk/activemq-c/src/main/c: CMS_Connection.cpp CMS_Connection.h
Date Fri, 22 Oct 2010 20:09:50 GMT
Author: tabish
Date: Fri Oct 22 20:09:50 2010
New Revision: 1026474

URL: http://svn.apache.org/viewvc?rev=1026474&view=rev
Log:
Implement wrappers for most methods in cms::Connection

Modified:
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.h

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp?rev=1026474&r1=1026473&r2=1026474&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp Fri Oct 22 20:09:50
2010
@@ -22,12 +22,17 @@
 
 #include <activemq/core/ActiveMQConnection.h>
 
+#include <cms/IllegalStateException.h>
+#include <cms/InvalidClientIdException.h>
+
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
 
 #include <memory>
 
+using namespace cms;
+
 ////////////////////////////////////////////////////////////////////////////////
 cms_status createDefaultConnection(CMS_ConnectionFactory* factory, CMS_Connection** connection)
{
 
@@ -115,3 +120,88 @@ cms_status startConnection(CMS_Connectio
 
     return result;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status stopConnection(CMS_Connection* connection) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(connection != NULL) {
+
+        try{
+            connection->connection->stop();
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status closeConnection(CMS_Connection* connection) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(connection != NULL) {
+
+        try{
+            connection->connection->close();
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setConnectionClientId(CMS_Connection* connection, const char* clientId) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(connection != NULL && clientId != NULL) {
+
+        try{
+            connection->connection->setClientID(clientId);
+        } catch(IllegalStateException& ex) {
+            result = CMS_ILLEGAL_STATE;
+        } catch(InvalidClientIdException& ex) {
+            result = CMS_INVALID_CLIENTID;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getConnectionClientId(CMS_Connection* connection, char* clientId, int size) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(connection != NULL && clientId != NULL && size > 0) {
+
+        try{
+            std::string theClientId = connection->connection->getClientID();
+
+            if(theClientId.size() < size) {
+
+                for(int i = 0; i < theClientId.size(); ++i) {
+                    clientId[i] = theClientId.at(i);
+                }
+
+                clientId[theClientId.size()] = '\0';
+
+            } else {
+                result = CMS_ERROR;
+            }
+
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.h?rev=1026474&r1=1026473&r2=1026474&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.h (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.h Fri Oct 22 20:09:50
2010
@@ -77,9 +77,62 @@ cms_status destroyConnection(CMS_Connect
  *
  * @param connection
  *      The Connection that is to be started.
+ *
+ * @return result code indicating the success or failure of the operation.
  */
 cms_status startConnection(CMS_Connection* connection);
 
+/**
+ * Stops the Connection instance.  Until a Connection is started any Message Consumers
+ * created by Sessions linked to the Connection will not be able to receive Messages.
+ *
+ * @param connection
+ *      The Connection that is to be stopped.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status stopConnection(CMS_Connection* connection);
+
+/**
+ * Closes the Connection instance.  Once closed a Connection cannot be restarted.  All the
+ * resources allocated from this connection will be closed as well, they must still be
+ * destroyed by the client.
+ *
+ * @param connection
+ *      The Connection that is to be closed.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status closeConnection(CMS_Connection* connection);
+
+/**
+ * Sets the Client Id for the given Connection instance.
+ *
+ * @param connection
+ *      The Connection whose client id is to be set.
+ * @param clientId
+ *      The new client Id to assign to the connection.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setConnectionClientId(CMS_Connection* connection, const char* clientId);
+
+/**
+ * Gets the Client Id for the given Connection instance.  The caller passes an array that
+ * the client id is copied into, if the array is not large enough to accommodate the client
+ * Id then an error status is returned.
+ *
+ * @param connection
+ *      The Connection whose client id is to be set.
+ * @param clientId
+ *      The new client Id to assign to the connection.
+ * @param size
+ *      The size of the character array that is to receive the client Id.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getConnectionClientId(CMS_Connection* connection, char* clientId, int size);
+
 #ifdef __cplusplus
 }
 #endif



Mime
View raw message