Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 50556 invoked from network); 7 Oct 2010 18:12:34 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Oct 2010 18:12:34 -0000 Received: (qmail 16326 invoked by uid 500); 7 Oct 2010 18:12:34 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 16261 invoked by uid 500); 7 Oct 2010 18:12:34 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 16254 invoked by uid 99); 7 Oct 2010 18:12:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 18:12:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 18:12:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 802592388999; Thu, 7 Oct 2010 18:12:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1005550 - in /activemq/activemq-cpp/trunk/activemq-c/src/main/c: CMS_Connection.cpp CMS_Destination.cpp CMS_Destination.h CMS_Message.cpp CMS_Message.h CMS_MessageConsumer.cpp CMS_MessageProducer.cpp CMS_Session.cpp Date: Thu, 07 Oct 2010 18:12:09 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101007181209.802592388999@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 + +#include +#include + +#include + +#ifdef HAVE_STDLIB_H +#include +#endif + +#include + +//////////////////////////////////////////////////////////////////////////////// +cms_status createDestination(CMS_Session* session, DESTINATION_TYPE type, + const char* name, CMS_Destination** destination) { + + cms_status result = CMS_SUCCESS; + std::auto_ptr 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 + +#include +#include + +#ifdef HAVE_STDLIB_H +#include +#endif + +#include + +//////////////////////////////////////////////////////////////////////////////// +cms_status createTextMessage(CMS_Session* session, CMS_Message** message, const char* body) { + + cms_status result = CMS_SUCCESS; + std::auto_ptr 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; }