Author: tabish
Date: Thu Oct 7 18:12:08 2010
New Revision: 1005550
URL: http://svn.apache.org/viewvc?rev=1005550&view=rev
Log:
Define and Implement portions of the Message and Destination API.
Modified:
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Connection.cpp
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.h
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageProducer.cpp
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Session.cpp
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=1005550&r1=1005549&r2=1005550&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 Thu
Oct 7 18:12:08 2010
@@ -40,9 +40,9 @@ cms_status createDefaultConnection(CMS_C
result = CMS_ERROR;
} else {
wrapper->connection = factory->factory->createConnection();
+ *connection = wrapper.release();
}
- *connection = wrapper.release();
} catch(...) {
result = CMS_ERROR;
}
@@ -66,9 +66,9 @@ cms_status createConnection(CMS_Connecti
result = CMS_ERROR;
} else {
wrapper->connection = factory->factory->createConnection(username,
password, clientId);
+ *connection = wrapper.release();
}
- *connection = wrapper.release();
} catch(...) {
result = CMS_ERROR;
}
Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp?rev=1005550&r1=1005549&r2=1005550&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.cpp Thu
Oct 7 18:12:08 2010
@@ -16,3 +16,71 @@
*/
#include <CMS_Destination.h>
+
+#include <Config.h>
+#include <types/CMS_Types.h>
+
+#include <activemq/core/ActiveMQConnection.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include <memory>
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status createDestination(CMS_Session* session, DESTINATION_TYPE type,
+ const char* name, CMS_Destination** destination) {
+
+ cms_status result = CMS_SUCCESS;
+ std::auto_ptr<CMS_Destination> wrapper( new CMS_Destination );
+
+ try{
+
+ if (session == NULL) {
+ result = CMS_ERROR;
+ } else {
+
+ switch(type) {
+ case CMS_TOPIC:
+ wrapper->destination = session->session->createTopic(name);
+ break;
+ case CMS_TEMPORARY_TOPIC:
+ wrapper->destination =
session->session->createTemporaryTopic();
+ break;
+ case CMS_TEMPORARY_QUEUE:
+ wrapper->destination =
session->session->createTemporaryQueue();
+ break;
+ default:
+ wrapper->destination = session->session->createQueue(name);
+ break;
+ }
+
+ wrapper->type = type;
+ *destination = wrapper.release();
+ }
+
+ } catch(...) {
+ result = CMS_ERROR;
+ }
+
+ return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status destroyDestination(CMS_Destination* destination) {
+
+ cms_status result = CMS_SUCCESS;
+
+ if(destination != NULL) {
+
+ try{
+ delete destination->destination;
+ delete destination;
+ } catch(...) {
+ result = CMS_ERROR;
+ }
+ }
+
+ return result;
+}
Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.h?rev=1005550&r1=1005549&r2=1005550&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Destination.h Thu Oct
7 18:12:08 2010
@@ -24,6 +24,34 @@
extern "C" {
#endif
+/**
+ * Creates a Destination from the Given Session instance. The type of
Destination is
+ * given by the DESTINATION_TYPE parameter.
+ *
+ * @param session
+ * The Session to use to create the new Destination.
+ * @param type
+ * The Type of Destination that is to be created.
+ * @param name
+ * The name to assign the Destination, in the case of Temporary
Destinations
+ * this parameter is ignored.
+ * @param destination
+ * The address of the location to store the new Destination instance.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status createDestination(CMS_Session* session, DESTINATION_TYPE type,
const char* name, CMS_Destination** destination);
+
+/**
+ * Destroy the given Destination instance.
+ *
+ * @param destination
+ * The Destination to destroy.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status destroyDestination(CMS_Destination* destination);
+
#ifdef __cplusplus
}
#endif
Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp?rev=1005550&r1=1005549&r2=1005550&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp Thu Oct
7 18:12:08 2010
@@ -16,3 +16,59 @@
*/
#include <CMS_Message.h>
+
+#include <Config.h>
+#include <types/CMS_Types.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include <memory>
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status createTextMessage(CMS_Session* session, CMS_Message** message,
const char* body) {
+
+ cms_status result = CMS_SUCCESS;
+ std::auto_ptr<CMS_Message> wrapper( new CMS_Message );
+
+ try{
+
+ if (session == NULL) {
+ result = CMS_ERROR;
+ } else {
+
+ if (body == NULL) {
+ wrapper->message = session->session->createTextMessage();
+ } else {
+ wrapper->message = session->session->createTextMessage(body);
+ }
+
+ wrapper->type = CMS_TEXT_MESSAGE;
+ *message = wrapper.release();
+ }
+
+ } catch(...) {
+ result = CMS_ERROR;
+ }
+
+ return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status destroyMessage(CMS_Message* message) {
+
+ cms_status result = CMS_SUCCESS;
+
+ if(message != NULL) {
+
+ try{
+ delete message->message;
+ delete message;
+ } catch(...) {
+ result = CMS_ERROR;
+ }
+ }
+
+ return result;
+}
Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h?rev=1005550&r1=1005549&r2=1005550&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h Thu Oct 7
18:12:08 2010
@@ -24,6 +24,31 @@
extern "C" {
#endif
+/**
+ * Creates a New Text Message from the given Session instance, if set the
value of the
+ * body parameter is assigned as the body of the Text Message.
+ *
+ * @param session
+ * The Session to use to create the new Text Message
+ * @param message
+ * The address of the location to store the new Message instance.
+ * @param body
+ * The text that should be assigned to the body of the Text Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status createTextMessage(CMS_Session* session, CMS_Message** message,
const char* body);
+
+/**
+ * Destroy the given Message instance.
+ *
+ * @param message
+ * The Message to destroy.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status destroyMessage(CMS_Message* message);
+
#ifdef __cplusplus
}
#endif
Modified:
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp?rev=1005550&r1=1005549&r2=1005550&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageConsumer.cpp
Thu Oct 7 18:12:08 2010
@@ -38,9 +38,9 @@ cms_status createDefaultConsumer(CMS_Ses
result = CMS_ERROR;
} else {
wrapper->consumer =
session->session->createConsumer(destination->destination);
+ *consumer = wrapper.release();
}
- *consumer = wrapper.release();
} catch(...) {
result = CMS_ERROR;
}
@@ -61,9 +61,9 @@ cms_status createConsumer(CMS_Session* s
} else {
wrapper->consumer = session->session->createConsumer(
destination->destination, selector, noLocal > 0 ? true :
false);
+ *consumer = wrapper.release();
}
- *consumer = wrapper.release();
} catch(...) {
result = CMS_ERROR;
}
Modified:
activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageProducer.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageProducer.cpp?rev=1005550&r1=1005549&r2=1005550&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageProducer.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_MessageProducer.cpp
Thu Oct 7 18:12:08 2010
@@ -42,9 +42,10 @@ cms_status createProducer(CMS_Session* s
} else {
wrapper->producer = session->session->createProducer(NULL);
}
+
+ *producer = wrapper.release();
}
- *producer = wrapper.release();
} catch(...) {
result = CMS_ERROR;
}
Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Session.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Session.cpp?rev=1005550&r1=1005549&r2=1005550&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Session.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Session.cpp Thu Oct
7 18:12:08 2010
@@ -38,9 +38,9 @@ cms_status createDefaultSession(CMS_Conn
result = CMS_ERROR;
} else {
wrapper->session = connection->connection->createSession();
+ *session = wrapper.release();
}
- *session = wrapper.release();
} catch(...) {
result = CMS_ERROR;
}
@@ -81,9 +81,9 @@ cms_status createSession(CMS_Connection*
return CMS_UNKNOWN_ACKTYPE;
}
wrapper->session =
connection->connection->createSession(cmsAckType);
+ *session = wrapper.release();
}
- *session = wrapper.release();
} catch(...) {
result = CMS_ERROR;
}